Skip to content

Commit

Permalink
numerical improvements and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminBlankertz committed Feb 15, 2014
1 parent 15f131f commit ca638f6
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 32 deletions.
6 changes: 4 additions & 2 deletions acquisition/stimulation/stimutil_cueArrows.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
props= {'cross' 0 '!DOUBLE[1]'
};
props_drawArrow= stimutil_drawArrow;
all_props= opt_catProps(props, props_drawArrow);

if nargin==0,
H= opt_catProps(props, props_drawArrow);
H= all_props;
return
end

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

for dd= 1:length(dirs),
if dd<length(dirs),
Expand Down
8 changes: 4 additions & 4 deletions fileio/file_readBV.m
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@
if nargout>1,
opt_mrk= opt_substruct(opt, props_readBVmarkers(:,1));
curmrk= file_readBVmarkers(fileNames{filePos}, opt_mrk);
curmrk.time= curmrk.time + dataOffset/cnt.fs*1000;
curmrk.time= curmrk.time + dataOffset*1000/cnt.fs;
% find markers in the loaded interval
inival= find(curmrk.time > skip/cnt.fs*1000 & ...
curmrk.time <= (skip+maxlen)/cnt.fs*1000);
inival= find(curmrk.time > skip*1000/cnt.fs & ...
curmrk.time <= (skip+maxlen)*1000/cnt.fs);
curmrk= mrk_selectEvents(curmrk, inival);
%let the markers start at zero
curmrk.time= curmrk.time - skip/cnt.fs*1000;
curmrk.time= curmrk.time - skip*1000/cnt.fs;

if firstFileToRead == filePos
mrk = curmrk;
Expand Down
2 changes: 1 addition & 1 deletion fileio/file_readBVmarkers.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
ii= strmatch([keyword '='], s);
fs= 1000000/sscanf(s{ii}, [keyword '=%f']);

Mrk.time= pos'/fs*1000;
Mrk.time= pos'*1000/fs;
% Round time to micro seconds
% Mrk.time= round(Mrk.time*1000)/1000;

Expand Down
2 changes: 1 addition & 1 deletion fileio/file_readNIRx.m
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
for f = file
[cnt, mrk,dum,mnt]= file_readNIRx(f{:}, varargin{:});
% T = [T size(cnt.x,1)]; % Alte Toolbox sample-basiert
T = [T size(cnt.x,1)/cnt.fs*1000];
T = [T size(cnt.x,1)*1000/cnt.fs];
if strcmp(f{:},file{1})
ccnt= cnt;
cmrk= mrk;
Expand Down
11 changes: 4 additions & 7 deletions fileio/file_readNIRxMarker.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@

% Clear opt.Path if mrkName contains absolute path (= starts with '/')
if fileutil_isAbsolutePath(mrkName),
opt.Path=[]; isdefault.Path=0;
opt.Path=[];
isdefault.Path=0;
end

