Skip to content

Commit

Permalink
additions and bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Treder committed Sep 5, 2012
1 parent e5d7e71 commit 1effb4f
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 35 deletions.
50 changes: 24 additions & 26 deletions markers/mrk_matchStimWithResp.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,37 @@
props= {'MinLatency' 0 '!DOUBLE[1]';
'MaxLatency' inf '!DOUBLE[1]';
'AllowOvershoot' 0 '!DOUBLE[1]';
'MissingresponsePolicy' 'reject' 'CHAR(reject accept)';
'MultiresponsePolicy' 'reject' 'CHAR(reject first last)';
'MissingresponsePolicy' 'reject' '!CHAR(reject accept)';
'MultiresponsePolicy' 'reject' '!CHAR(reject first last)';
'RemoveVoidClasses' 0 '!BOOL';
'Sort' 1 '!BOOL'};

props_selectEvents = mrk_selectEvents;
props_sortChron= mrk_sortChronologically;

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

opt= opt_proplistToStruct(varargin{:});
opt= opt_setDefaults(opt, props);
opt_checkProplist(opt, props);
opt_selectEvents = opt_substruct(opt, props_selectEvents(:,1));
opt_sortChron = opt_substruct(opt, props_sortChron(:,1));

misc_checkType(mrk_stim, 'STRUCT(pos fs)');
misc_checkType(mrk_resp, 'STRUCT(pos fs)');
misc_checkType(mrk_stim, 'STRUCT(time)');
misc_checkType(mrk_resp, 'STRUCT(time)');

stim_msec= [mrk_stim.pos/mrk_stim.fs*1000 inf];
resp_msec= mrk_resp.pos/mrk_resp.fs*1000;
stim_msec= [mrk_stim.time inf];
resp_msec= mrk_resp.time;

k= 0;
istim= [];
iresp= [];
multiple= [];
for ii= 1:length(mrk_stim.pos),
for ii= 1:length(mrk_stim.time),
valid_range(1)= stim_msec(ii) + opt.MinLatency;
if opt.allow_overshoot,
if opt.AllowOvershoot,
valid_range(2)= stim_msec(ii) + opt.MaxLatency;
else
valid_range(2)= min(stim_msec(ii+1), stim_msec(ii)+opt.MaxLatency);
Expand All @@ -72,8 +76,6 @@
ivalidresp= ivalidresp(1);
case 'last',
ivalidresp= ivalidresp(end);
otherwise,
error('unknown choice for multireponse_policy');
end
else
hasmultiresp= 0;
Expand All @@ -90,27 +92,23 @@
end
end

mrk= mrk_chooseEvents(mrk_stim, istim, opt);
mrk= mrk_selectEvents(mrk_stim, istim, opt_selectEvents);
if ~strcmp(opt.MissingresponsePolicy,'reject'),
mrk.missingresponse= isnan(iresp);
mrk= mrk_addIndexedField(mrk, 'missingresponse');
iresp(mrk.missingresponse)= 1;
mrk.event.missingresponse= isnan(iresp);
iresp(mrk.event.missingresponse)= 1;
end
mrk.latency= mrk_resp.pos(iresp)*1000/mrk_resp.fs - mrk.pos*1000/mrk.fs;
mrk.resp_toe= mrk_resp.toe(iresp);
mrk.event.latency= mrk_resp.time(iresp) - mrk.time;
iresp2= iresp;
if isfield(mrk, 'missingresponse') && ~isempty(mrk.missingresponse),
mrk.latency(mrk.missingresponse)= NaN;
mrk.resp_toe(mrk.missingresponse)= NaN;
iresp= iresp(~mrk.missingresponse);
iresp2(mrk.missingresponse)= NaN;
if isfield(mrk, 'missingresponse') && ~isempty(mrk.event.missingresponse),
mrk.latency(mrk.event.missingresponse)= NaN;
iresp= iresp(~mrk.event.missingresponse);
iresp2(mrk.event.missingresponse)= NaN;
end
mrk= mrk_addIndexedField(mrk, {'latency', 'resp_toe'});

if ~strcmpi(opt.MultiresponsePolicy, 'reject'),
mrk.multiresponse= multiple;
mrk= mrk_addIndexedField(mrk, 'multiresponse');
mrk.event.multiresponse= multiple;
end

