Skip to content

Commit

Permalink
Zeffiro developer: A regular push adding the changes made in the curr…
Browse files Browse the repository at this point in the history
…ent local repository to the remote origin. Contents of the folders ./data/ and ./profile/ are ignored. The update necessitates creating a personal access token.
  • Loading branch information
sampsapursiainen committed Jun 11, 2024
1 parent e2c6b88 commit 0b9c582
Show file tree
Hide file tree
Showing 21 changed files with 324 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assignin('base','zef',zef);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zef = zef_save(zef,project_file_name,project_file_folder,1);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zef = zef_create_finite_element_mesh(zef);
18 changes: 18 additions & 0 deletions +utilities/+brainstorm2zef/+m/zef_bst_edit_project.m
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions +utilities/+brainstorm2zef/+m/zef_bst_import_settings.m
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 7 additions & 0 deletions +utilities/+brainstorm2zef/+m/zef_bst_plugin_close.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function zef_bst_plugin_close

addpath(gcbo().folder_name)
rmpath(gcbo().folder_name)
closereq;

end
68 changes: 68 additions & 0 deletions +utilities/+brainstorm2zef/+m/zef_bst_plugin_start.m
Original file line number Diff line number Diff line change
@@ -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);
19 changes: 19 additions & 0 deletions +utilities/+brainstorm2zef/+m/zef_bst_reset_project.m
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions +utilities/+brainstorm2zef/+m/zef_bst_run.m
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions +utilities/+brainstorm2zef/+m/zef_bst_setup_file.m
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions +utilities/+brainstorm2zef/BrainStorm2Zeffiro_import.zef

This file was deleted.

8 changes: 0 additions & 8 deletions +utilities/+brainstorm2zef/bst_import_settings.m

This file was deleted.

3 changes: 3 additions & 0 deletions m/import/zef_bst_2_zef_sensors.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
sensor_orientations = [];
sensor_ind = [];
sensor_tag_cell = cell(0);
scaling_constant = 1000;

if not(isempty(varargin))
sensor_type = varargin{1};
Expand Down Expand Up @@ -45,6 +46,8 @@

end

sensor_positions = scaling_constant*sensor_positions;

sensor_ind = sensor_ind(:);
sensor_tag_cell = sensor_tag_cell(:);

Expand Down
3 changes: 2 additions & 1 deletion m/import/zef_bst_2_zef_surface.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
surface = [];
subject = [];
surface_properties = [];
scaling_constant = 1000;

if not(isempty(varargin))
subject = varargin{1};
Expand Down Expand Up @@ -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')
Expand Down
10 changes: 7 additions & 3 deletions m/zef_downsample_surfaces.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;']);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
1 change: 0 additions & 1 deletion m/zef_figure_tool.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
'InvertHardcopy',get(0,'defaultfigureInvertHardcopy'),...
'ScreenPixelsPerInchMode','manual' );


zef.h_zeffiro.Units = 'normalized';

zef.h_zeffiro.ContextMenu = uicontextmenu(zef.h_zeffiro);
Expand Down
99 changes: 99 additions & 0 deletions m/zef_find_relative_resolution.m
Original file line number Diff line number Diff line change
@@ -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



Loading

0 comments on commit 0b9c582

Please sign in to comment.