当前位置: 首页>>代码示例>>Python>>正文


Python MatlabCommand.run方法代码示例

本文整理汇总了Python中nipype.interfaces.matlab.MatlabCommand.run方法的典型用法代码示例。如果您正苦于以下问题:Python MatlabCommand.run方法的具体用法?Python MatlabCommand.run怎么用?Python MatlabCommand.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nipype.interfaces.matlab.MatlabCommand的用法示例。


在下文中一共展示了MatlabCommand.run方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _run_interface

# 需要导入模块: from nipype.interfaces.matlab import MatlabCommand [as 别名]
# 或者: from nipype.interfaces.matlab.MatlabCommand import run [as 别名]
	def _run_interface(self, runtime):
		from nipype.interfaces.spm.base import scans_for_fname,scans_for_fnames
		from nipype.utils.filemanip import filename_to_list,list_to_filename

		# setup parameters
		input_dir = "."
		in_files = "{"
		asl_first = str(self.inputs.first_image_type)
		TR = str(self.inputs.TR)
		# convert images to cell array string in matlab
		for f in sorted(scans_for_fnames(filename_to_list(self.inputs.in_files))):
			in_files += "'"+f+"',\n"
			input_dir = os.path.dirname(f)
		in_files = in_files[:-2]+"}"
		self.input_dir = input_dir

		d = dict(in_files=in_files,in_dir=input_dir,first_image_type=asl_first,TR =TR)
		myscript = Template("""
		warning('off','all');
		cd('$in_dir');
		input = char($in_files);
		asl_script(input,$first_image_type,0,$TR);
		exit;
		""").substitute(d)
		mlab = MatlabCommand(script=myscript,matlab_cmd="matlab -nodesktop -nosplash",mfile=True)
		result = mlab.run()
		return result.runtime
开发者ID:tseytlin,项目名称:gold-pype,代码行数:29,代码来源:wrappers.py

示例2: _run_interface

# 需要导入模块: from nipype.interfaces.matlab import MatlabCommand [as 别名]
# 或者: from nipype.interfaces.matlab.MatlabCommand import run [as 别名]
    def _run_interface(self, runtime):
        d = dict(worldmat=self.inputs.worldmat,
        src=self.inputs.src,
        trg=self.inputs.trg,
        output_file=self.inputs.output_file)
        #this is your MATLAB code template
        script = Template("""worldmat = '$worldmat';
        src = '$src';
        trg = '$trg';
        output_file = '$output_file'
        worldmat2flirtmap(worldmat, src, trg, output_file);
        exit;
        """).substitute(d)

        # mfile = True  will create an .m file with your script and executed.
        # Alternatively
        # mfile can be set to False which will cause the matlab code to be
        # passed
        # as a commandline argument to the matlab executable
        # (without creating any files).
        # This, however, is less reliable and harder to debug
        # (code will be reduced to
        # a single line and stripped of any comments).

        mlab = MatlabCommand(script=script, mfile=True)
        result = mlab.run()
        return result.runtime
开发者ID:jelman,项目名称:voxelwise_pib,代码行数:29,代码来源:worldmat2flirtmap_pywrapper.py

示例3: _run_interface

# 需要导入模块: from nipype.interfaces.matlab import MatlabCommand [as 别名]
# 或者: from nipype.interfaces.matlab.MatlabCommand import run [as 别名]
    def _run_interface(self, runtime):
        from nipype.interfaces.matlab import MatlabCommand
        def islist(i):
            if not isinstance(i,list):
                i = [str(i)]
                return i
            else:
                I = []
                for l in i:
                    if not l.endswith('.par'):
                        I.append(str(l))
                    else:
                        shutil.copy2(l,l+'.txt')
                        I.append(l+'.txt')
                return I

        info = {}
        info["functional_files"] = islist(self.inputs.functional_files)
        info["structural_files"] = islist(self.inputs.structural_files)
        info["csf_mask"] = islist(self.inputs.csf_mask)
        info["white_mask"] = islist(self.inputs.white_mask)
        info["grey_mask"] = islist(self.inputs.grey_mask)
        info["TR"] = float(self.inputs.tr)
        info["realignment_parameters"] = islist(self.inputs.realignment_parameters)
        info["outliers"] = islist(self.inputs.outliers)
        info["norm_components"] = islist(self.inputs.norm_components)
        info["filename"] = '%s/conn_%s.mat'%(os.getcwd(),self.inputs.project_name)
        info["n_subjects"] = int(self.inputs.n_subjects)
        conn_inputs = os.path.abspath('inputs_to_conn.mat')
        sio.savemat(conn_inputs, {"in":info})
        print "saved conn_inputs.mat file"
        script="""load %s; batch=bips_load_conn(in); conn_batch(batch)"""%conn_inputs
        mlab = MatlabCommand(script=script, mfile=True)
        result = mlab.run()
        return result.runtime
