Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to module input_files #1308

Open
NicolasGensollen opened this issue Oct 1, 2024 · 1 comment · May be fixed by #1311
Open

Improvements to module input_files #1308

NicolasGensollen opened this issue Oct 1, 2024 · 1 comment · May be fixed by #1311
Assignees

Comments

@NicolasGensollen
Copy link
Member

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"
    )
@NicolasGensollen
Copy link
Member Author

Keeping this open for now, but will likely be addressed in a more general way by #1398

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant