• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python filemanip.filename_to_list函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nipype.utils.filemanip.filename_to_list函数的典型用法代码示例。如果您正苦于以下问题:Python filename_to_list函数的具体用法?Python filename_to_list怎么用?Python filename_to_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _list_outputs

    def _list_outputs(self):
        outputs = self._outputs().get()

        jobtype = self.inputs.jobtype
        if jobtype.startswith('est'):
            outputs['normalization_parameters'] = []
            for imgf in filename_to_list(self.inputs.source):
                outputs['normalization_parameters'].append(fname_presuffix(imgf, suffix='_sn.mat', use_ext=False))
            outputs['normalization_parameters'] = list_to_filename(outputs['normalization_parameters'])

        if self.inputs.jobtype == "estimate":
            if isdefined(self.inputs.apply_to_files):
                outputs['normalized_files'] = self.inputs.apply_to_files
            outputs['normalized_source'] = self.inputs.source
        elif 'write' in self.inputs.jobtype:
            outputs['normalized_files'] = []
            if isdefined(self.inputs.apply_to_files):
                for imgf in filename_to_list(self.inputs.apply_to_files):
                    outputs['normalized_files'].append(fname_presuffix(imgf, prefix='w'))

            if isdefined(self.inputs.source):
                outputs['normalized_source'] = []
                for imgf in filename_to_list(self.inputs.source):
                    outputs['normalized_source'].append(fname_presuffix(imgf, prefix='w'))

        return outputs
开发者ID:danginsburg,项目名称:nipype,代码行数:26,代码来源:preprocess.py


示例2: median

def median(in_files):
    """Computes an average of the median of each realigned timeseries
    Parameters
    ----------
    in_files: one or more realigned Nifti 4D time series
    Returns
    -------
    out_file: a 3D Nifti file
    """
    import nibabel as nb
    import numpy as np
    import os
    from nipype.utils.filemanip import filename_to_list
    from nipype.utils.filemanip import split_filename

    average = None
    for idx, filename in enumerate(filename_to_list(in_files)):
        img = nb.load(filename)
        data = np.median(img.get_data(), axis=3)
        if average is None:
            average = data
        else:
            average = average + data
    median_img = nb.Nifti1Image(average / float(idx + 1), img.get_affine(), img.get_header())
    # filename = os.path.join(os.getcwd(), 'median.nii.gz')
    # median_img.to_filename(filename)
    _, base, _ = split_filename(filename_to_list(in_files)[0])
    nb.save(median_img, base + "_median.nii.gz")
    return os.path.abspath(base + "_median.nii.gz")
    return filename
开发者ID:fliem,项目名称:myelinconnect,代码行数:30,代码来源:functions.py


示例3: _list_outputs

    def _list_outputs(self):
        outputs = self._outputs().get()
        if isdefined(self.inputs.in_files):
            outputs['realignment_parameters'] = []
        for imgf in self.inputs.in_files:
            if isinstance(imgf,list):
                tmp_imgf = imgf[0]
            else:
                tmp_imgf = imgf
            outputs['realignment_parameters'].append(fname_presuffix(tmp_imgf,
                                                                     prefix='rp_',
                                                                     suffix='.txt',
                                                                     use_ext=False))
            if not isinstance(imgf,list) and func_is_3d(imgf):
                break;
        #if self.inputs.jobtype == "write" or self.inputs.jobtype == "estwrite":
        if isinstance(self.inputs.in_files[0], list):
            first_image = self.inputs.in_files[0][0]
        else:
            first_image = self.inputs.in_files[0]

        outputs['mean_image'] = fname_presuffix(first_image, prefix='meanu')
        outputs['realigned_files'] = []
        # get prefix for new files, or default 'u'
        file_prefix = self.inputs.write_prefix or 'u'
        for imgf in filename_to_list(self.inputs.in_files):
            realigned_run = []
            if isinstance(imgf,list):
                for inner_imgf in filename_to_list(imgf):
                    realigned_run.append(fname_presuffix(inner_imgf, prefix=file_prefix))
            else:
                realigned_run = fname_presuffix(imgf, prefix=file_prefix)
                outputs['realigned_files'].append(realigned_run)
        return outputs
