Skip to content

Commit

Permalink
Create commit for the version 2.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aliobaibk committed Jul 10, 2019
1 parent b1e9a9b commit 0bb81c7
Show file tree
Hide file tree
Showing 18 changed files with 2,720 additions and 17 deletions.
20 changes: 14 additions & 6 deletions best/changeLog.txt → CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
%% BEST CHANGE LOG %%
% 19 - 06 - 2019
- be_main_call: Fix opening of MATLAB parallel pool
- process_inverse_mem: Suppress warning 'eval(macro_method);'

% 25 - 07 - 2017
- launch from the 2016 SOURCE PANEL is now operational

% 08 - 09 - 2015
- cMEM EEG/MEG fusion is now operational

% 05 - 12 - 2014
- be_install : automatic update added
Expand Down Expand Up @@ -83,14 +91,14 @@
% 07 - 03 - 2014
- be_wavelet_inverse.m : remplacer "iwt_po" par "IWT_PO" (ligne 48)
- be_discrete_wavelet_transform : remplacer "fwt_po" par "FWT_PO" (ligne 44)
- be_struct_copy_fields : ajouter le champ "varargin" dans l'appel
- be_struct_copy_fields : ajouter le champ "varargin" dans l'appel à
la fonction "be_struct_copy_fields". Ceci
permet de sp�cifier si les options choisies
dans l'appel la fonction doivent "override"
les options par d�faut (ce qui n'�tait pas
permet de spécifier si les options choisies
dans l'appel à la fonction doivent "override"
les options par défaut (ce qui n'était pas
le cas avant)
- be_pipelineoptions : changer l'appel "be_struct_copyfields()" en
ajoutant le param�tre 1 la fin (override)
ajoutant le paramètre 1 à la fin (override)
(ligne 23)


674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Brain Entropy in space and time (BEst) plug-in for Brainstorm

[TUTORIAL](https://neuroimage.usc.edu/brainstorm/Tutorials/TutBEst)
10 changes: 6 additions & 4 deletions best/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
2.6.3
july 25th, 2017
Minor change:
- launch from the 2016 SOURCE PANEL is now operational
2.7.1

june 19th, 2019
Minor changes:
- Fix MATLAB parallelism
- Suppress warning for the custom Brainstorm process
6 changes: 3 additions & 3 deletions best/main/be_main_call.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@
% Initialize parallel computing
close_pool = true;
if MEMoptions.solver.parallel_matlab
if ~matlabpool('size')
matlabpool open
if isempty(gcp('nocreate'))
gcp;
else
close_pool = false;
end
Expand All @@ -155,7 +155,7 @@

% Initialize parallel computing
if MEMoptions.solver.parallel_matlab && close_pool
matlabpool close
delete(gcp('nocreate'))
end

elseif (nargout==1)
Expand Down
8 changes: 5 additions & 3 deletions best/mem/be_minimize_free_energy.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
end


if exist([matlabroot '/toolbox/optim/optim'],'dir')==7 && strcmp(mem_struct.optim_algo,'fminunc')
% if exist([matlabroot '/toolbox/optim/optim'],'dir')==7 && strcmp(mem_struct.optim_algo,'fminunc')
if (license('test','Optimization_Toolbox')&&strcmp(mem_struct.optim_algo,'fminunc'))
% Creating the options structure for MATLAB's fminunc function
options = optimset('GradObj', 'on', ...
'LargeScale', 'off', ...
Expand All @@ -70,8 +71,9 @@
mem_struct.nb_clusters);
iter = out.iterations;

elseif strcmp(mem_struct.optim_algo,'fminunc') && ...
exist([matlabroot '/toolbox/optim/optim'],'dir')~=7
% elseif strcmp(mem_struct.optim_algo,'fminunc') && ...
% exist([matlabroot '/toolbox/optim/optim'],'dir')~=7
elseif (~license('test','Optimization_Toolbox')&&strcmp(mem_struct.optim_algo,'fminunc'))
disp(['Matlab Optimization toolbox fminunc.m not found.' ...
' Using alternate optimization routine...'])
options = [];
Expand Down
210 changes: 210 additions & 0 deletions best/memNIRS/be_cmem_solver_NIRS.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
function [Results, OPTIONS] = be_cmem_solver_NIRS(HeadModel, OPTIONS, Results)
% cMEMSOLVER: Maximum Entropy on the Mean solution.
%
% NOTES:
% - This function is not optimized for stand-alone command calls.
% - Please use the generic BST_SOURCEIMAGING function, or the GUI.a
%
% INPUTS:
% - HeadModel : Brainstorm head model structure
% - OPTIONS : Structure of parameters (described in be_main.m)
% -solver : Parameters for MEM solver
% |- spatial_smoothing : optional spatial constraint on the
% variance of the active state function,
% for each cluster. Set to 1 to activate.
% |- NoiseCov : Noise variance-covariance matrix.
% Should be available from Brainstorm or can be
% estimated and provided separately
% |- active_var_mult : multiplier for the variance-covariance of
% the active state function
% |- inactive_var_mult : multiplier for the variance-covariance of
% the inactive state function (default: 0 i.e. a dirac)
% |- Optim_method : Choice of optimization routine. By
% default uses minFunc (Mark Schmidt's implementation). Specify 'fminunc' to use
% Matlab optimization toolbox routine.
% -clustering : Structure containing parcelization parameters
% |- MSP_R2_threshold : threshold (between 0 and 1) to filter
% data and forward operator in the msp
% calculation.
% |- MSP_window : number of samples to use for calculating the MSP.
% The window should be small enough to satisfy assumption of
% stationarity within that window.
% |- clusters_type : Set to 1 to used C. Grova's clustering
% method
% |- MSP_scores_threshold : Threshold of the MSP scores (between 0
% and 1). Set to 0 to keep all the scores.
% |- neighborhood_order: Nb. of neighbors used to cluterize
% cortical surface
% -model : Parameters for MEM model
% |-alpha_threshold : Threshold on the cluster probabilities of
% being active. Clusters whose probas are
% lower than this threshold will be turned off
% |- alpha : Option to specify the alpha probabilities
% manually
% |- alpha_method : Selection of the method to initialize the
% probability (alpha) of activation of the
% clusters (alpha).
% | 1 = average of the scores of sources in a cluster
% | 2 = maximum of the scores of sources in a cluster
% | 3 = median of the scores of sources in a cluster
% | 4 = equiprobable activity (0.5)
% |- active_mean_method: Selection of the method to initialize
% the mean of the "active state" law (mu).
% | 1 = null hypothesis
% | 2 = Null activity (0)
% -mandatory : structure containing data and channel information
% |- Data : Data to process (channels x time samples)
% -automatic : structure containing outputs
% |- Units : Structure for rescaling units
%
% OUTPUTS:
% - OPTIONS : Keep track of parameters
% - Results : Structure
% |- ImageGridAmp : Source activity (sources x times)
% |- ImagingKernel : Not computed ([])
%
% ==============================================
% Copyright (C) 2011 - MultiFunkIm & LATIS Team
%
% Authors: LATIS team, 2011
%
%% ==============================================
% License
%
% BEst is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% BEst 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 General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with BEst. If not, see <http://www.gnu.org/licenses/>.
% -------------------------------------------------------------------------


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TO DO LIST %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% INITIALIZE GLOBAL VARIABLE IF FIRST STUDY
%%%% CLEAR GLOBAL VARIABLE IF LAST STUDY
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END OF TO DO LIST %%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


global MEMglobal

if OPTIONS.optional.verbose
fprintf('\n\n===== pipeline cMEM\n');
end

%% Retrieve vertex connectivity - needed for clustering
%[OPTIONS, obj.VertConn] = be_vertex_connectivity(HeadModel, OPTIONS); % not necessary for NIRS
% WATCH OUT NIRS tomography FOV is not full mesh, it's part of mesh after
% threshold sensitivity
obj.VertConn = HeadModel.vertex_connectivity; % replaced by this line to retrieve vertex connectivity.
if isempty(OPTIONS.optional.clustering) && isempty(obj.VertConn) || diff(size(obj.VertConn))
fprintf('MEM error : no vertex connectivity matrix available.\n');
return
end

%% ===== Comment ===== %%
OPTIONS.automatic.Comment = OPTIONS.optional.Comment;
if strcmp( OPTIONS.automatic.Comment(1:3), 'MEM' )
OPTIONS.automatic.Comment = ['c' OPTIONS.optional.Comment];
end

%% ===== DC offset ===== %%
% we remove the DC offset the data
%[OPTIONS] = be_remove_dc(OPTIONS);

%% ===== Channels ===== %%
% we retrieve the channels name and the data
[OPTIONS, obj] = be_main_channel(HeadModel, obj, OPTIONS);

%% ===== AVG reference ===== %%
% we average reference the data
%[OPTIONS] = be_avg_reference(OPTIONS);

%% ===== Sources ===== %%
% we verify that all sources in the model have good leadfields
[OPTIONS, obj] = be_main_sources(obj, OPTIONS);

%% ===== Pre-whitening of the data ==== %%
% it uses empty-room data if available
% if PlOS one : nothing is done here
% [OPTIONS] = be_prewhite(OPTIONS);

%% ===== Pre-process the leadfield(s) ==== %%
% we keep leadfields of interest; we compute svd of normalized leadfields

[OPTIONS, obj] = be_main_leadfields(obj, OPTIONS);

%% ===== Normalization ==== %%
% we absorb units (pT, nA) in the data, leadfields; we normalize the data
% and the leadfields
[OPTIONS] = be_normalize_and_units_NIRS(OPTIONS);

%% ===== Apply temporal data window ===== %%
% check for a time segment to be localized
[OPTIONS] = be_apply_window( OPTIONS, [] );

%% ===== Double precision to single ===== %%
% relax the double precision for the msp (leadfield and data)
[OPTIONS] = be_switch_precision( OPTIONS, 'single' );

%% ===== Clusterize cortical surface ===== %%

[OPTIONS, obj] = be_main_clustering(obj, OPTIONS);

%% ===== Single precision to double ===== %%

[OPTIONS] = be_switch_precision( OPTIONS, 'double' );

%% ===== pre-processing for spatial smoothing (Green mat. square) ===== %%
% matrix W'W from the Henson paper
[OPTIONS, obj.GreenM2] = be_spatial_priorw( OPTIONS, obj.VertConn);


%% ===== Noise estimation ===== %%

[OPTIONS, obj] = be_main_data_preprocessing(obj, OPTIONS);

%% ===== Fuse modalities ===== %%

obj = be_fusion_of_modalities( [], obj, OPTIONS);

%% ===== Launch MEM ===== %%

fprintf('\n\n===== pipeline Signel Wavelength\n');
[obj.ImageGridAmp, OPTIONS] = be_launch_mem_NIRS(obj, OPTIONS);

%% ===== Inverse temporal data window ===== %%

[OPTIONS, obj] = be_apply_window( OPTIONS, obj );

% Clean up options
OPTIONS.automatic = struct( 'entropy_drops', OPTIONS.automatic.entropy_drops, ...
'final_alpha', {OPTIONS.automatic.final_alpha}, ...
'Comment', OPTIONS.automatic.Comment, ...
'initial_alpha', obj.ALPHA, ...
'clusters', obj.CLS, ...
'minimum_norm',OPTIONS.automatic.Modality(1).Jmne, ...
'MSP',obj.SCR);

% Results (full temporal sequence)
Results = struct(...
'ImageGridAmp', obj.ImageGridAmp, ...
'ImagingKernel', [], ...
'MEMoptions', OPTIONS); % ...
%'MEMdata', obj);

return




Loading

0 comments on commit 0bb81c7

Please sign in to comment.