Skip to content

Commit

Permalink
various updates on visualization functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Schultze-Kraft committed Feb 20, 2014
1 parent e5175c8 commit 7547251
Show file tree
Hide file tree
Showing 32 changed files with 145 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
cnt_cfy= struct('fs',1/mean(diff(time)), 'x',cfy, ...
'clab', {{sprintf('cfy %s vs %s', calib.result.classes{:})}});
epo_cfy= proc_segmentation(cnt_cfy, calib.mrk, [0 5000]);
fig_set(1, 'Name','classifier output', 'clf',1);
fig_set(1, 'Name','classifier output', 'Clf',1);
plot_channel(epo_cfy);

BTB= BTB_memo;
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@
cnt_cfy_EEG= struct('fs', 1/mean(diff(time(idx_EEG))), ...
'x', cfy(idx_EEG), 'clab',{{'cfy-EEG'}});
epo_cfy_EEG= proc_segmentation(cnt_cfy_EEG, mrk_cfy, [-5000 15000]);
fig_set(1, 'Name','EEG classifier output', 'clf',1);
fig_set(1, 'Name','EEG classifier output', 'Clf',1);
plot_channel(epo_cfy_EEG);

cnt_cfy_NIRS= struct('fs', 1/mean(diff(time(idx_NIRS))), ...
'x', cfy(idx_NIRS), 'clab',{{'cfy-NIRS'}});
epo_cfy_NIRS= proc_segmentation(cnt_cfy_NIRS, mrk_cfy, [-5000 15000]);
fig_set(2, 'Name','NIRS classifier output', 'clf',1);
fig_set(2, 'Name','NIRS classifier output', 'Clf',1);
plot_channel(epo_cfy_NIRS);

BTB= BTB_memo;
Expand Down
4 changes: 2 additions & 2 deletions online/demos/demo_bbcionline_calibrate_and_apply_NIRS.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
cnt_cfy= struct('fs', 1/mean(diff(time)), 'x',cfy, ...
'clab', {{sprintf('cfy %s vs %s', calib.result.classes{:})}});
epo_cfy= proc_segmentation(cnt_cfy, calib.mrk, [-10000 20000]);
fig_set(1, 'Name','classifier output', 'clf',1);
fig_set(1, 'Name','classifier output', 'Clf',1);
plot_channel(epo_cfy);

epo_auc= proc_aucValues(epo_cfy);
fig_set(2, 'clf',1, 'Name','AUC of classifier outputs');
fig_set(2, 'Clf',1, 'Name','AUC of classifier outputs');
plot_channel(epo_auc);

% The
3 changes: 3 additions & 0 deletions visualization/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
%
%MNT_ADAPTMONTAGE - Adapts an electrode montage to another electrode set
%MNT_RESTRICTMONTAGE - Restrict an electrode montage to a subset of channels
%MNT_RESTRICTNIRSMONTAGE - restrict a NIRS montage to a subset of channels
%MNT_GETNIRSMONTAGE - Get montage with NIRS channel positions
%MNT_SCALPTOGRID - Montage for grid plot with boxes at scalp locations
%MNT_SETELECTRODEPOSITIONS - Electrode positions of standard named channels
%MNT_SETGRID - Define a new eletrode grid layout for an electrode montage
Expand All @@ -31,6 +33,7 @@
%PLOT_SCALPLOADING - Visualize single channel loadings of a weight vector
%PLOT_SCALPOUTLINE - Schematic sketch of the scalp
%PLOT_SCALPPATTERN - Display average trials as scalp topography
%PLOT_CSPANALYSIS - Show CSP filters and patterns as topographies
%PLOT_SCOREMATRIX - Visualizes score matrix of e.g. r-values


19 changes: 1 addition & 18 deletions visualization/grid_addBars.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@
[opt, isdefault]= opt_setDefaults(opt, props);
opt_checkProplist(opt, props);

% If figure is already inVisible jvm_* functions should not be called
fig_Visible = strcmp(get(gcf,'Visible'),'on');
if fig_Visible
jvm= jvm_hideFig;
end

if ~ismatrix(fv.x),
error('only one Class allowed');
end
Expand Down Expand Up @@ -124,10 +118,6 @@
opt.Colormap(iswhite,:)= 0.9999*[1 1 1];
end
H.image= 'sorry: fakeimage - no handle';
% if ~isempty(opt.HScale),
% warning('sorry, no Colorbar in local colormap mode (so far)');
% opt.HScale= [];
% end
else
set(gcf, 'colormap',opt.Colormap);
end
Expand Down Expand Up @@ -218,15 +208,14 @@
fv.x(fv.x < opt.CLim(1)) = opt.CLim(1);
image_localColormap(fv.x(:,ci)', opt.Colormap, 'CLim',opt.CLim);
else
% H.image(jj)= image(fv.t, 1, fv.x(:,ci)', 'cDataMapping','scaled');
H.image(jj)= image(fv.x(:,ci)', 'cDataMapping','scaled');
end
set(H.ax(jj), AxesStyle{:});
ud= struct('type','ERP plus: bar', 'chan', str_vec2str(fv.clab(ci)));
set(H.ax(jj), 'userData',ud);
hold off;
if strcmp(get(H.ax(jj), 'box'), 'on'),
h= axis_redrawFrame(H.ax(jj), 'LineWidth',0.3);
h= axis_redrawFrame(H.ax(jj), 0.3);
if jj==1,
H.frame= h;
else
Expand All @@ -235,7 +224,6 @@
end
end
if diff(opt.CLim)==0, opt.CLim(2)= opt.CLim(2)+eps; end
%set(H.ax, 'xLim',fv.t([1 end]), 'xTick',[], 'yTick',[], 'CLim',opt.CLim);
set(H.ax, 'xLim',[0.5 size(fv.x,1)+0.5], 'xTick',[], 'yTick',[], ...
'CLim',opt.CLim);

Expand Down Expand Up @@ -279,11 +267,6 @@
end
end


if nargout==0,
clear H;
end

if fig_Visible
jvm_restoreFig(jvm, opt);
end
4 changes: 2 additions & 2 deletions visualization/grid_markInterval.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
k= 0;
for ih= hsp,
k= k+1;
axis_getQuitely(ih); %% this lets the legend vanish behind the axis
axis_getQuietly(ih); %% this lets the legend vanish behind the axis
yPatch= get(ih, 'yLim');
H.line(:,k)= line(ival([1 2; 1 2]), yPatch([1 1; 2 2]), ...
'Color',0.5*markCol, 'LineWidth',0.3);
Expand All @@ -51,7 +51,7 @@
end
set(H.line, 'UserData','ival line');
set(H.patch, 'EdgeColor','none', 'UserData','ival patch');
axis_getQuitely(old_ax);
axis_getQuietly(old_ax);
if isfield(get(old_ax,'UserData'),'hleg') & ...
~isnan(getfield(get(old_ax,'UserData'), 'hleg')),
legend;
Expand Down
12 changes: 9 additions & 3 deletions visualization/grid_markTimePoint.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
%GRID_MARKTIMEPOINT - Draw a time point inside grid plots as a vertical
%line
%
%grid_markTimePoint(tp, <chans, Linespec>)
%Synposis:
% H= grid_markTimePoint(TP, <CHANS, LINESPEC>)
%
%Input:
% TP: time point [msec]
% CHANS: channels which should be marked, default [] meaning all
% TP: time point [msec]
% CHANS: channels which should be marked, default [] meaning all
% LINESPEC: property/value list defining specifications for drawing the
% line
%
%Output:
% H: handle to line object

if ~exist('chans','var'), chans=[]; end

Expand Down
26 changes: 3 additions & 23 deletions visualization/grid_plot.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@
[opt, isdefault]= opt_setDefaults(opt, props);
opt_checkProplist(opt, props, props_channel, props_addScale);

% fig_Visible = strcmp(get(gcf,'Visible'),'on'); % If figure is already inVisible jvm_* functions should not be called
% if fig_Visible
% jvm= jvm_hideFig;
% end

if nargin<2 || isempty(mnt),
mnt= struct('clab',{epo.clab});
else
Expand Down Expand Up @@ -240,25 +235,19 @@
DisplayChannels= intersect(DisplayChannels, find(~isnan(mnt.box(1,1:end-1))),'legacy');
end
nDisps= length(DisplayChannels);
% mnt.clab{DisplayChannels(ii)} may differ from epo.clab{ii}, e.g. the former
% may be 'C3' while the latter is 'C3 lap'
idx= util_chanind(epo, mnt.clab(DisplayChannels));
axestitle= epo.clab(idx);

%w_cm= warning('query', 'bci:missing_channels');
%warning('off', 'bci:missing_channels');
%all_idx= 1:length(mnt.clab);
yLim= zeros(length(opt.ScaleGroup), 2);
for ig= 1:length(opt.ScaleGroup),
ax_idx= util_chanind(mnt.clab(DisplayChannels), opt.ScaleGroup{ig});
if isempty(ax_idx), continue; end
% ch_idx= find(ismember(all_idx, ax_idx));
ch_idx= util_chanind(epo, mnt.clab(DisplayChannels(ax_idx)));
if isnumeric(opt.ScalePolicy{ig}),
yLim(ig,:)= opt.ScalePolicy{ig};
else
dd= epo.x(:,ch_idx,:);
% idx= find(~isinf(dd(:)));
idx= find(abs(dd(:))<opt.ScaleUpperLimit & ...
abs(dd(:))>=opt.ScaleLowerLimit);
yl= [nanmin(dd(idx)) nanmax(dd(idx))];
Expand All @@ -283,12 +272,8 @@
yLim(ig,:)= [-1 1];
end
if ig==1 && length(ax_idx)>1,
% scale_with_group1= setdiff(1:nDisps, util_chanind(mnt.clab(DisplayChannels), ...
% [opt.ScaleGroup{2:end}]));
% set(H.ax(scale_with_group1), 'yLim',yLim(ig,:));
ch2group= ones(1,nDisps);
else
% set(H.ax(ax_idx), 'yLim',yLim(ig,:));
ch2group(ax_idx)= ig;
for ia= ax_idx,
if max(abs(yLim(ig,:)))>=100,
Expand Down Expand Up @@ -321,7 +306,6 @@
end
end
end
%warning(w_cm);

H.ax= zeros(1, nDisps);
opt_plot= {'Legend',1, 'Title','', 'UnitDispPolicy','none', ...
Expand All @@ -335,9 +319,9 @@
ic= DisplayChannels(ia);
if ~isempty(opt.Axes),
H.ax(ia)= opt.Axes(ic);
axis_getQuitely(H.ax(ia));
axis_getQuietly(H.ax(ia));
else
H.ax(ia)= axis_getQuitely('position', gridutil_getAxisPos(mnt, ic));
H.ax(ia)= axis_getQuietly('position', gridutil_getAxisPos(mnt, ic));
end
cchan = plot_channel(epo, mnt.clab{ic}, opt_channel, opt_plot{:}, ...
'YLim', yLim(ch2group(ia),:), ...
Expand Down Expand Up @@ -413,7 +397,7 @@
end

if ~isempty(opt.ShiftAxesUp) && opt.ShiftAxesUp~=0,
axis_shiftUp(opt.ShiftAxesUp);
gridutil_shiftAxesUp(opt.ShiftAxesUp);
end

if opt.HeadMode,
Expand All @@ -430,7 +414,3 @@
if nargout==0,
clear H;
end

% if fig_Visible
% jvm_restoreFig(jvm);
% end
2 changes: 1 addition & 1 deletion visualization/image_localColormap.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function image_localColormap(C, cmap, varargin)
opt_checkProplist(opt, props);

[sy,sx]= size(C);
if isdefault.Optimize & sx==1,
if isdefault.Optimize && sx==1,
opt.Optimize= 'columns';
end

Expand Down
30 changes: 15 additions & 15 deletions visualization/mnt_getNIRSMontage.m
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
function mnt = mnt_getNIRSMontage(varargin)
%MNT_GETNIRSMONTAGE - get montage with NIRS channel positions for a given set
% of sources and detectors. NIRS channels are placed half-way
% between a source and a detector on a spherical head model.
%MNT_GETNIRSMONTAGE - Get montage with NIRS channel positions
%
%Description:
% get montage with NIRS channel positions for a given set of sources and
% detectors. NIRS channels are placed half-way between a source and a
% detector on a spherical head model.
%
%Synopsis:
% MNT = nirs_getMontage(CLABSOURCE,CLABDETECTOR,<OPT>)
% If you give channels labels of the source and detectors (should
% correspond to EEG channel labels), montages for source and
% detectors are produced, as well as montages for the
% source-detector combinations.
% MNT = nirs_getMontage(CLABSOURCE,CLABDETECTOR,<OPT>)
% If you give channels labels of the source and detectors (should
% correspond to EEG channel labels), montages for source and
% detectors are produced, as well as montages for the
% source-detector combinations.
%
% MNT = nirs_getMontage(MNT,<OPT>)
% You can provide a montage struct wherein source and detector
% montages are already given in .source and .detector fields.
% In this case, only the source-detector combinations are determined.
% MNT = nirs_getMontage(MNT,<OPT>)
% You can provide a montage struct wherein source and detector
% montages are already given in .source and .detector fields.
% In this case, only the source-detector combinations are determined.
%
%Input
% OPT: struct or property/value list of optional properties:
Expand All @@ -40,13 +43,11 @@
% .detector - struct with montage for the detectors
%
%See also: setElectrodeMontage, nirs_reduceMontage
%

% [email protected] 2011
% Markus Wenzel 2013 (adapted it to the new toolbox)
% Jan Mehnert February 2014 (ready for public BBCI toolbox) ([email protected])


props= {'ClabPolicy' 'label' 'CHAR'
'Projection' 'euclidean' 'CHAR'
'PositionFcn' @mntutil_posExt55 'FUNC'
Expand Down Expand Up @@ -78,7 +79,6 @@
mnt.source = mnt_setElectrodePositions(clabSource, 'PositionFcn', opt.PositionFcn);
mnt.detector = mnt_setElectrodePositions(clabDetector, 'PositionFcn', opt.PositionFcn);
end


if any(isnan(mnt.source.pos_3d(:))) || any(isnan(mnt.detector.pos_3d(:)))
warning(['Some source/detector positions are NaN. Note that the NIRS channels '...
Expand Down
20 changes: 10 additions & 10 deletions visualization/mnt_restrictMontage.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
%MNT_RESTRICTMONTAGE - Restrict an electrode montage to a subset of channels.
%
%Synposis:
% mnt= mnt_restrictMontage(MNT, CHANS);
% mnt= mnt_restrictMontage(MNT, DAT);
% mnt= mnt_restrictMontage(MNT, CHANS);
% mnt= mnt_restrictMontage(MNT, DAT);
%
%Input:
% MNT: display montage, see setElectrodeMontage, setDisplayMontage
% CHANS: channels, format as accepted by util_chanind
% DAT: structure which has a field 'clab', such as cnt, epo, ...
% MNT: display montage, see setElectrodeMontage, setDisplayMontage
% CHANS: channels, format as accepted by util_chanind
% DAT: structure which has a field 'clab', such as cnt, epo, ...
%
%Output:
% MNT: updated display montage
% MNT: updated display montage
%
%Example:
% [cnt, mrk, mnt]= loadProcessedEEG('Gabriel_00_09_05/selfpaced2sGabriel');
% cnt_lap= proc_laplace(cnt);
% mnt= mnt_restrictMontage(mnt, cnt_lap);
% plotScalpPattern(mnt, cnt_lap.x(10000,:));
% [cnt, mrk, mnt]= loadProcessedEEG('Gabriel_00_09_05/selfpaced2sGabriel');
% cnt_lap= proc_laplace(cnt);
% mnt= mnt_restrictMontage(mnt, cnt_lap);
% plotScalpPattern(mnt, cnt_lap.x(10000,:));

if nargin==2 && isstruct(varargin{1}),
if isfield(varargin{1}, 'clab'),
Expand Down
20 changes: 11 additions & 9 deletions visualization/mnt_restrictNIRSMontage.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
function mnt = mnt_restrictNIRSMontage(mnt,varargin)
%MNT_RESTRICTNIRSMONTAGE - restricts the NIRS montage by selecting (a)
% specified NIRS channels and/or (b) sources or detectors and
% keeping only the corresponding NIRS channels AND/OR (c) keeping only
% informative NIRS channels (ie channels corresponding to a relatively
% small source-detector distance).
%MNT_RESTRICTNIRSMONTAGE - restrict a NIRS montage to a subset of channels
%
%Descpription:
% Restricts the NIRS montage by selecting (a) specified NIRS channels
% and/or (b) sources or detectors and keeping only the corresponding NIRS
% channels and/or (c) keeping only informative NIRS channels (i.e. channels
% corresponding to a relatively small source-detector distance).
%
%Synopsis:
% MNT = mnt_restrictNIRSMontage(MNT, CHANS, <OPT>)
Expand Down Expand Up @@ -36,8 +38,8 @@
%Output:
% MNT: updated montage
%
%Note: Use proc_selectChannels to reduce the NIRS data (cnt,dat,epo)
% according to the new montage.
%Note: Use proc_selectChannels to reduce the NIRS data (cnt, dat, epo)
% according to the new montage.
%
%See also: mnt_restrictMontage

Expand All @@ -50,7 +52,8 @@
'Detector' {} 'CHAR|CELL{CHAR}'
'RemoveOptodes' 1 'BOOL'
'HeadRadius' 10 'DOUBLE'
'Dist' 3.5 'DOUBLE'};
'Dist' 3.5 'DOUBLE'
};

if nargin==0,
mnt= props; return
Expand All @@ -74,7 +77,6 @@
opt_checkProplist(opt, props);
misc_checkType(mnt, 'STRUCT');


if ischar(opt.Source)
opt.Source = {opt.Source};
end
Expand Down
2 changes: 1 addition & 1 deletion visualization/plot_barWithAntenna.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
};

if nargin==0,
dat= props; return
H= props; return
end

misc_checkType(y,'!DOUBLE[- -]');
Expand Down
Loading

0 comments on commit 7547251

Please sign in to comment.