Skip to content

Commit

Permalink
converted to new toolbox convention, i.e. type checking and new optio…
Browse files Browse the repository at this point in the history
…nal argument structure. Proper commenting is still missing though...
  • Loading branch information
Sven Daehne committed Sep 19, 2012
1 parent 09dea7f commit 9e5f8f6
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions visualization/utils/visutil_correctIvalsForDisplay.m
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
function ival= visutil_correctIvalsForDisplay(ival, varargin)

if length(varargin)==1,
varargin= {'fs', varargin{1}};
varargin= {'Fs', varargin{1}};
end
opt= propertylist2struct(varargin{:});
opt= set_defaults(opt, ...
'fs', 100, ...
'sort', 1, ...
'only_point_intervals', 0);

if opt.sort,
misc_checkType(ival,'DOUBLE[- 2]');

props= {'Fs' 100 'DOUBLE[1]'
'Sort' 1 'BOOL'
'OnlyPointIntervals' 0 'BOOL' };

opt= opt_proplistToStruct(varargin{:});
[opt, isdefault]= opt_setDefaults(opt, props);
opt_checkProplist(opt, props);


if opt.Sort,
[so,si]= sort(ival(:,1));
ival= ival(si,:);
end

if opt.only_point_intervals,
if opt.OnlyPointIntervals,
to_be_checked= find(diff(ival, 1, 2)==0)';
else
to_be_checked= 1:size(ival, 1);
end

for ii= to_be_checked,
if ii==1 | ival(ii-1,2)<ival(ii,1),
ival(ii,1)= ival(ii,1) - 1000/opt.fs/2;
ival(ii,1)= ival(ii,1) - 1000/opt.Fs/2;
end
if ii==size(ival,1) | ival(ii,2)<ival(ii+1,2),
ival(ii,2)= ival(ii,2) + 1000/opt.fs/2;
ival(ii,2)= ival(ii,2) + 1000/opt.Fs/2;
end
end

0 comments on commit 9e5f8f6

Please sign in to comment.