Beispiel #1
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph

        from clinica.utils.ux import print_crash_files_and_exit, print_end_pipeline

        from .dwi_dti_pipeline import DwiDti

        pipeline = DwiDti(
            caps_directory=self.absolute_path(args.caps_directory),
            tsv_file=self.absolute_path(args.subjects_sessions_tsv),
            base_dir=self.absolute_path(args.working_directory),
            name=self.name,
        )

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(
                self.name, pipeline.base_dir, pipeline.base_dir_was_specified
            )
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #2
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph
        from clinica.pipelines.pet_volume.pet_volume_pipeline import PETVolume
        from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

        parameters = {
            'group_label': args.group_label,
            'acq_label': args.acq_label,
            'suvr_reference_region': args.suvr_reference_region,
            'pvc_psf_tsv': self.absolute_path(args.pvc_psf_tsv),
            'mask_tissues': args.mask_tissues,
            'mask_threshold': args.mask_threshold,
            'pvc_mask_tissues': args.pvc_mask_tissues,
            'smooth': args.smooth,
        }
        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),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name)

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #3
0
def cli(
    caps_directory: str,
    subjects_sessions_tsv: Optional[str] = None,
    working_directory: Optional[str] = None,
    n_procs: Optional[int] = None,
) -> None:
    """DTI-based processing of DWI datasets.

    https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/DWI_DTI/
    """
    from networkx import Graph

    from clinica.utils.ux import print_end_pipeline

    from .dwi_dti_pipeline import DwiDti

    pipeline = DwiDti(
        caps_directory=caps_directory,
        tsv_file=subjects_sessions_tsv,
        base_dir=working_directory,
        name=pipeline_name,
    )

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

    if isinstance(exec_pipeline, Graph):
        print_end_pipeline(
            pipeline_name, pipeline.base_dir, pipeline.base_dir_was_specified
        )
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph

        from clinica.utils.ux import print_crash_files_and_exit, print_end_pipeline

        from .dwi_preprocessing_using_phasediff_fieldmap_pipeline import (
            DwiPreprocessingUsingPhaseDiffFieldmap,
        )

        parameters = {
            'low_bval': args.low_bval
        }
        pipeline = DwiPreprocessingUsingPhaseDiffFieldmap(
            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),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name
        )

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir, pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #5
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph
        from .pet_surface_pipeline import PetSurface
        from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

        parameters = {'pet_tracer': args.pet_tracer, 'longitudinal': False}
        pipeline = PetSurface(
            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),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name)

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #6
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph
        from .spatial_svm_pipeline import SpatialSVM
        from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

        parameters = {
            'group_id': args.group_id,
            'fwhm': args.fwhm,
            'image_type': args.image_type,
            'pet_tracer': args.pet_tracer,
            'no_pvc': args.no_pvc
        }
        pipeline = SpatialSVM(
            caps_directory=self.absolute_path(args.caps_directory),
            tsv_file=self.absolute_path(args.subjects_sessions_tsv),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name)

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
def cli(
    caps_directory: str,
    atlas_path: Optional[str] = None,
    n_procs: Optional[int] = None,
) -> None:
    """Projection of the results of t1-freesurfer on another atlas.

    https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/T1_FreeSurfer/
    """
    from networkx import Graph

    from clinica.utils.ux import print_end_pipeline

    from .t1_freeesurfer_atlas_pipeline import T1FreeSurferAtlas

    pipeline = T1FreeSurferAtlas(
        caps_directory=caps_directory,
        atlas_path=atlas_path,
    )

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

    if isinstance(exec_pipeline, Graph):
        print_end_pipeline(pipeline_name, pipeline.base_dir,
                           pipeline.base_dir_was_specified)
    def run_command(self, args):
        from networkx import Graph

        from clinica.utils.ux import print_crash_files_and_exit, print_end_pipeline

        from .statistics_volume_correction_pipeline import StatisticsVolumeCorrection

        parameters = {
            "t_map": args.t_map,
            "height_threshold": args.height_threshold,
            "FWEp": args.FWEp,
            "FDRp": args.FDRp,
            "FWEc": args.FWEp,
            "FDRc": args.FDRp,
            "n_cuts": args.n_cuts,
        }

        pipeline = StatisticsVolumeCorrection(
            caps_directory=self.absolute_path(args.caps_directory),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name,
        )

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #9
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph

        from clinica.utils.ux import print_crash_files_and_exit, print_end_pipeline

        from .t1_freesurfer_pipeline import T1FreeSurfer

        parameters = {
            "recon_all_args": args.recon_all_args,
        }
        pipeline = T1FreeSurfer(
            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),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name,
            overwrite_caps=args.overwrite_outputs,
        )

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #10
0
def cli(
    caps_directory: str,
    subjects_sessions_tsv: Optional[str] = None,
    working_directory: Optional[str] = None,
    n_procs: Optional[int] = None,
    overwrite_outputs: bool = False,
) -> None:
    """Longitudinal pre-processing correction of T1w images with FreeSurfer.

    https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/T1_FreeSurfer_Longitudinal/"
    """
    from networkx import Graph

    from clinica.utils.ux import print_end_pipeline

    from .t1_freesurfer_longitudinal_correction_pipeline import (
        T1FreeSurferLongitudinalCorrection, )

    pipeline = T1FreeSurferLongitudinalCorrection(
        caps_directory=caps_directory,
        tsv_file=subjects_sessions_tsv,
        base_dir=working_directory,
        name=pipeline_name,
        overwrite_caps=overwrite_outputs,
    )

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

    if isinstance(exec_pipeline, Graph):
        print_end_pipeline(pipeline_name, pipeline.base_dir,
                           pipeline.base_dir_was_specified)
