nipreps / niworkflows

Common workflows for MRI (anatomical, functional, diffusion, etc)
https://www.nipreps.org/niworkflows
Apache License 2.0
87 stars 52 forks source link

``DerivativesDataSink`` drops ``fmapid`` entity when storing fieldmap reportlets #637

Closed oesteban closed 3 years ago

oesteban commented 3 years ago

DerivativesDataSink produces derivatives/dmriprep/sub-36/figures/sub-36_desc-pepolar_fieldmap.svg instead of derivatives/dmriprep/sub-36/figures/sub-36_fmapid-auto0000_desc-pepolar_fieldmap.svg

        DerivativesDataSink(
            base_directory=str(output_dir),
            datatype="figures",
            suffix="fieldmap",
            desc=fmap_type,
            dismiss_entities=("fmap",),
            allowed_entities=("fmapid",),
            source_file=["sub-36/fmap/sub-36_dir-1_run-1_epi.nii.gz", "sub-36/fmap/sub-36_dir-1_run-2_epi.nii.gz", "sub-36/fmap/sub-36_dir-2_run-1_epi.nii.gz", "sub-36/fmap/sub-36_dir-2_run-2_epi.nii.gz"],
            fmapid="auto0000"
        )

It seems that allowed_entities is not respected in this case.

oesteban commented 3 years ago

Okay, it seems to boil down to this line: https://github.com/nipreps/niworkflows/blob/32a33d61ab64e262a4ebcf8afcf232d70c2f92b3/niworkflows/interfaces/bids.py#L583

where build_path is passed

{'subject': '36', 'suffix': 'fieldmap', 'datatype': 'figures', 'extension': 'svg', 'desc': 'pepolar', 'fmapid': 'auto00000'}

and patterns contain those from our nipreps.json config:

[
...
 'sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_desc-{desc}]_{suffix<T1w|T2w|T1rho|T1map|T2map|T2star|FLAIR|FLASH|PDmap|PD|PDT2|inplaneT[12]|angio|dseg|mask|dwi|epiref|fieldmap|T2starw|MTw|TSE>}{extension<.html|.svg>|.svg}',
 'sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_run-{run}][_space-{space}][_cohort-{cohort}][_fmapid-{fmapid}][_desc-{desc}]_{suffix<fieldmap>}{extension<.html|.svg>|.svg}',
 'sub-{subject}/{datatype<figures>}/sub-{subject}[_ses-{session}]_task-{task}[_acq-{acquisition}][_ce-{ceagent}][_dir-{direction}][_rec-{reconstruction}][_run-{run}][_echo-{echo}][_space-{space}][_cohort-{cohort}][_desc-{desc}]_{suffix<bold>}{extension<.html|.svg>|.svg}']

Here, build_path returns 'sub-36/figures/sub-36_desc-pepolar_fieldmap.svg'.

Is it possible that the extension should have the initial dot? /cc @effigies @mgxd

oesteban commented 3 years ago

Okay, found it - the fieldmap-specific pattern was being overshadowed by the immediately previous pattern.