开发者ID:FCP-INDI,项目名称:BrainImagingPipelines,代码行数:37,代码来源:matlab_utils.py

示例4: _run_interface

# 需要导入模块: from nipype.interfaces.matlab import MatlabCommand [as 别名]
# 或者: from nipype.interfaces.matlab.MatlabCommand import run [as 别名]
	def _run_interface(self, runtime):
	
		d = dict(in_file=self.inputs.in_file,mask_file=self.inputs.mask_file,out_file=self.inputs.out_file)

		script = Template("""addpath('/home/sharad/fcon1000/lib/');in_file = '$in_file';mask_file = '$mask_file';out_file = '$out_file';reho(in_file,mask_file,out_file);exit;""").substitute(d)

		mlab = MatlabCommand(script=script, mfile=True)	
		result = mlab.run()
		return result.runtime
开发者ID:RanjitK,项目名称:NKI_NYU_Nipype,代码行数:11,代码来源:e_afni.py

示例5: _run_interface

# 需要导入模块: from nipype.interfaces.matlab import MatlabCommand [as 别名]
# 或者: from nipype.interfaces.matlab.MatlabCommand import run [as 别名]
    def _run_interface(self, runtime):
        d = dict(in_file=self.inputs.in_file,
        out_folder=self.inputs.out_folder,
        subject_id=self.inputs.subject_id)
        #this is your MATLAB code template
        script = Template("""
        	cd '$out_folder'
        	WaveletDespike('$in_file','$subject_id')""").substitute(d)

        mlab = MatlabCommand(script=script, mfile=True)
        result = mlab.run()
        return result.runtime
开发者ID:joebathelt,项目名称:Neuroimaging_PythonTools,代码行数:14,代码来源:own_nipype.py

示例6: version

# 需要导入模块: from nipype.interfaces.matlab import MatlabCommand [as 别名]
# 或者: from nipype.interfaces.matlab.MatlabCommand import run [as 别名]
    def version( matlab_cmd = None ):
        """Returns the path to the SPM directory in the Matlab path
        If path not found, returns None.

        Parameters
        ----------
        matlab_cmd : String specifying default matlab command

            default None, will look for environment variable MATLABCMD
            and use if found, otherwise falls back on MatlabCommand
            default of 'matlab -nodesktop -nosplash'

        Returns
        -------
        spm_path : string representing path to SPM directory

            returns None of path not found
        """
        if matlab_cmd is None:
            try:
                matlab_cmd = os.environ['MATLABCMD']
            except:
                matlab_cmd = 'matlab -nodesktop -nosplash'
        mlab = MatlabCommand(matlab_cmd = matlab_cmd)
        mlab.inputs.script = """
        if isempty(which('spm')),
        throw(MException('SPMCheck:NotFound','SPM not in matlab path'));
        end;
        spm_path = spm('dir');
        [name, version] = spm('ver');
        fprintf(1, 'NIPYPE path:%s|name:%s|release:%s', spm_path, name, version);
        exit;
        """
        mlab.inputs.mfile = False
        try:
            out = mlab.run()
        except (IOError,RuntimeError), e:
            # if no Matlab at all -- exception could be raised
            # No Matlab -- no spm
            logger.debug(str(e))
            return None
开发者ID:chaselgrove,项目名称:nipype,代码行数:43,代码来源:base.py

示例7: version

# 需要导入模块: from nipype.interfaces.matlab import MatlabCommand [as 别名]
# 或者: from nipype.interfaces.matlab.MatlabCommand import run [as 别名]
    def version( matlab_cmd = None ):
        """Returns the path to the SPM directory in the Matlab path
        If path not found, returns None.

        Parameters
        ----------
        matlab_cmd : String specifying default matlab command
        
            default None, will look for environment variable MATLABCMD
            and use if found, otherwise falls back on MatlabCommand
            default of 'matlab -nodesktop -nosplash'

        Returns
        -------
        spm_path : string representing path to SPM directory

            returns None of path not found
        """
        if matlab_cmd is None:
            try:
                matlab_cmd = os.environ['MATLABCMD']
            except:
                matlab_cmd = 'matlab -nodesktop -nosplash'
        mlab = MatlabCommand(matlab_cmd = matlab_cmd)
        mlab.inputs.script_file = 'spminfo'
        mlab.inputs.script = """
        if isempty(which('spm')),
        throw(MException('SPMCheck:NotFound','SPM not in matlab path'));
        end;
        spm_path = spm('dir');
        fprintf(1, 'NIPYPE  %s', spm_path);
        """
        out = mlab.run()
        if out.runtime.returncode == 0:
            spm_path = sd._strip_header(out.runtime.stdout)
        else:
            logger.debug(out.runtime.stderr)
            return None
        return spm_path
开发者ID:satra,项目名称:NiPypeold,代码行数:41,代码来源:base.py

示例8: _run_interface

# 需要导入模块: from nipype.interfaces.matlab import MatlabCommand [as 别名]
# 或者: from nipype.interfaces.matlab.MatlabCommand import run [as 别名]
    def _run_interface(self, runtime):
        path, name, ext = split_filename(self.inputs.time_course_image)
        data_dir = op.abspath('./matching')
        copy_to = op.join(data_dir, 'components')
        if not op.exists(copy_to):
            os.makedirs(copy_to)
        copy_to = op.join(copy_to, name)
        shutil.copyfile(self.inputs.time_course_image, copy_to + ext)
        if ext == '.img':
            shutil.copyfile(op.join(path, name) + '.hdr', copy_to + '.hdr')
        elif ext == '.hdr':
            shutil.copyfile(op.join(path, name) + '.img', copy_to + '.img')

        data_dir = op.abspath('./matching/components')
        in_files = self.inputs.in_files
        if len(self.inputs.in_files) > 1:
            print 'Multiple ({n}) input images detected! Copying to {d}...'.format(n=len(self.inputs.in_files), d=data_dir)
            for in_file in self.inputs.in_files:
                path, name, ext = split_filename(in_file)
                shutil.copyfile(in_file, op.join(data_dir, name) + ext)
                if ext == '.img':
                    shutil.copyfile(op.join(path, name) + '.hdr',
                                    op.join(data_dir, name) + '.hdr')
                elif ext == '.hdr':
                    shutil.copyfile(op.join(path, name) + '.img',
                                    op.join(data_dir, name) + '.img')
            print 'Copied!'

        elif isdefined(self.inputs.in_file4d):
            print 'Single four-dimensional image selected. Splitting and copying to {d}'.format(d=data_dir)
            in_files = nb.four_to_three(self.inputs.in_file4d)
            for in_file in in_files:
                path, name, ext = split_filename(in_file)
                shutil.copyfile(in_file, op.join(data_dir, name) + ext)
            print 'Copied!'

        else:
            raise Exception('Single functional image provided. Ending...')
            in_files = self.inputs.in_files

        nComponents = len(in_files)
        repetition_time = self.inputs.repetition_time
        coma_rest_lib_path = op.abspath(self.inputs.coma_rest_lib_path)

        data_dir = op.abspath('./matching')
        if not op.exists(data_dir):
            os.makedirs(data_dir)

        path, name, ext = split_filename(self.inputs.ica_mask_image)
        copy_to = op.join(data_dir, 'components')
        if not op.exists(copy_to):
            os.makedirs(copy_to)
        copy_to = op.join(copy_to, name)
        shutil.copyfile(self.inputs.ica_mask_image, copy_to + ext)
        
        if ext == '.img':
            shutil.copyfile(op.join(path, name) + '.hdr', copy_to + '.hdr')
        elif ext == '.hdr':
            shutil.copyfile(op.join(path, name) + '.img', copy_to + '.img')

        mask_file = op.abspath(self.inputs.ica_mask_image)
        out_stats_file = op.abspath(self.inputs.out_stats_file)
        d = dict(
            out_stats_file=out_stats_file, data_dir=data_dir, mask_name=mask_file,
            timecourse=op.abspath(self.inputs.time_course_image),
            subj_id=self.inputs.subject_id,
            nComponents=nComponents, Tr=repetition_time, coma_rest_lib_path=coma_rest_lib_path)

        script = Template("""
        restlib_path = '$coma_rest_lib_path';
        setup_restlib_paths(restlib_path)
        namesTemplate = {'rAuditory_corr','rCerebellum_corr','rDMN_corr','rECN_L_corr','rECN_R_corr','rSalience_corr','rSensorimotor_corr','rVisual_lateral_corr','rVisual_medial_corr','rVisual_occipital_corr'};
        indexNeuronal = 1:$nComponents;
        nCompo = $nComponents;
        out_stats_file = '$out_stats_file'; 
        Tr = $Tr;
        data_dir = '$data_dir'
        mask_name = '$mask_name'
        subj_id = '$subj_id'
        time_course_name = '$timecourse'

        [dataAssig maxGoF] = selectionMatchClassification(data_dir, subj_id, mask_name, time_course_name, namesTemplate,indexNeuronal,nCompo,Tr,restlib_path)
                            
        for i=1:size(dataAssig,1)
            str{i} = sprintf('Template %d: %s to component %d with GoF %f is neuronal %d prob=%f',dataAssig(i,1),namesTemplate{i},dataAssig(i,2),dataAssig(i,3),dataAssig(i,4),dataAssig(i,5));
            disp(str{i});
        end
        maxGoF
        templates = dataAssig(:,1)
        components = dataAssig(:,2)
        gofs = dataAssig(:,3)
        neuronal_bool = dataAssig(:,4)
        neuronal_prob = dataAssig(:,5)
        save '$out_stats_file'
        """).substitute(d)
        print 'Saving stats file as {s}'.format(s=out_stats_file)
        result = MatlabCommand(script=script, mfile=True,
                               prescript=[''], postscript=[''])
        r = result.run()
        return runtime
