[RESOLVED] Issue using import_dicom with PAR/REC files

Hi, hope you are doing well! I am trying to use qunex import_dicom to convert from Philips PAR/REC files to nii but have not been successful. The files get copied from /sessions/inbox/MR but are not converted (please see command and error below). In the QuNex documentation on onboarding dicom data I see that PAR/REC files are supported, is this fully implemented in QuNex 0.90.6, and if so is there an option that I need to include for it to work? Thank you for the help.

(/opt/env/qunex) [QuNex sessions]$ qunex import_dicom --sessionsfolder=/u/project/cbearden/data/Enigma/Utrecht/qunex_studyfolder/sessions --gzip=yes --check=any
/u/local/Modules/4.7.0/gcc-4.8.5/init/bash: line 37: /usr/bin/tclsh: No such file or directory

 ........................ Running QuNex v0.90.6 ........................ 

--- Full QuNex call for command: import_dicom 

gmri import_dicom --sessionsfolder="/u/project/cbearden/data/Enigma/Utrecht/qunex_studyfolder/sessions" --gzip="yes" --check="any" 


# Generated by QuNex 0.90.6 on 2022-03-24_10.48.1648144129.794416 /u/project/cbearden/data/Enigma/Utrecht/qunex_studyfolder/processing/logs/comlogs/tmp_import_dicom_2022-03-24_10.48.1648144129.794416.log
# /u/project/cbearden/data/Enigma/Utrecht/qunex_studyfolder/processing/logs/comlogs/tmp_import_dicom_2022-03-24_10.48.1648144129.794416.log
started running import_dicom at 2022-03-24 10:48:49, track progress in /u/project/cbearden/data/Enigma/Utrecht/qunex_studyfolder/processing/logs/comlogs/tmp_import_dicom_2022-03-24_10.48.1648144129.794416.log
# Generated by QuNex 0.90.6 on 2022-03-24_10.48.1648144129.794416
Started running import_dicom at 2022-03-24 10:48:49
call: gmri import_dicom gzip="yes" sessionsfolder="/u/project/cbearden/data/Enigma/Utrecht/qunex_studyfolder/sessions" check="any"
Running import_dicom
---> Checking for packets in /u/project/cbearden/data/Enigma/Utrecht/qunex_studyfolder/sessions/inbox/MR 
     ... using regular expression '(?P<packet_name>.*?)(?:\.zip$|\.tar$|\.tgz$|\.tar\..*$|$)'
     ... extracting subject id using regular expression '(?P<subject_id>.*)'

---> Found the following packets to process:
     subject: xjv1060213 ... xjv1060213 <= xjv1060213 <- xjv1060213
---> Starting to process 1 packets ...

---=== PROCESSING xjv1060213 ===---

...  copying xjv1060213 dicom files

Running sort_dicom
---> Processing 14 files from /u/project/cbearden/data/Enigma/Utrecht/qunex_studyfolder/sessions/xjv1060213/inbox

Traceback (most recent call last):
  File "/opt/qunex/python/qx_utilities/general/core.py", line 526, in runWithLog
    result = function(**args)
  File "/opt/qunex/python/qx_utilities/general/dicom.py", line 2535, in import_dicom
  File "/opt/qunex/python/qx_utilities/general/dicom.py", line 1532, in sort_dicom
    info = readPARInfo(dcm)
  File "/opt/qunex/python/qx_utilities/general/dicom.py", line 130, in readPARInfo
    info['TR']                 = float(info['Repetition time [msec]'])
KeyError: 'Repetition time [msec]'

Finished at 2022-03-24 10:48:53

I get the same error when trying sort_dicom for the single session

Charlie, hi!

PAR/REC processing is fully supported and works on the PAR/REC files that we have available. Based on your error report, it seems that the PAR format is not really stable or consistent. I am basing this on the fact that “Repetition time [msec]” information is either not present in your PAR files or the parameter is reported differently. In the PAR files we have available TR is reported as:

.    Repetition time [msec]             :   1000.00

The easy way to resolve this and possible other inconsistencies would be if you can share an example of a PAR file. You can either share it here or send it to me if you deem the information sensitive. I can then check for this and other possible inconsistencies and we can provide the fix in the next QuNex release.

All the best,


Hi Grega, great to hear from you! Thank you for offering to take a look at an example PAR file, I appreciate the help. Could I email it to you?


thanks for sending the example PAR files. As I suspected, there is a difference in the parameter name between the PAR files. In our par files, TR is reported as Repetition time [msec] and in your files as Repetition time [ms]. The rest of the parameters have the same name and there should be no problem with them. I’ll make the code more robust to such differences. On your end, if you would like to process the data before a new release of QuNex with a fix, you can search/replace Repetition time [ms] for Repetition time [msec] in all your PAR files, and they should be processed fine.

Actually, to ensure that files are perfect, you would need to replace 'Repetition time [ms] ' with 'Repetition time [msec]'. Note the two extra spaces at the end of the search string. This way the alignment of the lines will also stay the same.

Thanks a ton Grega! That is very helpful, I will try editing the PAR files