run_dicom_to_nifti(project_dir: str, subject_id: str, *, logger, runner: CommandRunner | None = None) -> None
Convert DICOMs to BIDS-compliant NIfTI for a subject.
Parameters
project_dir : str
BIDS project root directory.
subject_id : str
Subject identifier without the 'sub-' prefix.
logger : logging.Logger
Logger for progress and command output.
runner : CommandRunner, optional
Subprocess runner for streaming output.
Source code in tit/pre/dicom2nifti.py
| def run_dicom_to_nifti(
project_dir: str,
subject_id: str,
*,
logger,
runner: CommandRunner | None = None,
) -> None:
"""Convert DICOMs to BIDS-compliant NIfTI for a subject.
Parameters
----------
project_dir : str
BIDS project root directory.
subject_id : str
Subject identifier without the 'sub-' prefix.
logger : logging.Logger
Logger for progress and command output.
runner : CommandRunner, optional
Subprocess runner for streaming output.
"""
pm = get_path_manager(project_dir)
sourcedata_dir = Path(pm.sourcedata_subject(subject_id))
bids_anat_dir = Path(pm.bids_anat(subject_id))
bids_anat_dir.mkdir(parents=True, exist_ok=True)
converted = False
for modality in ("T1w", "T2w"):
if _process_modality(
modality,
sourcedata_dir,
bids_anat_dir,
subject_id,
pm,
logger,
runner,
):
converted = True
if not converted:
logger.warning("No DICOM files found or converted")
|