开发者ID:GIGA-Consciousness,项目名称:structurefunction,代码行数:102,代码来源:base.py

示例9: SPMCommand

# 需要导入模块: from nipype.interfaces.matlab import MatlabCommand [as 别名]
# 或者: from nipype.interfaces.matlab.MatlabCommand import run [as 别名]
class SPMCommand(BaseInterface):
    """Extends `BaseInterface` class to implement SPM specific interfaces.

    WARNING: Pseudo prototype class, meant to be subclassed
    """
    input_spec = SPMCommandInputSpec

    _jobtype = 'basetype'
    _jobname = 'basename'

    _matlab_cmd = None
    _paths = None
    _use_mcr = None

    def __init__(self, **inputs):
        super(SPMCommand, self).__init__(**inputs)
        self.inputs.on_trait_change(self._matlab_cmd_update, ['matlab_cmd',
                                                              'mfile',
                                                              'paths',
                                                              'use_mcr'])
        self._check_mlab_inputs()
        self._matlab_cmd_update()

    @classmethod
    def set_mlab_paths(cls, matlab_cmd=None, paths = None, use_mcr=None):
        cls._matlab_cmd = matlab_cmd
        cls._paths = paths
        cls._use_mcr = use_mcr

    def _matlab_cmd_update(self):
        # MatlabCommand has to be created here,
        # because matlab_cmb is not a proper input
        # and can be set only during init
        self.mlab = MatlabCommand(matlab_cmd=self.inputs.matlab_cmd,
                                  mfile=self.inputs.mfile,
                                  paths=self.inputs.paths,
                                  uses_mcr=self.inputs.use_mcr)
        self.mlab.inputs.script_file = 'pyscript_%s.m' % \
        self.__class__.__name__.split('.')[-1].lower()

    @property
    def jobtype(self):
        return self._jobtype

    @property
    def jobname(self):
        return self._jobname

    def _check_mlab_inputs(self):
        if not isdefined(self.inputs.matlab_cmd) and self._matlab_cmd:
            self.inputs.matlab_cmd = self._matlab_cmd
        if not isdefined(self.inputs.paths) and self._paths:
            self.inputs.paths = self._paths
        if not isdefined(self.inputs.use_mcr) and self._use_mcr:
            self.inputs.use_mcr = self._use_mcr

    def _run_interface(self, runtime):
        """Executes the SPM function using MATLAB."""
        self.mlab.inputs.script = self._make_matlab_command(deepcopy(self._parse_inputs()))
        results = self.mlab.run()
        runtime.returncode = results.runtime.returncode
        if self.mlab.inputs.uses_mcr:
            if 'Skipped' in results.runtime.stdout:
                self.raise_exception(runtime)
        runtime.stdout = results.runtime.stdout
        runtime.stderr = results.runtime.stderr
        runtime.merged = results.runtime.merged
        return runtime

    def _list_outputs(self):
        """Determine the expected outputs based on inputs."""

        raise NotImplementedError


    def _format_arg(self, opt, spec, val):
        """Convert input to appropriate format for SPM."""

        return val

    def _parse_inputs(self, skip=()):
        spmdict = {}
        metadata=dict(field=lambda t : t is not None)
        for name, spec in self.inputs.traits(**metadata).items():
            if skip and name in skip:
                continue
            value = getattr(self.inputs, name)
            if not isdefined(value):
                continue
            field = spec.field
            if '.' in field:
                fields = field.split('.')
                dictref = spmdict
                for f in fields[:-1]:
                    if f not in dictref.keys():
                        dictref[f] = {}
                    dictref = dictref[f]
                dictref[fields[-1]] = self._format_arg(name, spec, value)
            else:
                spmdict[field] = self._format_arg(name, spec, value)
