本文整理汇总了Python中nipype.utils.filemanip.split_f函数的典型用法代码示例。如果您正苦于以下问题:Python split_f函数的具体用法?Python split_f怎么用?Python split_f使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了split_f函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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!!!')
示例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