Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-n option not working #453

Closed
jeodai opened this issue Nov 26, 2020 · 2 comments
Closed

-n option not working #453

jeodai opened this issue Nov 26, 2020 · 2 comments

Comments

@jeodai
Copy link

jeodai commented Nov 26, 2020

I use dcm2niix to select series number which to convert by using option -n, but when -n applied, it only outputs json files, no nii files, however when -n removed, it works.

Did I get the right usage of -n option?

@neurolabusc
Copy link
Collaborator

The -n option requires you to specify the CRC number, not the series number. The idea here is to disambiguate competing images - e.g. if a user converts a folder with several studies in it, every DICOM study might have a "series 1". We also want to disambiguate situations where the same series from the same study will be saved as separate images, for example a series that generates both phase and magnitude images, or a series that is based on multiple echo times. The BIDS standard requires that each of these images is saved as a different image, even though they originate from the same study and series.

To understand the usage of this function, consider the multi-echo validation dataset. Note that series 4 will generate two images. We first run dcm2niix with the -n -1 option to identify which images we want to convert. Next we use -n 1003592311.2 to only convert the second echo of series 4.

$ dcm2niix -f %s -n -1 ~/src/dcm_qa_me  
Chris Rorden's dcm2niiX version v1.0.20201127  Clang12.0.0 ARM (64-bit MacOS)
Found 114 DICOM file(s)
Slices not stacked: echo varies (TE 20, 37.83; echo 1, 2). Use 'merge 2D slices' option to force stacking
	1003592311	~/src/dcm_qa_me/4_e1
 ~/src/dcm_qa_me/In/4_me_fMRI/0001.dcm
	1003592311.2	~/src/dcm_qa_me/4_e2
 ~/src/dcm_qa_me/In/4_me_fMRI/0002_e2.dcm
	1551009060.2	~/src/dcm_qa_me/3_e2_ph
 ~/src/dcm_qa_me/In/3_me_FieldMap_GRE/0001_e2_ph.dcm
	2536363799.2	~/src/dcm_qa_me/2_e2
 ~/src/dcm_qa_me/In/2_me_FieldMap_GRE/0001_e2.dcm
	2536363799	~/src/dcm_qa_me/2_e1
 ~/src/dcm_qa_me/In/2_me_FieldMap_GRE/0001.dcm
Conversion required 0.044012 seconds (0.043880 for core code).

$ dcm2niix -f %s  -n 1003592311.2 ~/src/dcm_qa_me
Chris Rorden's dcm2niiX version v1.0.20201127  Clang12.0.0 ARM (64-bit MacOS)
Found 114 DICOM file(s)
Slices not stacked: echo varies (TE 20, 37.83; echo 1, 2). Use 'merge 2D slices' option to force stacking
UINT16->INT16 Future release will change default. github.com/rordenlab/dcm2niix/issues/338
Convert 3 DICOM as ~/src/dcm_qa_me/4_e2 (64x64x30x3)
Conversion required 0.066670 seconds (0.066611 for core code).

The rationale for the -n option is to allow MRIcroGL and FSLeyes a way to provide a user interface for loading just one (or perhaps just a couple) images from a huge folder. The usage is not intuitive, but it is internally consistent and resolves name clashing conflicts.

@pauldmccarthy when looking at this issue I noted that while the -n option masks the creation of NIfTI images (which are slow to write and large), it did not mask the creation of BIDS JSON files (which are fast to write and small). I think this led to @jeodai's confusion. The latest development branch now generates no BIDS files for -n -1 and only the specified BIDS files for other values of -n. I assume that FSLeyes does not expect the unselected BIDS files. Just want to make sure there are no unintended consequences of my patch.

@pauldmccarthy
Copy link

Hi @neurolabusc thanks for the ping - in FSLeyes, I am actually using the -b o option to identify which series are present (I think I implemented this before you added the -n -1 option, and hadn't gotten around to updating). I just double checked against your development branch, and did not have any problems whatsoever :)

yarikoptic added a commit to neurodebian/dcm2niix that referenced this issue Apr 6, 2021
* commit 'v1.0.20200427-97-g0587941': (22 commits)
  Overflow for Siemens data [missing protocol name] (rordenlab#466)
  MacOS notarization, minor tweaks
  Increase details for series stacking, enhance merge override mode (rordenlab#463)
  Bump version date
  Retain Philips Scaling Values for images where scaling does not vary but volumes must be separated (rordenlab#461)
  Support huge PAR/REC files (rordenlab#460)
  Prevent dti4D overflow
  Fix PAR/REC ADC detection (rordenlab#462)
  DICOM field map calibrated in Hz given name _fieldmaphz (rordenlab#455)
  PAR/REC field map calibrated in Hz given name _fieldmaphz (rordenlab#455)
  Ignore LocationsInAcquisition (0020,1002) if number of slices is not evenly divisible with this value (rordenlab#459)
  Convert DICOM series where bit allocated (0028,0100) varies across slices (rordenlab#458)
  Clear RepetitionTimeExcitation (rordenlab#457)
  leak (rordenlab#454)
  Single file mode memory allocation (rordenlab#454)
  When -n is specified, only save BIDS for requested series (rordenlab#453)
  Use 1st study time if multiple times provided.
  Apple. M1. use C++ not. C
  Fix CMake for Apple Silicon (note similar change required for CloudFlare zlib)
  Only report b-value for GE data with 0043,1039 if EPI (0018,9018) (rordenlab#449)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants