Handling anatomical and fieldmap sequences that produce several images

Dear community,

I am working with QALAS data from recorded on Siemens and I am trying to find the most optimal way to process DICOM files into BIDS using heudiconv.

QALAS recordings come with the TB1TFL fieldmaps, which I process in the naïve fashion:

def create_key(template, outtype=('nii.gz',), annotation_classes=None):
    if template is None or not template:
        raise ValueError('Template must be a valid format string')
    return template, outtype, annotation_classes

def infotodict(seqinfo):
    folder_anat = 'sub-{subject}/{session}/anat/'
    folder_fmap = 'sub-{subject}/{session}/fmap/'

    qalas = create_key(str(folder_anat + 'sub-{subject}_{session}_acq-QALAS_run-00{item:01d}_QALAS'))
    tflb1map = create_key(str(folder_fmap + 'sub-{subject}_{session}_acq-QALAS_run-00{item:01d}_TB1TFL'))

    info = {
            qalas: [], 
            tflb1map: []}

    for s in seqinfo:
        if ('acq-qalas' in s.series_description):
            info[qalas].append(s.series_id)
        elif ('acq-tb1tfl' in s.series_description):
            info[tflb1map].append(s.series_id) 

    return info

Each recording produces only one row in dicominfo.tsv, the issue seems to be described here under “Step 2” (" Some values in dicominfo.tsv might be wrong"). As the result, I get the following output:

'sub/ses/anat/sub-{subject}_{session}_acq-QALAS_run-001_QALAS1.{nii.gz|.json}'
'sub/ses/anat/sub-{subject}_{session}_acq-QALAS_run-001_QALAS2.{nii.gz|.json}'
'sub/ses/anat/sub-{subject}_{session}_acq-QALAS_run-001_QALAS3.{nii.gz|.json}'
'sub/ses/anat/sub-{subject}_{session}_acq-QALAS_run-001_QALAS4.{nii.gz|.json}'
'sub/ses/anat/sub-{subject}_{session}_acq-QALAS_run-001_QALAS5.{nii.gz|.json}'
'sub/ses/anat/sub-{subject}_{session}_acq-QALAS_run-001_TB1TFL1.{nii.gz|.json}'
'sub/ses/anat/sub-{subject}_{session}_acq-QALAS_run-001_TB1TFL2.{nii.gz|.json}'

When the goal is to achieve the following output:

'sub/ses/anat/sub-{subject}_{session}_acq-QALAS_run-001_QALAS.{nii.gz|.json}'
'sub/ses/anat/sub-{subject}_{session}_acq-anatQALAS_run-001_TB1TFL.{nii.gz|.json}'
'sub/ses/anat/sub-{subject}_{session}_acq-fampQALAS_run-001_TB1TFL.{nii.gz|.json}'

There two different issues arise:

  • QALAS recording was divided in 5 different images, that should have been concatenated in the 4th dimension (like DWI or fMRI images). When dicominfo.tsv is created, it identifies dim3=640 and dim4=1 instead of desired dim3=128 and dim4=5. I tried manually updating dicominfo.tsv, but heudiconv seems to ignore it. Is there a flag somewhere in heudicnv processing pipeline that would allow me to concatinate images, analogous to “dcm2niix -m y”?
  • As long as dicominfo.tsv produces only one row for the TB1TFL fieldmap, I do not have means of distinguishing between the standard acq-anat (saved as TB1TFL1) and acq-famp (saved as TB1TFL2). Is there a way to force heudiconv to use a different key for naming instead appending the number at the end?

Thank you very much for your help! I am looking forward discussing it with you.
Maksim

General info:
heudiconv v1.0.1
singularity v3.7.3
Singularity command:

singularity run \
-B $sorted_folder/.. \
$sorted_folder/tools/heudiconv_latest.sif \ 
-d $sorted_folder/{subject}_ses-${ses}/* \
-o ${bids_folder} \
-s ${sub} \
-ss ${ses} \
-c dcm2niix \
-f ${bids_folder}/code/heuristic.py\
--grouping all \
-b