rordenlab / dcm2niix

dcm2nii DICOM to NIfTI converter: compiled versions available from NITRC
https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage
Other
898 stars 229 forks source link

Errors in file naming/JSON when converting from PARREC #195

Closed gb4944 closed 6 years ago

gb4944 commented 6 years ago

Hi, I've encountered an issue with the file naming/JSON generation from PARREC, using the latest pre-release (v1.0.20180328). An incorrect string is inserted into file names and and the JSON ProtocolName tag. A minimal command like dcm2niix input_dir/Subcortex_0016_014_R01_SB_INV1_12_1.PAR produces this type of file name:

PARREC_Subcortex_0016_014_R01_SB_INV1======tool4.2_19770703150928_12.nii

The string 19770703150928 doesn't seem to appear anywhere in the .PAR file, whereas ======tool4.2 seems to come from the first few lines of the file. The latter string is identical for all files I've tried, but the number series is different for each subject, and identical for different files for one subject.

Modifying the file name removes the number series, but ======tool4.2 seems to be read as part of the %p tag. dcm2niix -o output_dir -b y -ba y -f "sub-${subject_id}_echo-%e_inv-%p" -z y ${input_file} creates a file named sub-003_echo-1_inv-SB_INV1======tool4.2.nii.gz. The corresponding JSON contains the same string: "ProtocolName": "SB_INV1======tool4.2".

Thank you

neurolabusc commented 6 years ago

Please test the latest commit and close this issue if it fixes your issues. Note that PAR/REC is deprecated by Philips. In general, dcm2niix seems to fast and relatively robust solution. The one limitation is if you abort a 4D scan part way through and the number of 2D slices are not evenly divisible by the number of 3D volumes. In this case, dcm2niix will not convert the file, but it will tell you that you can salvage your data with dicm2nii.

With regards to specifying filenames (e.g. "-f %p_%s"), here are the conversions between the arguments and the PAR tags. Note that not all arguments have an equivalent (e.g. %i %j).

gb4944 commented 6 years ago

That fixed it, thank you very much!