How to use clinica - 10 common examples

To help you get started, we’ve selected a few clinica examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aramis-lab / clinica / clinica / utils / ux.py View on Github external
def print_crash_files_and_exit(log_file, working_directory):
    """Print command(s) to type in order to extract details after a Nipype RuntimeError and exit with an exception."""
    from colorama import Fore
    from .filemanip import extract_crash_files_from_log_file
    from .exceptions import ClinicaException
    from .stream import cprint

    cprint('%s\nError details can be found by opening the crash file(s) with the following command(s):%s' %
           (Fore.YELLOW, Fore.RESET))

    crash_files = extract_crash_files_from_log_file(log_file)
    for file in crash_files:
        cprint('%s- nipypecli crash %s%s' %
               (Fore.YELLOW, file,  Fore.RESET))

    cprint('%s\n'
           'If your pipeline crashed due to lack of space of network issues, '
           're-run the pipeline with the working directory (-wd %s).\n'
           'Known issues are displayed here: http://www.clinica.run/doc/InteractingWithClinica/#known-issues\n'
           'Otherwise, you can delete it.%s' %
           (Fore.YELLOW, working_directory, Fore.RESET))
    # Force the display of "Documentation can be found..."
    raise ClinicaException('')
github aramis-lab / clinica / clinica / pipelines / statistics_surface / statistics_surface_cli.py View on Github external
'group_label': args.group_id,
            'glm_type': args.glm_type,
            'custom_file': args.custom_file,
            'feature_label': args.feature_label,
            'full_width_at_half_maximum': args.full_width_at_half_maximum,
            'threshold_uncorrected_pvalue': args.threshold_uncorrected_pvalue,
            'threshold_corrected_pvalue': args.threshold_corrected_pvalue,
            'cluster_threshold': args.cluster_threshold
        }

        check_inputs(pipeline.caps_directory,
                     pipeline.parameters['custom_file'],
                     pipeline.parameters['full_width_at_half_maximum'],
                     pipeline.tsv_file)

        cprint("Parameters used for this pipeline:")
        cprint(pipeline.parameters)

        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)
github aramis-lab / clinica / clinica / iotools / load_cmdline_converter.py View on Github external
def load_name_converters():
    base_converters = join(split(realpath(__file__))[0], 'converters')
    for file in os.listdir(base_converters):
        if file.endswith(".py"):
            if re.match('__init__',file):
                continue
            if re.match('(.*)\.pyc$',file):
                continue

            f = "clinica.bids.converters.%s" % file.split('.')[0]
            mod = importlib.import_module(f)
            for name, obj in inspect.getmembers(mod):
                if name != 'CmdParser' and name != 'Converter' and inspect.isclass(obj):
                    x = obj()
                    if isinstance(x, clinica.engine.cmdparser.CmdParser) and isinstance(x, clinica.bids.abstract_converter.Converter):
                        del x
                        yield name
github aramis-lab / clinica / clinica / utils / atlas.py View on Github external
    @staticmethod
    def get_atlas_map():
        import os
        FSLDIR = os.environ.get('FSLDIR', '')
        if not FSLDIR:
            raise Exception('FSLDIR variable from FSL software is not set')
        return os.path.join(FSLDIR, 'data', 'atlases', 'JHU', 'JHU-ICBM-FA-1mm.nii.gz')

    @staticmethod
    def get_tsv_roi():
        from os.path import join, split, realpath
        return join(split(realpath(__file__))[0], '../resources/atlases', 'JHUTract_FS_LUT_newformat.txt')


class JHUTracts252mm(AtlasAbstract):
    def __init__(self):
        AtlasAbstract.__init__(self)

    @staticmethod
    def get_name_atlas(): return "JHUTracts25"

    @staticmethod
    def get_atlas_labels():
        import os
        FSLDIR = os.environ.get('FSLDIR', '')
        if not FSLDIR:
            raise Exception('FSLDIR variable from FSL software is not set')
        return os.path.join(FSLDIR, 'data', 'atlases', 'JHU', 'JHU-ICBM-tracts-maxprob-thr25-2mm.nii.gz')

    @staticmethod
    def get_atlas_map():
github aramis-lab / clinica / clinica / utils / atlas.py View on Github external
if not os.path.exists(os.path.join(SPM_HOME, 'toolbox', 'cat12')):
            raise Exception('CAT12 not included in SPM_HOME/toolbox')
        return os.path.join(SPM_HOME, 'toolbox', 'cat12', 'templates_1.50mm', 'hammers.nii')

    @staticmethod
    def get_atlas_map():
        from os.path import join, split, realpath
        return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'Template_MNI152.nii')

    @staticmethod
    def get_tsv_roi():
        from os.path import join, split, realpath
        return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'lut_Hammers_newformat.txt')


class LPBA40(AtlasAbstract):
    def __init__(self):
        AtlasAbstract.__init__(self)

    @staticmethod
    def get_name_atlas(): return "LPBA40"

    @staticmethod
    def get_atlas_labels():
        import os
        import platform
        if "SPM_HOME" not in os.environ:
            raise Exception('SPM_HOME variable from SPM software is not set')
        else:
            if "SPMSTANDALONE_HOME" in os.environ:
                if platform.system() == 'Darwin':
                    SPM_HOME = os.environ['SPMSTANDALONE_HOME'] + "/spm12.app/Contents/MacOS/spm12_mcr"
github aramis-lab / clinica / clinica / utils / atlas.py View on Github external
def get_atlas_labels():
        from os.path import join, split, realpath
        return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'AAL2.nii')

    @staticmethod
    def get_atlas_map():
        from os.path import join, split, realpath
        return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'Template_MNI152.nii')

    @staticmethod
    def get_tsv_roi():
        from os.path import join, split, realpath
        return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'lut_AAL2_newformat.txt')


class Hammers(AtlasAbstract):
    def __init__(self):
        AtlasAbstract.__init__(self)

    @staticmethod
    def get_name_atlas(): return "Hammers"

    @staticmethod
    def get_atlas_labels():
        import os
        import platform
        if "SPM_HOME" not in os.environ:
            raise Exception('SPM_HOME variable from SPM software is not set')
        else:
            if "SPMSTANDALONE_HOME" in os.environ:
                if platform.system() == 'Darwin':
                    SPM_HOME = os.environ['SPMSTANDALONE_HOME'] + "/spm12.app/Contents/MacOS/spm12_mcr"
github aramis-lab / clinica / clinica / utils / atlas.py View on Github external
    @staticmethod
    def get_atlas_map():
        import os
        FSLDIR = os.environ.get('FSLDIR', '')
        if not FSLDIR:
            raise Exception('FSLDIR variable from FSL software is not set')
        return os.path.join(FSLDIR, 'data', 'atlases', 'JHU', 'JHU-ICBM-FA-2mm.nii.gz')

    @staticmethod
    def get_tsv_roi():
        from os.path import join, split, realpath
        return join(split(realpath(__file__))[0], '../resources/atlases', 'JHUTract_FS_LUT_newformat.txt')


class JHUTracts501mm(AtlasAbstract):
    def __init__(self):
        AtlasAbstract.__init__(self)

    @staticmethod
    def get_name_atlas(): return "JHUTracts50"

    @staticmethod
    def get_atlas_labels():
        import os
        FSLDIR = os.environ.get('FSLDIR', '')
        if not FSLDIR:
            raise Exception('FSLDIR variable from FSL software is not set')
        return os.path.join(FSLDIR, 'data', 'atlases', 'JHU', 'JHU-ICBM-tracts-maxprob-thr50-1mm.nii.gz')

    @staticmethod
    def get_atlas_map():
github aramis-lab / clinica / clinica / utils / atlas.py View on Github external
    @staticmethod
    def get_atlas_map():
        import os
        FSLDIR = os.environ.get('FSLDIR', '')
        if not FSLDIR:
            raise Exception('FSLDIR variable from FSL software is not set')
        return os.path.join(FSLDIR, 'data', 'atlases', 'JHU', 'JHU-ICBM-FA-2mm.nii.gz')

    @staticmethod
    def get_tsv_roi():
        from os.path import join, split, realpath
        return join(split(realpath(__file__))[0], '../resources/atlases', 'JHUTract_FS_LUT_newformat.txt')


class AAL2(AtlasAbstract):
    def __init__(self):
        AtlasAbstract.__init__(self)

    @staticmethod
    def get_name_atlas(): return "AAL2"

    @staticmethod
    def get_atlas_labels():
        from os.path import join, split, realpath
        return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'AAL2.nii')

    @staticmethod
    def get_atlas_map():
        from os.path import join, split, realpath
        return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'Template_MNI152.nii')
github aramis-lab / clinica / clinica / pipelines / t1_volume_dartel2mni / t1_volume_dartel2mni_cli.py View on Github external
# 'bounding_box': None,
            'voxel_size': tuple(args.voxel_size) if args.voxel_size is not None else None,
            'modulation': args.modulate,
            'fwhm': args.smooth
        })

        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)
github aramis-lab / clinica / clinica / pipelines / dwi_preprocessing_using_t1 / dwi_preprocessing_using_t1_cli.py View on Github external
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),
            low_bval=args.low_bval,
        )

        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)