Skip to content

Commit

Permalink
[enh] set specific default depth-weighting for nirs (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Edouard2laire authored Oct 23, 2024
1 parent 7c561ae commit 31017be
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 20 deletions.
17 changes: 14 additions & 3 deletions best/cmem/solver/be_cmem_pipelineoptions.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
function DEF = be_cmem_pipelineoptions()
function DEF = be_cmem_pipelineoptions(DataTypes)

if nargin < 1 || isempty(DataTypes)
DataTypes = {'EEG'};
end

% clustering
DEF.clustering.clusters_type = 'static';
Expand All @@ -8,8 +12,15 @@
DEF.model.alpha_threshold = 0.0;
DEF.model.active_mean_method = 2;
DEF.model.alpha_method = 3;
DEF.model.depth_weigth_MNE = 0.5;
DEF.model.depth_weigth_MEM = 0.5;

if any(ismember( 'NIRS', DataTypes))
DEF.model.depth_weigth_MNE = 0.3;
DEF.model.depth_weigth_MEM = 0.3;
else
DEF.model.depth_weigth_MNE = 0.5;
DEF.model.depth_weigth_MEM = 0.5;
end


% automatic
DEF.automatic.selected_samples = [];
Expand Down
5 changes: 4 additions & 1 deletion best/rmem/solver/be_rmem_pipelineoptions.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
function DEF = be_rmem_pipelineoptions()
function DEF = be_rmem_pipelineoptions(DataTypes)
if nargin < 1 || isempty(DataTypes)
DataTypes = {'EEG'};
end

% clustering
DEF.clustering.clusters_type = 'blockwise';
Expand Down
16 changes: 13 additions & 3 deletions best/wmem/solver/be_wmem_pipelineoptions.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
function DEF = be_wmem_pipelineoptions()
function DEF = be_wmem_pipelineoptions(DataTypes)

if nargin < 1 || isempty(DataTypes)
DataTypes = {'EEG'};
end

% clustering
DEF.clustering.clusters_type = 'static';
Expand All @@ -9,8 +13,14 @@
DEF.model.alpha_threshold = 0;
DEF.model.active_mean_method = 2;
DEF.model.alpha_method = 6;
DEF.model.depth_weigth_MNE = 0.5;
DEF.model.depth_weigth_MEM = 0.5;

if any(ismember( 'NIRS', DataTypes))
DEF.model.depth_weigth_MNE = 0.3;
DEF.model.depth_weigth_MEM = 0.3;
else
DEF.model.depth_weigth_MNE = 0.5;
DEF.model.depth_weigth_MEM = 0.5;
end

% wavelet processing
DEF.wavelet.type = 'rdw';
Expand Down
11 changes: 6 additions & 5 deletions gui/be_main.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
end

% ==== CALL THE PACKAGE ==== %
if nargout==1
if nargout == 1
% No calculations, just options
Results = be_main_call(varargin{:});
varargout{1} = Results;
Expand All @@ -62,7 +62,7 @@
varargout{2} = OPTIONS;
end

return
end


% ----------------------------------------------------------------------- %
Expand Down Expand Up @@ -145,8 +145,9 @@
Def_OPTIONS.model.alpha_method = 3;
Def_OPTIONS.model.alpha_threshold = 0;
Def_OPTIONS.model.initial_lambda = 1;
Def_OPTIONS.model.depth_weigth_MNE = 0;
Def_OPTIONS.model.depth_weigth_MEM = 0;

Def_OPTIONS.model.depth_weigth_MNE = 0.5;
Def_OPTIONS.model.depth_weigth_MEM = 0.5;

% MEM solver
Def_OPTIONS.solver.NoiseCov = [];
Expand All @@ -159,5 +160,5 @@
Def_OPTIONS.solver.covariance_scale = 1;
Def_OPTIONS.solver.parallel_matlab = be_canUseParallelPool();

return
end

17 changes: 9 additions & 8 deletions gui/panel_brainentropy.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
SUBJ = cellfun( @(a) strrep( bst_fileparts( bst_fileparts( a ) ), filesep, '' ), DTS, 'uni', 0 );
[dum,STD] = cellfun( @(a) bst_get('Study', fullfile( bst_fileparts(a), 'brainstormstudy.mat' ) ), DTS, 'uni', 0 );
STD = cell2mat( STD );


ChannelTypes = inputData.ChannelTypes;
OPTIONS = OPTIONS.options.mem.Value;

if isfield(OPTIONS,'MEMpaneloptions') && ~isempty(OPTIONS.MEMpaneloptions)
Expand All @@ -75,17 +76,17 @@
[st,is] = bst_get('Study', fullfile( bst_fileparts(DTS{ii}), 'brainstormstudy.mat' ) );
STD = [STD is];
end

ChannelTypes = {};
OPTIONS = be_main();
else
% Unexpected call
fprintf('\n\n***\tError in call to panel_brainentropy\t***\n\tPlease report this bug to: [email protected]\n\n')
return
end

OPTIONS = be_struct_copy_fields(OPTIONS,be_cmem_pipelineoptions,[],0);
OPTIONS = be_struct_copy_fields(OPTIONS,be_wmem_pipelineoptions,[],0);
OPTIONS = be_struct_copy_fields(OPTIONS, be_rmem_pipelineoptions,[],0);
OPTIONS = be_struct_copy_fields(OPTIONS,be_cmem_pipelineoptions(ChannelTypes),[],0);
OPTIONS = be_struct_copy_fields(OPTIONS,be_wmem_pipelineoptions(ChannelTypes),[],0);
OPTIONS = be_struct_copy_fields(OPTIONS, be_rmem_pipelineoptions(ChannelTypes),[],0);

% Version
OPTIONS.automatic.version = '3.0.0';
Expand Down Expand Up @@ -1178,11 +1179,11 @@ function SwitchPipeline(varargin)
if any(selected)

if strcmp(choices(selected), 'cMEM')
NEW_OPTIONS = be_struct_copy_fields(OPTIONS, be_cmem_pipelineoptions,[],1);
NEW_OPTIONS = be_struct_copy_fields(OPTIONS, be_cmem_pipelineoptions(ChannelTypes),[],1);
elseif strcmp(choices(selected), 'wMEM')
NEW_OPTIONS = be_struct_copy_fields(OPTIONS, be_wmem_pipelineoptions,[],1);
NEW_OPTIONS = be_struct_copy_fields(OPTIONS, be_wmem_pipelineoptions(ChannelTypes),[],1);
elseif strcmp(choices(selected), 'rMEM')
NEW_OPTIONS = be_struct_copy_fields(OPTIONS, be_rmem_pipelineoptions,[],1);
NEW_OPTIONS = be_struct_copy_fields(OPTIONS, be_rmem_pipelineoptions(ChannelTypes),[],1);
end

%% Save options while changing the pipeline
Expand Down

0 comments on commit 31017be

Please sign in to comment.