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

Add FMAP conversion capability for ADNI #1119

Merged
merged 16 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions clinica/iotools/bids_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,13 +888,17 @@ def run_dcm2niix(
completed_process = subprocess.run(command, capture_output=True)

if completed_process.returncode != 0:
if completed_process.stdout is not None:
output_message = completed_process.stdout.decode('utf-8')
NicolasGensollen marked this conversation as resolved.
Show resolved Hide resolved
else:
output_message = ""
cprint(
msg=(
"DICOM to BIDS conversion with dcm2niix failed:\n"
f"command: {' '.join(command)}\n"
f"{completed_process.stdout.decode('utf-8')}"
f"{output_message}"
),
lvl="warning",
lvl="warning"
NicolasGensollen marked this conversation as resolved.
Show resolved Hide resolved
)
return False
cprint(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def compute_av45_fbb_pet_paths(source_dir, csv_dir, subjs_list, conversion_dir):
pet_meta_list = load_clinical_csv(csv_dir, "PET_META_LIST")

for subj in subjs_list:

NicolasGensollen marked this conversation as resolved.
Show resolved Hide resolved
# PET images metadata for subject
subject_pet_meta = pet_meta_list[pet_meta_list["Subject"] == subj]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def compute_dwi_paths(source_dir, csv_dir, subjs_list, conversion_dir):
]

for subj in subjs_list:

NicolasGensollen marked this conversation as resolved.
Show resolved Hide resolved
# Filter ADNIMERGE, MRI_LIST and QC for only one subject and sort the rows/visits by examination date
adnimerge_subj = adni_merge[adni_merge.PTID == subj]
adnimerge_subj = adnimerge_subj.sort_values("EXAMDATE")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def _convert_adni_fdg_pet(

import pandas as pd


NicolasGensollen marked this conversation as resolved.
Show resolved Hide resolved
from clinica.iotools.converters.adni_to_bids.adni_utils import (
load_clinical_csv,
paths_to_bids,
Expand All @@ -94,7 +95,6 @@ def _convert_adni_fdg_pet(

if subjects is None:
adni_merge = load_clinical_csv(csv_dir, "ADNIMERGE")

subjects = list(adni_merge.PTID.unique())
cprint(
"Calculating paths of FDG PET images. "
Expand All @@ -103,6 +103,7 @@ def _convert_adni_fdg_pet(
images = _compute_fdg_pet_paths(
source_dir, csv_dir, subjects, conversion_dir, preprocessing_step
)

cprint("Paths of FDG PET images found. Exporting images into BIDS ...")
modality = _get_modality_from_adni_preprocessing_step(preprocessing_step)
paths_to_bids(
Expand Down Expand Up @@ -172,6 +173,7 @@ def _compute_fdg_pet_paths(
from clinica.utils.pet import Tracer

pet_fdg_df = _get_pet_fdg_df(Path(csv_dir), subjects, preprocessing_step)

images = find_image_path(pet_fdg_df, source_dir, "FDG", "I", "Image_ID")
images.to_csv(
Path(conversion_dir) / f"{Tracer.FDG.value}_pet_paths.tsv",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def convert_adni_flair(
mod_to_update : bool
If True, pre-existing images in the BIDS directory
will be erased and extracted again.

NicolasGensollen marked this conversation as resolved.
Show resolved Hide resolved
n_procs : int, optional
The requested number of processes.
If specified, it should be between 1 and the number of available CPUs.
Expand Down Expand Up @@ -103,9 +103,10 @@ def compute_flair_paths(source_dir, csv_dir, subjs_list, conversion_dir):
# Loading needed .csv files
adni_merge = load_clinical_csv(csv_dir, "ADNIMERGE")
mayo_mri_qc = load_clinical_csv(csv_dir, "MAYOADIRL_MRI_IMAGEQC_12_08_15")
mayo_mri_qc = mayo_mri_qc[mayo_mri_qc.series_type == "AFL"]
mri_list = load_clinical_csv(csv_dir, "MRILIST")

mayo_mri_qc = mayo_mri_qc[mayo_mri_qc.series_type == "AFL"]

# Selecting FLAIR DTI images that are not MPR
mri_list = mri_list[mri_list.SEQUENCE.str.contains("flair", case=False, na=False)]
unwanted_sequences = ["_MPR_"]
Expand Down
Loading
Loading