def test_caching(): temp_dir = mkdtemp(prefix='test_memory_') old_rerun = config.get('execution', 'stop_on_first_rerun') try: # Prevent rerun to check that evaluation is computed only once config.set('execution', 'stop_on_first_rerun', 'true') mem = Memory(temp_dir) first_nb_run = nb_runs results = mem.cache(SideEffectInterface)(input1=2, input2=1) assert_equal(nb_runs, first_nb_run + 1) assert_equal(results.outputs.output1, [1, 2]) results = mem.cache(SideEffectInterface)(input1=2, input2=1) # Check that the node hasn't been rerun assert_equal(nb_runs, first_nb_run + 1) assert_equal(results.outputs.output1, [1, 2]) results = mem.cache(SideEffectInterface)(input1=1, input2=1) # Check that the node hasn been rerun assert_equal(nb_runs, first_nb_run + 2) assert_equal(results.outputs.output1, [1, 1]) finally: rmtree(temp_dir) config.set('execution', 'stop_on_first_rerun', old_rerun)
## for details. ## ## This software is distributed WITHOUT ANY WARRANTY; without even ## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ## PURPOSE. See the above copyright notices for more information. ## ################################################################################# import os import csv import sys import string import argparse """Import necessary modules from nipype.""" from nipype.utils.config import config config.set('logging', 'log_to_file', 'false') #--config.set('logging', 'workflow_level', 'DEBUG') #--config.set('logging', 'interface_level', 'DEBUG') config.set_log_dir(os.getcwd()) from nipype.interfaces.base import CommandLine, CommandLineInputSpec, TraitedSpec, File, Directory, traits, isdefined, BaseInterface from nipype.interfaces.utility import Merge, Split, Function, Rename, IdentityInterface import nipype.interfaces.io as nio # Data i/o import nipype.pipeline.engine as pe # pypeline engine from nipype.interfaces.freesurfer import ReconAll from nipype.utils.misc import package_check package_check('numpy', '1.3', 'tutorial1') package_check('scipy', '0.7', 'tutorial1')
## ## This software is distributed WITHOUT ANY WARRANTY; without even ## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ## PURPOSE. See the above copyright notices for more information. ## ################################################################################# import os import csv import sys import string import argparse """Import necessary modules from nipype.""" from nipype.utils.config import config config.set('logging', 'log_to_file', 'false') #--config.set('logging', 'workflow_level', 'DEBUG') #--config.set('logging', 'interface_level', 'DEBUG') config.set_log_dir(os.getcwd()) from nipype.interfaces.base import CommandLine, CommandLineInputSpec, TraitedSpec, File, Directory, traits, isdefined, BaseInterface from nipype.interfaces.utility import Merge, Split, Function, Rename, IdentityInterface import nipype.interfaces.io as nio # Data i/o import nipype.pipeline.engine as pe # pypeline engine from nipype.interfaces.freesurfer import ReconAll from nipype.utils.misc import package_check package_check('numpy', '1.3', 'tutorial1')
python fmri_fsl_reuse.py First tell python where to find the appropriate functions. """ import os # system functions """ .. note:: config for logging should be set before anything else """ from nipype.utils.config import config config.set("logging", "log_to_file", "false") config.set_log_dir(os.getcwd()) import nipype.interfaces.io as nio # Data i/o import nipype.interfaces.fsl as fsl # fsl import nipype.interfaces.utility as util # utility import nipype.pipeline.engine as pe # pypeline engine import nipype.algorithms.modelgen as model # model generation import nipype.algorithms.rapidart as ra # artifact detection from nipype.workflows.fmri.fsl import create_featreg_preproc, create_modelfit_workflow, create_fixed_effects_flow """ Preliminaries -------------