开发者ID:cindeem,项目名称:jagust_rsfmri,代码行数:34,代码来源:nipype_ext.py


示例4: _list_outputs

    def _list_outputs(self):
        outputs = self._outputs().get()

        jobtype = self.inputs.jobtype
        if jobtype.startswith('est'):
            outputs['normalization_parameters'] = []
            for imgf in filename_to_list(self.inputs.source):
                outputs['normalization_parameters'].append(fname_presuffix(imgf, suffix='_sn.mat', use_ext=False))
            outputs['normalization_parameters'] = list_to_filename(outputs['normalization_parameters'])

        if self.inputs.jobtype == "estimate":
            if isdefined(self.inputs.apply_to_files):
                outputs['normalized_files'] = self.inputs.apply_to_files
            outputs['normalized_source'] = self.inputs.source
        elif 'write' in self.inputs.jobtype:
            outputs['normalized_files'] = []
            if isdefined(self.inputs.apply_to_files):
                filelist = filename_to_list(self.inputs.apply_to_files)
                for f in filelist:
                    if isinstance(f, list):
                        run = [fname_presuffix(in_f, prefix=self.inputs.out_prefix) for in_f in f]
                    else:
                        run = [fname_presuffix(f, prefix=self.inputs.out_prefix)]
                    outputs['normalized_files'].extend(run)
            if isdefined(self.inputs.source):
                outputs['normalized_source'] = fname_presuffix(self.inputs.source, prefix=self.inputs.out_prefix)

        return outputs
开发者ID:neurospin,项目名称:caps-clinfmri,代码行数:28,代码来源:spm.py


示例5: __init__

    def __init__(self, input_names, output_names, function=None, **inputs):
        """

        Parameters
        ----------

        input_names: single str or list
            names corresponding to function inputs
        output_names: single str or list
            names corresponding to function outputs. has to match the number of outputs
        """

        super(Function, self).__init__(**inputs)
        if function:
            if hasattr(function, '__call__'):
                try:
                    self.inputs.function_str = getsource(function)
                except IOError:
                    raise Exception('Interface Function does not accept ' \
                                        'function objects defined interactively in a python session')
            elif isinstance(function, str):
                self.inputs.function_str = function
            else:
                raise Exception('Unknown type of function')
        self.inputs.on_trait_change(self._set_function_string, 'function_str')
        self._input_names = filename_to_list(input_names)
        self._output_names = filename_to_list(output_names)
        add_traits(self.inputs, [name for name in self._input_names])
        self._out = {}
        for name in self._output_names:
            self._out[name] = None
开发者ID:LTS5,项目名称:nipype,代码行数:31,代码来源:utility.py


示例6: build_filter1

def build_filter1(motion_params, comp_norm, outliers):
    """Builds a regressor set comprisong motion parameters, composite norm and
    outliers

    The outliers are added as a single time point column for each outlier


    Parameters
    ----------

    motion_params: a text file containing motion parameters and its derivatives
    comp_norm: a text file containing the composite norm
    outliers: a text file containing 0-based outlier indices

    Returns
    -------
    components_file: a text file containing all the regressors
    """
    out_files = []
    for idx, filename in enumerate(filename_to_list(motion_params)):
        params = np.genfromtxt(filename)
        norm_val = np.genfromtxt(filename_to_list(comp_norm)[idx])
        out_params = np.hstack((params, norm_val[:, None]))
        try:
            outlier_val = np.genfromtxt(filename_to_list(outliers)[idx])
        except IOError:
            outlier_val = np.empty((0))
        for index in np.atleast_1d(outlier_val):
            outlier_vector = np.zeros((out_params.shape[0], 1))
            outlier_vector[index] = 1
            out_params = np.hstack((out_params, outlier_vector))
        filename = os.path.join(os.getcwd(), "filter_regressor%02d.txt" % idx)
        np.savetxt(filename, out_params, fmt="%.10f")
        out_files.append(filename)
    return out_files
