def cli( dataset_directory: str, clinical_data_directory: str, bids_directory: str, clinical_data_only: bool = False, overwrite: bool = False, ) -> None: """AIBL to BIDS converter. Convert the imaging and clinical data of AIBL (https://aibl.csiro.au/adni/index.html), located in DATASET_DIRECTORY and CLINICAL_DATA_DIRECTORY respectively, to a BIDS dataset in the target BIDS_DIRECTORY. """ from os import makedirs from clinica.iotools.converters.aibl_to_bids.aibl_to_bids import ( convert_clinical_data, convert_images, ) from clinica.utils.check_dependency import check_dcm2niix check_dcm2niix() makedirs(bids_directory, exist_ok=True) if not clinical_data_only: convert_images( dataset_directory, clinical_data_directory, bids_directory, overwrite, ) convert_clinical_data(bids_directory, clinical_data_directory)
def run_command(self, args): """Run the converter with defined args.""" from os import makedirs from os.path import exists from clinica.iotools.converters.aibl_to_bids.aibl_to_bids import ( convert_clinical_data, convert_images, ) from clinica.utils.check_dependency import ( check_dcm2nii, check_dcm2niix, check_freesurfer, ) check_dcm2nii() check_dcm2niix() check_freesurfer() if not exists(args.bids_directory): makedirs(args.bids_directory) convert_images(args.dataset_directory, args.clinical_data_directory, args.bids_directory) convert_clinical_data(args.bids_directory, args.clinical_data_directory)
def run_aibl2bids(input_dir: PathLike, output_dir: PathLike, ref_dir: PathLike) -> None: from clinica.iotools.converters.aibl_to_bids.aibl_to_bids import ( convert_clinical_data, convert_images, ) # Arrange clinical_data_directory = input_dir / "Data_extract_3.2.5" dataset_directory = input_dir / "unorganized_data" # Act convert_images( dataset_directory, clinical_data_directory, output_dir / "bids", ) convert_clinical_data(output_dir / "bids", clinical_data_directory) # Assert compare_folders(output_dir / "bids", ref_dir / "bids", output_dir)
def test_run_Aibl2Bids(cmdopt): from clinica.iotools.converters.aibl_to_bids.aibl_to_bids import convert_clinical_data, convert_images from os.path import dirname, join, abspath from .comparison_functions import compare_folders root = join(dirname(abspath(__file__)), 'data', 'Aibl2Bids') dataset_directory = join(root, 'in', 'unorganized_data') clinical_data_directory = join(root, 'in', 'Data_extract_3.2.5') bids_directory = join(root, 'out', 'bids') clean_folder(join(root, 'out', 'bids'), recreate=True) # Perform conversion of dataset convert_images(dataset_directory, clinical_data_directory, bids_directory) convert_clinical_data(bids_directory, clinical_data_directory) # Evaluate difference between ref and out compare_folders(join(root, 'out'), join(root, 'ref'), shared_folder_name='bids') clean_folder(join(root, 'out', 'bids'), recreate=True)
def run_command(self, args): from os.path import exists from os import makedirs from colorama import Fore from clinica.iotools.converters.aibl_to_bids.aibl_to_bids import convert_clinical_data, convert_images from clinica.utils.check_dependency import is_binary_present, check_freesurfer from clinica.utils.exceptions import ClinicaMissingDependencyError list_binaries = ['dcm2niix', 'dcm2nii'] for binary in list_binaries: if not is_binary_present(binary): raise ClinicaMissingDependencyError( '%s\n[Error] Clinica could not find %s software: it is not present in your ' 'PATH environment.%s' % (Fore.RED, binary, Fore.RESET)) check_freesurfer() if not exists(args.bids_directory): makedirs(args.bids_directory) convert_images(args.dataset_directory, args.clinical_data_directory, args.bids_directory) convert_clinical_data(args.bids_directory, args.clinical_data_directory)
def run_command(self, args): from clinica.iotools.converters.aibl_to_bids.aibl_to_bids import convert_clinical_data, convert_images convert_images(args.dataset_directory, args.clinical_data_directory, args.bids_directory) convert_clinical_data(args.bids_directory, args.clinical_data_directory)