Assigning correct field map to EPI run out of multiple when function takes only one map

I am trying to unwarp my EPI runs but have multiple field maps per participant (one for the first two runs and the second for the third run). I see the SPM’s FieldMap and RealignUnwarp functions only handle one field map at a time.

Is it possible to iterate or otherwise over these three runs so each one gets the correct field map? I have duplicated the first field map so each EPI run has “its own” field map that matches the EPI run number, but still need to figure out how to actually assign them together.

The code I am using is below. At present, I am extracting the EPI runs, phase image, and magnitude images using DataGrabber and feeding them in when connecting the workflow.

## Making the voxel displacement map ##

makeVDM = pe.Node(spm.FieldMap(),name="makeVDM")   
makeVDM.inputs.echo_times = (4.92, 7.38)
makeVDM.inputs.blip_direction = 1
makeVDM.inputs.total_readout_time = 15.6  

## Unwarping with VDM and realigning ##

realignUnwarp = pe.Node(spm.RealignUnwarp(),name="realignUnwarp")
realignUnwarp.inputs.phase_map = 'VDM'
realignUnwarp.inputs.register_to_mean = True

Hi Gwyn,

I don’t have much experience with SPN, but if you’re planning to use fMRIprep for your analyses, you can use dcm2bids to assign the first fieldmap to runs 1-2 and the second fieldmap to run 1.

Check out the example configuration file here. The relevant part is this:

  "id": "task_rest",
  "datatype": "func",
  "suffix": "bold",
  "custom_entities": "task-rest",
  "criteria": {
    "ProtocolName": "func_task-*",
    "ImageType": ["ORIG*", "PRIMARY", "M", "MB", "ND", "MOSAIC"]
  }
},

{
  "datatype": "fmap",
  "suffix": "fmap",
  "criteria": {
    "ProtocolName": "*field_mapping*"
  },
  "sidecar_changes": {
    "IntendedFor": "task_rest"
  }
}, 

Here the first field defines the task file with id task_rest and the second field defined the fieldmap. Instead of "IntendedFor": "task_rest" you could have something like: "IntendedFor": ["task_1","task2"]. That way fMRIprep would know to use this fieldmap for both task_1 and task_2.

I hope this helps!
Roey

Hi Roey,

Thanks so much for your response! Unfortunately, I’m attempting everything in nipype rather than fMRIprep and dcm2bids is not available in nipype (I’ve ended up creating a very roundabout solution). However this is really convincing me to use fMRIprep for the next project given this flexibility…

Thanks,
Gwyn

1 Like