nipy / heudiconv

Flexible DICOM conversion into structured directory layouts
https://heudiconv.readthedocs.io
Other
236 stars 125 forks source link

Heudiconv converts SE EPI SBRefs despite heuristic.py ignoring them #616

Open sitek opened 1 year ago

sitek commented 1 year ago

Summary

Using a CMRR Spin Echo EPI sequence for PEPolar SDC correction on a 7T. We're collecting SE EPI before every BOLD run.

SBRef is exported separately:

image

So I exclude that series_description text in my heuristic.py:

                if ('FieldMap SE PA' in s.series_description):
                    if ~('SBRef' in s.series_description):
                        if ('M' in s.image_type):
                            info[fieldmap_se_pa].append(s.series_id)
                elif ('FieldMap SE AP' in s.series_description):
                    if ~('SBRef' in s.series_description):
                        if ('M' in s.image_type):
                            info[fieldmap_se_ap].append(s.series_id)

And—correctly—the SE EPI SBRef doesn't appear in *auto.txt – here's the output of cat .heudiconv/FLT10/ses-1/info/FLT10_ses-1.auto.txt:

                                                                 'MP2RAGE '
                                                                 '0p55'],
 ('sub-{subject}/anat/sub-{subject}_T1w', ('nii.gz',), None): ['10-T1w MP2RAGE '
                                                               '0p55'],
 ('sub-{subject}/anat/sub-{subject}_UNIT1', ('nii.gz',), None): ['11-T1w '
                                                                 'MP2RAGE '
                                                                 '0p55'],
 ('sub-{subject}/fmap/sub-{subject}_acq-func_dir-AP_run-{item:02d}_epi', ('nii.gz',), None): ['15-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '1',
                                                                                              '16-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '1',
                                                                                              '24-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '2',
                                                                                              '31-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '3',
                                                                                              '32-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '3',
                                                                                              '40-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '4',
                                                                                              '48-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '5',
                                                                                              '55-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '6',
                                                                                              '56-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '6',
                                                                                              '63-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'STgrid '
                                                                                              '1',
                                                                                              '64-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'STgrid '
                                                                                              '1',
                                                                                              '72-FieldMap '
                                                                                              'SE '
                                                                                              'AP '
                                                                                              'STgrid '
                                                                                              '2'],
 ('sub-{subject}/fmap/sub-{subject}_acq-func_dir-PA_run-{item:02d}_epi', ('nii.gz',), None): ['12-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '1',
                                                                                              '13-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '1',
                                                                                              '20-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '2',
                                                                                              '21-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '2',
                                                                                              '29-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '3',
                                                                                              '36-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '4',
                                                                                              '37-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '4',
                                                                                              '44-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '5',
                                                                                              '45-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '5',
                                                                                              '52-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '6',
                                                                                              '53-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'Tone '
                                                                                              'Learning '
                                                                                              '6',
                                                                                              '61-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'STgrid '
                                                                                              '1',
                                                                                              '69-FieldMap '
                                                                                              'SE '
                                                                                              'PA '
                                                                                              'STgrid '
                                                                                              '2'],
 ('sub-{subject}/func/sub-{subject}_task-stgrid_run-{item:02d}_bold', ('nii.gz',), None): ['67-STgrid '
                                                                                           '1',
                                                                                           '75-STgrid '
                                                                                           '2'],
 ('sub-{subject}/func/sub-{subject}_task-stgrid_run-{item:02d}_sbref', ('nii.gz',), None): ['66-STgrid '
                                                                                            '1',
                                                                                            '74-STgrid '
                                                                                            '2'],
 ('sub-{subject}/func/sub-{subject}_task-tonecat_run-{item:02d}_bold', ('nii.gz',), None): ['19-Tone '
                                                                                            'Learning '
                                                                                            '1',
                                                                                            '27-Tone '
                                                                                            'Learning '
                                                                                            '2',
                                                                                            '35-Tone '
                                                                                            'Learning '
                                                                                            '3',
                                                                                            '43-Tone '
                                                                                            'Learning '
                                                                                            '4',
                                                                                            '51-Tone '
                                                                                            'Learning '
                                                                                            '5',
                                                                                            '59-Tone '
                                                                                            'Learning '
                                                                                            '6'],
 ('sub-{subject}/func/sub-{subject}_task-tonecat_run-{item:02d}_sbref', ('nii.gz',), None): ['18-Tone '
                                                                                             'Learning '
                                                                                             '1',
                                                                                             '26-Tone '
                                                                                             'Learning '
                                                                                             '2',
                                                                                             '34-Tone '
                                                                                             'Learning '
                                                                                             '3',
                                                                                             '42-Tone '
                                                                                             'Learning '
                                                                                             '4',
                                                                                             '50-Tone '
                                                                                             'Learning '
                                                                                             '5',
                                                                                             '58-Tone '
                                                                                             'Learning '
                                                                                             '6'],
 ('sub-{subject}/swi/sub-{subject}_part-mag_swi', ('nii.gz',), None): ['76-SWI'],
 ('sub-{subject}/swi/sub-{subject}_part-phase_swi', ('nii.gz',), None): ['77-SWI'],
 ('sub-{subject}/swi/sub-{subject}_rec-mIP_swi', ('nii.gz',), None): ['78-SWI'],
 ('sub-{subject}/swi/sub-{subject}_swi', ('nii.gz',), None): ['79-SWI']}(py2023)

But heudiconv converts the SBRef files anyway and gives them part-{mag|phase} descriptors: image

with sub-FLT10_acq-func_dir-AP_run-01_part-mag_epi.json noting that they come from SBRef files: "SeriesDescription": "FieldMap_SE_AP_Tone_Learning_1_SBRef",

The files aren't ordered the same between AP and PA acquisitions, either—for instance, dir-AP_run-03 is a true SE EPI magnitude image, while dir-PA_run-03 is an SBRef part-{mag|phase} pair. This then throws off IntendedFor matching, since there's no dir-PA equivalent to dir-AP_run-03, so one of my bold runs doesn't get included in any dir-PA IntendedFor fields.

May be related to #549 and associated PRs.

Platform details:

Choose one:

yarikoptic commented 1 year ago

@sitek and @bpinsard - do you have samples of such peculiar data to share? (ideally openly, may be some phantoms)

sitek commented 1 year ago

@yarikoptic see anonymized brain dataset here

PeerHerholz commented 1 year ago

Hi @sitek & @yarikoptic,

I'm running into a comparable problem and was wondering if there are any updates concerning this?

Cheers, Peer