def test_instantiate_PETVolume():
    from clinica.pipelines.pet_volume.pet_volume_pipeline import PETVolume
    from os.path import dirname, join, abspath

    root = dirname(abspath(join(abspath(__file__), pardir)))
    root = join(root, 'data', 'PETVolume')
    pipeline = PETVolume(bids_directory=join(root, 'in', 'bids'),
                         caps_directory=join(root, 'in', 'caps'),
                         tsv_file=join(root, 'in', 'subjects.tsv'),
                         group_id='UnitTest',
                         fwhm_tsv=None)
    pipeline.build()
Ejemplo n.º 2
0
def test_run_PETVolume(cmdopt):
    from os.path import dirname, join, abspath
    import shutil
    from clinica.pipelines.pet_volume.pet_volume_pipeline import PETVolume

    working_dir = cmdopt
    root = dirname(abspath(join(abspath(__file__), pardir)))
    root = join(root, 'data', 'PETVolume')

    clean_folder(join(root, 'out', 'caps'), recreate=False)
    clean_folder(join(working_dir, 'PETVolume'))
    shutil.copytree(join(root, 'in', 'caps'), join(root, 'out', 'caps'))

    parameters = {
        'group_label': 'UnitTest',
        'acq_label': 'fdg',
        'suvr_reference_region': 'pons'
    }
    pipeline = PETVolume(bids_directory=join(root, 'in', 'bids'),
                         caps_directory=join(root, 'out', 'caps'),
                         tsv_file=join(root, 'in', 'subjects.tsv'),
                         base_dir=join(working_dir, 'PETVolume'),
                         parameters=parameters)
    pipeline.build()
    pipeline.run(plugin='MultiProc',
                 plugin_args={'n_procs': 4},
                 bypass_check=True)

    subjects = [
        'sub-ADNI011S4105', 'sub-ADNI023S4020', 'sub-ADNI035S4082',
        'sub-ADNI128S4832'
    ]
    out_files = [
        join(
            root, 'out/caps/subjects/' + sub +
            '/ses-M00/pet/preprocessing/group-UnitTest', sub +
            '_ses-M00_task-rest_acq-fdg_pet_space-Ixi549Space_suvr-pons_mask-brain_fwhm-8mm_pet.nii.gz'
        ) for sub in subjects
    ]
    ref_files = [
        join(
            root, 'ref', sub +
            '_ses-M00_task-rest_acq-fdg_pet_space-Ixi549Space_suvr-pons_mask-brain_fwhm-8mm_pet.nii.gz'
        ) for sub in subjects
    ]

    for i in range(len(out_files)):
        assert likeliness_measure(out_files[i], ref_files[i], (1e-2, 0.25),
                                  (1e-1, 0.001))

    clean_folder(join(root, 'out', 'caps'), recreate=False)
    clean_folder(join(working_dir, 'PETVolume'), recreate=False)
def test_instantiate_PETVolume():
    from os.path import dirname, join, abspath
    from clinica.pipelines.pet_volume.pet_volume_pipeline import PETVolume

    root = dirname(abspath(join(abspath(__file__), pardir)))
    root = join(root, 'data', 'PETVolume')

    parameters = {
        'group_label': 'UnitTest',
        'acq_label': 'fdg',
        'suvr_reference_region': 'pons'
    }
    pipeline = PETVolume(bids_directory=join(root, 'in', 'bids'),
                         caps_directory=join(root, 'in', 'caps'),
                         tsv_file=join(root, 'in', 'subjects.tsv'),
                         parameters=parameters)
    pipeline.build()
Ejemplo n.º 4
0
def test_instantiate_PETVolume(cmdopt):

    from clinica.pipelines.pet_volume.pet_volume_pipeline import PETVolume

    input_dir = Path(cmdopt["input"])
    root = input_dir / "PETVolume"

    parameters = {
        "group_label": "UnitTest",
        "acq_label": "fdg",
        "suvr_reference_region": "pons",
        "skip_question": True,
    }
    pipeline = PETVolume(
        bids_directory=fspath(root / "in" / "bids"),
        caps_directory=fspath(root / "in" / "caps"),
        tsv_file=fspath(root / "in" / "subjects.tsv"),
        parameters=parameters,
    )
    pipeline.build()
Ejemplo n.º 5
0
def test_instantiate_PETVolume():
    from os.path import abspath, dirname, join

    from clinica.pipelines.pet_volume.pet_volume_pipeline import PETVolume

    root = dirname(abspath(join(abspath(__file__), pardir)))
    root = join(root, "data", "PETVolume")

    parameters = {
        "group_label": "UnitTest",
        "acq_label": "fdg",
        "suvr_reference_region": "pons",
    }
    pipeline = PETVolume(
        bids_directory=join(root, "in", "bids"),
        caps_directory=join(root, "in", "caps"),
        tsv_file=join(root, "in", "subjects.tsv"),
        parameters=parameters,
    )
    pipeline.build()
Ejemplo n.º 6
0
def test_run_PETVolume(cmdopt):
    import shutil
    from os.path import abspath, dirname, join

    from clinica.pipelines.pet_volume.pet_volume_pipeline import PETVolume

    working_dir = cmdopt
    root = dirname(abspath(join(abspath(__file__), pardir, pardir)))
    root = join(root, "data", "PETVolume")

    clean_folder(join(root, "out", "caps"), recreate=False)
    clean_folder(join(working_dir, "PETVolume"))
    shutil.copytree(join(root, "in", "caps"), join(root, "out", "caps"))

    parameters = {
        "group_label": "UnitTest",
        "acq_label": "fdg",
        "suvr_reference_region": "pons",
    }
    pipeline = PETVolume(
        bids_directory=join(root, "in", "bids"),
        caps_directory=join(root, "out", "caps"),
        tsv_file=join(root, "in", "subjects.tsv"),
        base_dir=join(working_dir, "PETVolume"),
        parameters=parameters,
    )
    pipeline.build()
    pipeline.run(plugin="MultiProc",
                 plugin_args={"n_procs": 4},
                 bypass_check=True)

    subjects = [
        "sub-ADNI011S4105",
        "sub-ADNI023S4020",
        "sub-ADNI035S4082",
        "sub-ADNI128S4832",
    ]
    out_files = [
        join(
            root,
            "out/caps/subjects/" + sub +
            "/ses-M00/pet/preprocessing/group-UnitTest",
            sub +
            "_ses-M00_task-rest_acq-fdg_pet_space-Ixi549Space_suvr-pons_mask-brain_fwhm-8mm_pet.nii.gz",
        ) for sub in subjects
    ]
    ref_files = [
        join(
            root,
            "ref",
            sub +
            "_ses-M00_task-rest_acq-fdg_pet_space-Ixi549Space_suvr-pons_mask-brain_fwhm-8mm_pet.nii.gz",
        ) for sub in subjects
    ]

    for i in range(len(out_files)):
        assert likeliness_measure(out_files[i], ref_files[i], (1e-2, 0.25),
                                  (1e-1, 0.001))

    clean_folder(join(root, "out", "caps"), recreate=False)
    clean_folder(join(working_dir, "PETVolume"), recreate=False)
Ejemplo n.º 7
0
def run_PETVolume(
    input_dir: Path, output_dir: Path, ref_dir: Path, working_dir: Path
) -> None:
    import shutil

    from clinica.pipelines.pet_volume.pet_volume_pipeline import PETVolume

    # Arrange
    shutil.copytree(input_dir / "caps", output_dir / "caps", copy_function=shutil.copy)

    parameters = {
        "group_label": "UnitTest",
        "acq_label": "fdg",
        "suvr_reference_region": "pons",
        "skip_question": False,
    }
    pipeline = PETVolume(
        bids_directory=fspath(input_dir / "bids"),
        caps_directory=fspath(output_dir / "caps"),
        tsv_file=fspath(input_dir / "subjects.tsv"),
        base_dir=fspath(working_dir),
        parameters=parameters,
    )
    # Acte
    pipeline.build()
    pipeline.run(plugin="MultiProc", plugin_args={"n_procs": 4}, bypass_check=True)

    # Assert
    subjects = [
        "sub-ADNI011S4105",
        "sub-ADNI023S4020",
        "sub-ADNI035S4082",
        "sub-ADNI128S4832",
    ]
    out_files = [
        fspath(
            output_dir
            / "caps"
            / "subjects"
            / sub
            / "ses-M00/pet/preprocessing/group-UnitTest"
            / (
                sub
                + "_ses-M00_task-rest_acq-fdg_pet_space-Ixi549Space_suvr-pons_mask-brain_fwhm-8mm_pet.nii.gz"
            )
        )
        for sub in subjects
    ]
    ref_files = [
        fspath(
            ref_dir
            / (
                sub
                + "_ses-M00_task-rest_acq-fdg_pet_space-Ixi549Space_suvr-pons_mask-brain_fwhm-8mm_pet.nii.gz"
            )
        )
        for sub in subjects
    ]

    for i in range(len(out_files)):
        assert likeliness_measure(
            out_files[i], ref_files[i], (1e-2, 0.25), (1e-1, 0.001)
        )