#.........这里部分代码省略.........
开发者ID:chaselgrove,项目名称:nipype,代码行数:103,代码来源:base.py

示例10: _run_interface

# 需要导入模块: from nipype.interfaces.matlab import MatlabCommand [as 别名]
# 或者: from nipype.interfaces.matlab.MatlabCommand import run [as 别名]
    def _run_interface(self, runtime):
        list_path = op.abspath("SubjectList.lst")
        pet_path, _ = nifti_to_analyze(self.inputs.pet_file)
        t1_path, _ = nifti_to_analyze(self.inputs.t1_file)
        f = open(list_path, 'w')
        f.write("%s;%s" % (pet_path, t1_path))
        f.close()

        orig_t1 = nb.load(self.inputs.t1_file)
        orig_affine = orig_t1.get_affine()

        gm_uint8 = switch_datatype(self.inputs.grey_matter_file)
        gm_path, _ = nifti_to_analyze(gm_uint8)
        iflogger.info("Writing to %s" % gm_path)

        fixed_roi_file, fixed_wm, fixed_csf, remap_dict = fix_roi_values(
            self.inputs.roi_file, self.inputs.grey_matter_binary_mask, 
            self.inputs.white_matter_file,
            self.inputs.csf_file, self.inputs.use_fs_LUT)


        

        rois_path, _ = nifti_to_analyze(fixed_roi_file)
        iflogger.info("Writing to %s" % rois_path)
        iflogger.info("Writing to %s" % fixed_wm)
        iflogger.info("Writing to %s" % fixed_csf)

        wm_uint8 = switch_datatype(fixed_wm)
        wm_path, _ = nifti_to_analyze(wm_uint8)
        iflogger.info("Writing to %s" % wm_path)

        csf_uint8 = switch_datatype(fixed_csf)
        csf_path, _ = nifti_to_analyze(csf_uint8)
        iflogger.info("Writing to %s" % csf_path)

        if self.inputs.use_fs_LUT:
            fs_dir = os.environ['FREESURFER_HOME']
            LUT = op.join(fs_dir, "FreeSurferColorLUT.txt")
            dat_path = write_config_dat(
                fixed_roi_file, LUT, remap_dict)
        else:
            dat_path = write_config_dat(
                fixed_roi_file)
        iflogger.info("Writing to %s" % dat_path)

        d = dict(
            list_path=list_path,
            gm_path=gm_path,
            wm_path=wm_path,
            csf_path=csf_path,
            rois_path=rois_path,
            dat_path=dat_path,
            X_PSF=self.inputs.x_dir_point_spread_function_FWHM,
            Y_PSF=self.inputs.y_dir_point_spread_function_FWHM,
            Z_PSF=self.inputs.z_dir_point_spread_function_FWHM)
        script = Template("""       
        filelist = '$list_path';
        gm = '$gm_path';
        wm = '$wm_path';
        csf = '$csf_path';
        rois = '$rois_path';
        dat = '$dat_path';
        x_fwhm = '$X_PSF';
        y_fwhm = '$Y_PSF';
        z_fwhm = '$Z_PSF';
        runbatch_nogui(filelist, gm, wm, csf, rois, dat, x_fwhm, y_fwhm, z_fwhm)
        """).substitute(d)
        mlab = MatlabCommand(script=script, mfile=True,
                             prescript=[''], postscript=[''])
        result = mlab.run()

        _, foldername, _ = split_filename(self.inputs.pet_file)
        occu_MG_img = glob.glob("pve_%s/r_volume_Occu_MG.img" % foldername)[0]
        analyze_to_nifti(occu_MG_img, affine=orig_affine)
        occu_meltzer_img = glob.glob(
            "pve_%s/r_volume_Occu_Meltzer.img" % foldername)[0]
        analyze_to_nifti(occu_meltzer_img, affine=orig_affine)
        meltzer_img = glob.glob("pve_%s/r_volume_Meltzer.img" % foldername)[0]
        analyze_to_nifti(meltzer_img, affine=orig_affine)
        MG_rousset_img = glob.glob(
            "pve_%s/r_volume_MGRousset.img" % foldername)[0]
        analyze_to_nifti(MG_rousset_img, affine=orig_affine)
        MGCS_img = glob.glob("pve_%s/r_volume_MGCS.img" % foldername)[0]
        analyze_to_nifti(MGCS_img, affine=orig_affine)
        virtual_PET_img = glob.glob(
            "pve_%s/r_volume_Virtual_PET.img" % foldername)[0]
        analyze_to_nifti(virtual_PET_img, affine=orig_affine)
        centrum_semiovalue_WM_img = glob.glob(
            "pve_%s/r_volume_CSWMROI.img" % foldername)[0]
        analyze_to_nifti(centrum_semiovalue_WM_img, affine=orig_affine)
        alfano_alfano_img = glob.glob(
            "pve_%s/r_volume_AlfanoAlfano.img" % foldername)[0]
        analyze_to_nifti(alfano_alfano_img, affine=orig_affine)
        alfano_cs_img = glob.glob("pve_%s/r_volume_AlfanoCS.img" %
                                  foldername)[0]
        analyze_to_nifti(alfano_cs_img, affine=orig_affine)
        alfano_rousset_img = glob.glob(
            "pve_%s/r_volume_AlfanoRousset.img" % foldername)[0]
        analyze_to_nifti(alfano_rousset_img, affine=orig_affine)
#.........这里部分代码省略.........
开发者ID:GIGA-Consciousness,项目名称:structurefunction,代码行数:103,代码来源:pve.py

示例11: _run_interface

# 需要导入模块: from nipype.interfaces.matlab import MatlabCommand [as 别名]
# 或者: from nipype.interfaces.matlab.MatlabCommand import run [as 别名]
    def _run_interface(self, runtime):
        in_files = self.inputs.in_files
        data_dir = op.join(os.getcwd(),'origdata')
        if not op.exists(data_dir):
            os.makedirs(data_dir)
        all_names = []
        print 'Multiple ({n}) input images detected! Copying to {d}...'.format(n=len(self.inputs.in_files), d=data_dir)
        for in_file in self.inputs.in_files:
            path, name, ext = split_filename(in_file)
            shutil.copyfile(in_file, op.join(data_dir, name) + ext)
            if ext == '.img':
                shutil.copyfile(op.join(path, name) + '.hdr', op.join(data_dir, name) + '.hdr')
            elif ext == '.hdr':
                shutil.copyfile(op.join(path, name) + '.img', op.join(data_dir, name) + '.img')
            all_names.append(name)
        print 'Copied!'

        input_files_as_str = op.join(data_dir, os.path.commonprefix(all_names) + '*' + ext)
        number_of_components = self.inputs.desired_number_of_components
        output_dir = os.getcwd()
        prefix = self.inputs.prefix
        d = dict(output_dir=output_dir, prefix=prefix, number_of_components=number_of_components, in_files=input_files_as_str)
        variables = Template("""

        %% After entering the parameters, use icatb_batch_file_run(inputFile);

        modalityType = 'fMRI';
        which_analysis = 1;
        perfType = 1;
        keyword_designMatrix = 'no';
        dataSelectionMethod = 4;
        input_data_file_patterns = {'$in_files'};
        dummy_scans = 0;
        outputDir = '$output_dir';
        prefix = '$prefix';
        maskFile = [];
        group_pca_type = 'subject specific';
        backReconType = 'gica';

        %% Data Pre-processing options
        % 1 - Remove mean per time point
        % 2 - Remove mean per voxel
        % 3 - Intensity normalization
        % 4 - Variance normalization
        preproc_type = 3;
        pcaType = 1;
        pca_opts.stack_data = 'yes';
        pca_opts.precision = 'single';
        pca_opts.tolerance = 1e-4;
        pca_opts.max_iter = 1000;
        numReductionSteps = 2;
        doEstimation = 0;
        estimation_opts.PC1 = 'mean';
        estimation_opts.PC2 = 'mean';
        estimation_opts.PC3 = 'mean';

        numOfPC1 = $number_of_components;
        numOfPC2 = $number_of_components;
        numOfPC3 = 0;

        %% Scale the Results. Options are 0, 1, 2, 3 and 4
        % 0 - Don't scale
        % 1 - Scale to Percent signal change
        % 2 - Scale to Z scores
        % 3 - Normalize spatial maps using the maximum intensity value and multiply timecourses using the maximum intensity value
        % 4 - Scale timecourses using the maximum intensity value and spatial maps using the standard deviation of timecourses
        scaleType = 0;
        algoType = 1;
        refFunNames = {'Sn(1) right*bf(1)', 'Sn(1) left*bf(1)'};
        refFiles = {which('ref_default_mode.nii'), which('ref_left_visuomotor.nii'), which('ref_right_visuomotor.nii')};
        %% ICA Options - Name by value pairs in a cell array. Options will vary depending on the algorithm. See icatb_icaOptions for more details. Some options are shown below.
        %% Infomax -  {'posact', 'off', 'sphering', 'on', 'bias', 'on', 'extended', 0}
        %% FastICA - {'approach', 'symm', 'g', 'tanh', 'stabilization', 'on'}
        icaOptions =  {'posact', 'off', 'sphering', 'on', 'bias', 'on', 'extended', 0};
        """).substitute(d)

        file = open('input_batch.m', 'w')
        file.writelines(variables)
        file.close()

        script = """param_file = icatb_read_batch_file('input_batch.m');
        load(param_file);
        global FUNCTIONAL_DATA_FILTER;
        global ZIP_IMAGE_FILES;
        FUNCTIONAL_DATA_FILTER = '*.nii';
        ZIP_IMAGE_FILES = 'No';
        icatb_runAnalysis(sesInfo, 1);"""

        result = MatlabCommand(script=script, mfile=True, prescript=[''], postscript=[''])
        r = result.run()
        return runtime
开发者ID:GIGA-Consciousness,项目名称:structurefunction,代码行数:93,代码来源:gift.py


注:本文中的nipype.interfaces.matlab.MatlabCommand.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。