Пример #1
0
def test_run_PETVolume(cmdopt):
    from clinica.pipelines.pet_volume.pet_volume_pipeline import PETVolume
    from os.path import dirname, join, abspath, exists
    import shutil

    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'))

    pipeline = PETVolume(bids_directory=join(root, 'in', 'bids'),
                         caps_directory=join(root, 'out', 'caps'),
                         tsv_file=join(root, 'in', 'subjects.tsv'),
                         group_id='UnitTest',
                         fwhm_tsv=None)
    pipeline.base_dir = join(working_dir, 'PETVolume')
    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)
Пример #2
0
    def run_command(self, args):
        """
        """
        from tempfile import mkdtemp
        from clinica.utils.stream import cprint
        from clinica.pipelines.pet_volume.pet_volume_pipeline import PETVolume

        pipeline = PETVolume(
            bids_directory=self.absolute_path(args.bids_directory),
            caps_directory=self.absolute_path(args.caps_directory),
            tsv_file=self.absolute_path(args.subjects_sessions_tsv),
            group_id=args.group_id,
            fwhm_tsv=self.absolute_path(args.psf_tsv))

        pipeline.parameters.update({
            'pet_type': args.pet_tracer,
            'mask_tissues': args.mask_tissues,
            'mask_threshold': args.mask_threshold,
            'pvc_mask_tissues': args.pvc_mask_tissues,
            'smooth': args.smooth,
            'atlas_list': args.atlases
        })

        if args.working_directory is None:
            args.working_directory = mkdtemp()
        pipeline.base_dir = self.absolute_path(args.working_directory)

        if args.n_procs:
            pipeline.run(plugin='MultiProc',
                         plugin_args={'n_procs': args.n_procs})
        else:
            pipeline.run()

        cprint(
            "The " + self._name +
            " pipeline has completed. You can now delete the working directory ("
            + args.working_directory + ").")