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

Python filemanip.split_f函数代码示例

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

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



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

示例1: _run_interface

 def _run_interface(self, runtime):
             
     print 'in plot_coclass'
     
     coclass_matrix_file = self.inputs.coclass_matrix_file
     labels_file = self.inputs.labels_file
     list_value_range = self.inputs.list_value_range
         
     
     print 'loading coclass'
     coclass_mat = np.load(coclass_matrix_file)
     
     
     if isdefined(labels_file):
         
         print 'loading labels'
         labels = [line.strip() for line in open(labels_file)]
         
     else :
         labels = []
         
     if not isdefined(list_value_range):
     
         list_value_range = [np.amin(coclass_mat),np.amax(coclass_mat)]
     
     print 'plotting heatmap'
     
     path,fname,ext = split_f(coclass_matrix_file)
     
     plot_coclass_matrix_file =  os.path.abspath('heatmap_' + fname + '.eps')
     
     plot_ranged_cormat(plot_coclass_matrix_file,coclass_mat,labels,fix_full_range = list_value_range)
     
     return runtime
开发者ID:davidmeunier79,项目名称:dmgraphanalysis_nodes,代码行数:34,代码来源:coclass.py


示例2: convert_ds_to_raw_fif

def convert_ds_to_raw_fif(ds_file):
    import os
    import os.path as op
    
    from nipype.utils.filemanip import split_filename as split_f
    from mne.io import read_raw_ctf
    
    
    subj_path,basename,ext = split_f(ds_file)
    print subj_path,basename,ext
    raw = read_raw_ctf(ds_file)
    #raw_fif_file = os.path.abspath(basename + "_raw.fif")
    
    #raw.save(raw_fif_file)
    #return raw_fif_file

    
    raw_fif_file = os.path.join(subj_path,basename + "_raw.fif")
    if not op.isfile(raw_fif_file):
        raw = read_raw_ctf(ds_file)
        raw.save(raw_fif_file)
    else:
        print '*** RAW FIF file %s exists!!!' % raw_fif_file
        
    return raw_fif_file
开发者ID:davidmeunier79,项目名称:neuropype_ephy,代码行数:25,代码来源:import_ctf.py


示例3: compute_noise_cov

def compute_noise_cov(cov_fname, raw):
    import os.path as op

    from mne import compute_raw_covariance, pick_types, write_cov
    from nipype.utils.filemanip import split_filename as split_f
    from neuropype_ephy.preproc import create_reject_dict

    print '***** COMPUTE RAW COV *****' + cov_fname

    if not op.isfile(cov_fname):

        data_path, basename, ext = split_f(raw.info['filename'])
        fname = op.join(data_path, '%s-cov.fif' % basename)

        reject = create_reject_dict(raw.info)
#        reject = dict(mag=4e-12, grad=4000e-13, eog=250e-6)

        picks = pick_types(raw.info, meg=True, ref_meg=False, exclude='bads')

        noise_cov = compute_raw_covariance(raw, picks=picks, reject=reject)

        write_cov(fname, noise_cov)

    else:
        print '*** NOISE cov file %s exists!!!' % cov_fname

    return cov_fname
开发者ID:annapasca,项目名称:neuropype_ephy,代码行数:27,代码来源:compute_inv_problem.py


示例4: plot_coclass_matrix_labels_range

def plot_coclass_matrix_labels_range(coclass_matrix_file,labels_file,list_value_range):

    import numpy as np
    import os
    
    from nipype.utils.filemanip import split_filename as split_f
    
    from dmgraphanalysis.utils_plot import plot_ranged_cormat
    #from dmgraphanalysis.utils_plot import plot_cormat
    
    print 'loading labels'
    labels = [line.strip() for line in open(labels_file)]
    
    np_labels = np.array(labels,dtype = 'string')
    
    #print np_labels
    
    #print coclass_mat.shape
    
    print 'loading coclass'
    coclass_mat = np.load(coclass_matrix_file)
    
    
    print 'plotting heatmap'
    
    path,fname,ext = split_f(coclass_matrix_file)
    
    plot_coclass_matrix_file =  os.path.abspath('heatmap_' + fname + '.eps')
    
    plot_ranged_cormat(plot_coclass_matrix_file,coclass_mat,labels,fix_full_range = list_value_range)
    
    return plot_coclass_matrix_file
开发者ID:Lx37,项目名称:dmgraphanalysis,代码行数:32,代码来源:coclass.py


示例5: plot_igraph_coclass_matrix

def plot_igraph_coclass_matrix(coclass_matrix_file,gm_mask_coords_file,threshold):

    import numpy as np
    import os
    import pylab as pl
    
    from dmgraphanalysis.plot_igraph import plot_igraph_3D_int_mat
    
    from nipype.utils.filemanip import split_filename as split_f
    
    print 'loading coclass_matrix'
    coclass_matrix = np.load(coclass_matrix_file)
    
    path,fname,ext = split_f(coclass_matrix_file)
    
    
    print 'loading gm mask corres'
    
    gm_mask_coords = np.loadtxt(gm_mask_coords_file)
    
    print gm_mask_coords.shape
        
        
    print 'plotting igraph'
    
    coclass_matrix[coclass_matrix < threshold] = 0
    
    plot_igraph_3D_coclass_matrix_file = os.path.abspath('plot_igraph_3D_coclass_matrix.eps')
    
    plot_igraph_3D_int_mat(coclass_matrix,gm_mask_coords,plot_igraph_3D_coclass_matrix_file)
    
    return plot_igraph_3D_coclass_matrix_file    
开发者ID:Lx37,项目名称:dmgraphanalysis,代码行数:32,代码来源:coclass.py


示例6: get_MRI_sbj_dir

def get_MRI_sbj_dir(dcm_file):
    from nipype.utils.filemanip import split_filename as split_f
    import os.path as op
    
    MRI_sbj_dir, basename, ext = split_f(dcm_file)
    struct_filename = op.join(MRI_sbj_dir, 'struct.nii.gz')
    return struct_filename
开发者ID:davidmeunier79,项目名称:nipype,代码行数:7,代码来源:FS_utils.py


示例7: plot_coclass_matrix

def plot_coclass_matrix(coclass_matrix_file):

    import numpy as np
    import os
    import matplotlib.pyplot as plt
    import pylab as pl
    
    from nipype.utils.filemanip import split_filename as split_f
    
    print 'loading sum_coclass_matrix'
    
    sum_coclass_matrix = np.load(coclass_matrix_file)
    
    path,fname,ext = split_f(coclass_matrix_file)
    
    print 'plotting heatmap'
    
    plot_heatmap_coclass_matrix_file =  os.path.abspath('heatmap_' + fname + '.eps')
    
    #fig1 = figure.Figure()
    fig1 = plt.figure()
    ax = fig1.add_subplot(1,1,1)
    im = ax.matshow(sum_coclass_matrix)
    im.set_cmap('spectral')
    fig1.colorbar(im)
    
    fig1.savefig(plot_heatmap_coclass_matrix_file)
    
    plt.close(fig1)
    #fig1.close()
    del fig1
    
    
    ############# histogram 
    
    print 'plotting distance matrix histogram'
     
    #plt.figure()
    
    #plt.figure.Figure()
    
    
    plot_hist_coclass_matrix_file = os.path.abspath('hist_coclass_matrix.eps')
    
    #fig2 = figure.Figure()
    fig2 = plt.figure()
    ax = fig2.add_subplot(1,1,1)
    y, x = np.histogram(sum_coclass_matrix, bins = 100)
    ax.plot(x[:-1],y)
    #ax.bar(x[:-1],y, width = y[1]-y[0])
    fig2.savefig(plot_hist_coclass_matrix_file)
    
    plt.close(fig2)
    #fig2.close()
    del fig2
    
    return plot_hist_coclass_matrix_file,plot_heatmap_coclass_matrix_file
开发者ID:Lx37,项目名称:dmgraphanalysis,代码行数:57,代码来源:coclass.py


示例8: _list_outputs

 def _list_outputs(self):
     
     outputs = self._outputs().get()
     
     path,fname,ext = split_f(self.inputs.coclass_matrix_file)
     
     outputs["plot_coclass_matrix_file"] = os.path.abspath('heatmap_' + fname + '.eps')
     
     return outputs
开发者ID:davidmeunier79,项目名称:dmgraphanalysis_nodes,代码行数:9,代码来源:coclass.py