opt_checkProplist(opt, props);
Expand All @@ -65,17 +66,13 @@
% Remove \t's, flip bits and convert to decimal
desc = apply_cellwise(s{2},inline('bin2dec(fliplr(strrep(x,sprintf(''\t''),'''')))','x'))';
desc = apply_cellwise(desc,inline('sprintf(''%s%d'',y,x) ','x','y'),opt.Prefix);

% mrk.pos = pos; % new toolbox is not sample, but time based


% get sampling frequency
hdr=file_readNIRxHeader(fullName);
mrk.time= pos/hdr.fs*1000;
mrk.time= pos*1000/hdr.fs;

mrk.event.desc = desc';
end

%mrk.pos = double(mrk.pos);
mrk.time = double(mrk.time);

% New. Avoids errors in mrk_defineClasses. Adapted from file_readBVmarkers.
Expand Down
4 changes: 3 additions & 1 deletion misc/opt_substruct.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
% Let us be gracious:
if ischar(fld_list),
fld_list= {fld_list};
elseif iscell(fld_list) && ismember(size(fld_list,2), [2 3]),
fld_list= fld_list(:,1);
end

fldS= fieldnames(S);
[dmy, dmy, fld_idx]= intersect(lower(fld_list), lower(fldS),'legacy');
[dmy, dmy, fld_idx]= intersect(lower(fld_list), lower(fldS), 'legacy');
fld_list= fldS(fld_idx);

T= [];
Expand Down
4 changes: 2 additions & 2 deletions online/acquisition/bbci_acquire_offline.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
state.cnt= cnt;

if isfield(mrk, 'event') && isfield(mrk.event, 'desc'),
mrk.desc= mrk.event.desc;
mrk.desc= mrk.event.desc(:)';
else
mrk.desc= repmat({'dmy'}, size(mrk.time));
[dmy, mrk.desc]= max(mrk.y);
end
% --
state.mrk= mrk;
Expand Down
6 changes: 3 additions & 3 deletions online/acquisition/bbci_acquire_randomSignals.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
state= opt_setDefaults(state, props, 1);
state.nChannels= length(state.clab);
state.blocksize_sa= ceil(state.blocksize*state.fs/1000);
state.blocksize= state.blocksize_sa/state.fs*1000;
state.blocksize= state.blocksize_sa*1000/state.fs;
state.nsamples= 0;
state.start_time= tic;
output= {state};
Expand Down Expand Up @@ -94,15 +94,15 @@
packet= receive_udp(sock);
if ~isempty(packet),
% we don't know the marker position within the block -> set randomly
mrkTime= ceil(state.blocksize_sa*rand)/state.fs*1000;
mrkTime= ceil(state.blocksize_sa*rand)*1000/state.fs;
mrkDesc= str2int(packet); % -> check format
else
mrkTime= [];
mrkDesc= [];
end
case 'global',
if ~isempty(ACQ_MARKER),
mrkTime= ceil(state.blocksize_sa*rand)/state.fs*1000;
mrkTime= ceil(state.blocksize_sa*rand)*1000/state.fs;
mrkDesc= ACQ_MARKER;
ACQ_MARKER= [];
else
Expand Down
2 changes: 1 addition & 1 deletion online/apply_functions/bbci_apply_setDefaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
'trigger_param' {} 'CELL'
};
end
bbci.feedback(k).opt= opt_setDefaults('bbci.feedback(k).opt', props);
bbci.feedback(k).opt= opt_setDefaults(bbci.feedback(k).opt, props);
end


Expand Down
6 changes: 4 additions & 2 deletions online/bbci_calibrate.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
data.log= bbci_log_open(BC.log);

% Log info about calibration files and BBCI settings
bbci_log_write(data, '#Calibration files from folder <%s>:', BC.folder);
folder= fileparts(data.filename);
bbci_log_write(data, '#Calibration files from folder <%s>:', folder);
file_counter= 1;
for k= 1:length(data.fileinfo),
for f= 1:length(data.fileinfo{k}),
msg= sprintf('File %d: %s <%s>, size %d', file_counter, data.fileinfo{k}(f).name, ...
msg= sprintf('File %d: %s <%s>, size %d', file_counter, ...
data.fileinfo{k}(f).name, ...
data.fileinfo{k}(f).date, data.fileinfo{k}(f).bytes);
bbci_log_write(data, ['#' msg]);
file_counter= file_counter + 1;
Expand Down
3 changes: 2 additions & 1 deletion online/feedback/bbci_feedback_cursor_init.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
'FontUnits','normalized', opt.msg_spec{:}, fast_text{:});
set(H.msg_punch, opt.points_spec{:});

[H.cue, H.fixation]= stimutil_cueArrows(opt.classes, opt, ...
opt_cueArrows= opt_substruct(opt, stimutil_cueArrows);
[H.cue, H.fixation]= stimutil_cueArrows(opt.classes, opt_cueArrows, ...
'cross',1, ...
'cross_size',0.75, ...
'cross_width', 0.075);
Expand Down
12 changes: 7 additions & 5 deletions startup_bbci_toolbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ function startup_bbci_toolbox(varargin)
};
[BTB, isdefault]= opt_setDefaults(BTB, props);

private_folders_to_add= {'utils', 'startup'};
for kk= 1:length(private_folders_to_add),
folder= fullfile(BTB.PrivateDir, private_folders_to_add{kk});
if exist(folder, 'dir'),
addpath(genpath(folder));
if exist(BTB.PrivateDir, 'dir'),
private_folders_to_add= {'utils', 'startup'};
for kk= 1:length(private_folders_to_add),
folder= fullfile(BTB.PrivateDir, private_folders_to_add{kk});
if exist(folder, 'dir'),
addpath(genpath(folder));
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions transitional/convert_markers.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

mrk= rmfield(mrk_old, {'pos','fs'});

mrk.time= mrk_old.pos/mrk_old.fs*1000;
mrk.time= mrk_old.pos*1000/mrk_old.fs;
mrk.event= struct;
if isfield(mrk_old, 'toe'),
mrk.event.desc= mrk_old.toe(:);
mrk= rmfield(mrk, {'toe'});
end

mrk.event= struct;
if isfield(mrk, 'indexedByEpochs'),
mrk= rmfield(mrk, mrk.indexedByEpochs);
mrk= rmfield(mrk, 'indexedByEpochs');
Expand Down

0 comments on commit ca638f6

Please sign in to comment.