开发者ID:adamatus,项目名称:nipype,代码行数:35,代码来源:rsfmri_preprocessing.py


示例7: _run_interface

 def _run_interface(self, runtime):
     """Execute this module.
     """
     funcfilelist = filename_to_list(self.inputs.realigned_files)
     motparamlist = filename_to_list(self.inputs.realignment_parameters)
     for i,imgf in enumerate(funcfilelist):
         self._detect_outliers_core(imgf ,motparamlist[i], i, os.getcwd())
     return runtime
开发者ID:schwarty,项目名称:nipype,代码行数:8,代码来源:rapidart.py


示例8: test_filename_to_list

def test_filename_to_list():
    x = filename_to_list('foo.nii')
    yield assert_equal, x, ['foo.nii']
    x = filename_to_list(['foo.nii'])
    yield assert_equal, x, ['foo.nii']
    x = filename_to_list(('foo', 'bar'))
    yield assert_equal, x, ['foo', 'bar']
    x = filename_to_list(12.34)
    yield assert_equal, x, None
开发者ID:agramfort,项目名称:nipype,代码行数:9,代码来源:test_filemanip.py


示例9: clean_working_directory

def clean_working_directory(outputs, cwd, inputs, needed_outputs, config,
                            files2keep=None, dirs2keep=None):
    """Removes all files not needed for further analysis from the directory
    """
    if not outputs:
        return
    outputs_to_keep = outputs.get().keys()
    if needed_outputs and \
       str2bool(config['execution']['remove_unnecessary_outputs']):
        outputs_to_keep = needed_outputs
    # build a list of needed files
    output_files = []
    outputdict = outputs.get()
    for output in outputs_to_keep:
        output_files.extend(walk_outputs(outputdict[output]))
    needed_files = [path for path, type in output_files if type == 'f']
    if str2bool(config['execution']['keep_inputs']):
        input_files = []
        inputdict = inputs.get()
        input_files.extend(walk_outputs(inputdict))
        needed_files += [path for path, type in input_files if type == 'f']
    for extra in ['_0x*.json', 'provenance.xml', 'pyscript*.m',
                  'command.txt', 'result*.pklz', '_inputs.pklz', '_node.pklz']:
        needed_files.extend(glob(os.path.join(cwd, extra)))
    if files2keep:
        needed_files.extend(filename_to_list(files2keep))
    needed_dirs = [path for path, type in output_files if type == 'd']
    if dirs2keep:
        needed_dirs.extend(filename_to_list(dirs2keep))
    for extra in ['_nipype', '_report']:
        needed_dirs.extend(glob(os.path.join(cwd, extra)))
    logger.debug('Needed files: %s' % (';'.join(needed_files)))
    logger.debug('Needed dirs: %s' % (';'.join(needed_dirs)))
    files2remove = []
    if str2bool(config['execution']['remove_unnecessary_outputs']):
        for f in walk_files(cwd):
            if f not in needed_files:
                if len(needed_dirs) == 0:
                    files2remove.append(f)
                elif not any([f.startswith(dirname) for dirname in needed_dirs]):
                    files2remove.append(f)
    else:
        if not str2bool(config['execution']['keep_inputs']):
            input_files = []
            inputdict = inputs.get()
            input_files.extend(walk_outputs(inputdict))
            input_files = [path for path, type in input_files if type == 'f']
            for f in walk_files(cwd):
                if f in input_files and f not in needed_files:
                    files2remove.append(f)
    logger.debug('Removing files: %s' % (';'.join(files2remove)))
    for f in files2remove:
        os.remove(f)
    for key in outputs.copyable_trait_names():
        if key not in outputs_to_keep:
            setattr(outputs, key, Undefined)
    return outputs
开发者ID:FNNDSC,项目名称:nipype,代码行数:57,代码来源:utils.py


示例10: _format_arg

 def _format_arg(self, opt, spec, val):
     """Convert input to appropriate format for spm
     """
     if opt == 'target' or opt == 'source':
         return scans_for_fnames(filename_to_list(val),
                                 keep4d=True)
     if opt == 'apply_to_files':
         return scans_for_fnames(filename_to_list(val))
     return val
开发者ID:danginsburg,项目名称:nipype,代码行数:9,代码来源:preprocess.py


示例11: create_correlation_matrix

def create_correlation_matrix(infiles, roi, out_type, package):
    import os
    import numpy as np
    import scipy.io as sio
    import nibabel as nb
    from nipype.utils.filemanip import split_filename, filename_to_list

    for idx, fname in enumerate(filename_to_list(infiles)):
        data = np.squeeze(nb.load(fname).get_data())
        if idx == 0:
            timeseries = data
        else:
            timeseries = np.vstack((timeseries, data))
    roi_data = np.genfromtxt(roi)
    if not len(roi_data.shape) == 2:
        roi_data = roi_data[:, None]
    corrmat = np.zeros((roi_data.shape[1], timeseries.shape[0]))
    print timeseries.shape
    for i in xrange(roi_data.shape[1]):
        for j in xrange(timeseries.shape[0]):
            r = np.corrcoef(timeseries[j, :], roi_data[:, i])[0][1]
            corrmat[i, j] = np.sqrt(timeseries.shape[1] - 3) * 0.5 * np.log((1 + r) / (1 - r))

    # corrmat = np.corrcoef(timeseries,roi_data.T)
    print corrmat.shape

    _, name, _ = split_filename(filename_to_list(infiles)[0])
    if len(filename_to_list(infiles)) > 1:
        name = "combined_" + name
    if "mat" in out_type:
        matfile = os.path.abspath(name + ".mat")
        sio.savemat(matfile, {"corrmat": corrmat})
        output = matfile
    elif "hdf5" in out_type:
        hdf5file = os.path.abspath(name + ".hf5")
        if package == "h5py":
            import h5py

            f = h5py.File(hdf5file, "w")
            f.create_dataset("corrmat", data=corrmat, compression=5)
            f.close()
        else:
            from tables import openFile, Float64Atom, Filters

            h5file = openFile(hdf5file, "w")
            arr = h5file.createCArray(
                h5file.root, "corrmat", Float64Atom(), corrmat.shape, filters=Filters(complevel=5)
            )
            arr[:] = corrmat
            h5file.close()
        output = hdf5file
    else:
        raise Exception("Unknown output type")
    return output
开发者ID:stymy,项目名称:BrainImagingPipelines,代码行数:54,代码来源:workflow29.py


示例12: _format_arg

 def _format_arg(self, opt, spec, val):
     """Convert input to appropriate format for spm
     """
     if opt == 'in_files':
         return scans_for_fnames(filename_to_list(val))
     if opt == 'target':
         return scans_for_fname(filename_to_list(val))
     if opt == 'deformation':
         return np.array([list_to_filename(val)], dtype=object)
     if opt == 'deformation_field':
         return np.array([list_to_filename(val)], dtype=object)
     return val
开发者ID:ChadCumba,项目名称:nipype,代码行数:12,代码来源:utils.py


示例13: _generate_design

 def _generate_design(self):
     infolist = self.inputs.subject_info
     if self.inputs.concatenate_runs:
         infolist,nscans = self._concatenate_info(infolist)
         functional_runs = [filename_to_list(self.inputs.functional_runs)]
     else:
         functional_runs = filename_to_list(self.inputs.functional_runs)
     realignment_parameters = []
     if isdefined(self.inputs.realignment_parameters):
         rpfiles = filename_to_list(self.inputs.realignment_parameters)
         realignment_parameters.insert(0,np.loadtxt(rpfiles[0]))
         for rpf in rpfiles[1:]:
             mc = np.loadtxt(rpf)
             if self.inputs.concatenate_runs:
                 realignment_parameters[0] = np.concatenate((realignment_parameters[0],mc))
             else:
                 realignment_parameters.insert(len(realignment_parameters),mc)
     outliers = []
     if isdefined(self.inputs.outlier_files):
         outfiles = filename_to_list(self.inputs.outlier_files)
         try:
             outindices = np.loadtxt(outfiles[0],dtype=int)
             if outindices.size == 1:
                 outliers.insert(0,[outindices.tolist()])
             else:
                 outliers.insert(0,outindices.tolist())
         except IOError:
             outliers.insert(0,[])
         for i,rpf in enumerate(outfiles[1:]):
             try:
                 out = np.loadtxt(rpf,dtype=int)
             except IOError:
                 out = np.array([])
             if self.inputs.concatenate_runs:
                 if out.size>0:
                     if out.size == 1:
                         outliers[0].extend([(np.array(out)+sum(nscans[0:(i+1)])).tolist()])
                     else:
                         outliers[0].extend((np.array(out)+sum(nscans[0:(i+1)])).tolist())
             else:
                 if out.size == 1:
                     outliers.insert(len(outliers),[out.tolist()])
                 else:
                     outliers.insert(len(outliers),out.tolist())
     if self.inputs.is_sparse:
         infolist = self._generate_clustered_design(infolist)
         
     sessinfo = self._generate_standard_design(infolist,
                                               functional_runs=functional_runs,
                                               realignment_parameters=realignment_parameters,
                                               outliers=outliers)
     
     np.savez(self._get_outfilename(),session_info=sessinfo)
开发者ID:satra,项目名称:NiPypeold,代码行数:53,代码来源:modelgen.py


示例14: _run_interface

    def _run_interface(self, execute=True, cwd=None):
        old_cwd = os.getcwd()
        if not cwd:
            cwd = self._output_directory()
        os.chdir(cwd)

        nitems = len(filename_to_list(getattr(self.inputs, self.iterfield[0])))
        newnodes = []
        nodenames = []
        for i in range(nitems):
            nodenames.insert(i, '_' + self.name+str(i))
            newnodes.insert(i, Node(deepcopy(self._interface), name=nodenames[i]))
            newnodes[i]._interface.inputs.set(**deepcopy(self._interface.inputs.get()))
            for field in self.iterfield:
                fieldvals = filename_to_list(getattr(self.inputs, field))
                logger.debug('setting input %d %s %s'%(i, field,
                                                      fieldvals[i])) 
                setattr(newnodes[i].inputs, field,
                        fieldvals[i])
        workflowname = 'mapflow'
        iterflow = Workflow(name=workflowname)
        iterflow.base_dir = cwd
        iterflow.config = self.config
        iterflow.add_nodes(newnodes)
        iterflow.run(inseries=True)
        self._result = InterfaceResult(interface=[], runtime=[],
                                       outputs=self.outputs)
        for i in range(nitems):
            node = iterflow.get_exec_node('.'.join((workflowname,
                                                    nodenames[i])))
            runtime = Bunch(returncode = 0, environ = deepcopy(os.environ.data), hostname = gethostname())
            self._result.runtime.insert(i, runtime)
            if node.result and hasattr(node.result, 'runtime'):
                self._result.runtime[i] = node.result.runtime
                if node.result.runtime.returncode != 0:
                    raise Exception('iternode %s:%d did not run'%(node._id, i))
                self._result.interface.insert(i, node.result.interface)
        for key, _ in self.outputs.items():
            values = []
            for i in range(nitems):
                node = iterflow.get_exec_node('.'.join((workflowname,
                                                        nodenames[i])))
                if node.result.outputs:
                    values.insert(i, node.result.outputs.get()[key])
                else:
                    values.insert(i, None)
            if any([val != Undefined for val in values]) and self._result.outputs:
                #logger.debug('setting key %s with values %s' %(key, str(values)))
                setattr(self._result.outputs, key, values)
            #else:
            #    logger.debug('no values for key %s' %key)
        os.chdir(old_cwd)