示例9: _list_outputs

 def _list_outputs(self):
     
     outputs = self._outputs().get()
     
     path, fname, ext = split_f(self.inputs.Pajek_net_file)
 
     outputs["rada_log_file"] = os.path.abspath(fname + '.log')
 
     return outputs
开发者ID:davidmeunier79,项目名称:dmgraphanalysis_nodes,代码行数:9,代码来源:modularity.py


示例10: _list_outputs

 def _list_outputs(self):
     
     outputs = self._outputs().get()
     
     net_List_file = self.inputs.net_List_file
     
     path, fname, ext = split_f(net_List_file)
 
     outputs["Pajek_net_file"] = os.path.abspath(fname + '.net')
 
     return outputs
开发者ID:davidmeunier79,项目名称:neuropype_graph,代码行数:11,代码来源:rada.py


示例11: split_fif_into_eo_ec

def split_fif_into_eo_ec(fif_file, lCondStart, lCondEnd, first_samp, cond):
  # import mne
  import os
  from nipype.utils.filemanip import split_filename as split_f
  from mne.io import Raw
  subj_path, basename, ext = split_f(fif_file)
  # raw1 = raw.crop(tmin=10, tmax=30)
  # print("I did smth")
# --------------- Delete later ----------------------- #
  subj_name = subj_path[-5:]
  results_dir = subj_path[:-6]
  results_dir += '2016'
  subj_path = results_dir + '/' + subj_name
  if not os.path.exists(subj_path):
      os.makedirs(subj_path)
########################################################

  print(fif_file)
  Raw_fif = Raw(fif_file, preload=True)
  # first_samp_time = Raw_fif.index_as_time(Raw_fif.first_samp)
  lRaw_cond = []
  # print("I did smth")

  if cond == 'eo':
    eo_ec_split_fif = subj_path + '/' + basename + '_eo'
  elif cond == 'ec':
    eo_ec_split_fif = subj_path + '/' + basename + '_ec'

  for i in range(len(lCondStart)):
    tmin = lCondStart[i] - first_samp
    tmax = lCondEnd[i] - first_samp
    # To make sure, that my eo-ec time intervals are inside the recording
    if i == 0:
      tmin += 0.5
    if i == range(len(lCondStart))[-1]:
      tmax -= 0.5
    ####################################
    # print("tmin = ")
    # print(tmin)
    # print("tmax = ")
    # print(tmax)
    fif_cropped = Raw_fif.crop(tmin=tmin, tmax=tmax)
    cropped_filename = eo_ec_split_fif + '_' + str(i) + ext
    fif_cropped.save(cropped_filename, overwrite=True)
    lRaw_cond.append(fif_cropped)

  Raw_cond = lRaw_cond[0]
  Raw_cond.append(lRaw_cond[1:])

  print(eo_ec_split_fif)
  eo_ec_split_fif = eo_ec_split_fif + ext
  Raw_cond.save(eo_ec_split_fif, overwrite=True)
  return eo_ec_split_fif
开发者ID:dmalt,项目名称:ICA_clean_pipeline,代码行数:53,代码来源:split_data.py


示例12: _get_fwd_filename

    def _get_fwd_filename(self, raw_info, aseg, spacing):

        data_path, raw_fname, ext = split_f(raw_info['filename'])

        if aseg == traits.Undefined:
            fwd_filename = op.join(data_path, '%s-%s-fwd.fif'
                                   % (raw_fname, spacing))
        else:
            fwd_filename = op.join(data_path, '%s-%s-aseg-fwd.fif'
                                   % (raw_fname, spacing))

        print '*** fwd_filename %s ***' % fwd_filename
        return fwd_filename
开发者ID:dmalt,项目名称:neuropype_ephy,代码行数:13,代码来源:LF_computation.py


示例13: _get_fwd_filename

    def _get_fwd_filename(self, raw_info, aseg, spacing, is_blind):

        data_path, raw_fname, ext = split_f(raw_info['filename'])

        fwd_filename = '%s-%s' % (raw_fname, spacing)
        if is_blind:
            fwd_filename += '-blind'
        if aseg:
            fwd_filename += '-aseg'

        fwd_filename = op.join(data_path, fwd_filename + '-fwd.fif')

        print '\n *** fwd_filename %s ***\n' % fwd_filename
        return fwd_filename
开发者ID:annapasca,项目名称:neuropype_ephy,代码行数:14,代码来源:LF_computation.py


示例14: get_ext_file

def get_ext_file(raw_file):
    from nipype.utils.filemanip import split_filename as split_f

    subj_path, basename, ext = split_f(raw_file)

    print raw_file
    is_ds = False
    if ext is 'ds':
        is_ds = True
        return is_ds
    elif ext is 'fif':
        return is_ds
    else:
        raise RuntimeError('only fif and ds file format!!!')
开发者ID:dmalt,项目名称:neuropype_ephy,代码行数:14,代码来源:preproc_meeg.py


示例15: is_trans

def is_trans(raw_info):
    import os.path as op

    from nipype.utils.filemanip import split_filename as split_f

    data_path, raw_fname, ext = split_f(raw_info['filename'])

    # check if the co-registration file was created
    # if not raise an runtime error
    trans_fname = op.join(data_path, '%s-trans.fif' % raw_fname)
    if not op.isfile(trans_fname):
        raise RuntimeError('*** coregistration file %s NOT found!!!'
                           % trans_fname)

    return trans_fname
开发者ID:dmalt,项目名称:neuropype_ephy,代码行数:15,代码来源:compute_fwd_problem.py


示例16: import_mat_to_conmat

def import_mat_to_conmat(mat_file,orig_channel_names_file,orig_channel_coords_file):

    import os
    import numpy as np

    import mne

    from mne.io import RawArray	
    from nipype.utils.filemanip import split_filename as split_f

    from scipy.io import loadmat

    subj_path,basename,ext = split_f(mat_file)

    mat = loadmat(mat_file)

    #field_name = basename.split('_')[0]
    #field_name = basename.split('_')[1]
    #print field_name
    print mat["mat_x"].shape


    raw_data = np.array(mat["mat_x"],dtype = "f")
    print raw_data
    print raw_data.shape

    conmat_file = os.path.abspath(basename +".npy")

    np.save(conmat_file,raw_data)

    correct_channel_coords = np.loadtxt(orig_channel_coords_file)
    
    print correct_channel_coords
    
    
    correct_channel_names = np.loadtxt(orig_channel_coords_file)
    
    print correct_channel_names
    
    ### save channel coords
    channel_coords_file = os.path.abspath("correct_channel_coords.txt")
    np.savetxt(channel_coords_file ,correct_channel_coords , fmt = '%s')

    ### save channel names
    channel_names_file = os.path.abspath("correct_channel_names.txt")
    np.savetxt(channel_names_file,correct_channel_names , fmt = '%s')

    return conmat_file,channel_coords_file,channel_names_file
开发者ID:dmalt,项目名称:neuropype_ephy,代码行数:48,代码来源:import_mat.py


示例17: compute_ts_inv_sol

def compute_ts_inv_sol(raw, fwd_filename, cov_fname, snr, inv_method, aseg):
    import os.path as op
    import numpy as np
    import mne
    from mne.minimum_norm import make_inverse_operator, apply_inverse_raw
    from nipype.utils.filemanip import split_filename as split_f

    print '***** READ FWD SOL %s *****' % fwd_filename
    forward = mne.read_forward_solution(fwd_filename)

    # Convert to surface orientation for cortically constrained
    # inverse modeling
    if not aseg:
        forward = mne.convert_forward_solution(forward, surf_ori=True)

    lambda2 = 1.0 / snr ** 2

    # compute inverse operator
    print '***** COMPUTE INV OP *****'
    inverse_operator = make_inverse_operator(raw.info, forward, cov_fname,
                                             loose=0.2, depth=0.8)

    # apply inverse operator to the time windows [t_start, t_stop]s
    # TEST
    t_start = 0  # sec
    t_stop = 3  # sec
    start, stop = raw.time_as_index([t_start, t_stop])
    print '***** APPLY INV OP ***** [%d %d]sec' % (t_start, t_stop)
    stc = apply_inverse_raw(raw, inverse_operator, lambda2, inv_method,
                            label=None,
                            start=start, stop=stop, pick_ori=None)

    print '***'
    print 'stc dim ' + str(stc.shape)
    print '***'

    subj_path, basename, ext = split_f(raw.info['filename'])
    data = stc.data

    print 'data dim ' + str(data.shape)

    # save results in .npy file that will be the input for spectral node
    print '***** SAVE SOL *****'
    ts_file = op.abspath(basename + '.npy')
    np.save(ts_file, data)

    return ts_file
开发者ID:annapasca,项目名称:neuropype_ephy,代码行数:47,代码来源:compute_inv_problem.py


示例18: plot_order_coclass_matrix_labels

def plot_order_coclass_matrix_labels(coclass_matrix_file,node_order_vect_file,labels_file):

    import numpy as np
    import os
    
    from nipype.utils.filemanip import split_filename as split_f
    
    from dmgraphanalysis.utils_plot import plot_cormat
    
    print 'loading labels'
    labels = [line.strip() for line in open(labels_file)]
    
    np_labels = np.array(labels,dtype = 'string')
    
    #print np_labels
    
    #print coclass_mat.shape
    
    print 'loading coclass'
    coclass_mat = np.load(coclass_matrix_file)
    
    print 'loading node order'
    
    node_order_vect = np.array(np.loadtxt(node_order_vect_file),dtype = 'int')
    
    print 'reordering labels'
    #print node_order_vect
    np_reordered_labels = np_labels[node_order_vect]
    
    list_reordered_labels = np_reordered_labels.tolist()
    
    print 'reordering coclass'
    
    mat = coclass_mat[node_order_vect,: ]
    
    reordered_coclass_mat = mat[:, node_order_vect]
    
    path,fname,ext = split_f(coclass_matrix_file)
    
    print 'plotting reorder heatmap'
    
    plot_reordered_coclass_matrix_file =  os.path.abspath('reordered_heatmap_' + fname + '.eps')
    
    plot_cormat(plot_reordered_coclass_matrix_file,reordered_coclass_mat,list_reordered_labels)
    
    return plot_reordered_coclass_matrix_file
开发者ID:Lx37,项目名称:dmgraphanalysis,代码行数:46,代码来源:coclass.py


示例19: community_list_Louvain

def community_list_Louvain(Louvain_bin_file,Louvain_conf_file,louvain_bin_path):
    
    import os
    from nipype.utils.filemanip import split_filename as split_f
    
    #path, fname, ext = '','',''
    path, fname, ext = split_f(Louvain_bin_file)
    
    Louvain_mod_file = os.path.abspath(fname + '.mod')
    
    cmd = os.path.join(louvain_bin_path,'community') + ' ' + Louvain_bin_file + ' ' +  Louvain_conf_file + ' > ' + Louvain_mod_file
    
    print "executing command " + cmd
    
    os.system(cmd)
    
    return Louvain_mod_file
开发者ID:Lx37,项目名称:dmgraphanalysis,代码行数:17,代码来源:modularity.py


示例20: import_tsmat_to_ts

def import_tsmat_to_ts(tsmat_file,data_field_name = 'F', good_channels_field_name = 'ChannelFlag'):
    #,orig_channel_names_file,orig_channel_coords_file):

    import os
    import numpy as np

    import mne

    from mne.io import RawArray	
    from nipype.utils.filemanip import split_filename as split_f

    from scipy.io import loadmat
    print tsmat_file
        
    subj_path,basename,ext = split_f(tsmat_file)

    mat = loadmat(tsmat_file)

    raw_data = np.array(mat[data_field_name],dtype = "f")
    print raw_data.shape

    if good_channels_field_name != None:
        
        print "Using good channels to sort channels"
        good_channels = np.array(mat[good_channels_field_name])
        print good_channels.shape
        
        
        good_channels = good_channels.reshape(good_channels.shape[0])
        print good_channels.shape
        
        
        good_data = raw_data[good_channels == 1,:]
        
        print good_data.shape
        
    else:
        print "No channel sorting" 
        good_data = raw_data
        
    #### save data
    print good_data.shape
    
    ts_file = os.path.abspath("tsmat.npy")
    np.save(ts_file,good_data)
    return ts_file
开发者ID:dmalt,项目名称:neuropype_ephy,代码行数:46,代码来源:import_mat.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python filemanip.split_filename函数代码示例发布时间:2022-05-27
下一篇:
Python filemanip.list_to_filename函数代码示例发布时间: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