Skip to content

Commit

Permalink
Clusters: Save clusters in channel file, load automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
ftadel committed Jan 16, 2023
1 parent 8f26feb commit 8403a86
Show file tree
Hide file tree
Showing 17 changed files with 411 additions and 290 deletions.
1 change: 1 addition & 0 deletions doc/updates.txt
Expand Up @@ -4,6 +4,7 @@ January 2023
- Distrib: Enable compilation on Linux and MacOS
- IO: Export matrix files as EDF+
- Inverse: Display scouts on source-level PSD as PSD figures
- Clusters: Save clusters in channel file, load automatically
--------------------------------------------------------------
November 2022
- Forward: Display leadfield sensitivity (surface, MRI, isosurface)
Expand Down
15 changes: 10 additions & 5 deletions toolbox/core/bst_figures.m
Expand Up @@ -53,7 +53,7 @@
% For more information type "brainstorm license" at command prompt.
% =============================================================================@
%
% Authors: Francois Tadel, 2008-2021
% Authors: Francois Tadel, 2008-2023
% Martin Cousineau, 2017

eval(macro_method);
Expand Down Expand Up @@ -1073,10 +1073,12 @@ function SetCurrentFigure(hFig, Type)
panel_record('CurrentFigureChanged_Callback', hFig);
% Update tab: Display (for raster plots/erpimage)
panel_display('UpdatePanel', hFig);
% FigureId = getappdata(hFig, 'FigureId');
% if ~isempty(FigureId) && isequal(FigureId.SubType, 'erpimage')
% panel_display('UpdatePanel', hFig);
% end
% Update list of clusters
if ~isempty(hFig) && ~isequal(oldFigType, hFig)
if gui_brainstorm('isTabVisible', 'Cluster')
panel_cluster('CurrentFigureChanged_Callback', hFig);
end
end
case 'Type3D'
% Only when figure changed (within the figure type)
if ~isempty(hFig) && ~isequal(oldFigType, hFig)
Expand All @@ -1094,6 +1096,9 @@ function SetCurrentFigure(hFig, Type)
if gui_brainstorm('isTabVisible', 'iEEG')
panel_ieeg('CurrentFigureChanged_Callback', hFig);
end
if gui_brainstorm('isTabVisible', 'Cluster')
panel_cluster('CurrentFigureChanged_Callback', hFig);
end
end
case 'TypeTF'
% Only when figure changed (whatever the type of the figure is)
Expand Down
12 changes: 7 additions & 5 deletions toolbox/core/bst_memory.m
Expand Up @@ -67,7 +67,7 @@
% For more information type "brainstorm license" at command prompt.
% =============================================================================@
%
% Authors: Francois Tadel, 2008-2022
% Authors: Francois Tadel, 2008-2023
% Martin Cousineau, 2019

eval(macro_method);
Expand Down Expand Up @@ -556,6 +556,7 @@ function LoadChannelFile(iDS, ChannelFile)
% Save in DataSet structure
GlobalData.DataSet(iDS).ChannelFile = file_win2unix(ChannelFile);
GlobalData.DataSet(iDS).Channel = ChannelMat.Channel;
GlobalData.DataSet(iDS).Clusters = ChannelMat.Clusters;
GlobalData.DataSet(iDS).IntraElectrodes = ChannelMat.IntraElectrodes;
GlobalData.DataSet(iDS).MegRefCoef = ChannelMat.MegRefCoef;
GlobalData.DataSet(iDS).Projector = ChannelMat.Projector;
Expand All @@ -582,8 +583,9 @@ function LoadChannelFile(iDS, ChannelFile)
GlobalData.DataSet(iDS).Channel(i).Loc = [0;0;0];
GlobalData.DataSet(iDS).Channel(i).Type = 'EEG';
end
GlobalData.DataSet(iDS).MegRefCoef = [];
GlobalData.DataSet(iDS).Projector = [];
GlobalData.DataSet(iDS).MegRefCoef = [];
GlobalData.DataSet(iDS).Projector = [];
GlobalData.DataSet(iDS).Clusters = [];
GlobalData.DataSet(iDS).IntraElectrodes = [];
end
end
Expand Down Expand Up @@ -3204,8 +3206,6 @@ function CheckFrequencies()
% Get next surface
panel_scout('SetCurrentSurface', CurrentSurface);
end
% Unload clusters
panel_cluster('RemoveAllClusters');
end
% Empty the clipboard
bst_set('Clipboard', []);
Expand Down Expand Up @@ -3264,6 +3264,7 @@ function CheckFrequencies()
gui_hide('Stat');
gui_hide('iEEG');
gui_hide('Spikes');
gui_hide('Cluster');
end
if isNewProgress
bst_progress('stop');
Expand Down Expand Up @@ -3529,6 +3530,7 @@ function SaveChannelFile(iDS)
% Get modified fields
ChannelMat.Channel = GlobalData.DataSet(iDS).Channel;
ChannelMat.IntraElectrodes = GlobalData.DataSet(iDS).IntraElectrodes;
ChannelMat.Clusters = GlobalData.DataSet(iDS).Clusters;
% History: Edit channel file
ChannelMat = bst_history('add', ChannelMat, 'edit', 'Edited manually');
% Save file
Expand Down
3 changes: 2 additions & 1 deletion toolbox/core/bst_navigator.m
Expand Up @@ -395,8 +395,9 @@ function DbNavigation( action, iDataSets )
% Load new channel file
ChannelMat = in_bst_channel(newChannelFile);
GlobalData.DataSet(iDS).Channel = ChannelMat.Channel;
GlobalData.DataSet(iDS).MegRefCoef = ChannelMat.MegRefCoef;
GlobalData.DataSet(iDS).MegRefCoef = ChannelMat.MegRefCoef;
GlobalData.DataSet(iDS).Projector = ChannelMat.Projector;
GlobalData.DataSet(iDS).Clusters = ChannelMat.Clusters;
GlobalData.DataSet(iDS).IntraElectrodes = ChannelMat.IntraElectrodes;
end
end
Expand Down
6 changes: 4 additions & 2 deletions toolbox/db/db_template.m
Expand Up @@ -21,7 +21,7 @@
% For more information type "brainstorm license" at command prompt.
% =============================================================================@
%
% Authors: Francois Tadel, 2008-2022
% Authors: Francois Tadel, 2008-2023


switch lower(structureName)
Expand Down Expand Up @@ -235,6 +235,7 @@
'Label', [], ...
'Type', []), ...
'Channel', [], ... % [nChannels] Structure array, one structure per sensor
'Clusters', [], ...
'IntraElectrodes', [], ...
'History', []);

Expand Down Expand Up @@ -751,6 +752,7 @@
'Channel', repmat(db_template('ChannelDesc'), 0), ...
'MegRefCoef', [], ...
'Projector', repmat(db_template('Projector'), 0), ...
'Clusters', repmat(db_template('Cluster'), 0), ...
'IntraElectrodes', repmat(db_template('IntraElectrode'), 0), ...
'isChannelModified', 0, ...
'HeadPoints', [], ...
Expand Down Expand Up @@ -867,6 +869,7 @@
template = struct(...
'Sensors', '', ... % File on which the scout is defined
'Label', '', ... % Comment
'Color', [], ... % [1x3] RGB values between 0 and 1
'Function', 'Mean'); % Cluster function: PCA, FastPCA, Mean, Max, Power, All

case 'globaldata'
Expand Down Expand Up @@ -951,7 +954,6 @@
'hButtonTransY', [], ...
'hButtonTransZ', [], ...
'hButtonResize', [])), ...
'Clusters', repmat(db_template('Cluster'), 0), ...
'CurrentFigure', struct(...
'Type3D', [], ...
'Type2D', [], ...
Expand Down
2 changes: 2 additions & 0 deletions toolbox/gui/gui_brainstorm.m
Expand Up @@ -1190,6 +1190,8 @@ function ShowToolTab(tabTitle)
panel_surface('UpdatePanel');
case 'iEEG'
panel_ieeg('UpdatePanel');
case 'Cluster'
panel_cluster('UpdatePanel');
end
% Select tab
SetSelectedTab(tabTitle, 0);
Expand Down

0 comments on commit 8403a86

Please sign in to comment.