From 76ebcc80506489ebfcc47cd7a8433dea5245f079 Mon Sep 17 00:00:00 2001 From: nedaeh Date: Mon, 8 Feb 2016 14:18:45 -0800 Subject: [PATCH] * fixes for MATLAB 2015b compatibility (change to how the stack entries are formatted) * utl_whichfile is now robust to badly named .m files * tutorial_erd1 script now correctly imports only the EEG channels of the data --- code/arguments/arg_define.m | 4 ++-- code/helpers/hlp_resolve.m | 13 +++++++++---- code/utils/utl_whichfile.m | 9 +++++++-- userscripts/tutorial_erd1.m | 10 +++++----- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/code/arguments/arg_define.m b/code/arguments/arg_define.m index 6ef2bd53..febd69b2 100644 --- a/code/arguments/arg_define.m +++ b/code/arguments/arg_define.m @@ -371,7 +371,7 @@ % cached wrapper around process_spec function varargout = process_spec_cached(caller_name,spec,report_type,assign_defaults,perform_namecheck) persistent cache; - caller_field = caller_name; + caller_field = ['x' caller_name]; caller_field(~((caller_field>='a'&caller_field<='z') | (caller_field>='A'&caller_field<='Z') | (caller_field>='0'&caller_field<='9'))) = '_'; key = [report_type 'a'+assign_defaults]; try @@ -501,7 +501,7 @@ signature(structmask) = cellfun(@fieldnames,signature(structmask),'UniformOutput',false); end % determine the number n of arguments that were specified positionally - caller_field = caller_name; + caller_field = ['x' caller_name]; caller_field(~((caller_field>='a'&caller_field<='z') | (caller_field>='A'&caller_field<='Z') | (caller_field>='0'&caller_field<='9'))) = '_'; [n,violations,ignored] = hlp_nanocache(caller_field,10,@get_num_positionals,fmt,length(first_names),signature,structmask,permitted_names,skipped_positionals); diff --git a/code/helpers/hlp_resolve.m b/code/helpers/hlp_resolve.m index e033f24b..0ea5f14a 100644 --- a/code/helpers/hlp_resolve.m +++ b/code/helpers/hlp_resolve.m @@ -54,13 +54,18 @@ end % check for all entries whether they refer to a stack frame... -marker = 'make_func/@(f,a,frame__'; -frames = find(strncmp(entries,marker,23)); - +if hlp_matlab_version < 806 + marker = 'make_func/@(f,a,frame__'; +else + marker = '@(f,a,frame__'; +end +frames = find(strncmp(entries,marker,length(marker))); + + % go through all stack frames... symbol = char(x); for k=frames - frameid = entries{k}(24:end-14); + frameid = entries{k}(length(marker)+1:end-14); % and check if the symbol is present there, then look up if isfield(tracking.stack.frames.(frameid),symbol) outargs = tracking.stack.frames.(frameid).(symbol); diff --git a/code/utils/utl_whichfile.m b/code/utils/utl_whichfile.m index 5020d5ce..c65ce9f5 100644 --- a/code/utils/utl_whichfile.m +++ b/code/utils/utl_whichfile.m @@ -65,8 +65,13 @@ function populate_records(path) populate_records([path filesep info.name]); end else % found a file? add it to the table if an .m file - if length(info.name) > 2 && strcmp(info.name(end-1:end),'.m') - filenames.(info.name(1:end-2)) = [path filesep info.name]; end + if length(info.name) > 2 && strcmp(info.name(end-1:end),'.m') + try + filenames.(info.name(1:end-2)) = [path filesep info.name]; + catch + disp_once('utl_whichfile: found .m file that is not a function name: %s (ignoring)',[path filesep info.name]); + end + end end end end diff --git a/userscripts/tutorial_erd1.m b/userscripts/tutorial_erd1.m index 652b1fb2..e30062a1 100644 --- a/userscripts/tutorial_erd1.m +++ b/userscripts/tutorial_erd1.m @@ -18,7 +18,7 @@ %% --- using the Common Spatial Pattern method --- % load the data set (BCI2000 format) -traindata = io_loadset('bcilab:/userdata/tutorial/imag_movements1/calib/DanielS001R01.dat'); +traindata = io_loadset('bcilab:/userdata/tutorial/imag_movements1/calib/DanielS001R01.dat','channels',1:29); % define the approach (here: Common Spatial Patterns without any customization) myapproach = 'CSP'; @@ -33,7 +33,7 @@ %% --- using the Common Spatial Pattern method with some custom options --- % load the data set (BCI2000 format) -traindata = io_loadset('bcilab:/userdata/tutorial/imag_movements1/calib/DanielS001R01.dat'); +traindata = io_loadset('bcilab:/userdata/tutorial/imag_movements1/calib/DanielS001R01.dat','channels',1:29); % define the approach % Note: The settings found in the GUI "Review/Edit Approach" Panel can be translated literally @@ -81,7 +81,7 @@ % may run into a local optimum or over-fit spuriously correlated bands % load the data set -traindata = io_loadset('bcilab:/userdata/tutorial/imag_movements1/calib/DanielS001R01.dat'); +traindata = io_loadset('bcilab:/userdata/tutorial/imag_movements1/calib/DanielS001R01.dat','channels',1:29); % define the approach myapproach = {'SpecCSP' 'SignalProcessing',{'EpochExtraction',[0.5 3]}}; @@ -97,7 +97,7 @@ % ( click into the figure to stop the update (and make sure that your click was registered) ) % load feedback session -testdata = io_loadset('bcilab:/userdata/tutorial/imag_movements1/feedback/DanielS001R01.dat'); +testdata = io_loadset('bcilab:/userdata/tutorial/imag_movements1/feedback/DanielS001R01.dat','channels',1:29); % play it back in real time run_readdataset('Dataset',testdata); @@ -115,7 +115,7 @@ % (the number of pattern pairs found optimal should be 3 in this case) % load the data set (BCI2000 format) -traindata = io_loadset('bcilab:/userdata/tutorial/imag_movements1/calib/DanielS001R01.dat'); +traindata = io_loadset('bcilab:/userdata/tutorial/imag_movements1/calib/DanielS001R01.dat','channels',1:29); % define approach myapproach = {'CSP' 'Prediction',{'FeatureExtraction',{'PatternPairs',search(1,2,3)}}};