开发者ID:danginsburg,项目名称:nipype,代码行数:52,代码来源:engine.py


示例15: _format_arg

 def _format_arg(self, opt, spec, val):
     """Convert input to appropriate format for spm
     """
     if opt == "target" or (opt == "source" and self.inputs.jobtype != "write"):
         return scans_for_fnames(filename_to_list(val), keep4d=True)
     if opt == "apply_to_files":
         return scans_for_fnames(filename_to_list(val))
     if opt == "source" and self.inputs.jobtype == "write":
         if isdefined(self.inputs.apply_to_files):
             return scans_for_fnames(val + self.inputs.apply_to_files)
         else:
             return scans_for_fnames(val)
     return val
开发者ID:chaselgrove,项目名称:nipype,代码行数:13,代码来源:preprocess.py


示例16: build_filter1

def build_filter1(motion_params, outliers, comp_norm=None, detrend_poly=None):
    """From https://github.com/nipy/nipype/blob/master/examples/
    rsfmri_vol_surface_preprocessing_nipy.py#L261
    
    Builds a regressor set comprisong motion parameters, composite norm and
    outliers. The outliers are added as a single time point column for each outlier
    
    Parameters
    ----------
    motion_params: a text file containing motion parameters and its derivatives
    comp_norm: a text file containing the composite norm
    outliers: a text file containing 0-based outlier indices
    detrend_poly: number of polynomials to add to detrend
    
    Returns
    -------
    components_file: a text file containing all the regressors
    """
    
    from nipype.utils.filemanip import filename_to_list
    import numpy as np
    import os
    from scipy.special import legendre
    
    out_files = []
    for idx, filename in enumerate(filename_to_list(motion_params)):
        params = np.genfromtxt(filename)
        if comp_norm:
            norm_val = np.genfromtxt(filename_to_list(comp_norm)[idx])
            out_params = np.hstack((params, norm_val[:, None]))
        else:
            out_params = params
        try:
            outlier_val = np.genfromtxt(filename_to_list(outliers)[idx])
        except IOError:
            outlier_val = np.empty((0))
        for index in np.atleast_1d(outlier_val):
            outlier_vector = np.zeros((out_params.shape[0], 1))
            outlier_vector[index] = 1
            out_params = np.hstack((out_params, outlier_vector))
        if detrend_poly:
            timepoints = out_params.shape[0]
            X = np.ones((timepoints, 1))
            for i in range(detrend_poly):
                X = np.hstack((X, legendre(
                    i + 1)(np.linspace(-1, 1, timepoints))[:, None]))
            out_params = np.hstack((out_params, X))
        filename = os.path.join(os.getcwd(), "mcart_regressor.txt") #"filter_regressor%02d.txt" % idx)
        np.savetxt(filename, out_params, fmt="%.10f")
        out_files.append(filename)
    return out_files
开发者ID:JanisReinelt,项目名称:pipelines,代码行数:51,代码来源:motionfilter.py


示例17: _format_arg

 def _format_arg(self, opt, spec, val):
     """Convert input to appropriate format for spm
     """
     if opt == 'target' or (opt == 'source' and self.inputs.jobtype != "write"):
         return scans_for_fnames(filename_to_list(val),
                                 keep4d=True)
     if opt == 'apply_to_files':
         return np.array(filename_to_list(val), dtype=object)
     if opt == 'source' and self.inputs.jobtype == "write":
         if isdefined(self.inputs.apply_to_files):
             return scans_for_fnames(val+self.inputs.apply_to_files)
         else:
             return scans_for_fnames(val)
     return val
开发者ID:IBIC,项目名称:nipype,代码行数:14,代码来源:preprocess.py


示例18: _list_outputs

 def _list_outputs(self):
     """Execute this module.
     """
     outdir = self.inputs.base_directory
     if not isdefined(outdir):
         outdir = '.'
     outdir = os.path.abspath(outdir)
     if isdefined(self.inputs.container):
         outdir = os.path.join(outdir, self.inputs.container)
     if not os.path.exists(outdir):
         os.makedirs(outdir)
     for key,files in self.inputs._outputs.items():
         iflogger.debug("key: %s files: %s"%(key, str(files)))
         files = filename_to_list(files)
         outfiles = []
         tempoutdir = outdir
         for d in key.split('.'):
             if d[0] == '@':
                 continue
             tempoutdir = os.path.join(tempoutdir,d)
         
         # flattening list
         if isinstance(files, list):
             if isinstance(files[0], list):
                 files = [item for sublist in files for item in sublist]
                 
         for src in filename_to_list(files):
             src = os.path.abspath(src)
             if os.path.isfile(src):
                 dst = self._get_dst(src)
                 dst = os.path.join(tempoutdir, dst)
                 dst = self._substitute(dst)
                 path,_ = os.path.split(dst)
                 if not os.path.exists(path):
                     os.makedirs(path)
                 iflogger.debug("copyfile: %s %s"%(src, dst))
                 copyfile(src, dst, copy=True)
             elif os.path.isdir(src):
                 dst = self._get_dst(os.path.join(src,''))
                 dst = os.path.join(tempoutdir, dst)
                 dst = self._substitute(dst)
                 path,_ = os.path.split(dst)
                 if not os.path.exists(path):
                     os.makedirs(path)
                 if os.path.exists(dst):
                     iflogger.debug("removing: %s"%dst)
                     shutil.rmtree(dst)
                 iflogger.debug("copydir: %s %s"%(src, dst))
                 shutil.copytree(src, dst)
     return None
开发者ID:danginsburg,项目名称:nipype,代码行数:50,代码来源:io.py


示例19: _format_arg

 def _format_arg(self, opt, spec, val):
     """Convert input to appropriate format for spm
     """
     if opt == 'template':
         return scans_for_fname(filename_to_list(val))
     if opt == 'source':
         return scans_for_fname(filename_to_list(val))
     if opt == 'apply_to_files':
         return scans_for_fnames(filename_to_list(val))
     if opt == 'parameter_file':
         return np.array([list_to_filename(val)], dtype=object)
     if opt in ['write_wrap']:
         if len(val) != 3:
             raise ValueError('%s must have 3 elements' % opt)
     return super(Normalize, self)._format_arg(opt, spec, val)
开发者ID:neurospin,项目名称:caps-clinfmri,代码行数:15,代码来源:spm.py


示例20: median

def median(in_files):
    """Computes an average of the median of each realigned timeseries

    Parameters
    ----------

    in_files: one or more realigned Nifti 4D time series

    Returns
    -------

    out_file: a 3D Nifti file
    """
    average = None
    for idx, filename in enumerate(filename_to_list(in_files)):
        img = nb.load(filename)
        data = np.median(img.get_data(), axis=3)
        if average is None:
            average = data
        else:
            average = average + data
    median_img = nb.Nifti1Image(average / float(idx + 1), img.affine,
                                img.header)
    filename = os.path.join(os.getcwd(), 'median.nii.gz')
    median_img.to_filename(filename)
    return filename
开发者ID:Conxz,项目名称:nipype,代码行数:26,代码来源:rsfmri_vol_surface_preprocessing_nipy.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python filemanip.fname_presuffix函数代码示例发布时间:2022-05-27
下一篇:
Python filemanip.copyfile函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap