Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
branelab committed Nov 10, 2021
1 parent 645f104 commit d88d3fe
Show file tree
Hide file tree
Showing 12 changed files with 494 additions and 0 deletions.
77 changes: 77 additions & 0 deletions Untitled.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

%% INFANT Anatomy
load('C:\BRANELab\matlab_progs\general_progs\EEG_sim\SimSignals_GUI\anatomy\ANATOMY_DEFAULT_BRANELab_EEG_BioSemi_66ch_MRIvolume_1yr_infant.mat');

a=fieldnames(anatomy);
for k=1:length(a)
eval(sprintf('%s = anatomy.%s;',a{k},a{k}))
end
save('C:\BRANELab\matlab_progs\general_progs\EEG_sim\SimSignals_GUI\anatomy\ANATOMY_DEFAULT_BRANELab_MEEG_1yr_infant.mat','mri', 'vol', 'elec', 'please_read', 'pial_mesh', 'sens_adult_dewar', 'sens_infant_dewar', 'sens_adult_dewar_supine', 'mesh_hd', 'bnd', 'elec_good', 'chan_idx', 'vol_leadfield', 'mesh_sourcemodel', 'mesh_leadfield', 'leadfield', 'vol2', 'vx_locs', 'eeg_vol_leadfield', 'vol_infant_dewar', 'vol_adult_dewar', 'vol_adult_dewar_supine', 'meg_vol_leadfield', 'vol_eeg');

% adult dewar sitting
anatomy.sens_adult_dewar.coilori = anatomy.sens_adult_dewar.coilori(1:size(anatomy.sens_adult_dewar.label,1),:);
anatomy.sens_adult_dewar.coilpos = anatomy.sens_adult_dewar.coilpos(1:size(anatomy.sens_adult_dewar.label,1),:);
anatomy.sens_adult_dewar.tra = anatomy.sens_adult_dewar.tra(1:size(anatomy.sens_adult_dewar.label,1),1:size(anatomy.sens_adult_dewar.label,1));
% adult dewar supine
anatomy.sens_adult_dewar_supine.coilori = anatomy.sens_adult_dewar_supine.coilori(1:size(anatomy.sens_adult_dewar_supine.label,1),:);
anatomy.sens_adult_dewar_supine.coilpos = anatomy.sens_adult_dewar_supine.coilpos(1:size(anatomy.sens_adult_dewar_supine.label,1),:);
anatomy.sens_adult_dewar_supine.tra = anatomy.sens_adult_dewar_supine.tra(1:size(anatomy.sens_adult_dewar_supine.label,1),1:size(anatomy.sens_adult_dewar_supine.label,1));
% infant dewar
anatomy.sens_infant_dewar.coilori = anatomy.sens_infant_dewar.coilori(1:size(anatomy.sens_infant_dewar.label,1),:);
anatomy.sens_infant_dewar.coilpos = anatomy.sens_infant_dewar.coilpos(1:size(anatomy.sens_infant_dewar.label,1),:);
anatomy.sens_infant_dewar.tra = anatomy.sens_infant_dewar.tra(1:size(anatomy.sens_infant_dewar.label,1),1:size(anatomy.sens_infant_dewar.label,1));


%% ADULT Anatomy
sens_adult = anatomy.sens_adult_dewar; % first load in infant anatomy above
anatomy2 = load('C:\BRANELab\matlab_progs\general_progs\EEG_sim\SimSignals_GUI\anatomy\ANATOMY_DEFAULT_Biosemi_72ch_Tujillo.mat');
% % re-aligning sensors to adult dewar <-- but no need to do this because they were already aligned
% cfg = [];
% cfg.method = 'interactive';
% cfg.elec = sens_adult;
% % cfg.channel = sens_idx;
% cfg.headshape = anatomy_adult.scalp.bnd(1);
% sens_aligned = ft_electroderealign(cfg,sens_adult);
anatomy2.sens_adult=sens_adult;
a=fieldnames(anatomy2);
for k=1:length(a)
eval(sprintf('%s = anatomy2.%s;',a{k},a{k}))
end
save('C:\BRANELab\matlab_progs\general_progs\EEG_sim\SimSignals_GUI\anatomy\ANATOMY_DEFAULT_MEEG_adult_Tujillo.mat','mri', 'vol', 'elec', 'please_read', 'pial_mesh', 'sens_adult_dewar', 'sens_infant_dewar', 'sens_adult_dewar_supine', 'mesh_hd', 'bnd', 'elec_good', 'chan_idx', 'vol_leadfield', 'mesh_sourcemodel', 'mesh_leadfield', 'leadfield', 'vol2', 'vx_locs', 'eeg_vol_leadfield', 'vol_infant_dewar', 'vol_adult_dewar', 'vol_adult_dewar_supine', 'meg_vol_leadfield', 'vol_eeg');


%% Plot anatomy
figure(1); clf;

% Infant adult dewar supine
subplot(2,2,1); cla;
ft_plot_mesh(anatomy.vol.bnd(3),'facecolor',[1 .6 .4]*.75,'edgecolor',[1 .6 .4]*.85,'facealpha',.4,'edgealpha',.4);
ft_plot_mesh(anatomy.pial_mesh,'facecolor',[1 1 1]*.8,'edgecolor','none','facealpha',1,'edgealpha',1);
ft_plot_sens(anatomy.sens_adult_dewar_supine,'label','off', 'chantype','meg','edgecolor','k'); %,'label','off');
ft_plot_sens(anatomy.elec,'label','off', 'chantype','eeg','facecolor','b','edgecolor','b'); %,'label','off');
view(-90,0); c=camlight; lighting gouraud; material dull; axis tight; p_axis = [get(gca,'XLim') get(gca,'YLim')];

% Infant adult dewar sitting
subplot(2,2,2); cla;
ft_plot_mesh(anatomy.vol.bnd(3),'facecolor',[1 .6 .4]*.75,'edgecolor',[1 .6 .4]*.85,'facealpha',.4,'edgealpha',.4);
ft_plot_mesh(anatomy.pial_mesh,'facecolor',[1 1 1]*.8,'edgecolor','none','facealpha',1,'edgealpha',1);
ft_plot_sens(anatomy.sens_adult_dewar,'label','off', 'chantype','meg','edgecolor','k'); %,'label','off');
ft_plot_sens(anatomy.elec,'label','off', 'chantype','eeg','facecolor','b','edgecolor','b'); %,'label','off');
view(-90,0); c=camlight; lighting gouraud; material dull; axis tight; %axis( p_axis )

% Infant infant dewar
subplot(2,2,3); cla;
ft_plot_mesh(anatomy.vol.bnd(3),'facecolor',[1 .6 .4]*.75,'edgecolor',[1 .6 .4]*.85,'facealpha',.4,'edgealpha',.4);
ft_plot_mesh(anatomy.pial_mesh,'facecolor',[1 1 1]*.8,'edgecolor','none','facealpha',1,'edgealpha',1);
ft_plot_sens(anatomy.sens_infant_dewar,'label','off', 'chantype','meg','edgecolor','k'); %,'label','off');
ft_plot_sens(anatomy.elec,'label','off', 'chantype','eeg','facecolor','b','edgecolor','b'); %,'label','off');
view(-90,0); c=camlight; lighting gouraud; material dull; axis( p_axis )

% Adult dewar
subplot(2,2,4); cla;
ft_plot_mesh(anatomy2.scalp.bnd,'facecolor',[1 .6 .4]*.75,'edgecolor',[1 .6 .4]*.85,'facealpha',.4,'edgealpha',.4);
ft_plot_mesh(anatomy2.pial_mesh,'facecolor',[1 1 1]*.8,'edgecolor','none','facealpha',1,'edgealpha',1);
ft_plot_sens(anatomy2.sens_adult,'label','off', 'chantype','meg','edgecolor','k'); %,'label','off');
ft_plot_sens(anatomy2.elec,'label','off', 'chantype','eeg','facecolor','b','edgecolor','b'); %,'label','off');
view(-90,0); c=camlight; lighting gouraud; material dull; axis tight

16 changes: 16 additions & 0 deletions Untitled2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@



sens_data = h.sim_data.sens_noise_final;
% sens_data = h.sim_data.sens_sig_data;
leadfield = h.inv_soln(h.current_inv_soln).leadfield;

vx_idx = h.sim_data.cfg.source.vx_idx;
source_ori = h.sim_data.cfg.source.vx_ori;
%% conversion factor needed for EEG because Field Trips lead fields appear to be different than in Brainstorm (openmeeg) --> Not sure why this is?
% adjustment needed by user to get reasonable 150-200 fT for 35-40 nA dipoles in audiotry cortices like in Herdman et al., 2003 NeuroImage dataset
lf_gain = str2num(h.edit_leadfield_gain.String);
source_data = project_inverse_SimSignals(sens_data,leadfield,vx_idx,source_ori,lf_gain);

figure(2); clf; plot(squeeze(nanmean(h.sim_data.sig_final,3)),'k','linewidth',2); hold on; plot(squeeze(nanmean(source_data(:,:,:),3)));

22 changes: 22 additions & 0 deletions Untitled3.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@




peak_tfr = h.current_inv_peak_fc_data;
true_tfr = h.current_inv_true_fc_data;
act_samps = h.inv_soln(h.current_inv_soln).params.act_samps;
peak_tfr(abs(peak_tfr)>0)=10; % values of 10 = significant index; 0 = not significant
true_tfr(abs(true_tfr)>0)=5; % values of 5 = significant index; 0 = not significant


diff_tfr = peak_tfr-true_tfr;
hit_tfr = nan(size(diff_tfr)); hit_tfr(diff_tfr==5)=1;
miss_tfr = nan(size(diff_tfr)); miss_tfr(diff_tfr== -5) = 1;
fa_tfr = nan(size(diff_tfr)); fa_tfr(diff_tfr== 10) = 1;
cr_tfr = nan(size(diff_tfr)); cr_tfr(diff_tfr== 0) = 1;


num_peak_sig = squeeze(nansum(nansum(peak_tfr(:,:,act_samps),3),1));
num_true_sig = squeeze(nansum(nansum(true_tfr(:,:,act_samps),3),1));


153 changes: 153 additions & 0 deletions WinOnTop.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
function wasOnTop = WinOnTop( figureHandle, isOnTop )
%WINONTOP allows to trigger figure's "Always On Top" state
%
%% INPUT ARGUMENTS:
%
% # figureHandle - Matlab's figure handle, scalar
% # isOnTop - logical scalar or empty array
%
%
%% USAGE:
%
% * WinOnTop( hfigure, true ); - switch on "always on top"
% * WinOnTop( hfigure, false ); - switch off "always on top"
% * WinOnTop( hfigure ); - equal to WinOnTop( hfigure,true);
% * WinOnTop(); - equal to WinOnTop( gcf, true);
% * WasOnTop = WinOnTop(...); - returns boolean value "if figure WAS on top"
% * isOnTop = WinOnTop(hfigure,[]) - get "if figure is on top" property
%
% For Matlab windows, created via `hf=uifigure()` use `uifigureOnTop()`, see:
% https://www.mathworks.com/matlabcentral/fileexchange/73134-uifigureontop
%
%% LIMITATIONS:
%
% * java enabled
% * figure must be visible
% * figure's "WindowStyle" should be "normal"
% * figureHandle should not be casted to double, if using HG2 (R2014b+)
%
%
% Written by Igor
% [email protected]
%
% 2013.06.16 - Initial version
% 2013.06.27 - removed custom "ishandle_scalar" function call
% 2015.04.17 - adapted for changes in matlab graphics system (since R2014b)
% 2016.05.21 - another ishg2() checking mechanism
% 2016.09.24 - fixed IsOnTop vs isOnTop bug
% 2019.10.27 - link for uifigureOnTop; connected to github; renamed to "demo_"
%
% Copyright (c) 2016, Igor
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
%
% * Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
% * Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in
% the documentation and/or other materials provided with the distribution
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.



%% Parse Inputs

if ~exist('figureHandle','var'); figureHandle = gcf; end

assert(...
isscalar( figureHandle ) &&...
ishandle( figureHandle ) &&...
strcmp(get(figureHandle,'Type'),'figure'),...
...
'WinOnTop:Bad_figureHandle_input',...
'%s','Provided figureHandle input is not a figure handle'...
);

assert(...
strcmp('on',get(figureHandle,'Visible')),...
'WinOnTop:FigInisible',...
'%s','Figure Must be Visible'...
);

assert(...
strcmp('normal',get(figureHandle,'WindowStyle')),...
'WinOnTop:FigWrongWindowStyle',...
'%s','WindowStyle Must be Normal'...
);

if ~exist('isOnTop','var'); isOnTop=true; end

assert(...
islogical( isOnTop ) && ...
isscalar( isOnTop ) || ...
isempty( isOnTop ), ...
...
'WinOnTop:Bad_isOnTop_input',...
'%s','Provided isOnTop input is neither boolean, nor empty'...
);


%% Pre-checks

error(javachk('swing',mfilename)) % Swing components must be available.


%% Action

% Flush the Event Queue of Graphic Objects and Update the Figure Window.
drawnow expose

warnStruct=warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
jFrame = get(handle(figureHandle),'JavaFrame');
warning(warnStruct.state,'MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');

drawnow


if ishg2(figureHandle)
jFrame_fHGxClient = jFrame.fHG2Client;
else
jFrame_fHGxClient = jFrame.fHG1Client;
end


wasOnTop = jFrame_fHGxClient.getWindow.isAlwaysOnTop;

if ~isempty(isOnTop)
jFrame_fHGxClient.getWindow.setAlwaysOnTop(isOnTop);
end

end


function tf = ishg2(figureHandle)
% There's a detailed discussion, how to check "if using HG2" here:
% http://www.mathworks.com/matlabcentral/answers/136834-determine-if-using-hg2
% however, it looks like there's no perfect solution.
%
% This approach, suggested by Cris Luengo:
% http://www.mathworks.com/matlabcentral/answers/136834#answer_156739
% should work OK, assuming user is NOT passing a figure handle, casted to
% double, like this:
%
% hf=figure();
% WinOnTop(double(hf));
%

tf = isa(figureHandle,'matlab.ui.Figure');

end
Binary file added terms_use.mat
Binary file not shown.
21 changes: 21 additions & 0 deletions toggle_light_OnOff_Callback.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function toggle_light_OnOff_Callback(varargin)
global h

axes(h.axes_3D_images);

if h.toggle_light_OnOff.Value == 0 % off
% lighting off;
delete(findall(gca,'Type','light'));
h.toggle_light_OnOff.ForegroundColor = [1 0 0]; h.toggle_light_OnOff.BackgroundColor = [1 1 1]*.9;
h.toggle_light_OnOff.String = 'Light Off';

elseif h.toggle_light_OnOff.Value == 1
delete(findall(gca,'Type','light'))
% if ~isvalid(h.camlight)
h.camlight1 = camlight;
h.camlight2 = camlight; % double camlight to make it brighter
lighting gouraud; material dull;
% end
h.toggle_light_OnOff.ForegroundColor = [0 .6 0]; h.toggle_light_OnOff.BackgroundColor = [1 1 1];
h.toggle_light_OnOff.String = 'Light On';
end
21 changes: 21 additions & 0 deletions toggle_light_OnOff_axes_anatomy.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function toggle_light_OnOff_axes_anatomy(varargin)
global h

axes(h.axes_anatomy);

if h.toggle_light_OnOff_anat.Value == 0 % off
% lighting off;
delete(findall(gca,'Type','light'));
h.toggle_light_OnOff_anat.ForegroundColor = [1 0 0]; h.toggle_light_OnOff_anat.BackgroundColor = [1 1 1]*.9;
h.toggle_light_OnOff_anat.String = 'Light Off';

elseif h.toggle_light_OnOff_anat.Value == 1
delete(findall(gca,'Type','light'))
% if ~isvalid(h.camlight)
h.camlight1 = camlight;
h.camlight2 = camlight; % double camlight to make it brighter
lighting gouraud; material dull;
% end
h.toggle_light_OnOff_anat.ForegroundColor = [0 .6 0]; h.toggle_light_OnOff_anat.BackgroundColor = [1 1 1];
h.toggle_light_OnOff_anat.String = 'Light On';
end
14 changes: 14 additions & 0 deletions toggle_peak_locs.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function toggle_peak_locs(varargin)
global h

h.map3D_peak_ori = handle(h.map3D_peak_ori);
if h.radio_3D_peak_locs.Value == 1
h.map3D_peak_locs(1).Visible = 'on'; %h.map3D_peak_locs(2).Visible = 'on';
h.map3D_peak_locs(2).Visible = 'on'; %h.map3D_peak_locs(2).Visible = 'on';
for v=1:length(h.map3D_peak_ori); h.map3D_peak_ori(v).Visible='on'; end
elseif h.radio_3D_peak_locs.Value == 0
h.map3D_peak_locs(1).Visible = 'off'; %h.map3D_peak_locs(2).Visible = 'off';
h.map3D_peak_locs(2).Visible = 'off'; %h.map3D_peak_locs(2).Visible = 'off';
for v=1:length(h.map3D_peak_ori); h.map3D_peak_ori(v).Visible='off'; end
end
bs_plot_peak_waves;
10 changes: 10 additions & 0 deletions toggle_true_locs.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function toggle_true_locs(varargin)
global h
for v=1:3
if h.radio_3D_true_locs.Value == 1
set(handle(h.map3D_true_locs(1,v)),'Visible','on'); set(handle(h.map3D_true_locs(2,v)),'Visible','on');
elseif h.radio_3D_true_locs.Value == 0
set(handle(h.map3D_true_locs(1,v)),'Visible','off'); set(handle(h.map3D_true_locs(2,v)),'Visible','off');
end
end
bs_plot_peak_waves;
Loading

0 comments on commit d88d3fe

Please sign in to comment.