Issue with Field Maps and HeuDiConv grouping — incorrect TSV metadata

Hi everyone,

I am converting my raw data to BIDS format. I’m encountering an issue with HeuDiConv during the conversion of field maps, and I suspect it has to do with how the tool groups sequences into the CSV file during the conversion process.

I am using dcm2niix within HeuDiConv to convert raw DICOM files into BIDS format. The dataset includes dual-echo GRE field mapping sequences with two echo times. dcm2niix correctly generates the nifti files and associated JSON sidecars, with accurate metadata:

gre_field_mapping_1acq_e1.json
gre_field_mapping_1acq_e1.nii
gre_field_mapping_1acq_e2.json
gre_field_mapping_1acq_e2.nii         
gre_field_mapping_1acq_e2_ph.json
gre_field_mapping_1acq_e2_ph.nii

If I check the echo times in JSON files it correctly shows 0.01 sec, 0.01246 sec and 0.01246 sec respectively for _e1, _e2 and _e2_ph files.

However, when HeuDiConv generates the TSV file that groups the sequences, it seems to misinterpret or incorrectly group the echoes, resulting in misleading or duplicated entries for the field map sequences. Here is the part of the TSV file:

dim1 dim2 dim3 dim4 TR TE protocol_name
64 64 128 1 1.02 12.46 gre_field_mapping_1acq_rl
64 64 64 1 1.02 12.46 gre_field_mapping_1acq_rl

As you can see there is definitely a problem: there is only two field_mapping protocols with the same TE (there should be three and two of them with different TE).

I am running HeuDiConv using docker on our lab server:

  docker run --rm -v "${project_path}:/base" nipy/heudiconv:latest \
    -d "/base/raw_data/sub-{subject}/sess-{session}/*/*.dcm" \
    -o "/base/analysis/heudiconv_first_outputs/" \
    -f convertall -s "$subj_id" -ss "$sess_id" \
    -c none

I plan to use the heuristic.py file later to organise the data in BIDS-valid format, but if the grouping is done wrong at the first step it seems hard to find a solution.

I am wondering if:

  1. Has anyone encountered similar issues with HeuDiConv misgrouping multi-echo field map sequences?
  2. Are there known bugs or limitations in HeuDiConv’s handling of dual-echo field maps?
  3. Is there a recommended workaround or fix (e.g., manually adjusting the heuristic file, editing the TSV)?

Any help or insights would be greatly appreciated! I’d be happy to provide more details if needed.

Thanks in advance!

After investigating the issue further, it seems that EchoTime is not considered during the grouping of DICOMs in HeuDiConv, specifically in dicoms.py function. This seems to be why field maps with different EchoTimes are incorrectly grouped.

The code explicitly groups echoes by default, as seen here.

The issue might be improved in the ‘group_dicoms_into_seqinfos()’ function. I am not sure how exactly to do it, but gonna investigate further!

If anyone has ideas or suggestions, please let me know!

P.S. I’ve created a GitHub issue.