-
Notifications
You must be signed in to change notification settings - Fork 87
Description
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: strAlso, 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
clinica/clinica/utils/input_files.py
Lines 51 to 61 in 954d4a9
| 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"
)