questions > Specifying a series number does not output nifti files, only json sidecars
Showing 1-2 of 2 posts
Display:
Results per page:
Mar 31, 2020  11:03 PM | Margaret Mahan
Specifying a series number does not output nifti files, only json sidecars
If I run: dcm2niix -n 12 -o output_dir input_dir

where the series number is confirmed to be 12; the outputs are only json sidecars and these are created for all series numbers in the input_dir. No nifti files are created. The same is true for *any* number passed as the parameter to -n (for example, -n 2, -n 3) if it was to indicate the nth series in the scan. So neither selecting a number via series number (from DICOM header) or a number based on the nth series in the sequence produces the expected result.

The message in the terminal after execution shows no errors:
Chris Rorden's dcm2niiX version v1.0.20200331 Clang11.0.3 (64-bit MacOS)
Found 647 DICOM file(s)
Conversion required 1.102604 seconds (1.098819 for core code).

on the same data, running:  

dcm2niix -o output_dir input_dir

outputs both the nifti files for each series number and their respective json sidecars.

The message in the terminal after execution shows no errors:
Chris Rorden's dcm2niiX version v1.0.20200331 Clang11.0.3 (64-bit MacOS)
Found 647 DICOM file(s)
Convert 420 DICOM as .../test_output/tome_test_rfMRI_REST_AP_20170906081132_12 (104x104x72x420)
Convert 128 DICOM as .../test_AAHScout_20170906081132_2 (160x160x128x1)
Convert 99 DICOM as .../test_dMRI_dir98_AP_20170906081132_20 (140x140x92x99)
Conversion required 3.558888 seconds (3.543063 for core code).

A diff between the two json sidecar files from both approaches with series number = 12, indicates there are no differences in these files. 

I have run this compiling dcm2niix from git clone and curl of the latest version. Both produce the same result as above. 

Could you please advise how to specify conversion of a specific series number in a dicom directory using dcm2niix?

Thank you,
Maggie
Apr 1, 2020  11:04 AM | Chris Rorden
RE: Specifying a series number does not output nifti files, only json sidecars
For modern versions of dcm2niix the -n parameter specifies the CRC for the Media Storage SOP Instance UID (0002,0003). The issue here is that Series number can often not disambiguate images from a study, and particularly between studies. Further, there are cases where even the 0002,0003 does not disambiguate data. A classic example is Siemens field maps (see the dcm_qa_me repository for an example). Here, different echoes share the same series, instance number, and 0002,0003. This example has led to a lot of data loss, where archival systems assume the two echoes are duplicates of the same echo, and only stores one of the two distinct images. 
  To see the proper use of the -n parameter try out MRIcroGL or FSLeyes. When a user selects a DICOM folder these tools first call the '-n -1' parameter to get the UIDs as well as easily parsed file information (below I use '-f %s_%p' to allow me to parse the series number and the protocol name). Your script can call the -n -1 parameter just like MRIcroGL and FSLeyes do, parse the values that are critical for your study, and extract the desired dataset by providing the CRC value.
  So in the case below, to convert the first echo of Series 4 I would convert '-n 1003592311', while to convert the second echo I would use '-n 1003592311.2'.


>>dcm2niix -n -1 -f %s_%p ./dcm_qa_me
Chris Rorden's dcm2niiX version v1.0.20200331 (JP2:OpenJPEG) (JP-LS:CharLS) Clang11.0.0 (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 ./dcm_qa_me/4_me_fMRI_e1
./dcm_qa_me/In/4_me_fMRI/0001.dcm
1003592311.2 ./dcm_qa_me/4_me_fMRI_e2
./dcm_qa_me/In/4_me_fMRI/0002_e2.dcm
1551009060.2 ./dcm_qa_me/3_me_FieldMap_GRE_e2_ph
./dcm_qa_me/In/3_me_FieldMap_GRE/0001_e2_ph.dcm
2536363799.2 ./dcm_qa_me/2_me_FieldMap_GRE_e2
./dcm_qa_me/In/2_me_FieldMap_GRE/0001_e2.dcm
2536363799 ./dcm_qa_me/2_me_FieldMap_GRE_e1
./dcm_qa_me/In/2_me_FieldMap_GRE/0001.dcm
2536363799 ./dcm_qa_me/dcm_qa_me_me_FieldMap_GRE_20180502123244_2_e1
./dcm_qa_me/In/2_me_FieldMap_GRE/0001.dcm
Conversion required 0.123608 seconds (0.120624 for core code).

I realize this is not as simple as you were expecting, but it unfortunately reflects the complexity of DICOM images that are seen in the wild. While a simple situation may work for all your data, it would not prove robust when exposed to more complicated datasets. Therefore, dcm2niix provides a complex but robust solution, and allows you to write a simple script that will allow you to resolve the situations common with your datasets.