Skip to content

Commit

Permalink
[ENH] Add FMAP conversion capability for ADNI (#1119)
Browse files Browse the repository at this point in the history
* Fix string handling for ADNI-to-BIDS CSV parsing

* Fix issues that occurred after moving to Linux

* Added FMAP conversion

* Fixed FMAP method

* Incorporate latest Clinica dev with FMAP

* Adjusted per PR comments

* Adjusted per PR comments #2

* Review PR1119

* Remove duplicated function

* Make code more robust, remove duplication

* Pre-commit test

* Fix more linting issues

* Fix additional linting issues

---------

Co-authored-by: AliceJoubert <[email protected]>
  • Loading branch information
tharpm95 and AliceJoubert authored May 7, 2024
1 parent 81fbca8 commit f5b6442
Show file tree
Hide file tree
Showing 10 changed files with 638 additions and 136 deletions.
6 changes: 5 additions & 1 deletion clinica/iotools/bids_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,11 +888,15 @@ 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")
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",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,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 +102,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 +172,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 @@ -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

0 comments on commit f5b6442

Please sign in to comment.