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
Sampsa Pursiainen (TAU) committed Oct 3, 2022
1 parent e0bbea6 commit 47adc81
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 7 deletions.
2 changes: 1 addition & 1 deletion m/lead_field/zef_lead_field_matrix.m
Expand Up @@ -265,7 +265,7 @@
end

if zef.source_interpolation_on
zef_source_interpolation;
zef = zef_source_interpolation(zef);
end

if nargout == 0
Expand Down
11 changes: 9 additions & 2 deletions m/zef_transfer_matrix.m
Expand Up @@ -238,9 +238,16 @@

% Define block size

delete(gcp('nocreate'))
parallel_processes = eval( 'zef.parallel_processes');
parpool(parallel_processes);
if isempty(gcp('nocreate'))
parpool(n_parallel);
else
h_pool = gcp;
if not(isequal(h_pool.NumWorkers,parallel_processes))
delete(h_pool)
parpool(parallel_processes);
end
end
processes_per_core = eval( 'zef.processes_per_core');
tic;
block_size = parallel_processes*processes_per_core;
Expand Down
30 changes: 28 additions & 2 deletions scripts/inverse_sensitivity/zef_run_sensitivity_maps.m
@@ -1,3 +1,29 @@
project_struct = zeffiro_interface('start_mode','nodisplay','open_project','data/example_projects/ary_sphere_project_2');
%This script calculates averaged sensitivity maps using the MNE and dipole
%scan tools. Start the script from the root folder by first adding the
%script folder into the path (addpath('scripts/inverse_sensitivity')).

%Import the spherical Ary domain.
project_struct = zeffiro_interface('start_mode','nodisplay','open_project','data/example_projects/ary_sphere_project');

%Set mesh resolution and generate a finite element mesh.
project_struct.mesh_resolution = 6;
project_struct = zef_create_finite_element_mesh(project_struct);

%Set the desired number of source positions and generate a lead field.
project_struct.n_sources = 500;
project_struct = zef_eeg_lead_field(project_struct);

%Set noise level and number of cases to be averaged.
noise_level = -30;
n_cases = 2;

%Start the MNE tool and calculate a map for sLORETA.
project_struct = zef_minimum_norm_estimation(project_struct);
sensitivity_map_sLoreta = zef_sensitivity_map_mne(project_struct, 'sLORETA', n_cases, noise_level);

%Start the dipole scan tool and calculate a map.
project_struct = zef_dipole_start(project_struct);
sensitivity_map = zef_sensitivity_map_dipoleScan(project_struct, 2, -30)
sensitivity_map_dipoleScan = zef_sensitivity_map_dipoleScan(project_struct, n_cases, noise_level);

%Close Zeffiro.
zef_close_all;
14 changes: 14 additions & 0 deletions scripts/inverse_sensitivity/zef_sensitivity_map_dipoleScan.m
Expand Up @@ -22,6 +22,10 @@
hauk_map.angle_vec_avg = zeros(size(hauk_map.angle_vec{1}));
hauk_map.mag_vec_avg = zeros(size(hauk_map.mag_vec{1}));

hauk_map.dist_vec_std = zeros(size(hauk_map.dist_vec{1}));
hauk_map.angle_vec_std = zeros(size(hauk_map.angle_vec{1}));
hauk_map.mag_vec_std = zeros(size(hauk_map.mag_vec{1}));

for i = 1 : n_reconstructions
hauk_map.dist_vec_avg = hauk_map.dist_vec_avg + hauk_map.dist_vec{i};
hauk_map.angle_vec_avg = hauk_map.angle_vec_avg + hauk_map.angle_vec{i};
Expand All @@ -32,5 +36,15 @@
hauk_map.angle_vec_avg = hauk_map.angle_vec_avg/n_reconstructions;
hauk_map.mag_vec_avg = hauk_map.mag_vec_avg/n_reconstructions;

for i = 1 : n_reconstructions
hauk_map.dist_vec_std = hauk_map.dist_vec_std + (hauk_map.dist_vec{i} - hauk_map.dist_vec_avg).^2;
hauk_map.angle_vec_std = hauk_map.angle_vec_std + (hauk_map.angle_vec{i} - hauk_map.angle_vec_avg).^2;
hauk_map.mag_vec_std = hauk_map.mag_vec_std + (hauk_map.mag_vec{i} - hauk_map.mag_vec_avg).^2;
end

hauk_map.dist_vec_std = sqrt(hauk_map.dist_vec_std/(n_reconstructions-1));
hauk_map.angle_vec_std = sqrt(hauk_map.angle_vec_std/(n_reconstructions-1));
hauk_map.mag_vec_std = sqrt(hauk_map.mag_vec_std/(n_reconstructions-1));


end
2 changes: 1 addition & 1 deletion scripts/inverse_sensitivity/zef_sensitivity_map_mne.m
Expand Up @@ -8,7 +8,7 @@
end

weighting_type_cell = {'mne','dspm','sloreta'};
weighting_type = find(ismember(weighting_type_cell,weighting_type));
weighting_type = find(ismember(weighting_type_cell,lower(weighting_type)));

sensitivity_map = struct;
sensitivity_map.weighting_type = weighting_type_cell{weighting_type};
Expand Down
2 changes: 1 addition & 1 deletion scripts/zef_KalmanDemo.m
Expand Up @@ -2,7 +2,7 @@ function KalmanDemo()
% How to use kalman without GUI

% Create project
project_struct = zef_
project_struct = zeffiro_interface('start_mode','nodisplay','import_to_new_project','scripts/scripts_for_importing/multicompartment_head_project/import_segmentation.zef');

% Set mesh resolution
project_struct.mesh_resolution = 4.5;
Expand Down

0 comments on commit 47adc81

Please sign in to comment.