[RESOLVED] Hcp_pre_freesurfer errors when using Siemens fieldmap

Continuing the discussion from [RESOLVED] Hcp_fmri_volume errors when using Siemens fieldmap:


Dear Qunex experts, I am getting the same error in hcp_pre_freesurfer pipeline. Both phase and magnitude fieldmaps are present: /unprocessed/FieldMap/1002_FieldMap_Magnitude.nii.gz /unprocessed/FieldMap/1002_FieldMap_Phase.nii.gz and the fieldmaps have fm(1) specified in the batch file (attached). However, I am getting the following error:


# Generated by QuNex 0.93.6 on 2022-08-22_20.06.41.541732
gmri hcp_pre_freesurfer \
  --sessionsfolder="/storage/brno2/home/pe_so/qunex/ocd/sessions" \
  --sessions="/storage/brno2/home/pe_so/qunex/ocd/processing/batch.txt" \
  --overwrite="no" \
  --logfolder="/storage/brno2/home/pe_so/qunex/ocd/processing/logs" \
  --sessionids="" \

Starting multiprocessing sessions in /storage/brno2/home/pe_so/qunex/ocd/processing/batch.txt with a pool of 1 concurrent processes

---- Running local

Starting processing of sessions 1002 at Monday, 22. August 2022 20:06:41

Session id: 1002 
[started on Monday, 22. August 2022 20:06:41]
Running HCP PreFreeSurfer Pipeline [HCPStyleData] ...

---> T1w image file present.
---> T2w image file present.
ERROR: Unknown error occured: 
Traceback (most recent call last):
  File "/opt/qunex/python/qx_utilities/hcp/process_hcp.py", line 735, in hcp_pre_freesurfer
    fmmag = hcp['fieldmap'][int(fmnum)]['magnitude']
KeyError: 1

HCP PreFS completed on Monday, 22. August 2022 20:06:41

Thank you for your help,
batch.txt (3.1 KB)

Hi Petr,

can you try setting


You can set this in the command call or change line #31 in your batch file. Let me know if this works.


Hi Jure,
unfortunately the same error occurs:/

The algorithm looks for the FieldMap Magnitude file with the following pattern:


Can you provide us with contents of


And also the contents of any FieldMap subfolders if they exist. Thanks!

The files should be at:


All of this is created in the import_dicom => create_session_info => setup_hcp pipeline. Did you maybe do any edits to input parameters, files or output folders after you ran this or in the middle of running it?

Hi Jure,
this is the content of the /unprocessed folder:

Diffusion FieldMap T1w T2w

1002_DWI_dir30_AP.bval 1002_DWI_dir30_AP.bvec 1002_DWI_dir30_AP.nii.gz 1002_DWI_dir30_PA.bval 1002_DWI_dir30_PA.bvec 1002_DWI_dir30_PA.nii.gz

1002_FieldMap_Magnitude.nii.gz 1002_FieldMap_Phase.nii.gz



I am not aware to change anything during/after import_dicom => create_session_info => setup_hcp pipeline but I will rerun the steps to be sure.

Thank you, Petr

Can you also paste the mapping file here, just so we have all the information, thanks!

So, the problem is that /unprocessed/FieldMap/1002_FieldMap_Magnitude.nii.gz should be stored in /unprocessed/FieldMap1/1002_FieldMap_Magnitude.nii.gz. Let us know if the 1 will be again missing from the FieldMap folder and we will investigate what is going on. We ran some tests but were unable to reproduce the described issue.