Beispiel #11
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph
        from fmri_preprocessing_pipeline import fMRIPreprocessing
        from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

        parameters = {
            'full_width_at_half_maximum': args.full_width_at_half_maximum,
            't1_native_space': args.t1_native_space,
            'freesurfer_brain_mask': args.freesurfer_brain_mask,
            'unwarping': args.unwarping,
        }
        pipeline = fMRIPreprocessing(
            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),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name
        )

        if args.n_procs:
            exec_pipeline = pipeline.run(plugin='MultiProc',
                                         plugin_args={'n_procs': args.n_procs})
        # elif args.slurm:
        #     exec_pipeline = pipeline.run(plugin='SLURMGraph',
        #                                  plugin_args={'dont_resubmit_completed_jobs': True,
        #                                               'sbatch_args': args.sbatch_args})
        else:
            exec_pipeline = pipeline.run()

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir, pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #12
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph

        from clinica.utils.ux import print_crash_files_and_exit, print_end_pipeline

        from .t1_volume_parcellation_pipeline import T1VolumeParcellation

        parameters = {
            "group_label": args.group_label,
        }
        pipeline = T1VolumeParcellation(
            caps_directory=self.absolute_path(args.caps_directory),
            tsv_file=self.absolute_path(args.subjects_sessions_tsv),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name,
        )

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #13
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph
        from .dwi_connectome_pipeline import DwiConnectome
        from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

        parameters = {'n_tracks': args.n_tracks}
        pipeline = DwiConnectome(
            caps_directory=self.absolute_path(args.caps_directory),
            tsv_file=self.absolute_path(args.subjects_sessions_tsv),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name)

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
    def run_command(self, args):
        from networkx import Graph
        from .statistics_volume_pipeline import StatisticsVolume
        from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

        parameters = {
            'contrast': args.contrast,
            'feature_type': args.feature_type,
            'group_id': args.group_id,
            'custom_files': args.custom_files,
            'cluster_threshold': args.cluster_threshold,
            'group_id_caps': args.group_id_caps,
            'full_width_at_half_maximum': args.full_width_at_half_maximum
        }

        pipeline = StatisticsVolume(
            caps_directory=self.absolute_path(args.caps_directory),
            tsv_file=self.absolute_path(
                args.subject_visits_with_covariates_tsv),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name)

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #15
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph
        from .t1_linear_pipeline import T1Linear
        from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

        parameters = {'crop_image': args.crop_image}

        # Most of the time, you will want to instantiate your pipeline with a
        # BIDS and CAPS directory as inputs:
        pipeline = T1Linear(
            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),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name)

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #16
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph
        from .t1_volume_tissue_segmentation_pipeline import T1VolumeTissueSegmentation
        from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

        parameters = {
            'tissue_classes': args.tissue_classes,
            'dartel_tissues': args.dartel_tissues,
            'tissue_probability_maps': args.tissue_probability_maps,
            'save_warped_unmodulated': not args.dont_save_warped_unmodulated,
            'save_warped_modulated': args.save_warped_modulated,
        }
        pipeline = T1VolumeTissueSegmentation(
            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),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name
        )

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir, pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #17
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph

        from clinica.utils.ux import print_crash_files_and_exit, print_end_pipeline

        from .pet_surface_pipeline import PetSurface

        parameters = {
            "acq_label": args.acq_label,
            "suvr_reference_region": args.suvr_reference_region,
            "pvc_psf_tsv": self.absolute_path(args.pvc_psf_tsv),
            "longitudinal": False,
        }
        pipeline = PetSurface(
            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),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name,
        )

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph
        from .t1_volume_register_dartel_pipeline import T1VolumeRegisterDartel
        from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

        parameters = {
            'group_label': args.group_label,
            'tissues': args.tissues,
        }
        pipeline = T1VolumeRegisterDartel(
            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),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name)

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #19
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph
        from .t1_volume_parcellation_pipeline import T1VolumeParcellation
        from clinica.utils.check_dependency import verify_cat12_atlases
        from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

        # If the user wants to use any of the atlases of cat12 and has not installed it, we just remove it from the list
        # of the computed atlases
        args.atlases = verify_cat12_atlases(args.atlases)

        parameters = {
            'group_id': args.group_id,
            'atlases': args.atlases,
        }
        pipeline = T1VolumeParcellation(
            caps_directory=self.absolute_path(args.caps_directory),
            tsv_file=self.absolute_path(args.subjects_sessions_tsv),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name)

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #20
0
def cli(
    caps_directory: str,
    t_map: str,
    height_threshold: str,
    fwep: float,
    fdrp: float,
    fwec: float,
    fdrc: float,
    n_cuts: int = 8,
    working_directory: Optional[str] = None,
    n_procs: Optional[int] = None,
) -> None:
    """Statistical correction of statistics-volume pipeline.

       T_MAP is the name of the T statistic map used for the correction.

       HEIGHT_THRESHOLD is the T value corresponding to an uncorrected p-value of 0.001.

       FWEp is the Family-Wise Error peak threshold.

       FDRp is the False Discovery Rate peak threshold.

       Finally, FWEc and FDRc stand for the respective correction parameters.

    Prerequisite: You have to perform the statistics-volume pipeline before running this pipeline.

    https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/Stats_Volume/
    """
    from networkx import Graph

    from clinica.utils.ux import print_end_pipeline

    from .statistics_volume_correction_pipeline import StatisticsVolumeCorrection

    parameters = {
        "t_map": t_map,
        "height_threshold": height_threshold,
        "FWEp": fwep,
        "FDRp": fdrp,
        "FWEc": fwec,
        "FDRc": fdrc,
        "n_cuts": n_cuts,
    }

    pipeline = StatisticsVolumeCorrection(
        caps_directory=caps_directory,
        base_dir=working_directory,
        parameters=parameters,
        name=pipeline_name,
    )

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

    if isinstance(exec_pipeline, Graph):
        print_end_pipeline(pipeline_name, pipeline.base_dir,
                           pipeline.base_dir_was_specified)
Beispiel #21
0
def cli(
    bids_directory: str,
    caps_directory: str,
    acq_label: str,
    suvr_reference_region: str,
    pvc_psf_tsv: str,
    subjects_sessions_tsv: Optional[str] = None,
    working_directory: Optional[str] = None,
    n_procs: Optional[int] = None,
    yes: bool = False,
) -> None:
    """Surface-based processing of PET images.

       ACQ_LABEL corresponds to the label given to the PET acquisition, specifying the tracer used. Frequently used values are 'fdg'
     or 'av45'.

       The reference region must be precised to perform intensity normalization. Accepted values include: 'pons', 'cerebellumPons', 'pons2', 'cerebellumPons2'.

       PVC_PSF_TSV is the TSV file containing the psf_x, psf_y and psf_z of the PSF for each PET image.

    See https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/PET_Surface/
    """
    from networkx import Graph

    from clinica.utils.ux import print_end_pipeline

    from .pet_surface_pipeline import PetSurface

    parameters = {
        "acq_label": acq_label,
        "suvr_reference_region": suvr_reference_region,
        "pvc_psf_tsv": pvc_psf_tsv,
        "longitudinal": False,
        "skip_question": yes,
    }

    pipeline = PetSurface(
        bids_directory=bids_directory,
        caps_directory=caps_directory,
        tsv_file=subjects_sessions_tsv,
        base_dir=working_directory,
        parameters=parameters,
        name=pipeline_name,
    )

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

    if isinstance(exec_pipeline, Graph):
        print_end_pipeline(
            pipeline_name, pipeline.base_dir, pipeline.base_dir_was_specified
        )
Beispiel #22
0
def cli(
    ctx: click.Context,
    bids_directory: str,
    caps_directory: str,
    recon_all_args: str,
    working_directory: Optional[str] = None,
    subjects_sessions_tsv: Optional[str] = None,
    n_procs: Optional[int] = None,
    overwrite_outputs: bool = False,
    yes: bool = False,
    atlas_path: Optional[str] = None,
) -> None:
    """Cross-sectional pre-processing of T1w images with FreeSurfer.

    https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/T1_FreeSurfer/
    """
    from networkx import Graph

    from clinica.utils.ux import print_end_pipeline

    from ..t1_freesurfer_atlas import t1_freesurfer_atlas_cli
    from .t1_freesurfer_pipeline import T1FreeSurfer

    parameters = {"recon_all_args": recon_all_args, "skip_question": yes}

    pipeline = T1FreeSurfer(
        bids_directory=bids_directory,
        caps_directory=caps_directory,
        tsv_file=subjects_sessions_tsv,
        base_dir=working_directory,
        parameters=parameters,
        name=pipeline_name,
        overwrite_caps=overwrite_outputs,
    )

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

    if isinstance(exec_pipeline, Graph):
        print_end_pipeline(pipeline_name, pipeline.base_dir,
                           pipeline.base_dir_was_specified)

    if atlas_path is not None:
        ctx.invoke(
            t1_freesurfer_atlas_cli.cli,
            caps_directory=caps_directory,
            atlas_path=atlas_path,
            n_procs=n_procs,
        )
Beispiel #23
0
def cli(
    bids_directory: str,
    caps_directory: str,
    acq_label: str,
    suvr_reference_region: str,
    uncropped_image: bool = False,
    save_pet_in_t1w_space: bool = False,
    subjects_sessions_tsv: Optional[str] = None,
    working_directory: Optional[str] = None,
    n_procs: Optional[int] = None,
) -> None:
    """Affine registration of PET images to the MNI standard space.

       ACQ_LABEL corresponds the label given to the PET acquisition, specifying the tracer used. Frequently used values are 'fdg' or 'av45'.

       The reference region must be precised to perform intensity normalization. Accepted values include: 'pons', 'cerebellumPons', 'pons2', 'cerebellumPons2'.

    Prerequisite: You need to have performed the t1-linear pipeline on your T1-weighted MR images.

    See https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/PET_Linear/"
    """
    from networkx import Graph

    from clinica.utils.ux import print_end_pipeline

    from .pet_linear_pipeline import PETLinear

    parameters = {
        "acq_label": acq_label,
        "suvr_reference_region": suvr_reference_region,
        "uncropped_image": uncropped_image,
        "save_PETinT1w": save_pet_in_t1w_space,
    }

    pipeline = PETLinear(
        bids_directory=bids_directory,
        caps_directory=caps_directory,
        tsv_file=subjects_sessions_tsv,
        base_dir=working_directory,
        parameters=parameters,
        name=pipeline_name,
    )

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

    if isinstance(exec_pipeline, Graph):
        print_end_pipeline(pipeline_name, pipeline.base_dir,
                           pipeline.base_dir_was_specified)
Beispiel #24
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from colorama import Fore
        from networkx import Graph

        from clinica.utils.exceptions import ClinicaException
        from clinica.utils.ux import print_crash_files_and_exit, print_end_pipeline

        from .spatial_svm_pipeline import SpatialSVM

        if args.orig_input_data == "pet-volume":
            if args.acq_label is None:
                raise ClinicaException(
                    f"{Fore.RED}You selected pet-volume pipeline without setting --acq_label flag. "
                    f"Clinica will now exit.{Fore.RESET}")
            if args.suvr_reference_region is None:
                raise ClinicaException(
                    f"{Fore.RED}You selected pet-volume pipeline without setting --suvr_reference_region flag. "
                    f"Clinica will now exit.{Fore.RESET}")

        parameters = {
            # Clinica compulsory arguments
            "group_label": args.group_label,
            "orig_input_data": args.orig_input_data,
            # Optional arguments for inputs from pet-volume pipeline
            "acq_label": args.acq_label,
            "use_pvc_data": args.use_pvc_data,
            "suvr_reference_region": args.suvr_reference_region,
            # Advanced arguments
            "fwhm": args.full_width_half_maximum,
        }
        pipeline = SpatialSVM(
            caps_directory=self.absolute_path(args.caps_directory),
            tsv_file=self.absolute_path(args.subjects_sessions_tsv),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name,
        )

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #25
0
def cli(
    bids_directory: str,
    caps_directory: str,
    group_label: str,
    smooth: List[int] = (8, ),
    tissues: List[int] = (1, 2, 3),
    modulate: bool = True,
    voxel_size: Tuple[float, float, float] = (1.5, 1.5, 1.5),
    subjects_sessions_tsv: Optional[str] = None,
    working_directory: Optional[str] = None,
    n_procs: Optional[int] = None,
) -> None:
    """Register DARTEL template to MNI space.

       GROUP_LABEL is an user-defined identifier to target a specific group of subjects. For this pipeline, it is associated to the DARTEL template that you had created when running the t1-volume pipeline.

    https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/T1_Volume/
    """
    from networkx import Graph

    from clinica.utils.ux import print_end_pipeline

    from .t1_volume_dartel2mni_pipeline import T1VolumeDartel2MNI

    parameters = {
        "group_label": group_label,
        "tissues": tissues,
        "voxel_size": voxel_size,
        "modulate": modulate,
        "smooth": smooth,
    }

    pipeline = T1VolumeDartel2MNI(
        bids_directory=bids_directory,
        caps_directory=caps_directory,
        tsv_file=subjects_sessions_tsv,
        base_dir=working_directory,
        parameters=parameters,
        name=pipeline_name,
    )

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

    if isinstance(exec_pipeline, Graph):
        print_end_pipeline(pipeline_name, pipeline.base_dir,
                           pipeline.base_dir_was_specified)
def cli(
    bids_directory: str,
    caps_directory: str,
    tissue_classes: List[int] = (1, 2, 3),
    dartel_tissues: List[int] = (1, 2, 3),
    tissue_probability_maps: Optional[str] = None,
    dont_save_warped_unmodulated: bool = False,
    save_warped_modulated: bool = False,
    subjects_sessions_tsv: Optional[str] = None,
    working_directory: Optional[str] = None,
    n_procs: Optional[int] = None,
    yes: bool = False,
) -> None:
    """Tissue segmentation, bias correction and spatial normalization to MNI space of T1w images with SPM.

    https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/T1_Volume/
    """
    from networkx import Graph

    from clinica.utils.ux import print_end_pipeline

    from .t1_volume_tissue_segmentation_pipeline import T1VolumeTissueSegmentation

    parameters = {
        "tissue_classes": tissue_classes,
        "dartel_tissues": dartel_tissues,
        "tissue_probability_maps": tissue_probability_maps,
        "save_warped_unmodulated": not dont_save_warped_unmodulated,
        "save_warped_modulated": save_warped_modulated,
        "skip_question": yes,
    }

    pipeline = T1VolumeTissueSegmentation(
        bids_directory=bids_directory,
        caps_directory=caps_directory,
        tsv_file=subjects_sessions_tsv,
        base_dir=working_directory,
        parameters=parameters,
        name=pipeline_name,
    )

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

    if isinstance(exec_pipeline, Graph):
        print_end_pipeline(pipeline_name, pipeline.base_dir,
                           pipeline.base_dir_was_specified)
def cli(
    bids_directory: str,
    caps_directory: str,
    low_bval: int = 5,
    subjects_sessions_tsv: Optional[str] = None,
    working_directory: Optional[str] = None,
    n_procs: Optional[int] = None,
    use_cuda: bool = False,
    initrand: bool = False,
) -> None:
    """Preprocessing of raw DWI datasets using a T1w image.

    https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/DWI_Preprocessing/
    """
    from networkx import Graph

    from clinica.utils.ux import print_end_pipeline

    from .dwi_preprocessing_using_t1_pipeline import DwiPreprocessingUsingT1

    parameters = {
        "low_bval": low_bval,
        "use_cuda": use_cuda,
        "initrand": initrand,
    }

    pipeline = DwiPreprocessingUsingT1(
        bids_directory=bids_directory,
        caps_directory=caps_directory,
        tsv_file=subjects_sessions_tsv,
        base_dir=working_directory,
        parameters=parameters,
        name=pipeline_name,
    )

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

    if isinstance(exec_pipeline, Graph):
        print_end_pipeline(
            pipeline_name, pipeline.base_dir, pipeline.base_dir_was_specified
        )
Beispiel #28
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph
        from clinica.pipelines.pet_volume.pet_volume_pipeline import PETVolume
        from clinica.utils.check_dependency import verify_cat12_atlases
        from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

        parameters = {
            'group_id': args.group_id,
            'psf_tsv': self.absolute_path(args.psf_tsv),
            'pet_tracer': args.pet_tracer,
            'mask_tissues': args.mask_tissues,
            'mask_threshold': args.mask_threshold,
            'pvc_mask_tissues': args.pvc_mask_tissues,
            'smooth': args.smooth,
            'atlases': args.atlases,
        }

        # If the user wants to use any of the atlases of CAT12 and has not installed it, we just remove it from the list
        # of the computed atlases
        parameters['atlases'] = verify_cat12_atlases(args.atlases)

        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),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name)

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
Beispiel #29
0
    def run_command(self, args):
        """Run the pipeline with defined args."""
        from networkx import Graph

        from clinica.utils.ux import print_crash_files_and_exit, print_end_pipeline

        from .deeplearning_prepare_data_pipeline import DeepLearningPrepareData

        parameters = {
            # Add your own pipeline parameters here to use them inside your
            # pipeline. See the file `deeplearning_prepare_data_pipeline.py` to
            # see an example of use.
            "modality": args.modality,
            "extract_method": args.extract_method,
            "patch_size": args.patch_size,
            "stride_size": args.stride_size,
            "slice_direction": args.slice_direction,
            "slice_mode": args.slice_mode,
            "use_uncropped_image": args.use_uncropped_image,
            "custom_suffix": args.custom_suffix,
        }

        pipeline = DeepLearningPrepareData(
            caps_directory=self.absolute_path(args.caps_directory),
            tsv_file=self.absolute_path(args.subjects_sessions_tsv),
            base_dir=self.absolute_path(args.working_directory),
            parameters=parameters,
            name=self.name,
        )

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

        if isinstance(exec_pipeline, Graph):
            print_end_pipeline(self.name, pipeline.base_dir,
                               pipeline.base_dir_was_specified)
        else:
            print_crash_files_and_exit(args.logname, pipeline.base_dir)
def cli(
    caps_directory: str,
    group_label: str,
    subjects_sessions_tsv: Optional[str] = None,
    working_directory: Optional[str] = None,
    n_procs: Optional[int] = None,
    modulate: bool = True,
) -> None:
    """Computation of mean GM concentration for a set of regions.

       GROUP_LABEL is an user-defined identifier to target a specific group of subjects. For this pipeline, it is associated to the DARTEL template that you had created when running the t1-volume pipeline.

    https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/T1_Volume/
    """
    from networkx import Graph

    from clinica.utils.ux import print_end_pipeline

    from .t1_volume_parcellation_pipeline import T1VolumeParcellation

    parameters = {"group_label": group_label, "modulate": modulate}

    pipeline = T1VolumeParcellation(
        caps_directory=caps_directory,
        tsv_file=subjects_sessions_tsv,
        base_dir=working_directory,
        parameters=parameters,
        name=pipeline_name,
    )

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

    if isinstance(exec_pipeline, Graph):
        print_end_pipeline(
            pipeline_name, pipeline.base_dir, pipeline.base_dir_was_specified
        )