Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
faust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
faust group
faust
Commits
5c7d174c
Commit
5c7d174c
authored
8 years ago
by
Nicolas Bellot
Committed by
hhakim
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
demo : BSL simplification
parent
c39148ed
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
misc/demo/Brain_source_localization/BSL.m
+65
-181
65 additions, 181 deletions
misc/demo/Brain_source_localization/BSL.m
misc/demo/Brain_source_localization/Fig_BSL.m
+20
-74
20 additions, 74 deletions
misc/demo/Brain_source_localization/Fig_BSL.m
with
85 additions
and
255 deletions
misc/demo/Brain_source_localization/BSL.m
+
65
−
181
View file @
5c7d174c
...
...
@@ -5,13 +5,13 @@
% matrices [2], including FAuSTs, and OMP solver. It reproduces the
% source localization experiment of [1].
% The results are stored in "./output/results_BSL_user.mat".
% DURATION: Computations should take around 10 minutes.
%
% The MEG gain matrices used are
% DURATION: Computations should take around 10 minutes.
%
% The MEG gain matrices used are
% - those in "./output/M_user.mat" if available
% - or the precomputed ones in "./precomputed_results_MEG/M_X.mat"
%
% For more information on the FAuST Project, please visit the website of
% For more information on the FAuST Project, please visit the website of
% the project : <http://faust.gforge.inria.fr>
%
%% License:
...
...
@@ -19,36 +19,36 @@
% INRIA Rennes, FRANCE
% http://www.inria.fr/
%
% The FAuST Toolbox is distributed under the terms of the GNU Affero
% The FAuST Toolbox is distributed under the terms of the GNU Affero
% General Public License.
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU Affero General Public License as published
% it under the terms of the GNU Affero General Public License as published
% by the Free Software Foundation.
%
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% See the GNU Affero General Public License for more details.
%
% You should have received a copy of the GNU Affero General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
%% Contacts:
%% Contacts:
% Nicolas Bellot : nicolas.bellot@inria.fr
% Leman Adrien : adrien.leman@inria.fr
% Luc Le Magoarou: luc.le-magoarou@inria.fr
% Remi Gribonval : remi.gribonval@inria.fr
%
%% References:
% [1] Le Magoarou L. and Gribonval R., "Flexible multi-layer sparse
% approximations of matrices and applications", Journal of Selected
% [1] Le Magoarou L. and Gribonval R., "Flexible multi-layer sparse
% approximations of matrices and applications", Journal of Selected
% Topics in Signal Processing, 2016.
% <https://hal.archives-ouvertes.fr/hal-01167948v1>
%
% [2] A. Gramfort, M. Luessi, E. Larson, D. Engemann, D. Strohmeier,
% [2] A. Gramfort, M. Luessi, E. Larson, D. Engemann, D. Strohmeier,
% C. Brodbeck, L. Parkkonen, M. Hamalainen, MNE software for processing
% MEG and EEG data <http://www.ncbi.nlm.nih.gov/pubmed/24161808>,
% NeuroImage, Volume 86, 1 February 2014, Pages 446-460, ISSN 1053-8119,
% MEG and EEG data <http://www.ncbi.nlm.nih.gov/pubmed/24161808>,
% NeuroImage, Volume 86, 1 February 2014, Pages 446-460, ISSN 1053-8119,
% [DOI] <http://dx.doi.org/10.1016/j.neuroimage.2013.10.027>
%%
...
...
@@ -61,216 +61,100 @@
runPath
=
which
(
mfilename
);
pathname
=
fileparts
(
runPath
);
BSL_data_pathName
=
strcat
(
pathname
,
'/
data
/'
)
;
BSL_data_pathName
=
[
pathname
filesep
'
data
'
]
;
% files where a precomputed FauST approximation of MEG matrix are stored
MEG_FAuST_list_filename
=
{
'M_6.mat'
,
'M_8.mat'
,
'M_16.mat'
,
'M_25.mat'
};
RCG_approxS_MEG
=
[
6
,
8
,
16
,
25
];
nb_approx_MEG
=
length
(
RCG_approxS_MEG
);
MEG_approxS_norm
=
cell
(
1
,
nb_approx_MEG
);
nb_FAuST_MEG
=
length
(
MEG_FAuST_list_filename
);
% list of the MEG matrices (the original one and her Faust approximations)
MEG_list
=
cell
(
1
,
nb_FAuST_MEG
+
1
);
nb_MEG_matrix
=
length
(
MEG_list
);
%Loading
of
the MEG matrix
load
([
BSL_data_pathName
'X_meg.mat'
]);
load
([
BSL_data_pathName
'curv.mat'
]);
%
%
Loading the MEG matrix
load
([
BSL_data_pathName
filesep
'X_meg.mat'
]);
load
([
BSL_data_pathName
filesep
'curv.mat'
]);
points2
=
points
;
points
=
points
(
points_used_idx
,:);
X_norm
=
normalizeCol
(
X_fixed
);
disp
([
'MEG size : '
int2str
(
size
(
X_norm
))]);
%% Loading of the MEG matrix approximations
% wrapper C++ faust
MEG_faustS
=
cell
(
1
,
nb_approx_MEG
);
% store the different wrapper faust objet
faustS_mult
=
cell
(
1
,
nb_approx_MEG
);
% store the different function_handle that makes the multiplication by the faust
trans_faustS_mult
=
cell
(
1
,
nb_approx_MEG
);
% % store the different function_handle that makes the multiplication by the transpose of a faust
MEG_matrix
=
normalizeCol
(
X_fixed
);
% normalization of the columns of the MEG matrix
MEG_list
{
1
}
=
MEG_matrix
;
% matlab faust (no C++ Faust Toolbox code is running)
matlab_faustS_mult
=
cell
(
1
,
nb_approx_MEG
);
matlab_trans_faustS_mult
=
cell
(
1
,
nb_approx_MEG
);
for
i
=
1
:
nb_approx_MEG
RCG_approxS_MEG
(
i
);
load
([
BSL_data_pathName
'M_'
int2str
(
RCG_approxS_MEG
(
i
))
]);
disp
([
'fact size : '
int2str
(
size
(
facts
{
1
},
1
))
' '
int2str
(
size
(
facts
{
end
},
2
))]);
%% structure faust
facts
=
normalizeCol
(
facts
,
lambda
);
fc
=
Faust
(
facts
);
trans_fc
=
fc
'
;
trans_facts
=
faust_transpose
(
facts
);
% matlab faust (no C++ Faust Toolbox code is running)
matlab_trans_faustS_mult
{
i
}
=@
(
x
)
f_mult
(
trans_facts
,
x
);
% function handle
matlab_faustS_mult
{
i
}
=@
(
x
)
f_mult
(
facts
,
x
);
% function handle
% wrapper C++ faust
trans_faustS_mult
{
i
}
=@
(
x
)
mtimes_trans
(
fc
,
x
,
1
);
% function handle
faustS_mult
{
i
}
=@
(
x
)
mtimes_trans
(
fc
,
x
,
0
);
% function handle
MEG_Faust_list
{
i
}
=
fc
;
% store the different faust approximations
end
M
=
size
(
X_norm
,
2
);
params
.
Ntraining
=
20
;
% Number of training vectors
params
.
Sparsity
=
2
;
% Number of sources per training vector
params
.
dist_paliers
=
[
0.01
,
0.05
,
0.08
,
0.5
];
params
.
solver_choice
=
'omp'
;
%params.solver_choice='iht';
opt_handle
=
0
;
% ==1 the faust is given to the solver by function handle
% ==0 the faust is given to the solver as an object
%% Loading the precomputed FAuST representing the MEG matrix
% RCG (Relative Complexity Gain) : the theoretical speed-up using Faust
RCG_list
=
zeros
(
1
,
nb_FAuST_MEG
);
for
i
=
1
:
nb_FAuST_MEG
load
([
BSL_data_pathName
filesep
MEG_FAuST_list_filename
{
i
}]);
facts
=
normalizeCol
(
facts
,
lambda
);
% normalization of the columns of the MEG matrix
MEG_FAuST
=
Faust
(
facts
);
% construct the FAuST from its factors
MEG_list
{
i
+
1
}
=
MEG_FAuST
;
% store the different FAuST approximations
RCG_list
(
i
)
=
RCG
(
MEG_FAuST
);
% compute the RCG of the given FAuST
end
Ntraining
=
params
.
Ntraining
;
Sparsity
=
params
.
Sparsity
;
dist_paliers
=
params
.
dist_paliers
;
solver_choice
=
params
.
solver_choice
;
M
=
size
(
MEG_matrix
,
2
);
Ntraining
=
100
;
% Number of training vectors
Sparsity
=
2
;
% Number of sources per training vector
dist_paliers
=
[
0.01
,
0.05
,
0.08
,
0.5
];
resDist
=
zeros
(
nb_approx_MEG
+
1
,
numel
(
dist_paliers
)
-
1
,
Sparsity
,
Ntraining
);
% (Matrice,methode,dist_sources,src_nb,run);
compute_Times
=
zeros
(
nb_approx_MEG
+
1
,
numel
(
dist_paliers
)
-
1
,
Ntraining
);
resDist_matlab
=
zeros
(
nb_approx_MEG
+
1
,
numel
(
dist_paliers
)
-
1
,
Sparsity
,
Ntraining
);
% (Matrice,methode,dist_sources,src_nb,run);
compute_Times_matlab
=
zeros
(
nb_approx_MEG
+
1
,
numel
(
dist_paliers
)
-
1
,
Ntraining
);
resDist
=
zeros
(
nb_MEG_matrix
,
numel
(
dist_paliers
)
-
1
,
Sparsity
,
Ntraining
);
% (Matrice,dist_sources,src_nb,run);
compute_Times
=
zeros
(
nb_MEG_matrix
,
numel
(
dist_paliers
)
-
1
,
Ntraining
);
h
=
waitbar
(
0
,[
'Brain Source Localization : MEG matrix and its faust approximations with
'
solver_choice
'
solver'
]);
h
=
waitbar
(
0
,[
'Brain Source Localization : MEG matrix and its faust approximations with
omp
solver'
]);
nb_palier
=
numel
(
dist_paliers
)
-
1
;
for
k
=
1
:
nb_palier
;
%Parameters settings
Gamma
=
zeros
(
size
(
X_norm
,
2
)
,
Ntraining
);
Gamma
=
zeros
(
M
,
Ntraining
);
for
ii
=
1
:
Ntraining
dist_sources
=
-
1
;
while
~
((
dist_paliers
(
k
)
<
dist_sources
)
&&
(
dist_sources
<
dist_paliers
(
k
+
1
)))
Gamma
(:,
ii
)
=
sparse_coeffs
(
X_norm
,
1
,
Sparsity
);
%
Gamma
(:,
ii
)
=
sparse_coeffs
(
MEG_matrix
,
1
,
Sparsity
);
%
idx
=
find
(
Gamma
(:,
ii
));
dist_sources
=
norm
(
points
(
idx
(
1
))
-
points
(
idx
(
2
)));
end
end
Data
=
X_norm
*
Gamma
;
sol_solver
=
zeros
(
size
(
Gamma
));
sol_solver_hat
=
zeros
(
size
(
Gamma
));
sol_solver_hat2
=
zeros
(
size
(
Gamma
));
err_solver
=
zeros
(
2
,
Ntraining
);
err_solver_hat
=
zeros
(
2
,
Ntraining
);
err_solver_hat2
=
zeros
(
2
,
Ntraining
);
diff_solver
=
zeros
(
2
,
Ntraining
);
dist_solver
=
zeros
(
Sparsity
,
Ntraining
);
dist_solver_hat
=
zeros
(
Sparsity
,
Ntraining
);
dist_solver_hat2
=
zeros
(
Sparsity
,
Ntraining
);
Data
=
MEG_matrix
*
Gamma
;
for
i
=
1
:
Ntraining
%disp([' i=' num2str(i) '/' num2str(
Ntraining)
]
)
waitbar
(((
k
-
1
)
*
Ntraining
+
i
)/(
nb_palier
*
Ntraining
));
waitbar
(((
k
-
1
)
*
Ntraining
+
i
)/(
nb_palier
*
Ntraining
))
;
idx
=
find
(
Gamma
(:,
i
));
dist_sources
=
norm
(
points
(
idx
(
1
))
-
points
(
idx
(
2
)));
for
j
=
1
:
nb_MEG_matrix
if
strcmp
(
solver_choice
,
'omp'
)
%OMP
tic
[
sol_solver
(:,
i
),
err_mse_solver
,
iter_time_solver
]
=
greed_omp_chol
(
Data
(:,
i
),
X_norm
,
M
,
'stopTol'
,
1
*
Sparsity
,
'verbose'
,
false
);
tdense
=
toc
;
elseif
strcmp
(
solver_choice
,
'iht'
)
%IHT
tic
[
sol_solver
(:,
i
),
err_mse_solver
,
iter_time_solver
]
=
hard_l0_Mterm
(
Data
(:,
i
),
X_norm
,
M
,
1
*
Sparsity
,
'verbose'
,
false
,
'maxIter'
,
1000
);
tdense
=
toc
;
else
error
(
'invalid solver choice: must be omp or iht'
);
end
MEG_FAuST
=
MEG_list
{
j
};
err_solver
(
1
,
i
)
=
norm
(
X_norm
*
Gamma
(:,
i
)
-
X_norm
*
sol_solver
(:,
i
))/
norm
(
X_norm
*
Gamma
(:,
i
));
err_solver
(
2
,
i
)
=
isequal
(
find
(
Gamma
(:,
i
)),
find
(
sol_solver
(:,
i
)
>
1e-4
));
idx_solver
=
find
(
sol_solver
(:,
i
));
resDist
(
1
,
k
,
1
,
i
)
=
min
(
norm
(
points
(
idx
(
1
))
-
points
(
idx_solver
(
1
))),
norm
(
points
(
idx
(
1
))
-
points
(
idx_solver
(
2
))));
resDist
(
1
,
k
,
2
,
i
)
=
min
(
norm
(
points
(
idx
(
2
))
-
points
(
idx_solver
(
1
))),
norm
(
points
(
idx
(
2
))
-
points
(
idx_solver
(
2
))));
compute_Times
(
1
,
k
,
i
)
=
tdense
;
resDist_matlab
(
1
,
k
,
1
,
i
)
=
min
(
norm
(
points
(
idx
(
1
))
-
points
(
idx_solver
(
1
))),
norm
(
points
(
idx
(
1
))
-
points
(
idx_solver
(
2
))));
resDist_matlab
(
1
,
k
,
2
,
i
)
=
min
(
norm
(
points
(
idx
(
2
))
-
points
(
idx_solver
(
1
))),
norm
(
points
(
idx
(
2
))
-
points
(
idx_solver
(
2
))));
compute_Times_matlab
(
1
,
k
,
i
)
=
tdense
;
%% find the active source
tic
sol_solver
=
greed_omp_chol
(
Data
(:,
i
),
MEG_FAuST
,
M
,
'stopTol'
,
1
*
Sparsity
,
'verbose'
,
false
);
compute_Times
(
j
,
k
,
i
)
=
toc
;
for
ll
=
1
:
nb_approx_MEG
MEG_Faust
=
MEG_Faust_list
{
ll
};
%% objet faust
if
strcmp
(
solver_choice
,
'omp'
)
%OMP
if
(
opt_handle
==
1
)
tic
[
sol_solver_hat
(:,
i
),
err_mse_solver_hat
,
iter_time_solver_hat
]
=
greed_omp_chol
(
Data
(:,
i
),
faustS_mult
{
ll
},
M
,
'stopTol'
,
1
*
Sparsity
,
'verbose'
,
false
,
'P_trans'
,
trans_faustS_mult
{
ll
});
t_cpp
=
toc
;
else
tic
[
sol_solver_hat
(:,
i
),
err_mse_solver_hat
,
iter_time_solver_hat
]
=
greed_omp_chol
(
Data
(:,
i
),
MEG_Faust
,
M
,
'stopTol'
,
1
*
Sparsity
,
'verbose'
,
false
);
t_cpp
=
toc
;
end
elseif
strcmp
(
solver_choice
,
'iht'
)
%IHT
if
(
opt_handle
==
1
)
tic
[
sol_solver_hat
(:,
i
),
err_mse_solver
,
iter_time_solver
]
=
hard_l0_Mterm
(
Data
(:,
i
),
faustS_mult
{
ll
},
M
,
1
*
Sparsity
,
'verbose'
,
false
,
'maxIter'
,
1000
,
'P_trans'
,
trans_faustS_mult
{
ll
});
t_cpp
=
toc
;
else
tic
[
sol_solver_hat
(:,
i
),
err_mse_solver
,
iter_time_solver
]
=
hard_l0_Mterm
(
Data
(:,
i
),
MEG_Faust
,
M
,
1
*
Sparsity
,
'verbose'
,
false
,
'maxIter'
,
1000
);
t_cpp
=
toc
;
end
else
error
(
'invalid solver choice: must be omp or iht'
);
end
err_solver_hat
(
1
,
i
)
=
norm
(
X_norm
*
Gamma
(:,
i
)
-
MEG_Faust
*
sol_solver_hat
(:,
i
))/
norm
(
X_norm
*
Gamma
(:,
i
));
err_solver_hat
(
2
,
i
)
=
isequal
(
find
(
Gamma
(:,
i
)),
find
(
sol_solver_hat
(:,
i
)
>
1e-4
));
idx_solver
=
find
(
sol_solver_hat
(:,
i
));
resDist
(
ll
+
1
,
k
,
1
,
i
)
=
min
(
norm
(
points
(
idx
(
1
))
-
points
(
idx_solver
(
1
))),
norm
(
points
(
idx
(
1
))
-
points
(
idx_solver
(
2
))));
resDist
(
ll
+
1
,
k
,
2
,
i
)
=
min
(
norm
(
points
(
idx
(
2
))
-
points
(
idx_solver
(
1
))),
norm
(
points
(
idx
(
2
))
-
points
(
idx_solver
(
2
))));
compute_Times
(
ll
+
1
,
k
,
i
)
=
t_cpp
;
tic
%% matlab function
if
strcmp
(
solver_choice
,
'omp'
)
% OMP
tic
[
sol_solver_hat
(:,
i
),
err_mse_solver_hat
,
iter_time_solver_hat
]
=
greed_omp_chol
(
Data
(:,
i
),
matlab_faustS_mult
{
ll
},
M
,
'stopTol'
,
1
*
Sparsity
,
'P_trans'
,
matlab_trans_faustS_mult
{
ll
},
'verbose'
,
false
);
tmatlab
=
toc
;
elseif
strcmp
(
solver_choice
,
'iht'
)
% IHT
tic
[
sol_solver_hat
(:,
i
),
err_mse_solver
,
iter_time_solver
]
=
hard_l0_Mterm
(
Data
(:,
i
),
matlab_faustS_mult
{
ll
},
M
,
1
*
Sparsity
,
'verbose'
,
false
,
'maxIter'
,
1000
,
'P_trans'
,
matlab_trans_faustS_mult
{
ll
},
'verbose'
,
false
);
tmatlab
=
toc
;
else
error
(
'invalid solver choice : must be omp or iht'
);
end
err_solver_hat
(
1
,
i
)
=
norm
(
X_norm
*
Gamma
(:,
i
)
-
MEG_Faust
*
sol_solver_hat
(:,
i
))/
norm
(
X_norm
*
Gamma
(:,
i
));
err_solver_hat
(
2
,
i
)
=
isequal
(
find
(
Gamma
(:,
i
)),
find
(
sol_solver_hat
(:,
i
)
>
1e-4
));
idx_solver
=
find
(
sol_solver_hat
(:,
i
));
resDist_matlab
(
ll
+
1
,
k
,
1
,
i
)
=
min
(
norm
(
points
(
idx
(
1
))
-
points
(
idx_solver
(
1
))),
norm
(
points
(
idx
(
1
))
-
points
(
idx_solver
(
2
))));
resDist_matlab
(
ll
+
1
,
k
,
2
,
i
)
=
min
(
norm
(
points
(
idx
(
2
))
-
points
(
idx_solver
(
1
))),
norm
(
points
(
idx
(
2
))
-
points
(
idx_solver
(
2
))));
compute_Times_matlab
(
ll
+
1
,
k
,
i
)
=
tmatlab
;
end
% compute the distance between the estimated source and the real one
idx_solver
=
find
(
sol_solver
);
resDist
(
j
,
k
,
1
,
i
)
=
min
(
norm
(
points
(
idx
(
1
))
-
points
(
idx_solver
(
1
))),
norm
(
points
(
idx
(
1
))
-
points
(
idx_solver
(
2
))));
resDist
(
j
,
k
,
2
,
i
)
=
min
(
norm
(
points
(
idx
(
2
))
-
points
(
idx_solver
(
1
))),
norm
(
points
(
idx
(
2
))
-
points
(
idx_solver
(
2
))));
end
end
end
close
(
h
);
matfile
=
fullfile
(
pathname
,
'output/results_BSL_user'
);
save
(
matfile
,
'resDist'
,
'params'
,
'resDist_matlab'
,
'RCG_approxS_MEG'
,
'nb_approx_MEG'
,
'compute_Times'
,
'compute_Times_matlab'
,
'RCG_approxS_MEG'
);
save
(
matfile
,
'resDist'
,
'Sparsity'
,
'RCG_list'
,
'compute_Times'
,
'Ntraining'
);
...
...
This diff is collapsed.
Click to expand it.
misc/demo/Brain_source_localization/Fig_BSL.m
+
20
−
74
View file @
5c7d174c
...
...
@@ -55,12 +55,13 @@ figure_dir = [pathname filesep '..' filesep 'Figures'];
format_fig
=
'-dpng'
;
load
(
matfile
);
Ntraining
=
params
.
Ntraining
;
Sparsity
=
params
.
Sparsity
;
solver_choice
=
params
.
solver_choice
;
nb_MEG_matrix
=
length
(
MEG_list
);
nb_approx_MEG
=
nb_MEG_matrix
-
1
;
solver_choice
=
'omp'
;
Ntest
=
Ntraining
*
Sparsity
;
%% convergence analysis
d1
=
cat
(
4
,
resDist
(:,
1
,
1
,:),
resDist
(:,
1
,
2
,:));
...
...
@@ -102,9 +103,9 @@ text(xTicks(round(mean(2*(nb_approx_MEG+1)+1:3*(nb_approx_MEG+1)))), minY - vert
for
i
=
1
:
nb_approx_MEG
text
(
xTicks
(
i
+
1
),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_
approxS_MEG
(
i
))
'}$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
i
+
2
+
nb_approx_MEG
),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_
approxS_MEG
(
i
))
' }$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
i
+
1
+
2
*
(
nb_approx_MEG
+
1
)),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_
approxS_MEG
(
i
))
' }$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
i
+
1
),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_
list
(
i
))
'}$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
i
+
2
+
nb_approx_MEG
),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_
list
(
i
))
' }$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
i
+
1
+
2
*
(
nb_approx_MEG
+
1
)),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_
list
(
i
))
' }$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
end
...
...
@@ -115,66 +116,14 @@ print(figure_name, format_fig);
%% MATLAB convergence analysis
d1
=
cat
(
4
,
resDist_matlab
(:,
1
,
1
,:),
resDist_matlab
(:,
1
,
2
,:));
d2
=
cat
(
4
,
resDist_matlab
(:,
2
,
1
,:),
resDist_matlab
(:,
2
,
2
,:));
d3
=
cat
(
4
,
resDist_matlab
(:,
3
,
1
,:),
resDist_matlab
(:,
3
,
2
,:));
test2
=
100
*
[
squeeze
(
d1
);
zeros
(
1
,
Ntest
);
squeeze
(
d2
);
zeros
(
1
,
Ntest
);
squeeze
(
d3
)];
f
=
figure
(
'color'
,[
1
1
1
]);
title
(
'MATLAB'
);
T
=
bplot
(
test2
','
linewidth
'
,
1.5
);
legend
(
T
);
ylabel
(
'Distance between true and estimated sources (cm)'
)
box
on
ax
=
gca
;
x_tick
=
[
1
:
nb_approx_MEG
+
1
;
nb_approx_MEG
+
3
:
2
*
nb_approx_MEG
+
3
;
2
*
nb_approx_MEG
+
5
:
3
*
nb_approx_MEG
+
5
];
mean_x_tick
=
round
(
mean
(
x_tick
,
2
));
set
(
ax
,
'XTick'
,
reshape
(
x_tick
'
,
1
,
numel
(
x_tick
)));
set
(
ax
,
'xticklabel'
,
[])
axi
=
axis
;
axis
([
0
3
*
(
nb_approx_MEG
+
2
)
-
0.3
4.7
])
HorizontalOffset
=
10
;
verticalOffset
=
0.43
;
verticalOffset2
=
0.7
;
yTicks
=
get
(
ax
,
'ytick'
);
xTicks
=
get
(
ax
,
'xtick'
);
minY
=
min
(
yTicks
);
text
(
xTicks
(
1
),
minY
-
verticalOffset
,
'$\mathbf{M}$'
,
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
2
+
nb_approx_MEG
),
minY
-
verticalOffset
,
'$\mathbf{M}$'
,
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
1
+
2
*
(
nb_approx_MEG
+
1
)),
minY
-
verticalOffset
,
'$\mathbf{M}$'
,
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
round
(
mean
(
1
:(
nb_approx_MEG
+
1
)))),
minY
-
verticalOffset2
,
'$1<d<5$'
,
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
round
(
mean
(
nb_approx_MEG
+
2
:
2
*
(
nb_approx_MEG
+
1
)))),
minY
-
verticalOffset2
,
'$5<d<8$'
,
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
round
(
mean
(
2
*
(
nb_approx_MEG
+
1
)
+
1
:
3
*
(
nb_approx_MEG
+
1
)))),
minY
-
verticalOffset2
,
'$d>8$'
,
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
for
i
=
1
:
nb_approx_MEG
text
(
xTicks
(
i
+
1
),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_approxS_MEG
(
i
))
'}$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
i
+
2
+
nb_approx_MEG
),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_approxS_MEG
(
i
))
' }$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
i
+
1
+
2
*
(
nb_approx_MEG
+
1
)),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_approxS_MEG
(
i
))
' }$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
end
title
([
'BSL - convergence (matlab faust) '
solver_choice
' solver '
]);
f
.
Name
=
[
'Brain Source Localization : convergence with '
solver_choice
' solver (matlab)'
];
figure_name
=
[
figure_dir
filesep
'BSL-convergence_matlab_'
solver_choice
'_solver'
];
print
(
figure_name
,
format_fig
);
%% time comparison
timeS
_Cpp
=
cat
(
3
,
compute_Times
(:,
1
,:),
compute_Times
(:,
2
,:),
compute_Times
(:,
3
,:));
timeS
_matlab
=
cat
(
3
,
compute_Times_matlab
(:,
1
,:),
compute_Times_matlab
(:,
2
,:),
compute_Times_matlab
(:,
3
,:))
;
timeS
=
cat
(
3
,
compute_Times
(:,
1
,:),
compute_Times
(:,
2
,:),
compute_Times
(:,
3
,:));
timeS
=
squeeze
(
1000
*
timeS
)
'
;
timeS_matlab
=
squeeze
(
1000
*
timeS_matlab
)
'
;
timeS_Cpp
=
squeeze
(
1000
*
timeS_Cpp
)
'
;
timeS
=
reshape
([
timeS_Cpp
;
timeS_matlab
],
3
*
Ntraining
,(
nb_approx_MEG
+
1
)
*
2
);
timeS
(:,
1
)
=
[];
% twice the time of the MEG matrix solver
f
=
figure
(
'color'
,[
1
1
1
]);
T
=
bplot
(
timeS
,
'linewidth'
,
1.5
);
...
...
@@ -200,8 +149,8 @@ text(xTicks(1), minY - verticalOffset, '$\mathbf{M}$','HorizontalAlignment','cen
for
i
=
1
:
nb_approx_MEG
text
(
xTicks
(
2
*
i
),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_
approxS_MEG
(
i
))
'}^{Cpp
}$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
2
*
i
+
1
),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_approxS_MEG
(
i
))
'}^{Matlab}$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
xTicks
(
i
+
1
),
minY
-
verticalOffset
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_
list
(
i
))
'
}$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
end
title
([
'BSL - time comparison (FAUST vs dense matrix) '
solver_choice
' solver'
]);
f
.
Name
=
[
'Brain Source Localization : time comparison with '
solver_choice
'solver'
];
...
...
@@ -214,33 +163,30 @@ print(figure_name, format_fig);
%% speed-up
mean_Times
=
mean
(
timeS_Cpp
);
mean_Times_matlab
=
mean
(
timeS_matlab
);
%% speed-up
mean_Times
=
mean
(
timeS
);
dense_matrix_time
=
mean_Times
(
1
);
real_RCG
=
dense_matrix_time
.
/
mean_Times
;
real_RCG_matlab
=
dense_matrix_time
.
/
mean_Times_matlab
;
f
=
figure
;
ax
=
gca
;
set
(
ax
,
'xticklabel'
,
[])
set
(
ax
,
'Visible'
,
'off'
);
semilogy
(
1
:
nb_approx_MEG
,
RCG_
approxS_MEG
,
'linewidth'
,
1.5
);
semilogy
(
1
:
nb_approx_MEG
,
RCG_
list
,
'linewidth'
,
1.5
);
set
(
ax
,
'XTick'
,[]);
hold
on
semilogy
(
1
:
nb_approx_MEG
,
real_RCG
(
2
:
end
),
'linewidth'
,
1.5
);
semilogy
(
1
:
nb_approx_MEG
,
real_RCG_matlab
(
2
:
end
),
'linewidth'
,
1.5
);
semilogy
(
1
:
nb_approx_MEG
,
ones
(
1
,
nb_approx_MEG
),
'linewidth'
,
1.5
);
verticalOffset
=
1.5
;
minY
=
min
([
0.9
,
real_RCG
(
2
:
end
),
real_RCG_matlab
(
2
:
end
),
RCG_approxS_MEG
]);
maxY
=
max
([
0.9
,
real_RCG
(
2
:
end
),
real_RCG_matlab
(
2
:
end
),
RCG_approxS_MEG
]);
minY
=
min
([
0.9
,
real_RCG
(
2
:
end
),
RCG_list
]);
maxY
=
max
([
0.9
,
real_RCG
(
2
:
end
),
RCG_list
]);
axis
([
1
,
nb_approx_MEG
,
minY
,
maxY
]);
for
i
=
1
:
nb_approx_MEG
text
(
i
,
minY
-
log
(
maxY
/
minY
)/
20
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_
approxS_MEG
(
i
))
'}$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
text
(
i
,
minY
-
log
(
maxY
/
minY
)/
20
,
[
'$\widehat{\mathbf{M}}_{'
int2str
(
RCG_
list
(
i
))
'}$'
],
'HorizontalAlignment'
,
'center'
,
'interpreter'
,
'latex'
);
end
legend
(
'theoretical
RCG'
,
'
speed
up
C++ wrapper faust'
,
'speed up MATLAB faust
'
,
'neutral speed up'
);
legend
(
'theoretical speed
-
up
'
,
'speed up FAuST
'
,
'neutral speed up'
);
title
([
'BSL - speed up using FAUST '
solver_choice
' solver'
]);
f
.
Name
=
[
'Brain Source Localization : speed-up Faust with '
solver_choice
'solver'
];
figure_name
=
[
figure_dir
filesep
'BSL-speed_up_'
solver_choice
' solver'
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment