Skip to content

Commit

Permalink
Fixed some inconsistencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminBlankertz committed Feb 13, 2014
1 parent f4d104f commit c2c138f
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 89 deletions.
18 changes: 9 additions & 9 deletions PRELIMINARY/file_NIRSreadMatlab.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
mnt=make_NIRSmnt;


if ~ismember('*', filename,'legacy')
if ~ismember('*', filename)

load(filename)
cnt.x=ni.dat;
cnt.fs=ni.sf;
cnt.clab=mnt.clab;
cnt.title=filename;
mrk.time=ni.mrk(:,1)'/cnt.fs*1000;
mrk.desc=ni.mrk(:,2)';
mrk.event.desc=ni.mrk(:,2)';
mrk.className={'left','right'};
mrk.y=zeros(2,size(mrk.desc,2));
mrk.y(1,:)=mrk.desc==1;
mrk.y(2,:)=mrk.desc==2;
mrk.y=zeros(2,size(mrk.event.desc,2));
mrk.y(1,:)=mrk.event.desc==1;
mrk.y(2,:)=mrk.event.desc==2;
disp(sprintf('%s loaded',filename))
else
load(filename(1:end-1))
Expand All @@ -27,11 +27,11 @@
cnt1.clab=mnt.clab;
cnt1.title=[filename(1:end-1) '02.mat']
mrk1.time=ni.mrk(:,1)'/cnt1.fs*1000;
mrk1.desc=ni.mrk(:,2)';
mrk1.event.desc=ni.mrk(:,2)';
mrk1.className={'left','right'};
mrk1.y=zeros(2,size(mrk1.desc,2));
mrk1.y(1,:)=mrk1.desc==1;
mrk1.y(2,:)=mrk1.desc==2;
mrk1.y=zeros(2,size(mrk1.event.desc,2));
mrk1.y(1,:)=mrk1.event.desc==1;
mrk1.y(2,:)=mrk1.event.desc==2;

load([filename(1:end-1) '02.mat'])
cnt2.x=ni.dat;
Expand Down
3 changes: 3 additions & 0 deletions classification/applyClassifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@


fv= proc_flaten(fv);
if ~isfield(C, 'applyFcn'),
C.applyFcn= @apply_separatingHyperplane;
end

if ~exist('idx','var'),
out= C.applyFcn(C, fv.x);
Expand Down
14 changes: 7 additions & 7 deletions fileio/file_loadMatlab.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
error('more output arguments than requested variables');
end

props = {'Path', BTB.MatDir 'CHAR';
'Vars', vars(1:nargout) 'CELL{CHAR}|CHAR';
'CLab' '*' 'CHAR|CELL{CHAR}';
'Ival' [] 'DOUBLE[2]';
'Fs' [] 'DOUBLE[1]';
props = {'Path', BTB.MatDir 'CHAR';
'Vars', vars(1:nargout) 'CELL{CHAR}|CHAR';
'CLab' '*' 'CHAR|CELL{CHAR}';
'Ival' [] 'DOUBLE[2]';
'Fs' [] 'DOUBLE[1]';
};

misc_checkType(file,'!CHAR');
Expand All @@ -93,7 +93,7 @@
return;
end

fullname= [opt.Path filesep file];
fullname= fullfile(opt.Path, file);
if fileutil_isAbsolutePath(file),
if ~isdefault.Path,
warning('opt.Path is ignored, since file is given with absolute path');
Expand All @@ -105,7 +105,7 @@

% keyboard

if ismember('*', file,'legacy'),
if ismember('*', file),
[filepath, filename]= fileparts(fullname);
dd= dir(filepath);
resr= regexp({dd.name}, filename);
Expand Down
4 changes: 2 additions & 2 deletions fileio/file_writeBVmarkers.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ function file_writeBVmarkers(file, mrk, varargin)
elseif length(mrk)==1
for im = 1:length(mrk.type)
fprintf(fid, ['Mk%d=%s,%s,%u,%u,%u,%s' 13 10], im, ...
mrk.type{im}, mrk.desc{im}, mrk.pos(im), ...
mrk.type{im}, mrk.event.desc{im}, mrk.pos(im), ...
mrk.length(im), mrk.chan(im), mrk.time{im});
end
else
for im= 1:length(mrk),
fprintf(fid, ['Mk%d=%s,%s,%u,%u,%u,%s' 13 10], im, ...
mrk(im).type, mrk(im).desc, mrk(im).pos, ...
mrk(im).type, mrk(im).event.desc, mrk(im).pos, ...
mrk(im).length, mrk(im).chan, mrk(im).time);
end
end
Expand Down
11 changes: 6 additions & 5 deletions markers/mrk_defineClasses.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,24 @@
opt= opt_setDefaults(opt, props);
opt_checkProplist(opt, props);

misc_checkType(mk, 'STRUCT(time desc)');
misc_checkType(mk, 'STRUCT(time event)');
misc_checkType(mk.event, 'STRUCT(desc)');
misc_checkType(classDef, 'CELL');

nClasses= size(classDef,2);
mrk= struct('time', mk.time, 'desc',mk.desc);
mrk= struct('time', mk.time, 'event',struct('desc',mk.event.desc));
mrk.y= zeros(nClasses, numel(mrk.time));
for cc= 1:nClasses,
if isnumeric(classDef{1,cc}),
% vector as in {[10 11], [20:26]; 'target', 'nontarget'}
mrk.y(cc,:)= ismember(mk.desc, classDef{1,cc},'legacy');
mrk.y(cc,:)= ismember(mk.event.desc, classDef{1,cc});
elseif iscell(classDef{1,cc}),
% cell of strings as in {{'S 10','S 11'}, {'S 20','S 21'};
% 'target', 'nontarget'}
mrk.y(cc,:)= ismember(mk.desc, classDef{1,cc},'legacy');
mrk.y(cc,:)= ismember(mk.event.desc, classDef{1,cc});
else
% single string as in {'S10', 'S20'; 'target', 'nontarget'}
mrk.y(cc,:)= ismember(mk.desc, classDef(1,cc),'legacy');
mrk.y(cc,:)= ismember(mk.event.desc, classDef(1,cc));
end
end

Expand Down
8 changes: 5 additions & 3 deletions online/acquisition/bbci_acquire_offline.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@
state.cnt_idx= 1:state.cnt_step;
state.clab= cnt.clab;
state.cnt= cnt;
% -- transitional
if ~isfield(mrk, 'desc'),
mrk.desc= mrk.toe;

if isfield(mrk, 'event') && isfield(mrk.event, 'desc'),
mrk.desc= mrk.event.desc;
else
mrk.desc= repmat({'dmy'}, size(mrk.time));
end
% --
state.mrk= mrk;
Expand Down
1 change: 0 additions & 1 deletion online/bbci_load.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
%
%Synopsis:
% DATA= bbci_load(BBCI);
%


bbci= bbci_calibrate_setDefaults(bbci);
Expand Down
17 changes: 7 additions & 10 deletions online/calibration/bbci_calibrate_ERPSpeller.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
'CP5,CP3,CP1,CPz,CP2,CP4,CP6\n' ...
'P7,P5,P3,Pz,P4,P6,P8\n' ...
'PO7,PO3,O1,Oz,O2,PO4,PO8']);

% MODEL muss nach xvalidation entweder struct oder char sein, nicht
% function handle ... da ist entweder in xvalidation was falsch oder
% woanders...

props= {'ref_ival' [-200 0] '!DOUBLE[1 2]'
'disp_ival' [-200 800] '!DOUBLE[1 2]'
Expand Down Expand Up @@ -63,7 +59,7 @@
};
[opt, isdefault]= opt_setDefaults('bbci.calibrate.settings', props);

nClassesGuess= length(unique(opt.mrk2feedback_fcn(opt.cue_markers),'legacy'));
nClassesGuess= length(unique(opt.mrk2feedback_fcn(opt.cue_markers)));
[opt, isdefault]= ...
opt_overrideIfDefault(opt, isdefault, 'nClasses', nClassesGuess);
[opt, isdefault]= ...
Expand Down Expand Up @@ -161,9 +157,9 @@
fig_closeIfExists(5);
end
if iscell(BC_result.rejected_clab), %% that means rejected_clab is not NaN
cidx= find(ismember(BC_result.clab, BC_result.rejected_clab,'legacy'));
cidx= find(ismember(BC_result.clab, BC_result.rejected_clab));
BC_result.clab(cidx)= [];
cidx= find(ismember(BC_result.cfy_clab, BC_result.rejected_clab,'legacy'));
cidx= find(ismember(BC_result.cfy_clab, BC_result.rejected_clab));
BC_result.cfy_clab(cidx)= [];
end
else
Expand Down Expand Up @@ -228,7 +224,7 @@
%
if opt.create_figs,
fig_set(1, 'name','ERP - grid plot', 'set',{'Visible','off'});
H= grid_plot(epo, mnt, defopt_erps);%, 'ColorOrder',opt_scalp_erp.colorOrder);
H= grid_plot(epo, mnt, defopt_erps, 'ColorOrder',opt_scalp_erp.ColorOrder);
%grid_markInterval(BC_result.cfy_ival);
if isfield(H, 'scale'),
grid_addBars(epo_r, 'HScale',H.scale);
Expand All @@ -238,8 +234,9 @@
set(gcf, 'Visible','on');

