本文整理汇总了Python中mmvt_utils.get_user_fol函数的典型用法代码示例。如果您正苦于以下问题:Python get_user_fol函数的具体用法?Python get_user_fol怎么用?Python get_user_fol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_user_fol函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _connections_origin_update
def _connections_origin_update():
if bpy.context.scene.connections_origin == 'rois':
bpy.context.scene.connections_file = op.join(mu.get_user_fol(), 'rois_con.npz')
elif bpy.context.scene.connections_origin == 'electrodes':
bpy.context.scene.connections_file = op.join(mu.get_user_fol(), 'electrodes', 'electrodes_con.npz')
else:
print('Wrong connection type!!!')
if ConnectionsPanel.d == {}:
load_connections_file()
示例2: eeg_data_and_meta
def eeg_data_and_meta():
if DataMakerPanel.eeg_data is None:
data_fname = op.join(mu.get_user_fol(), 'eeg', 'eeg_data.npy')
meta_fname = op.join(mu.get_user_fol(), 'eeg', 'eeg_data_meta.npz')
if op.isfile(data_fname) and op.isfile(meta_fname):
DataMakerPanel.eeg_data = np.load(data_fname, mmap_mode='r')
DataMakerPanel.eeg_meta = np.load(meta_fname)
else:
DataMakerPanel.eeg_data = DataMakerPanel.eeg_meta = None
return DataMakerPanel.eeg_data, DataMakerPanel.eeg_meta
示例3: fmri_files_update
def fmri_files_update(self, context):
#todo: there are two frmi files list (the other one in fMRI panel)
user_fol = mu.get_user_fol()
for hemi in mu.HEMIS:
fname = op.join(user_fol, 'fmri', 'fmri_{}_{}.npy'.format(bpy.context.scene.fmri_files, hemi))
ColoringMakerPanel.fMRI[hemi] = np.load(fname)
fmri_data_maxmin_fname = op.join(mu.get_user_fol(), 'fmri', 'fmri_activity_map_minmax_{}.pkl'.format(
bpy.context.scene.fmri_files))
if op.isfile(fmri_data_maxmin_fname):
data_min, data_max = mu.load(fmri_data_maxmin_fname)
ColoringMakerPanel.fmri_activity_colors_ratio = 256 / (data_max - data_min)
ColoringMakerPanel.fmri_activity_data_min = data_min
ColoringMakerPanel.fmri_activity_data_max = data_max
示例4: import_brain
def import_brain(context=None):
# self.brain_layer = DataMakerPanel.addon.BRAIN_EMPTY_LAYER
# self.current_root_path = mu.get_user_fol() # bpy.path.abspath(bpy.context.scene.conf_path)
if _addon() is None:
print('addon is None!')
return
user_fol = mu.get_user_fol()
print("importing ROIs")
import_rois(user_fol)
import_hemis_for_functional_maps(user_fol)
import_subcorticals(op.join(user_fol, 'subcortical'))
# if op.isdir(op.join(user_fol, 'cerebellum')):
# import_subcorticals(op.join(user_fol, 'cerebellum'), 'Cerebellum')
if context:
last_obj = context.active_object.name
print('last obj is -' + last_obj)
# create_inflating_morphing()
if bpy.data.objects.get(' '):
bpy.data.objects[' '].select = True
if context:
context.scene.objects.active = bpy.data.objects[' ']
if context:
bpy.data.objects[last_obj].select = False
DataMakerPanel.addon.show_rois()
bpy.types.Scene.brain_imported = True
print('cleaning up')
for obj in bpy.data.objects['Subcortical_structures'].children:
# print(obj.name)
if obj.name[-1] == '1':
obj.name = obj.name[0:-4]
bpy.ops.object.select_all(action='DESELECT')
print('Brain importing is Finished ')
示例5: plot_activity
def plot_activity(map_type, faces_verts, threshold, meg_sub_activity=None,
plot_subcorticals=True, override_current_mat=True, clusters=False):
current_root_path = mu.get_user_fol() # bpy.path.abspath(bpy.context.scene.conf_path)
not_hiden_hemis = [hemi for hemi in HEMIS if not bpy.data.objects[hemi].hide]
frame_str = str(bpy.context.scene.frame_current)
loop_indices = {}
for hemi in not_hiden_hemis:
colors_ratio, data_min = None, None
if map_type == 'MEG':
fname = op.join(current_root_path, 'activity_map_' + hemi, 't' + frame_str + '.npy')
if op.isfile(fname):
f = np.load(fname)
if _addon().colorbar_values_are_locked():
data_max, data_min = _addon().get_colorbar_max_min()
colors_ratio = 256 / (data_max - data_min)
else:
colors_ratio = ColoringMakerPanel.meg_activity_colors_ratio
data_min = ColoringMakerPanel.meg_activity_data_min
data_max = ColoringMakerPanel.meg_activity_data_max
_addon().set_colorbar_max_min(data_max, data_min)
_addon().set_colorbar_title('MEG')
else:
print("Can't load {}".format(fname))
return False
elif map_type == 'FMRI':
if not ColoringMakerPanel.fmri_activity_data_min is None and \
not ColoringMakerPanel.fmri_activity_data_max is None:
if _addon().colorbar_values_are_locked():
data_max, data_min = _addon().get_colorbar_max_min()
colors_ratio = 256 / (data_max - data_min)
else:
colors_ratio = ColoringMakerPanel.fmri_activity_colors_ratio
data_min = ColoringMakerPanel.fmri_activity_data_min
data_max = ColoringMakerPanel.fmri_activity_data_max
_addon().set_colorbar_max_min(data_max, data_min)
_addon().set_colorbar_title('fMRI')
if clusters:
f = [c for h, c in ColoringMakerPanel.fMRI_clusters.items() if h == hemi]
else:
f = ColoringMakerPanel.fMRI[hemi]
if bpy.context.scene.coloring_both_pial_and_inflated:
for cur_obj in [bpy.data.objects[hemi], bpy.data.objects['inflated_{}'.format(hemi)]]:
activity_map_obj_coloring(cur_obj, f, faces_verts[hemi], threshold, override_current_mat, data_min,
colors_ratio)
else:
if _addon().is_pial():
cur_obj = bpy.data.objects[hemi]
elif _addon().is_inflated():
cur_obj = bpy.data.objects['inflated_{}'.format(hemi)]
activity_map_obj_coloring(cur_obj, f, faces_verts[hemi], threshold, override_current_mat, data_min, colors_ratio)
if plot_subcorticals and not bpy.context.scene.objects_show_hide_sub_cortical and not meg_sub_activity is None:
if map_type == 'MEG':
if not bpy.data.objects['Subcortical_meg_activity_map'].hide:
color_object_homogeneously(meg_sub_activity, '_meg_activity', threshold)
if map_type == 'FMRI':
fmri_subcortex_activity_color(threshold, override_current_mat)
return True
示例6: load_faces_verts
def load_faces_verts():
faces_verts = {}
current_root_path = mu.get_user_fol()
faces_verts['lh'] = np.load(op.join(current_root_path, 'faces_verts_lh.npy'))
faces_verts['rh'] = np.load(op.join(current_root_path, 'faces_verts_rh.npy'))
# faces_verts['cortex'] = np.load(op.join(current_root_path, 'faces_verts_cortex.npy'))
return faces_verts
示例7: draw
def draw(self, context):
layout = self.layout
# layout.prop(context.scene, 'conf_path')
col = self.layout.column(align=True)
col.prop(context.scene, 'atlas', text="Atlas")
# if not bpy.types.Scene.brain_imported:
# col.operator("ohad.anatomy_preproc", text="Run Preporc", icon='BLENDER')
col.operator("ohad.brain_importing", text="Import Brain", icon='MATERIAL_DATA')
# if not bpy.types.Scene.electrodes_imported:
electrodes_positions_files = glob.glob(op.join(mu.get_user_fol(), 'electrodes', 'electrodes*positions*.npz'))
if len(electrodes_positions_files) > 0:
col.prop(context.scene, 'bipolar', text="Bipolar")
col.prop(context.scene, 'electrodes_radius', text="Electrodes' radius")
col.prop(context.scene, 'electrodes_positions_files', text="")
col.operator("ohad.electrodes_importing", text="Import Electrodes", icon='COLOR_GREEN')
# if bpy.types.Scene.brain_imported and (not bpy.types.Scene.brain_data_exist):
col = self.layout.column(align=True)
col.operator(AddDataToBrain.bl_idname, text="Add data to Brain", icon='FCURVE')
col.prop(context.scene, 'brain_no_conds_stat', text="")
col.operator(AddDataNoCondsToBrain.bl_idname, text="Add no conds data to Brain", icon='FCURVE')
col.prop(context.scene, 'import_unknown', text="Import unknown")
# if bpy.types.Scene.electrodes_imported and (not bpy.types.Scene.electrodes_data_exist):
col.operator("ohad.electrodes_add_data", text="Add data to Electrodes", icon='FCURVE')
if len(DataMakerPanel.evoked_files) > 0:
layout.label(text='External MEG evoked files:')
layout.prop(context.scene, 'meg_evoked_files', text="")
layout.operator(AddOtherSubjectMEGEvokedResponse.bl_idname, text="Add MEG evoked response", icon='FCURVE')
if len(DataMakerPanel.externals) > 0:
layout.prop(context.scene, 'evoked_objects', text="")
select_text = 'Deselect' if get_external_meg_evoked_selected() else 'Select'
select_icon = 'BORDER_RECT' if select_text == 'Select' else 'PANEL_CLOSE'
layout.operator(SelectExternalMEGEvoked.bl_idname, text=select_text, icon=select_icon)
示例8: invoke
def invoke(self, context, event=None):
input_file = op.join(mu.get_user_fol(), 'electrodes',
'{}.npz'.format(bpy.context.scene.electrodes_positions_files))
import_electrodes(input_file, _addon().ELECTRODES_LAYER)
bpy.types.Scene.electrodes_imported = True
print('Electrodes importing is Finished ')
return {"FINISHED"}
示例9: plot_activity
def plot_activity(map_type, faces_verts, threshold, meg_sub_activity=None,
plot_subcorticals=True, override_current_mat=True, clusters=False):
current_root_path = mu.get_user_fol() # bpy.path.abspath(bpy.context.scene.conf_path)
hemispheres = [hemi for hemi in HEMIS if not bpy.data.objects[hemi].hide]
frame_str = str(bpy.context.scene.frame_current)
# loop_indices = {}
for hemi in hemispheres:
if map_type == 'MEG':
fname = op.join(current_root_path, 'activity_map_' + hemi, 't' + frame_str + '.npy')
if op.isfile(fname):
f = np.load(fname)
else:
print("Can't load {}".format(fname))
return False
elif map_type == 'FMRI':
# fname = op.join(current_root_path, 'fmri_{}{}.npy'.format('clusters_' if clusters else '', hemi))
# f = np.load(fname)
if clusters:
f = [c for h, c in ColoringMakerPanel.fMRI_clusters.items() if h == hemi]
else:
f = ColoringMakerPanel.fMRI[hemi]
cur_obj = bpy.data.objects[hemi]
# loop_indices[hemi] =
activity_map_obj_coloring(cur_obj, f, faces_verts[hemi], threshold, override_current_mat)
if plot_subcorticals and not bpy.context.scene.objects_show_hide_sub_cortical:
if map_type == 'MEG':
if not bpy.data.objects['Subcortical_meg_activity_map'].hide:
color_object_homogeneously(meg_sub_activity, '_meg_activity', threshold)
if map_type == 'FMRI':
fmri_subcortex_activity_color(threshold, override_current_mat)
return True
示例10: fmri_files_update
def fmri_files_update(self, context):
#todo: there are two frmi files list (the other one in fMRI panel)
user_fol = mu.get_user_fol()
# fmri_files = glob.glob(op.join(user_fol, 'fmri', '*_lh.npy'))
for hemi in mu.HEMIS:
fname = op.join(user_fol, 'fmri', 'fmri_{}_{}.npy'.format(bpy.context.scene.fmri_files, hemi))
ColoringMakerPanel.fMRI[hemi] = np.load(fname)
示例11: init
def init(addon):
user_fol = mu.get_user_fol()
clusters_labels_files = glob.glob(op.join(user_fol, 'fmri', 'clusters_labels_*.pkl'))
# old code was saving those files as npy instead of pkl
clusters_labels_files.extend(glob.glob(op.join(user_fol, 'fmri', 'clusters_labels_*.npy')))
# fmri_blobs = glob.glob(op.join(user_fol, 'fmri', 'blobs_*_rh.npy'))
fMRI_clusters_files_exist = len(clusters_labels_files) > 0 # and len(fmri_blobs) > 0
if not fMRI_clusters_files_exist:
return None
fMRIPanel.addon = addon
fMRIPanel.lookup, fMRIPanel.clusters_labels = {}, {}
fMRIPanel.cluster_labels = {}
files_names = [mu.namebase(fname)[len('clusters_labels_'):] for fname in clusters_labels_files]
clusters_labels_items = [(c, c, '', ind) for ind, c in enumerate(files_names)]
bpy.types.Scene.fmri_clusters_labels_files = bpy.props.EnumProperty(
items=clusters_labels_items, description="fMRI files", update=fmri_clusters_labels_files_update)
bpy.context.scene.fmri_clusters_labels_files = files_names[0]
for file_name, clusters_labels_file in zip(files_names, clusters_labels_files):
fMRIPanel.clusters_labels[file_name] = np.load(clusters_labels_file)
fMRIPanel.clusters_labels[file_name] = support_old_verions(fMRIPanel.clusters_labels[file_name])
fMRIPanel.lookup[file_name] = create_lookup_table(fMRIPanel.clusters_labels[file_name])
bpy.context.scene.fmri_cluster_val_threshold = 3
bpy.context.scene.fmri_cluster_size_threshold = 50
bpy.context.scene.search_closest_cluster_only_in_filtered = True
bpy.context.scene.fmri_what_to_plot = 'blob'
bpy.context.scene.fmri_how_to_sort = 'tval'
update_clusters()
# addon.clear_cortex()
register()
fMRIPanel.init = True
示例12: load_meg_subcortical_activity
def load_meg_subcortical_activity():
meg_sub_activity = None
current_root_path = mu.get_user_fol() # bpy.path.abspath(bpy.context.scene.conf_path)
subcortical_activity_file = op.join(current_root_path,'subcortical_meg_activity.npz')
if op.isfile(subcortical_activity_file):
meg_sub_activity = np.load(subcortical_activity_file)
return meg_sub_activity
示例13: grab_camera
def grab_camera(self=None, do_save=True):
RenderFigure.update_camera = False
bpy.context.scene.X_rotation = X_rotation = math.degrees(bpy.data.objects['Camera'].rotation_euler.x)
bpy.context.scene.Y_rotation = Y_rotation = math.degrees(bpy.data.objects['Camera'].rotation_euler.y)
bpy.context.scene.Z_rotation = Z_rotation = math.degrees(bpy.data.objects['Camera'].rotation_euler.z)
bpy.context.scene.X_location = X_location = bpy.data.objects['Camera'].location.x
bpy.context.scene.Y_location = Y_location = bpy.data.objects['Camera'].location.y
bpy.context.scene.Z_location = Z_location = bpy.data.objects['Camera'].location.z
if do_save:
if op.isdir(op.join(mu.get_user_fol(), 'camera')):
camera_fname = op.join(mu.get_user_fol(), 'camera', 'camera.pkl')
mu.save((X_rotation, Y_rotation, Z_rotation, X_location, Y_location, Z_location), camera_fname)
print('Camera location was saved to {}'.format(camera_fname))
else:
mu.message(self, "Can't find the folder {}".format(mu.get_user_fol(), 'camera'))
RenderFigure.update_camera = True
示例14: invoke
def invoke(self, context, event=None):
closest_mesh_name, vertex_ind, vertex_co = self.find_vertex_index_and_mesh_closest_to_cursor()
print(vertex_co)
self.create_empty_in_vertex_location(vertex_co)
data_path = mu.get_user_fol()
self.keyframe_empty_test('Activity_in_vertex', closest_mesh_name, vertex_ind, data_path)
return {"FINISHED"}
示例15: combine_four_brain_perspectives
def combine_four_brain_perspectives():
data_min, data_max = _addon().get_colorbar_max_min()
background = bpy.context.scene.background_color
figure_name = 'splitted_lateral_medial_{}_{}.png'.format(
'inflated' if _addon().is_inflated() else 'pial', background)
figure_fname = op.join(mu.get_user_fol(), 'figures', figure_name)
colors_map = _addon().get_colormap_name().replace('-', '_')
x_left_crop, x_right_crop, y_top_crop, y_buttom_crop = (300, 300, 0, 0)
w_fac, h_fac = (1.5, 1)
cmd = '{} -m src.utils.figures_utils '.format(bpy.context.scene.python_cmd) + \
'-f combine_four_brain_perspectives,combine_brain_with_color_bar --fol {} --data_max {} --data_min {} '.format(
op.join(mu.get_user_fol(), 'figures'), data_max, data_min) + \
'--figure_fname {} --colors_map {} --x_left_crop {} --x_right_crop {} --y_top_crop {} --y_buttom_crop {} '.format(
figure_fname, colors_map, x_left_crop, x_right_crop, y_top_crop, y_buttom_crop) + \
'--w_fac {} --h_fac {} --facecolor {}'.format(w_fac, h_fac, background)
mu.run_command_in_new_thread(cmd, False)