Skip to content

Commit

Permalink
modifications to make demo_analysis_ERD work
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminBlankertz committed Aug 20, 2012
1 parent afc1806 commit 024eaea
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 70 deletions.
62 changes: 62 additions & 0 deletions demos/demo_analysis_ERD.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
file= 'Pavel_01_11_23/selfpaced2sPavel';

%% Load data
hdr= file_readBVheader(file);
Wps= [42 49]/hdr.fs*2;
[n, Ws]= cheb2ord(Wps(1), Wps(2), 3, 40);
[filt.b, filt.a]= cheby2(n, 50, Ws);
[cnt, mrk_orig]= file_readBV([file '*'], 'Fs',100, 'Filt',filt, ...
'Clab', {'not','E*'});

%% Marker struct
stimDef= {[65 70], [74 192];
'left','right'};
mrk= mrk_defineClasses(mrk_orig, stimDef);

%% Electrode Montage
grd= sprintf(['scale,_,F3,Fz,F4,_,legend\n' ...
'FC5,FC3,FC1,FCz,FC2,FC4,FC6\n' ...
'C5,C3,C1,Cz,C2,C4,C6\n' ...
'CP5,CP3,CP1,CPz,CP2,CP4,CP6']);
mnt= get_electrodePositions(cnt.clab);
mnt= mnt_setGrid(mnt, grd);

colOrder= [245 159 0; 0 150 200]/255;
ival_erd= [-1000 500];
band_erd= [11 14];
ival_scalps= -800:200:200;

% Bandpass to the frequency band of interest
[b,a]= butter(5, band_erd/cnt.fs*2);
cnt= proc_filt(cnt, b, a);

% Artifact rejection based on variance criterion
mrk= reject_varEventsAndChannels(cnt, mrk, ival_erd, ...
'DoBandpass', 0, ...
'Verbose', 1);

epo= proc_segmentation(cnt, mrk, ival_erd);
erd_lar= proc_localAverageReference(epo, mnt, 'Radius',0.4);
erd_lar= proc_envelope(erd_lar, 'MovAvgMsec', 200);
erd_lar= proc_baseline(erd_lar, [], 'trialwise', 0);
erd= proc_envelope(epo, 'MovAvgMsec', 200);
erd= proc_baseline(erd, [], 'trialwise', 0);
erd_lar_r= proc_rSquareSigned(erd_lar);
erd_r= proc_rSquareSigned(erd);

fig_set(1)
H= grid_plot(erd, mnt, defopt_erps, 'colorOrder',colOrder);
grid_addBars(erd_r, 'HScale',H.scale);
fig_set(5)
H= grid_plot(erd_lar, mnt, defopt_erps, 'colorOrder',colOrder);
grid_addBars(erd_lar_r, 'HScale',H.scale);

fig_set(2);
H= plot_scalpEvolutionPlusChannel(erd, mnt, clab, ival_scalps, ...
defopt_scalp_erp, ...
'ExtrapolateToMean', 1, ...
'ColorOrder',colOrder);
grid_addBars(erd_r);

fig_set(4, 'shrink',[1 2/3]);
plot_scalpEvolutionPlusChannel(erd_r, mnt, clab, ival_scalps, defopt_scalp_r);
41 changes: 21 additions & 20 deletions processing/proc_envelope.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,44 @@
% added channelwise option by Claudia
% 07-2012 Johannes Hoehne - Updated documentation and parameter naming

props= {'envelopMethod' 'hilbert'
'movAvgMethod' 'centered'
'movAvgMilisec' 100
'movAvgOpts' {}
'channelwise' false};
props= {'envelopMethod' 'hilbert' '!CHAR(hilbert)'
'movAvgMethod' 'centered' '!CHAR'
'movAvgMsec' 100 'DOUBLE[1]'
'movAvgOpts' {} 'CELL'
'channelwise' false 'BOOL'};

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

if length(varargin)==1,
opt= struct('appendix', varargin{1});
else
opt= propertylist2struct(varargin{:});
opt= opt_proplistToStruct(varargin{:});
end

[opt, isdefault]= opt_setDefaults(opt, props);
opt_checkProplist(opt, props);

sz= size(dat.x);
switch(lower(opt.envelopMethod)),
case 'hilbert',
if opt.channelwise
for ch = 1:sz(2)
x(:,ch,:) = abs(hilbert(squeeze(dat.x(:,ch,:))));
end
dat.x = x;
else
dat.x= abs(hilbert(dat.x(:,:)));
dat.x= reshape(dat.x, sz);
end

if opt.channelwise
for ch = 1:sz(2)
x(:,ch,:) = abs(hilbert(squeeze(dat.x(:,ch,:))));
end
dat.x = x;
else
dat.x= abs(hilbert(dat.x(:,:)));
dat.x= reshape(dat.x, sz);
end
otherwise,
error('unknown envelop method');
end

if ~isempty(opt.movAvgOpts),
dat= proc_movingAverage(dat, opt.movAvgMilisec, opt.movAvgOpts{:});
elseif ~isempty(opt.movAvgMilisec) & opt.movAvgMilisec>0,
dat= proc_movingAverage(dat, opt.movAvgMilisec, opt.movAvgMethod);
dat= proc_movingAverage(dat, opt.movAvgMsec, opt.movAvgOpts{:});
elseif ~isempty(opt.movAvgMsec) && opt.movAvgMsec>0,
dat= proc_movingAverage(dat, opt.movAvgMsec, opt.movAvgMethod);
end
1 change: 0 additions & 1 deletion processing/proc_rSquareSigned.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
%
% SEE proc_TTest, proc_rValues, proc_rSquare

% bb 03/2003, ida.first.fhg.de

if length(varargin)>0 & isstruct(varargin{1}),
fv2= varargin{1};
Expand Down
33 changes: 16 additions & 17 deletions visualization/utils/defopt_scalp_erp.m
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
function opt= defopt_scalp_erp(varargin)

props= {'Shading','interp', ...
'Extrapolation',1, ...
'ExtrapolateToMean',0, ...
'Resolution', 71, ...
'CLim','sym', ...
'ShrinkColorbar', 0.2, ...
'Colormap',jet(51), ...
'Contour',5, ...
'LineWidth', 2, ...
'ChannelLineStyleOrder', {'thick','thin'}, ...
'IvalColor', [0.8 0.8 0.8; 0.6 0.6 0.6], ...
'ContourPolicy', 'strict', ...
'ContourLineprop', {'LineWidth',0.3}, ...
'MarkMarkerProperties', {'MarkerSize',6, 'LineWidth',1}, ...
'GlobalCLim',1, ...
'Renderer', 'contourf', ...
'LegendPos','NorthWest'};
props= {'Shading' 'flat'
'Extrapolation' 1
'ExtrapolateToMean' 0
'Resolution' 71
'CLim' 'sym'
'ShrinkColorbar' 0.2
'Colormap' jet(51)
'Contour' 5
'LineWidth' 2
'ChannelLineStyleOrder' {'thick' 'thin'}
'IvalColor' [0.8 0.8 0.8; 0.6 0.6 0.6]
'ContourPolicy' 'strict'
'ContourLineprop' {'LineWidth' 0.3}
'MarkMarkerProperties' {'MarkerSize' 6, 'LineWidth' 1}
'GlobalCLim' 1
'LegendPos' 'NorthWest'};

opt= opt_proplistToStruct(varargin{:});
opt= opt_setDefaults(opt, props);
30 changes: 15 additions & 15 deletions visualization/utils/defopt_scalp_power.m
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
function opt= defopt_scalp_power(varargin)

props= {'Shading', 'flat';
'Extrapolation', 1;
'ExtrapolateToMean', 0;
'Resolution', 61;
'CLim', 'range';
'IvalColor', [0.8 0.8 0.8; 0.6 0.6 0.6];
'LineWidth', 2;
'ChannelLineStyleOrder', {'thick','thin'};
'Colormap', cmap_hsvFade(51, [4/6 0], 1, 1);
'Contour', 5;
'ContourPolicy', 'strict';
'ContourLineprop', {'LineWidth',0.3};
'MarkMarkerProperties', {'MarkerSize',6, 'LineWidth',1};
'GlobalCLim', 1;
'LegendPos', 'NorthEast'};
props= {'Shading' 'flat'
'Extrapolation' 1
'ExtrapolateToMean' 0
'Resolution' 61
'CLim' 'range'
'IvalColor' [0.8 0.8 0.8; 0.6 0.6 0.6]
'LineWidth' 2
'ChannelLineStyleOrder' {'thick' 'thin'}
'Colormap' cmap_hsvFade(51, [4/6 0], 1, 1)
'Contour' 5
'ContourPolicy' 'strict'
'ContourLineprop' {'LineWidth' 0.3}
'MarkMarkerProperties' {'MarkerSize' 6, 'LineWidth' 1}
'GlobalCLim' 1
'LegendPos' 'NorthEast'};

opt= opt_proplistToStruct(varargin{:});
opt= opt_setDefaults(opt, props);
34 changes: 17 additions & 17 deletions visualization/utils/defopt_scalp_r.m
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
function opt= defopt_scalp_r(varargin)

props= {'Extrapolation', 1;
'ExtrapolateToMean', 0;
'Resolution', 71;
'CLim', 'sym';
'ShrinkColorbar', 0.2;
'ColorOrder', [0 0 0];
'Colormap', cmap_posneg(51);
'LineWidth', 2;
'ChannelLineStyleOrder', {'thick','thin'};
'IvalColor', [0.8 0.8 0.8; 0.6 0.6 0.6];
'Contour', 5;
'ContourPolicy', 'withinrange';
'ContourLineprop', {'LineWidth',0.3};
'MarkMarkerProperties', {'MarkerSize',6, 'LineWidth',1};
'ChannelAtBottom', 1;
'GlobalCLim', 1;
'LegendPos', 'NorthWest'};
props= {'Extrapolation' 1
'ExtrapolateToMean' 0
'Resolution' 71
'CLim' 'sym'
'ShrinkColorbar' 0.2
'ColorOrder' [0 0 0]
'Colormap' cmap_posneg(51)
'LineWidth' 2
'ChannelLineStyleOrder' {'thick' 'thin'}
'IvalColor' [0.8 0.8 0.8; 0.6 0.6 0.6]
'Contour' 5
'ContourPolicy' 'withinrange'
'ContourLineprop' {'LineWidth' 0.3}
'MarkMarkerProperties' {'MarkerSize' 6, 'LineWidth' 1}
'ChannelAtBottom' 1
'GlobalCLim' 1
'LegendPos' 'NorthWest'};

opt= opt_proplistToStruct(varargin{:});
opt= opt_setDefaults(opt, props);

0 comments on commit 024eaea

Please sign in to comment.