Skip to content

Commit

Permalink
solve issue #491 (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
camillebrianceau authored Oct 24, 2023
1 parent 67d4047 commit ce15fb8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 1 addition & 3 deletions clinicadl/quality_check/t1_volume/quality_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@

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
)
logger.info(
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(
Expand Down
19 changes: 12 additions & 7 deletions clinicadl/quality_check/t1_volume/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit ce15fb8

Please sign in to comment.