fig_set(2, 'name','ERP - scalp maps', 'set',{'Visible','off'});
H= plot_scalpEvolutionPlusChannel(epo, mnt, opt.clab_erp, BC_result.cfy_ival, ...
opt_scalp_erp);
H= plot_scalpEvolutionPlusChannel(epo, mnt, opt.clab_erp, ...
BC_result.cfy_ival, ...
opt_scalp_erp);
grid_addBars(epo_r);
set(gcf, 'Visible','on');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% Subject-independent kickstart classifier
cfy_dir= [BBCI.RawDir 'subject_independent_classifiers/vitalbci_season2/'];
cfy_dir= [BTB.RawDir 'subject_independent_classifiers/vitalbci_season2/'];
bbci= load([cfy_dir 'kickstart_vitalbci_season2_C3CzC4_9-15_15-35']);

% EEG file used of offline simulation of online processing
Expand All @@ -11,7 +11,7 @@
bbci.source.acquire_param= {cnt, mrk};

bbci.log.output= 'file';
bbci.log.folder= BBCI.TmpDir;
bbci.log.folder= BTB.TmpDir;
bbci.log.classifier= 1;

data= bbci_apply(bbci);
Expand Down
4 changes: 2 additions & 2 deletions online/demos/demo_bbcionline_apply_ERP_Speller.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
bbci.quit_condition.running_time= 2*60;

bbci.log.output= 'screen&file';
bbci.log.file= fullfile(BBCI.TmpDir, 'log');
bbci.log.file= fullfile(BTB.TmpDir, 'log');
bbci.log.classifier= 1;

data= bbci_apply_uni(bbci);
Expand All @@ -48,7 +48,7 @@
'delimiter','','commentstyle','shell');

