def run_oasis3tobids(input_dir: PathLike, output_dir: PathLike, ref_dir: PathLike) -> None: from clinica.iotools.converters.oasis3_to_bids.oasis3_to_bids import convert_images # Arrange clinical_data_directory = input_dir / "clinical_data" # Act convert_images(input_dir / "unorganized", output_dir / "bids", clinical_data_directory) # Assert compare_folders(output_dir / "bids", ref_dir / "bids", output_dir)
def test_run_Nifd2Bids(cmdopt): import shutil from os.path import abspath, dirname, join from clinica.iotools.converters.nifd_to_bids.nifd_to_bids import ( convert_clinical_data, convert_images, ) root = join(dirname(abspath(__file__)), pardir, pardir, "data", "Nifd2Bids") clean_folder(join(root, "out", "bids"), recreate=True) clean_folder(join(root, "out", "clinical_data"), recreate=False) shutil.copytree( join(root, "in", "clinical_data"), join(root, "out", "clinical_data") ) # Data location dataset_directory = join(root, "in", "unorganized") bids_directory = join(root, "out", "bids") clinical_data_directory = join(root, "out", "clinical_data") # Conversion to_convert = convert_images( dataset_directory, bids_directory, clinical_data_directory ) convert_clinical_data(bids_directory, clinical_data_directory, to_convert) compare_folders_structures(bids_directory, join(root, "ref", "hashes_nifd.p")) clean_folder(join(root, "out", "bids"), recreate=True) clean_folder(join(root, "out", "clinical_data"), recreate=False)
def run_command(self, args): from clinica.iotools.converters.nifd_to_bids.nifd_to_bids import convert_images, convert_clinical_data from clinica.iotools.converter_utils import check_bin from clinica.utils.stream import cprint from colorama import Fore import sys missing_bin = check_bin('dcm2niix') if missing_bin: cprint( Fore.RED + 'dcm2niix is required.' + ' Install it and re-run the converter. You can use the following link :' + Fore.BLUE + '\nhttps://github.com/rordenlab/dcm2niix' + Fore.RESET) cprint('Exiting clinica...') sys.exit() # to_convert = convert_images(args.dataset_directory, args.ida_file, args.bids_directory) # convert_clinical_data(args.bids_directory, args.ida_file, args.clinical_data_file, to_convert) to_convert = convert_images(args.dataset_directory, args.bids_directory, args.clinical_data_directory) convert_clinical_data(args.bids_directory, args.clinical_data_directory, to_convert) cprint(Fore.GREEN + 'Conversion to BIDS succeeded' + Fore.RESET)
def test_run_Nifd2Bids(cmdopt): from clinica.iotools.converters.nifd_to_bids.nifd_to_bids import convert_clinical_data, convert_images from os.path import dirname, join, abspath import shutil root = join(dirname(abspath(__file__)), pardir, 'data', 'Nifd2Bids') clean_folder(join(root, 'out', 'bids'), recreate=True) clean_folder(join(root, 'out', 'clinical_data'), recreate=False) shutil.copytree(join(root, 'in', 'clinical_data'), join(root, 'out', 'clinical_data')) # Data location dataset_directory = join(root, 'in', 'unorganized') bids_directory = join(root, 'out', 'bids') clinical_data_directory = join(root, 'out', 'clinical_data') # Conversion to_convert = convert_images(dataset_directory, bids_directory, clinical_data_directory) convert_clinical_data(bids_directory, clinical_data_directory, to_convert) compare_folders_structures(bids_directory, join(root, 'ref', 'hashes_nifd.p')) clean_folder(join(root, 'out', 'bids'), recreate=True) clean_folder(join(root, 'out', 'clinical_data'), recreate=False)
def cli( dataset_directory: str, clinical_data_directory: str, bids_directory: str, ) -> None: """NIFD to BIDS converter. Convert the imaging and clinical data of NIFD (http://4rtni-ftldni.ini.usc.edu/), located in DATASET_DIRECTORY and CLINICAL_DATA_DIRECTORY respectively, to a BIDS dataset in the target BIDS_DIRECTORY. """ from clinica.iotools.converters.nifd_to_bids.nifd_to_bids import convert_images from clinica.utils.check_dependency import check_dcm2niix from clinica.utils.stream import cprint check_dcm2niix() convert_images(dataset_directory, bids_directory, clinical_data_directory) cprint("Conversion to BIDS succeeded.")
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 root = dirname(abspath(join(abspath(__file__), pardir))) root = join(root, '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): """Run the converter with defined args.""" from colorama import Fore from clinica.iotools.converters.nifd_to_bids.nifd_to_bids import convert_images, convert_clinical_data from clinica.utils.stream import cprint from clinica.utils.check_dependency import check_dcm2niix check_dcm2niix() # to_convert = convert_images(args.dataset_directory, args.ida_file, args.bids_directory) # convert_clinical_data(args.bids_directory, args.ida_file, args.clinical_data_file, to_convert) to_convert = convert_images(args.dataset_directory, args.bids_directory, args.clinical_data_directory) convert_clinical_data(args.bids_directory, args.clinical_data_directory, to_convert) cprint(Fore.GREEN + 'Conversion to BIDS succeeded' + Fore.RESET)
def test_run_Aibl2Bids(cmdopt): from os.path import abspath, dirname, join from clinica.iotools.converters.aibl_to_bids.aibl_to_bids import ( convert_clinical_data, convert_images, ) root = dirname(abspath(join(abspath(__file__), pardir, pardir))) root = join(root, "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_nifd2bids(input_dir: PathLike, output_dir: PathLike, ref_dir: PathLike) -> None: import shutil from clinica.iotools.converters.nifd_to_bids.nifd_to_bids import convert_images # Arrange shutil.copytree( input_dir / "clinical_data", output_dir / "clinical_data", copy_function=shutil.copy, ) # Arrange - Data location clinical_data_directory = output_dir / "clinical_data" # Acte - Conversion to_convert = convert_images(input_dir / "unorganized", output_dir / "bids", clinical_data_directory) # Assert compare_folders_structures(fspath(output_dir / "bids"), fspath(ref_dir / "hashes_nifd.p"))