diff --git a/clinicadl/quality_check/t1_volume/quality_check.py b/clinicadl/quality_check/t1_volume/quality_check.py index 9e9262605..166350614 100644 --- a/clinicadl/quality_check/t1_volume/quality_check.py +++ b/clinicadl/quality_check/t1_volume/quality_check.py @@ -9,12 +9,11 @@ import pandas as pd -from .utils import extract_metrics +from clinicadl.quality_check.t1_volume.utils import extract_metrics def quality_check(caps_dir: Path, output_directory: Path, group_label): logger = getLogger("clinicadl.quality_check") - extract_metrics( caps_dir=caps_dir, output_dir=output_directory, group_label=group_label ) @@ -22,7 +21,6 @@ def quality_check(caps_dir: Path, output_directory: Path, group_label): f"Quality check metrics extracted at {output_directory / 'QC_metrics.tsv'}." ) qc_df = pd.read_csv(output_directory / "QC_metrics.tsv", sep="\t") - rejection1_df = qc_df[qc_df.max_intensity > 0.95] rejection1_df.to_csv(output_directory / "pass_step-1.tsv", sep="\t", index=False) logger.info( diff --git a/clinicadl/quality_check/t1_volume/utils.py b/clinicadl/quality_check/t1_volume/utils.py index 79677e78b..2ace21ccd 100644 --- a/clinicadl/quality_check/t1_volume/utils.py +++ b/clinicadl/quality_check/t1_volume/utils.py @@ -63,11 +63,15 @@ def extract_metrics(caps_dir: Path, output_dir: Path, group_label): results_df = pd.DataFrame(columns=columns) subjects = list((caps_dir / "subjects").iterdir()) - subjects = [subject for subject in subjects if str(subject)[:4:] == "sub-"] + subjects = [ + subject.stem for subject in subjects if str(subject.stem)[:4:] == "sub-" + ] for subject in subjects: subject_path = caps_dir / "subjects" / subject sessions = list(subject_path.iterdir()) - sessions = [session for session in sessions if str(session)[:4:] == "ses-"] + sessions = [ + session.stem for session in sessions if str(session.stem)[:4:] == "ses-" + ] for session in sessions: image_path = ( subject_path @@ -76,12 +80,13 @@ def extract_metrics(caps_dir: Path, output_dir: Path, group_label): / "spm" / "segmentation" / "normalized_space" - / subject - + "_" - + session - + "_T1w_segm-graymatter_space-Ixi549Space_modulated-off_probability.nii.gz" + / ( + subject + + "_" + + session + + "_T1w_segm-graymatter_space-Ixi549Space_modulated-off_probability.nii.gz" + ) ) - if image_path.is_file(): # GM analysis image_nii = nib.load(image_path)