% validate makers that evoked calculation of control signals
isequal(marker_desc, mrk.desc(1:length(marker_desc))')
isequal(marker_desc, mrk.event.desc(1:length(marker_desc)))

% offline processing of the data
epo= proc_segmentation(cnt, mrk, [ref_ival(1) cfy_ival(end)], 'clab', bbci.signal.clab);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
bbci.adaptation.active= 1;
bbci.adaptation.fcn= @bbci_adaptation_pmean;
bbci.adaptation.param= {struct('ival',[500 4000])};
bbci.adaptation.filename= '$BBCI.TmpDir/bbci_classifier_pmean';
bbci.adaptation.filename= '$BTB.TmpDir/bbci_classifier_pmean';
bbci.adaptation.log.output= 'screen';

bbci.quit_condition.marker= 254;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

% In demos, we just write to the temp folder. Otherwise, the default
% choice would be fine.
BC.save.folder= BBCI.TmpDir;
BC.log.folder= BBCI.TmpDir;
BC.save.folder= BTB.TmpDir;
BC.log.folder= BTB.TmpDir;

bbci= struct('calibrate', BC);

Expand All @@ -23,7 +23,7 @@
bbci.source.acquire_param= {calib.cnt, calib.mrk};

bbci.log.output= 'screen&file';
bbci.log.folder= BBCI.TmpDir;
bbci.log.folder= BTB.TmpDir;
bbci.log.classifier= 1;

data= bbci_apply(bbci);
Expand Down
16 changes: 8 additions & 8 deletions online/demos/demo_bbcionline_calibrate_and_apply_EEG_and_NIRS.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
%% first do the calibration for the NIRS:
BBCI.NirsMatDir = [BBCI.DataDir 'nirs/uni/'];
BTB.NirsMatDir = [BTB.DataDir 'nirs/uni/'];
BC= [];
BC.fcn= @bbci_calibrate_tinyNIRS;
BC.read_fcn=@file_NIRSreadMatlab;
BC.folder= BBCI.NirsMatDir;
BC.folder= BTB.NirsMatDir;
BC.file= 'VPeag_10_06_17/ni_imag_fbarrow_pcovmeanVPeag*';
BC.save.folder= BBCI.TmpDir;
BC.log.folder= BBCI.TmpDir;
BC.save.folder= BTB.TmpDir;
BC.log.folder= BTB.TmpDir;

bbci_nirs= struct('calibrate', BC);
[bbci_nirs, calib_nirs]= bbci_calibrate(bbci_nirs);
Expand All @@ -18,14 +18,14 @@
%% now do the calibration for the EEG data:
BC= [];
BC.fcn= @bbci_calibrate_tinyCsp;
BC.folder= BBCI.RawDir;
BC.folder= BTB.RawDir;
BC.file= 'VPeag_10_06_17/imag_fbarrow_pcovmeanVPeag*';
BC.read_fcn=@file_readBV;
BC.read_param= {'fs',100};
BC.marker_fcn= @mrk_defineClasses;
BC.marker_param= {{1, 2; 'left', 'right'}};
BC.save.folder= BBCI.TmpDir;
BC.log.folder= BBCI.TmpDir;
BC.save.folder= BTB.TmpDir;
BC.log.folder= BTB.TmpDir;

bbci= struct('calibrate', BC);

Expand Down Expand Up @@ -73,7 +73,7 @@

% for log:
bbci.log.output= 'screen&file';
bbci.log.folder= BBCI.TmpDir;
bbci.log.folder= BTB.TmpDir;
bbci.log.classifier= 1;

% % or just load the predefined classifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

% In demos, we just write to the temp folder. Otherwise, the default
% choice would be fine.
BC.save.folder= BBCI.TmpDir;
BC.log.folder= BBCI.TmpDir;
BC.save.folder= BTB.TmpDir;
BC.log.folder= BTB.TmpDir;

bbci= struct('calibrate', BC);

Expand All @@ -22,7 +22,7 @@
bbci.source.acquire_param= {calib.cnt, calib.mrk};

bbci.log.output= 'screen&file';
bbci.log.folder= BBCI.TmpDir;
bbci.log.folder= BTB.TmpDir;
bbci.log.classifier= 1;

data= bbci_apply_uni(bbci);
Expand All @@ -32,7 +32,7 @@
textread(data.log.filename, log_format, ...
'delimiter','','commentstyle','shell');

isequal(marker_desc, calib.mrk.desc')
isequal(marker_desc, calib.mrk.event.desc)

ref_ival= bbci.feature.proc{1}{2};
cfy_ival= bbci.feature.proc{2}{2};
Expand Down
18 changes: 9 additions & 9 deletions online/demos/demo_bbcionline_calibrate_and_apply_NIRS.m
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
BBCI.NirsMatDir = [BBCI.DataDir 'nirs/uni/'];
BTB.NirsMatDir = [BTB.DataDir 'nirs/uni/'];

BC= [];
BC.fcn= @bbci_calibrate_tinyNIRS;
BC.read_fcn=@file_NIRSreadMatlab;
BC.folder= BBCI.NirsMatDir;
BC.folder= BTB.NirsMatDir;
BC.file= 'VPeag_10_06_17/ni_imag_fbarrow_pcovmeanVPeag*';
%BC.file= 'VPeae_10_03_05/ni_imag_fbarrow_pcovmeanVPeae*';
%BC.file= 'VPeah_10_06_19/ni_imag_fbarrow_pcovmeanVPeah*';
%BC.file= 'VPeaj_10_06_22/ni_imag_fbarrow_pcovmeanVPeaj*';

% define a tmp folder
BC.save.folder= BBCI.TmpDir;
BC.log.folder= BBCI.TmpDir;
BC.save.folder= BTB.TmpDir;
BC.log.folder= BTB.TmpDir;

% rewrite to bbci variable
bbci= struct('calibrate', BC);
Expand All @@ -24,10 +24,10 @@
%%

% load feedback file:
file = [BBCI.NirsMatDir 'VPeag_10_06_17/ni_imag_fbarrow_pmeanVPeag'];
%file = [BBCI.NirsMatDir 'VPeae_10_03_05/ni_imag_fbarrow_pmeanVPeae'];
%file = [BBCI.NirsMatDir 'VPeah_10_06_19/ni_imag_fbarrow_pmeanVPeah'];
%file = [BBCI.NirsMatDir 'VPeaj_10_06_22/ni_imag_fbarrow_pmeanVPeaj'];
file = [BTB.NirsMatDir 'VPeag_10_06_17/ni_imag_fbarrow_pmeanVPeag'];
%file = [BTB.NirsMatDir 'VPeae_10_03_05/ni_imag_fbarrow_pmeanVPeae'];
%file = [BTB.NirsMatDir 'VPeah_10_06_19/ni_imag_fbarrow_pmeanVPeah'];
%file = [BTB.NirsMatDir 'VPeaj_10_06_22/ni_imag_fbarrow_pmeanVPeaj'];

[cnt, mrk]= file_NIRSreadMatlab(file);

Expand All @@ -37,7 +37,7 @@

% define some logging
bbci.log.output= 'screen&file';
bbci.log.folder= BBCI.TmpDir;
bbci.log.folder= BTB.TmpDir;
bbci.log.classifier= 1;

% start the feedback
Expand Down
Loading

0 comments on commit c2c138f

Please sign in to comment.