From e786b01a07d58ee885f8039801041303d8a2da12 Mon Sep 17 00:00:00 2001 From: rcassani Date: Tue, 6 Aug 2024 14:01:55 -0400 Subject: [PATCH] Channel: Add (S)EEG locations from other Study channel file - Feature for IEEG development - See also: https://neuroimage.usc.edu/forums/t/47486 --- toolbox/tree/tree_callbacks.m | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/toolbox/tree/tree_callbacks.m b/toolbox/tree/tree_callbacks.m index 5aaf790c6..78955ba63 100644 --- a/toolbox/tree/tree_callbacks.m +++ b/toolbox/tree/tree_callbacks.m @@ -2888,6 +2888,36 @@ function fcnPopupImportChannel(bstNodes, jMenu, isAddLoc) jMenu = gui_component('Menu', jMenu, [], 'Add EEG positions', IconLoader.ICON_CHANNEL, [], []); % Import from file gui_component('MenuItem', jMenu, [], 'Import from file', IconLoader.ICON_CHANNEL, [], @(h,ev)channel_add_loc(iAllStudies, [], 1)); + % From other Studies within same Subject + sStudies = bst_get('Study', iAllStudies); + % If adding locations to multiple channel files, they must be from the same subject + if length(unique({sStudies.BrainStormSubject})) == 1 + sSubject = bst_get('Subject', sStudies(1).BrainStormSubject); + if sSubject.UseDefaultChannel == 0 + % Only consider Studies with ChannelFile + [sStudies, iStudies] = bst_get('StudyWithSubject', sSubject.FileName); + iChStudies = ~cellfun(@isempty, {sStudies.Channel}); + sStudies = sStudies(iChStudies); + iStudies = iStudies(iChStudies); + [~, ixDiff] = setdiff(iStudies, iAllStudies); + if ~isempty(ixDiff) + % Create menu and entries + AddSeparator(jMenu); + jMenuStudy = gui_component('Menu', jMenu, [], 'From other studies', IconLoader.ICON_CHANNEL, [], []); + for ix = 1 : length(ixDiff) + conditionName = sStudies(ixDiff(ix)).Condition{1}; + if strcmpi(conditionName(1:4), '@raw') + iconLoader = IconLoader.ICON_RAW_FOLDER_CLOSE; + conditionName(1:4) = ''; + else + iconLoader = IconLoader.ICON_FOLDER_CLOSE; + end + % Menu entry + gui_component('MenuItem', jMenuStudy, [], conditionName, iconLoader, [], @(h,ev)channel_add_loc(iAllStudies, sStudies(ixDiff(ix)).Channel.FileName, 1)); + end + end + end + end % If only SEEG/ECOG, stop here (we do not want to offer the standard EEG caps, it doesn't make sense) if (isAddLoc < 2) return;