Skip to content

Commit

Permalink
[FIX] Ignore real and imaginary scans in ADNI (aramis-lab#1029)
Browse files Browse the repository at this point in the history
* log dcm2niix command in debug or warning mode depending on sucess or failure

* remove unused imports and explicit level of logging

* remove unused imports and explicit level of logging again

* Use Pathlib in path_to_bids and remove real and imaginary images generated by dcm2niix

* Apply suggestions from code review
  • Loading branch information
NicolasGensollen authored Dec 8, 2023
1 parent ee5649d commit a19bade
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 156 deletions.
10 changes: 7 additions & 3 deletions clinica/iotools/bids_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,10 +833,10 @@ def _build_dcm2niix_command(
bids_sidecar: bool = True,
) -> list:
"""Generate the dcm2niix command from user inputs."""
command = ["dcm2niix", "-w", "0", "-f", output_fmt, "-o", output_dir]
command = ["dcm2niix", "-w", "0", "-f", output_fmt, "-o", str(output_dir)]
command += ["-9", "-z", "y"] if compress else ["-z", "n"]
command += ["-b", "y", "-ba", "y"] if bids_sidecar else ["-b", "n"]
command += [input_dir]
command += [str(input_dir)]

return command

Expand Down Expand Up @@ -889,12 +889,16 @@ def run_dcm2niix(
cprint(
msg=(
"DICOM to BIDS conversion with dcm2niix failed:\n"
f"command: {command}\n"
f"command: {' '.join(command)}\n"
f"{completed_process.stdout.decode('utf-8')}"
),
lvl="warning",
)
return False
cprint(
f"DICOM to BIDS conversion with dcm2niix failed:\ncommand: {' '.join(command)}\n",
lvl="debug",
)
return True


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ def convert_adni_flair(
If specified, it should be between 1 and the number of available CPUs.
Default=1.
"""
from os import path

import pandas as pd

from clinica.iotools.converters.adni_to_bids.adni_utils import (
load_clinical_csv,
paths_to_bids,
Expand All @@ -55,10 +51,11 @@ def convert_adni_flair(
subjects = list(adni_merge.PTID.unique())

cprint(
f"Calculating paths of FLAIR images. Output will be stored in {conversion_dir}."
f"Calculating paths of FLAIR images. Output will be stored in {conversion_dir}.",
lvl="info",
)
images = compute_flair_paths(source_dir, csv_dir, subjects, conversion_dir)
cprint("Paths of FLAIR images found. Exporting images into BIDS ...")
cprint("Paths of FLAIR images found. Exporting images into BIDS ...", lvl="info")
# flair_paths_to_bids(images, dest_dir)
paths_to_bids(
images, destination_dir, "flair", mod_to_update=mod_to_update, n_procs=n_procs
Expand Down
Loading

0 comments on commit a19bade

Please sign in to comment.