Skip to content

Improvements to module input_files #1308

@NicolasGensollen

Description

@NicolasGensollen

The module clinica.utils.input_files defines a long list of dictionaries which are used as query patterns in the clinica_file_reader functions.

First of all, there are a lot of these objects which are not used in the code base. A few examples:

T2W_LINEAR
FLAIR_T2W_LINEAR
T1W_EXTENSIVE
FLAIR_T2W_LINEAR_CROPPED

We clearly should get rid of them.

All these patterns could also be better represented with dataclasses since they have a defined structure. Something like that would already enrich the code:

@dataclass
class Pattern:
    pattern: str
    description: str
    needed_pipeline: str

Also, a lot of these patterns could be factorized in functions taking some parameters (the hemisphere, the name of the atlas, the pet tracer...) instead of being copy-pasted.

For example this

T1_FS_LONG_SURF_R = {
"pattern": "t1/long-*/freesurfer_longitudinal/sub-*_ses-*.long.sub-*_*/surf/rh.white",
"description": "right white matter/gray matter border surface (rh.white) generated with t1-freesurfer-longitudinal.",
"needed_pipeline": "t1-freesurfer and t1-freesurfer longitudinal",
}
T1_FS_LONG_SURF_L = {
"pattern": "t1/long-*/freesurfer_longitudinal/sub-*_ses-*.long.sub-*_*/surf/lh.white",
"description": "left white matter/gray matter border surface (lh.white) generated with t1-freesurfer-longitudinal.",
"needed_pipeline": "t1-freesurfer and t1-freesurfer longitudinal",
}

could easily be factorized in:

def get_t1_freesurfer_longitudinal_white_matter_surface_pattern(
    hemisphere: Union[str, HemiSphere],
) -> Pattern:
    hemisphere = HemiSphere(hemisphere)
    return Pattern(
        f"t1/long-*/freesurfer_longitudinal/sub-*_ses-*.long.sub-*_*/surf/{hemisphere.value}.white",
        (
            f"{'right' if hemisphere == HemiSphere.RIGHT else 'left'} white matter/gray matter border "
            f"surface ({hemisphere.value}.white) generated with t1-freesurfer-longitudinal."
        ),
        "t1-freesurfer and t1-freesurfer longitudinal"
    )

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions