diff --git a/+utilities/+brainstorm2zef/+m/+postprocessing_script_bank/zef_bst_return_project_structure.m b/+utilities/+brainstorm2zef/+m/+postprocessing_script_bank/zef_bst_return_project_structure.m new file mode 100644 index 000000000..97bce5e52 --- /dev/null +++ b/+utilities/+brainstorm2zef/+m/+postprocessing_script_bank/zef_bst_return_project_structure.m @@ -0,0 +1 @@ +assignin('base','zef',zef); \ No newline at end of file diff --git a/+utilities/+brainstorm2zef/+m/+postprocessing_script_bank/zef_bst_save_project_structure.m b/+utilities/+brainstorm2zef/+m/+postprocessing_script_bank/zef_bst_save_project_structure.m new file mode 100644 index 000000000..758816a52 --- /dev/null +++ b/+utilities/+brainstorm2zef/+m/+postprocessing_script_bank/zef_bst_save_project_structure.m @@ -0,0 +1 @@ +zef = zef_save(zef,project_file_name,project_file_folder,1); \ No newline at end of file diff --git a/+utilities/+brainstorm2zef/+m/+run_script_bank/zef_bst_create_finite_element_mesh.m b/+utilities/+brainstorm2zef/+m/+run_script_bank/zef_bst_create_finite_element_mesh.m new file mode 100644 index 000000000..d34a6bf23 --- /dev/null +++ b/+utilities/+brainstorm2zef/+m/+run_script_bank/zef_bst_create_finite_element_mesh.m @@ -0,0 +1 @@ +zef = zef_create_finite_element_mesh(zef); diff --git a/+utilities/+brainstorm2zef/+m/zef_bst_edit_project.m b/+utilities/+brainstorm2zef/+m/zef_bst_edit_project.m new file mode 100644 index 000000000..ba415f0b7 --- /dev/null +++ b/+utilities/+brainstorm2zef/+m/zef_bst_edit_project.m @@ -0,0 +1,18 @@ +function zef_bst_edit_project + +h_parent = get(gcbo,'Parent'); +addpath(h_parent.folder_name); +h_text_1 = findobj(h_parent.Children,'Tag','setup_file'); + +[folder_name,file_name] = fileparts(h_text_1.String); + +project_file_name = [folder_name filesep file_name '.mat']; + +if not(isequal(exist(project_file_name),2)) +zef = zeffiro_interface('start_mode','nodisplay','import_to_new_project',h_text_1.String,'save_project',project_file_name,'exit_zeffiro',true); +addpath(h_parent.folder_name); +end + +zef = zeffiro_interface('start_mode','display','open_project',project_file_name); + +end \ No newline at end of file diff --git a/+utilities/+brainstorm2zef/+m/zef_bst_import_settings.m b/+utilities/+brainstorm2zef/+m/zef_bst_import_settings.m new file mode 100644 index 000000000..876250844 --- /dev/null +++ b/+utilities/+brainstorm2zef/+m/zef_bst_import_settings.m @@ -0,0 +1,12 @@ +zef = zef_add_bounding_box(zef); +zef.exclude_box = 1; +zef.max_surface_face_count = 0.5; +zef.mesh_smoothing_on = 1; +zef.mesh_resolution = 3; +zef.refinement_on = 1; +zef.refinement_surface_on = 1; +import_compartment_list_aux = zef_get_active_compartments(zef); +import_compartment_list_aux = import_compartment_list_aux(end-2:end-1); +import_compartment_list_aux = import_compartment_list_aux(:)'; +zef.refinement_surface_compartments = [-1 import_compartment_list_aux]; +zef_mesh_tool; \ No newline at end of file diff --git a/+utilities/+brainstorm2zef/+m/zef_bst_plugin_close.m b/+utilities/+brainstorm2zef/+m/zef_bst_plugin_close.m new file mode 100644 index 000000000..a932f1e36 --- /dev/null +++ b/+utilities/+brainstorm2zef/+m/zef_bst_plugin_close.m @@ -0,0 +1,7 @@ +function zef_bst_plugin_close + +addpath(gcbo().folder_name) +rmpath(gcbo().folder_name) +closereq; + +end \ No newline at end of file diff --git a/+utilities/+brainstorm2zef/+m/zef_bst_plugin_start.m b/+utilities/+brainstorm2zef/+m/zef_bst_plugin_start.m new file mode 100644 index 000000000..52fbf1f5e --- /dev/null +++ b/+utilities/+brainstorm2zef/+m/zef_bst_plugin_start.m @@ -0,0 +1,68 @@ + +function zef_bst_plugin_start(folder_name) + +h_fig = figure(... + 'PaperUnits',get(0,'defaultfigurePaperUnits'),... + 'Units','normalized',... + 'OuterPosition',[0.5 0.5 0.25 0.25],... + 'Renderer',get(0,'defaultfigureRenderer'),... + 'Visible','on',... + 'Color',get(0,'defaultfigureColor'),... + 'CloseRequestFcn','utilities.brainstorm2zef.m.zef_bst_plugin_close;',... + 'CurrentAxesMode','manual',... + 'IntegerHandle','off',... + 'NextPlot',get(0,'defaultfigureNextPlot'),... + 'Colormap',[0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0],... + 'DoubleBuffer','off',... + 'Name','ZEFFIRO-Brainstorm plugin',... + 'NumberTitle','off',... + 'HandleVisibility','callback',... + 'DeleteFcn','closereq;',... + 'Tag','zeffiro_bst_plugin',... + 'UserData',[],'ToolBar','none','MenuBar','none',... + 'WindowStyle',get(0,'defaultfigureWindowStyle'),... + 'Resize',get(0,'defaultfigureResize'),... + 'PaperPosition',get(0,'defaultfigurePaperPosition'),... + 'PaperSize',[20.99999864 29.69999902],... + 'PaperType',get(0,'defaultfigurePaperType'),... + 'InvertHardcopy',get(0,'defaultfigureInvertHardcopy'),... + 'ScreenPixelsPerInchMode','manual' ); + +file_name = 'BrainStorm2Zeffiro_import.zef'; +subfolder_name = ['+utilities' filesep '+brainstorm2zef' filesep 'data']; + +h_button_1 = uicontrol('Style','pushbutton','Parent',h_fig,'Visible','on','Units','normalized','Position',[0.60 0.80 0.35 0.15],'String','Select file','Callback','utilities.brainstorm2zef.m.zef_bst_setup_file;'); +h_button_2 = uicontrol('Style','pushbutton','Parent',h_fig,'Visible','on','Units','normalized','Position',[0.60 0.35 0.35 0.15],'String','Reset project','Callback','utilities.brainstorm2zef.m.zef_bst_reset_project;'); +h_button_3 = uicontrol('Style','pushbutton','Parent',h_fig,'Visible','on','Units','normalized','Position',[0.60 0.20 0.35 0.15],'String','Edit project','Callback','utilities.brainstorm2zef.m.zef_bst_edit_project;'); +h_button_5 = uicontrol('Style','pushbutton','Parent',h_fig,'Visible','on','Units','normalized','Position',[0.60 0.05 0.35 0.15],'String','Run script','Callback','utilities.brainstorm2zef.m.zef_bst_run;'); + +run_script_list = dir([folder_name filesep '+utilities' filesep '+brainstorm2zef' filesep '+m' filesep '+run_script_bank']); +run_script_list = {run_script_list().name}'; +run_script_list = run_script_list(3:end); + +postprocessing_script_list = dir([folder_name filesep '+utilities' filesep '+brainstorm2zef' filesep '+m' filesep '+postprocessing_script_bank']); +postprocessing_script_list = {postprocessing_script_list().name}'; +postprocessing_script_list = postprocessing_script_list(3:end); + +for i = 1 : length(run_script_list) +[~,name_string] = fileparts(run_script_list{i}); +run_script_list{i} = name_string; +end + +for i = 1 : length(postprocessing_script_list) +[~,name_string] = fileparts(postprocessing_script_list{i}); +postprocessing_script_list{i} = name_string; +end + +h_popmenu_1 = uicontrol('Style','popupmenu','Parent',h_fig,'Visible','on','Units','normalized','Position',[0.05 0.05 0.35 0.1],'String',postprocessing_script_list,'Tag','postprocessing_script'); +h_popmenu_2 = uicontrol('Style','popupmenu','Parent',h_fig,'Visible','on','Units','normalized','Position',[0.05 0.35 0.35 0.1],'String',run_script_list,'Tag','run_script'); + +h_text_1 = uicontrol('Style','text','Parent',h_fig,'Units','normalized','String',[folder_name filesep subfolder_name filesep file_name],'HorizontalAlignment','left','Position',[0.05 0.55 0.9 0.2],'BackgroundColor',[0.9 0.9 0.9],'Tag','setup_file'); +h_text_2 = uicontrol('Style','text','Parent',h_fig,'Units','normalized','String','Postprocessing script:','HorizontalAlignment','left','Position',[0.05 0.15 0.35 0.1],'BackgroundColor',[0.94 0.94 0.94]); +h_text_3 = uicontrol('Style','text','Parent',h_fig,'Units','normalized','String','Run script:','HorizontalAlignment','left','Position',[0.05 0.45 0.35 0.1],'BackgroundColor',[0.94 0.94 0.94]); + +h_axes = uiaxes('Parent',h_fig,'visible','on','Units','normalized','Position',[0.05 0.775 0.375 0.20],'FontSize',0.587962962962963,'Tag','image_axes','BackgroundColor',[0.94 0.94 0.94],'Visible','off'); +imagesc(h_axes,imread([folder_name filesep 'fig' filesep 'zeffiro_logo.png'], 'BackgroundColor', [0.94 0.94 0.94])); + +addprop(h_fig,'folder_name'); +set(h_fig,'folder_name',folder_name); \ No newline at end of file diff --git a/+utilities/+brainstorm2zef/+m/zef_bst_reset_project.m b/+utilities/+brainstorm2zef/+m/zef_bst_reset_project.m new file mode 100644 index 000000000..68a7d85e2 --- /dev/null +++ b/+utilities/+brainstorm2zef/+m/zef_bst_reset_project.m @@ -0,0 +1,19 @@ +function zef_bst_reset_project + +h_parent = get(gcbo,'Parent'); +addpath(h_parent.folder_name); +h_text_1 = findobj(h_parent.Children,'Tag','setup_file'); + +[folder_name,file_name] = fileparts(h_text_1.String); + +project_file_name = [folder_name filesep file_name '.mat']; + +if isequal(exist(project_file_name),2) +delete(project_file_name) +end + +zef = zeffiro_interface('start_mode','nodisplay','import_to_new_project',h_text_1.String,'save_project',project_file_name,'exit_zeffiro',true); +addpath(h_parent.folder_name); +disp('Done.') + +end \ No newline at end of file diff --git a/+utilities/+brainstorm2zef/+m/zef_bst_run.m b/+utilities/+brainstorm2zef/+m/zef_bst_run.m new file mode 100644 index 000000000..219a146b9 --- /dev/null +++ b/+utilities/+brainstorm2zef/+m/zef_bst_run.m @@ -0,0 +1,29 @@ +function zef_bst_run + +h_parent = get(gcbo,'Parent'); +addpath(h_parent.folder_name); +h_text_1 = findobj(h_parent.Children,'Tag','setup_file'); +h_popupmenu_1 = findobj(h_parent.Children,'Tag','postprocessing_script'); +h_popupmenu_2 = findobj(h_parent.Children,'Tag','run_script'); + +[project_file_folder, project_file_name] = fileparts(h_text_1.String); + +project_file_name = [project_file_name '.mat']; + +if not(isequal(exist(project_file_name),2)) +zef = zeffiro_interface('start_mode','nodisplay','import_to_new_project',h_text_1.String,'save_project',[project_file_folder filesep project_file_name],'exit_zeffiro',true); +addpath(h_parent.folder_name); +end + +run_script_name = ['utilities.brainstorm2zef.m.run_script_bank']; +run_script_name = [run_script_name '.' h_popupmenu_2.String{h_popupmenu_2.Value}]; + +postprocessing_script_name = ['utilities.brainstorm2zef.m.postprocessing_script_bank']; +postprocessing_script_name = [postprocessing_script_name '.' h_popupmenu_1.String{h_popupmenu_1.Value}]; + +zef = zeffiro_interface('start_mode','nodisplay','open_project',[project_file_folder filesep project_file_name],'run_script',run_script_name,'exit_zeffiro',true); +addpath(h_parent.folder_name); +eval(postprocessing_script_name); +disp('Done.') + +end \ No newline at end of file diff --git a/+utilities/+brainstorm2zef/+m/zef_bst_setup_file.m b/+utilities/+brainstorm2zef/+m/zef_bst_setup_file.m new file mode 100644 index 000000000..dc26735d0 --- /dev/null +++ b/+utilities/+brainstorm2zef/+m/zef_bst_setup_file.m @@ -0,0 +1,13 @@ +function zef_bst_setup_file + +h_parent = get(gcbo,'Parent'); +addpath(h_parent.folder_name); +h_text_1 = findobj(h_parent.Children,'Tag','setup_file'); + +folder_name = get(h_parent,'folder_name'); + +[file_name folder_name] = uigetfile('*.zef','Select setup file', folder_name); + +h_text_1.String = [folder_name filesep file_name]; + +end \ No newline at end of file diff --git a/+utilities/+brainstorm2zef/BrainStorm2Zeffiro_import.zef b/+utilities/+brainstorm2zef/BrainStorm2Zeffiro_import.zef deleted file mode 100644 index 0ae633cf2..000000000 --- a/+utilities/+brainstorm2zef/BrainStorm2Zeffiro_import.zef +++ /dev/null @@ -1,8 +0,0 @@ -type,sensors,name,Electrodes,modality,EEG,tag,EEG,database,bst -type,segmentation,name,Scalp,database,bst,tag,Scalp,parameter_name,sigma,parameter_value,0.33 -type,segmentation,name,Skull,database,bst,tag,Skull,parameter_name,sigma,parameter_value,0.0064 -type,segmentation,name,CSF,database,bst,tag,CSF,parameter_name,sigma,parameter_value,1.79 -type,segmentation,name,Gray,activity,1,database,bst,tag,Gray,parameter_name,parameter_value,0.33 -type,segmentation,name,Parcellation,on,0,activity,1,database,bst,atlas,Desikan-Killiany,atlas_compartment,Gray,tag,cortex_280284V -type,segmentation,name,White,activity,3,database,bst,tag,White,parameter_name,sigma,parameter_value,0.14 -type,script,filename,utilities.brainstorm2zef.bst_import_settings diff --git a/+utilities/+brainstorm2zef/bst_import_settings.m b/+utilities/+brainstorm2zef/bst_import_settings.m deleted file mode 100644 index 7c64798bb..000000000 --- a/+utilities/+brainstorm2zef/bst_import_settings.m +++ /dev/null @@ -1,8 +0,0 @@ -zef = zef_add_bounding_box(zef); -zef.exclude_box = 1; -zef.max_surface_face_count = 4; -zef.mesh_smoothing_on = 1; -zef.refinement_on = 1; -zef.refinement_surface_on = 1; -zef.refinement_surface_compartments = [-1 5 6]; -zef_mesh_tool; diff --git a/m/import/zef_bst_2_zef_sensors.m b/m/import/zef_bst_2_zef_sensors.m index 2241767f0..0a107634c 100644 --- a/m/import/zef_bst_2_zef_sensors.m +++ b/m/import/zef_bst_2_zef_sensors.m @@ -8,6 +8,7 @@ sensor_orientations = []; sensor_ind = []; sensor_tag_cell = cell(0); +scaling_constant = 1000; if not(isempty(varargin)) sensor_type = varargin{1}; @@ -45,6 +46,8 @@ end +sensor_positions = scaling_constant*sensor_positions; + sensor_ind = sensor_ind(:); sensor_tag_cell = sensor_tag_cell(:); diff --git a/m/import/zef_bst_2_zef_surface.m b/m/import/zef_bst_2_zef_surface.m index d25f95ee2..7bf24826d 100644 --- a/m/import/zef_bst_2_zef_surface.m +++ b/m/import/zef_bst_2_zef_surface.m @@ -7,6 +7,7 @@ surface = []; subject = []; surface_properties = []; +scaling_constant = 1000; if not(isempty(varargin)) subject = varargin{1}; @@ -44,7 +45,7 @@ end if isfield(surface_data,'Vertices') - vertices = surface_data.Vertices; + vertices = scaling_constant*surface_data.Vertices; end if isfield(surface_data,'Faces') diff --git a/m/zef_downsample_surfaces.m b/m/zef_downsample_surfaces.m index 3316e9b14..7011d3b71 100644 --- a/m/zef_downsample_surfaces.m +++ b/m/zef_downsample_surfaces.m @@ -6,12 +6,16 @@ zef.h = zef_waitbar(0,1,'Resampling surfaces.'); zef.temp_time = now; +relative_resolution_vec = zef_find_relative_resolution(zef); zef.number_of_compartments = length(zef.compartment_tags); +active_compartment_ind = 0; for zef_k = 1 : zef.number_of_compartments zef.temp_var_0 = zef.compartment_tags{zef_k}; + zef.temp_patch_data.scaling = eval(['zef.' zef.temp_var_0 '_scaling;']); if eval(['zef.' zef.temp_var_0 '_on']) + active_compartment_ind = active_compartment_ind + 1; if eval(['isfield(zef,"' zef.temp_var_0 '_points_original_surface_mesh")']) if eval(['not(isempty(zef.' zef.temp_var_0 '_points_original_surface_mesh))']) zef.temp_patch_data.vertices_all = eval(['zef.' zef.temp_var_0 '_points_original_surface_mesh;']); @@ -49,10 +53,10 @@ zef.temp_patch_data.vertice_ind_aux(zef.temp_patch_data.unique_faces_ind) = [1:length(zef.temp_patch_data.unique_faces_ind)]; zef.temp_patch_data.faces = zef.temp_patch_data.vertice_ind_aux(zef.temp_patch_data.faces); zef.temp_patch_data.vertices = zef.temp_patch_data.vertices_all(zef.temp_patch_data.unique_faces_ind,:); - zef.temp_patch_data_aux = zef_set_surface_resolution(zef,zef.temp_patch_data,zef.max_surface_face_count); + zef.temp_patch_data_aux = zef_set_surface_resolution(zef,zef.temp_patch_data,zef.max_surface_face_count*relative_resolution_vec(active_compartment_ind)); zef.temp_patch_data_aux.vertices = zef_smooth_surface(zef.temp_patch_data_aux.vertices,zef.temp_patch_data_aux.faces,1e-2,1); if eval(['zef.' zef.temp_var_0 '_sources']) - if isempty(zef.temp_patch_data_aux.vertices) || isempty(zef.temp_patch_data_aux.vertices) || zef.bypass_inflate + if isempty(zef.temp_patch_data_aux.vertices) || zef.bypass_inflate zef.temp_patch_data_aux.vertices_inflated = []; else [zef.temp_patch_data_aux.vertices_inflated] = zef_inflate_surface(zef,zef.temp_patch_data_aux.vertices,zef.temp_patch_data_aux.faces); @@ -67,7 +71,7 @@ else zef.temp_patch_data.faces = zef.temp_patch_data.faces_all; zef.temp_patch_data.vertices = zef.temp_patch_data.vertices_all; - zef.temp_patch_data_aux = zef_set_surface_resolution(zef,zef.temp_patch_data,zef.max_surface_face_count); + zef.temp_patch_data_aux = zef_set_surface_resolution(zef,zef.temp_patch_data,zef.max_surface_face_count*relative_resolution_vec(active_compartment_ind)); zef.temp_patch_data_aux.vertices = zef_smooth_surface(zef.temp_patch_data_aux.vertices,zef.temp_patch_data_aux.faces,1e-2,1); if eval(['zef.' zef.temp_var_0 '_sources']) > 0 zef.temp_patch_data_aux.vertices_inflated = zef_inflate_surface(zef,zef.temp_patch_data_aux.vertices,zef.temp_patch_data_aux.faces); diff --git a/m/zef_figure_tool.m b/m/zef_figure_tool.m index b01b56c86..af0074b4d 100644 --- a/m/zef_figure_tool.m +++ b/m/zef_figure_tool.m @@ -47,7 +47,6 @@ 'InvertHardcopy',get(0,'defaultfigureInvertHardcopy'),... 'ScreenPixelsPerInchMode','manual' ); - zef.h_zeffiro.Units = 'normalized'; zef.h_zeffiro.ContextMenu = uicontextmenu(zef.h_zeffiro); diff --git a/m/zef_find_relative_resolution.m b/m/zef_find_relative_resolution.m new file mode 100644 index 000000000..b7caf6ab7 --- /dev/null +++ b/m/zef_find_relative_resolution.m @@ -0,0 +1,99 @@ +function relative_resolution_vec = zef_find_relative_resolution(zef) + +[active_compartments, source_compartments] = zef_get_active_compartments(zef); + +source_compartments = find(ismember(active_compartments,source_compartments)); + +relative_resolution_vec = ones(size(active_compartments)); + +if zef.refinement_on + +if zef.refinement_surface_on + +rel_num_vec_aux = zef.refinement_surface_number(:).*ones(length(zef.refinement_surface_compartments),1); + +for i = 1 : length(zef.refinement_surface_compartments) + +if isequal(zef.refinement_surface_compartments(i),-1) + +relative_resolution_vec(source_compartments) = (4.^rel_num_vec_aux(i)).*relative_resolution_vec(source_compartments); + +else + +relative_resolution_vec(zef.refinement_surface_compartments(i)) = (4.^rel_num_vec_aux(i)).*relative_resolution_vec(zef.refinement_surface_compartments(i)); + +end + +end + +end + +if zef.refinement_surface_on_2 + +rel_num_vec_aux = zef.refinement_surface_number_2(:).*ones(length(zef.refinement_surface_compartments_2),1); + +for i = 1 : length(zef.refinement_surface_compartments_2) + +if isequal(zef.refinement_surface_compartments_2(i),-1) + +relative_resolution_vec(source_compartments) = (4.^rel_num_vec_aux(i)).*relative_resolution_vec(source_compartments); + +else + +relative_resolution_vec(zef.refinement_surface_compartments_2(i)) = (4.^rel_num_vec_aux(i)).*relative_resolution_vec(zef.refinement_surface_compartments_2(i)); + +end + +end + +end + + +if zef.refinement_volume_on + +rel_num_vec_aux = zef.refinement_volume_number(:).*ones(length(zef.refinement_volume_compartments),1); + +for i = 1 : length(zef.refinement_volume_compartments) + +if isequal(zef.refinement_volume_compartments(i),-1) + +relative_resolution_vec(source_compartments) = (4.^rel_num_vec_aux(i)).*relative_resolution_vec(source_compartments); + +else + +relative_resolution_vec(zef.refinement_volume_compartments(i)) = (4.^rel_num_vec_aux(i)).*relative_resolution_vec(zef.refinement_volume_compartments(i)); + +end + +end + +end + +if zef.refinement_volume_on_2 + +rel_num_vec_aux = zef.refinement_volume_number_2(:).*ones(length(zef.refinement_volume_compartments_2),1); + +for i = 1 : length(zef.refinement_volume_compartments_2) + +if isequal(zef.refinement_volume_compartments_2(i),-1) + +relative_resolution_vec(source_compartments) = (4.^rel_num_vec_aux(i)).*relative_resolution_vec(source_compartments); + +else + +relative_resolution_vec(zef.refinement_volume_compartments_2(i)) = (4.^rel_num_vec_aux(i)).*relative_resolution_vec(zef.refinement_volume_compartments_2(i)); + +end + +end + +end + + + +end + +end + + + diff --git a/m/zef_import_segmentation.m b/m/zef_import_segmentation.m index f2d658465..5da369ee8 100644 --- a/m/zef_import_segmentation.m +++ b/m/zef_import_segmentation.m @@ -319,8 +319,10 @@ if isequal(lower(surface_name_aux),lower(tag)) surface_found = 1; [vertices_aux, faces_aux] = zef_bst_2_zef_surface(subject,surface_ind_aux); + if str2num(invert) + faces_aux = faces_aux(:,[1 3 2]); + end zef = zef_merge_surface_mesh(zef,compartment_tag,faces_aux,vertices_aux,merge); - eval(['zef.' compartment_tag '_scaling = 1000;']); if not(isempty(atlas)) if isempty(atlas_tag) atlas_tag = atlas; @@ -481,7 +483,6 @@ [sensor_positions, sensor_orientations, sensor_ind, sensor_tag_cell] = zef_bst_2_zef_sensors(tag); if isequal(modality,'EEG') eval(['zef.' sensor_tag '_points = sensor_positions;']); - eval(['zef.' sensor_tag '_scaling = 1000;']); end diff --git a/mlapp/zef_mesh_tool_app.mlapp b/mlapp/zef_mesh_tool_app.mlapp index 7837a19d8..84c0f8681 100644 Binary files a/mlapp/zef_mesh_tool_app.mlapp and b/mlapp/zef_mesh_tool_app.mlapp differ diff --git a/mlapp/zef_mesh_tool_app_exported.m b/mlapp/zef_mesh_tool_app_exported.m index 6cf531bd8..06b1c8640 100644 --- a/mlapp/zef_mesh_tool_app_exported.m +++ b/mlapp/zef_mesh_tool_app_exported.m @@ -3,41 +3,41 @@ % Properties that correspond to app components properties (Access = public) h_mesh_tool matlab.ui.Figure - h_pushbutton21 matlab.ui.control.Button - h_run_forward_simulation matlab.ui.control.Button - h_interpolate matlab.ui.control.Button - h_field_downsampling matlab.ui.control.Button - h_surface_downsampling matlab.ui.control.Button - h_checkbox_mesh_smoothing_on matlab.ui.control.CheckBox - h_refinement_on matlab.ui.control.CheckBox - h_source_interpolation_on matlab.ui.control.CheckBox - h_downsample_surfaces matlab.ui.control.CheckBox - SurfacetrianglesmaxLabel matlab.ui.control.Label - CuttingplanecoeffEditFieldLabel_4 matlab.ui.control.Label - CuttingplanecoeffEditFieldLabel_5 matlab.ui.control.Label - CuttingplanecoeffEditFieldLabel_6 matlab.ui.control.Label - CuttingplanecoeffEditFieldLabel_7 matlab.ui.control.Label - UnitLabel matlab.ui.control.Label - h_popupmenu6 matlab.ui.control.DropDown - DirectionsDropDownLabel matlab.ui.control.Label - h_popupmenu2 matlab.ui.control.DropDown - CuttingplanecoeffEditFieldLabel_8 matlab.ui.control.Label - h_edit65 matlab.ui.control.NumericEditField - h_edit_meshing_accuracy matlab.ui.control.NumericEditField - h_smoothing_strength matlab.ui.control.NumericEditField - h_edit76 matlab.ui.control.NumericEditField - h_edit75 matlab.ui.control.NumericEditField - h_max_surface_face_count matlab.ui.control.NumericEditField - h_pushbutton23 matlab.ui.control.Button - h_pushbutton34 matlab.ui.control.Button - InflatingiterationsLabel matlab.ui.control.Label - CuttingplanecoeffEditFieldLabel_9 matlab.ui.control.Label - h_inflate_strength matlab.ui.control.NumericEditField - h_inflate_n_iterations matlab.ui.control.NumericEditField - h_forward_simulation_table matlab.ui.control.Table - h_save_forward_simulation_profile matlab.ui.control.Button - h_forward_simulation_script matlab.ui.control.TextArea h_forward_simulation_update_from_profile matlab.ui.control.Button + h_forward_simulation_script matlab.ui.control.TextArea + h_save_forward_simulation_profile matlab.ui.control.Button + h_forward_simulation_table matlab.ui.control.Table + h_inflate_n_iterations matlab.ui.control.NumericEditField + h_inflate_strength matlab.ui.control.NumericEditField + CuttingplanecoeffEditFieldLabel_9 matlab.ui.control.Label + InflatingiterationsLabel matlab.ui.control.Label + h_pushbutton34 matlab.ui.control.Button + h_pushbutton23 matlab.ui.control.Button + h_max_surface_face_count matlab.ui.control.NumericEditField + h_edit75 matlab.ui.control.NumericEditField + h_edit76 matlab.ui.control.NumericEditField + h_smoothing_strength matlab.ui.control.NumericEditField + h_edit_meshing_accuracy matlab.ui.control.NumericEditField + h_edit65 matlab.ui.control.NumericEditField + CuttingplanecoeffEditFieldLabel_8 matlab.ui.control.Label + h_popupmenu2 matlab.ui.control.DropDown + DirectionsDropDownLabel matlab.ui.control.Label + h_popupmenu6 matlab.ui.control.DropDown + UnitLabel matlab.ui.control.Label + CuttingplanecoeffEditFieldLabel_7 matlab.ui.control.Label + CuttingplanecoeffEditFieldLabel_6 matlab.ui.control.Label + CuttingplanecoeffEditFieldLabel_5 matlab.ui.control.Label + CuttingplanecoeffEditFieldLabel_4 matlab.ui.control.Label + SurfacetrianglesmaxLabel matlab.ui.control.Label + h_downsample_surfaces matlab.ui.control.CheckBox + h_source_interpolation_on matlab.ui.control.CheckBox + h_refinement_on matlab.ui.control.CheckBox + h_checkbox_mesh_smoothing_on matlab.ui.control.CheckBox + h_surface_downsampling matlab.ui.control.Button + h_field_downsampling matlab.ui.control.Button + h_interpolate matlab.ui.control.Button + h_run_forward_simulation matlab.ui.control.Button + h_pushbutton21 matlab.ui.control.Button h_menu_forward_simulation_table_context matlab.ui.container.ContextMenu h_menu_forward_simulation_table_add matlab.ui.container.Menu h_menu_forward_simulation_table_delete matlab.ui.container.Menu @@ -96,7 +96,7 @@ function createComponents(app) % Create h_downsample_surfaces app.h_downsample_surfaces = uicheckbox(app.h_mesh_tool); - app.h_downsample_surfaces.Text = 'Downsample surf.'; + app.h_downsample_surfaces.Text = 'Resample surf.'; app.h_downsample_surfaces.Position = [192 198 163 22]; % Create SurfacetrianglesmaxLabel @@ -225,9 +225,6 @@ function createComponents(app) % Create h_menu_forward_simulation_table_context app.h_menu_forward_simulation_table_context = uicontextmenu(app.h_mesh_tool); - - % Assign app.h_menu_forward_simulation_table_context - app.h_forward_simulation_table.ContextMenu = app.h_menu_forward_simulation_table_context; % Create h_menu_forward_simulation_table_add app.h_menu_forward_simulation_table_add = uimenu(app.h_menu_forward_simulation_table_context); @@ -236,6 +233,9 @@ function createComponents(app) % Create h_menu_forward_simulation_table_delete app.h_menu_forward_simulation_table_delete = uimenu(app.h_menu_forward_simulation_table_context); app.h_menu_forward_simulation_table_delete.Text = 'Delete'; + + % Assign app.h_menu_forward_simulation_table_context + app.h_forward_simulation_table.ContextMenu = app.h_menu_forward_simulation_table_context; % Show the figure after all components are created app.h_mesh_tool.Visible = 'off'; diff --git a/zeffiro_interface.m b/zeffiro_interface.m index db2a2413c..d3455caed 100755 --- a/zeffiro_interface.m +++ b/zeffiro_interface.m @@ -236,10 +236,12 @@ end -addpath(fullfile("m")) +addpath([fileparts(mfilename('fullpath')) filesep 'm']); zef_close_all(); +addpath([fileparts(mfilename('fullpath'))]); + %% Set zef fields based on name–value arguments. zef = struct;