if opt.Sort,
mrk= mrk_sortChronologically(mrk, opt);
mrk= mrk_sortChronologically(mrk, opt_sortChron);
end
4 changes: 2 additions & 2 deletions markers/mrk_selectEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
% IDX: DOUBLE - Indices of events that are to be selected (or discarded, in the
% second variant with keyword 'not')
% OPT: PROPLIST - Struct or property/value list of optional properties:
% 'Sort' - BOOL: Evokes a call to mrk_sortChronologically.
% 'Sort' - BOOL: Evokes a call to mrk_sortChronologically (default 0).
% 'RemoveVoidClasses' - BOOL: Deletes empty classes (default 1), requires
% MRK to have a field 'y'.

Expand Down Expand Up @@ -53,7 +53,7 @@
end

if isfield(mrk, 'event'),
for Fld= fieldnames(mrk.event),
for Fld= fieldnames(mrk.event)'
fld= Fld{1};
tmp= getfield(mrk.event, fld);
sz= size(tmp);
Expand Down
8 changes: 5 additions & 3 deletions markers/mrk_sortChronologically.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
% Benjamin Blankertz


props= {'Sort', 0 'BOOL'
'RemoveVoidClasses' 1 'BOOL'};
props_selectEvents= mrk_sortChronologically;
props= {'Sort', 0 'BOOL';
'RemoveVoidClasses' 1 'BOOL';
'Classwise' 0 '!BOOL';
};
props_selectEvents= mrk_selectEvents;

if nargin==0,
mrk= opt_catProps(props, props_selectEvents);
Expand Down
2 changes: 1 addition & 1 deletion misc/misc_history.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
return
end

misc_checkType(ob,'STRUCT');
misc_checkType(obj,'STRUCT');

if isfield(obj,'history')
ht = obj.history;
Expand Down
2 changes: 1 addition & 1 deletion misc/opt_setDefaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
% property names in PROPLIST. In the case of a match, the variant of
% PROPSPEC is used.
%
%See also opt_checkProplist, opt_proplist2struct.
%See also opt_checkProplist, opt_proplistToStruct.
%
%Example:
% opt= struct('linewidth',3, 'color','k')
Expand Down
2 changes: 1 addition & 1 deletion visualization/mnt_adaptMontage.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function mnt= mnt_adaptMontage(mnt, varargin);
function mnt= mnt_adaptMontage(mnt, varargin)
%MNT_ADAPTMONTAGE - Adapts an electrode montage to another electrode set
%
%Usage:
Expand Down
2 changes: 1 addition & 1 deletion visualization/plot_barWithAntenna.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

misc_checkType(y,'!DOUBLE[- -]');
misc_checkType(y_sem,'!DOUBLE[- -]');
opt= propertylist2struct(varargin{:});
opt= opt_proplistToStruct(varargin{:});
[opt, isdefault]= opt_setDefaults(opt, props);
opt_checkProplist(opt, props);

Expand Down
11 changes: 11 additions & 0 deletions visualization/private/abr2xyz.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function [x,y,z]= abr2xyz(a,b,r)
%[x,y,z]= abr2xyz(a,b,r)

if nargin<3, r=1; end

a= a*pi/180;
b= b*pi/180;

x= r .* sin(a) .* cos(b);
y= r .* sin(b);
z= r .* cos(a) .* cos(b);
29 changes: 29 additions & 0 deletions visualization/private/getGrid.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function grid= getGrid(displayMontage)
%grid= getGrid(displayMontage)
%
% IN displayMontage - any *.mnt file in EEG_CFG_DIR,
% e.g., 'small', 'medium', 'large',
% or a string defining the montage
%
% OUT grid - 2-d cell array containing the channel labels
%
% GLOBZ EEG_CFG_DIR

global EEG_CFG_DIR;

if ismember(',', displayMontage) || ismember(sprintf('\n'), displayMontage),
readFcn= 'strread';
montage= displayMontage;
else
readFcn= 'textread';
montage= fullfile(EEG_CFG_DIR, [displayMontage '.mnt']);
if ~exist(montage, 'file'),
error(sprintf('unknown montage (checked %s)', ...
montage));
end
end
grid= feval(readFcn, montage, '%s');
width= 1 + sum(grid{1}==',');
grid= cell(1, width);
[grid{:}]= feval(readFcn, montage, repmat('%s',1,width), 'delimiter',',');
grid= [grid{:}];

0 comments on commit 1effb4f

Please sign in to comment.