Skip to content

Commit cee238a

Browse files
committed
* Fixed the lack of a min-phase highpass FIR filter.
* Added the ability to read "private" plugins from ~/.bcilab/code
1 parent 8c4f65e commit cee238a

File tree

11 files changed

+68
-29
lines changed

11 files changed

+68
-29
lines changed

RELEASE NOTES.TXT

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ The latest versions of the toolbox can be found at github.com/sccn/BCILAB, and r
8080

8181
=== Known Issues in Beta Version ===
8282
- utl_kernelize has a bug that renders it non-working (affects ml_trainsvm and ml_trainrvm)
83-
- flt_fir has no minimum-phase implementation for high-pass filters yet, which means that it will incur possibly
84-
intolerable delay (workaround: use flt_iir, or, if working with epochs, flt_spectrum)
8583
- flt_standardize with the sphere setting turned on is not robust to signals that are (almost) rank-deficient
8684
- flt_iir flips the signal sign under some settings (though consistently) and causes rather high CPU load during
8785
online processing
@@ -236,6 +234,8 @@ Minor New Features
236234
- flt_standardize: can now also do multivariate sphering (whitening)
237235
- tutorial_erp1.m: added a few new approaches to demo new features
238236
- added UnLocBox toolbox to dependencies (primarily for some of its prox operators)
237+
- added the ability to read private plugins from ~/.bcilab/code
238+
- added robust re-referencing
239239

240240
Major Changes:
241241
- arg_tovals: now by default sets the arg_direct flag to false rather than true, meaning that some
1.05 KB
Binary file not shown.

code/environment/env_load_dependencies.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ function env_load_dependencies(dependency_dir,autocompile)
113113
end
114114

115115
% rebuild path
116-
rmpath(added_paths{:});
117-
addpath(added_paths{:});
116+
if ~isempty(added_paths)
117+
rmpath(added_paths{:});
118+
addpath(added_paths{:});
119+
end
118120
end
119121

120122

code/environment/env_startup.m

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ function env_startup(varargin)
216216
% load all dependencies, recursively...
217217
disp('Loading BCILAB dependencies...');
218218
env_load_dependencies(dependency_dir,opts.autocompile);
219+
if exist(env_translatepath('home:/.bcilab/code/dependencies'),'dir')
220+
env_load_dependencies(env_translatepath('home:/.bcilab/code/dependencies'),opts.autocompile); end
219221

220222
if ischar(opts.worker)
221223
try
@@ -421,21 +423,45 @@ function env_startup(varargin)
421423
end
422424
tracking.logfile = env_translatepath('home:/.bcilab/logs/bcilab_console.log');
423425
try
424-
if ~exist([hlp_homedir filesep '.bcilab' filesep 'logs'],'dir')
425-
mkdir([hlp_homedir filesep '.bcilab' filesep 'logs']); end
426+
diary(tracking.logfile);
426427
if exist(tracking.logfile,'file')
427428
warning off MATLAB:DELETE:Permission
428429
delete(tracking.logfile);
429430
warning on MATLAB:DELETE:Permission
430431
end
431432
catch,end
432-
try diary(tracking.logfile); catch,end
433-
434-
if ~exist([hlp_homedir filesep '.bcilab' filesep 'models'],'dir')
435-
mkdir([hlp_homedir filesep '.bcilab' filesep 'models']); end
436-
if ~exist([hlp_homedir filesep '.bcilab' filesep 'approaches'],'dir')
437-
mkdir([hlp_homedir filesep '.bcilab' filesep 'approaches']); end
438433

434+
try
435+
% create directories in the user's .bcilab folder...
436+
home_basedir = [hlp_homedir filesep '.bcilab' filesep];
437+
home_codedirs = {['code' filesep 'filters'],['code' filesep 'dataset_editing'], ...
438+
['code' filesep 'machine_learning'], ['code' filesep 'paradigms']};
439+
home_miscdirs = {'models','approaches','code',['code' filesep 'dependencies'],'logs'};
440+
for d = [home_codedirs home_miscdirs]
441+
try
442+
subdir = [home_basedir d{1}];
443+
if ~exist(subdir,'dir')
444+
mkdir(subdir); end
445+
catch e
446+
disp(['Could not create directory: ' subdir ': ' e.message]);
447+
end
448+
end
449+
% and add the code directories to the path
450+
for d = home_codedirs
451+
addpath(genpath([home_basedir d{1}])); end
452+
% add the env_add.m file to the dependencies folder
453+
add_file = [home_basedir 'code' filesep 'dependencies' filesep 'env_add.m'];
454+
if ~exist(add_file,'file')
455+
try
456+
f = fopen(add_file,'w');
457+
fwrite(f,' ');
458+
fclose(f);
459+
catch e
460+
disp(['Could not create file ' add_file ': ' e.message]);
461+
end
462+
end
463+
catch,end
464+
439465
% create a menu
440466
if ~(isequal(opts.menu,false) || isequal(opts.menu,0))
441467
try

code/filters/flt_clean_settings.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
% a function that creates a list of cleaning parameters, for some defaults
6060
make_clean_params = @(flatlines,drifts,regression,windows,channels,dropouts,peaks,spikes,shaping) { ...
6161
arg_subtoggle({'flatlines','FlatlineRemoval'},flatlines,@flt_clean_flatlines,'Removal of flat-line channels.'), ...
62-
arg({'drifts','DriftCutoff'},drifts,[],'Drift-correction high-pass filter. This is the frequency specification of a (zero-phase) filter: [transition-start, transition-end], in Hz'), ...
62+
arg({'drifts','DriftCutoff'},drifts,[],'Drift-correction high-pass filter. This is the frequency specification of the filter: [transition-start, transition-end], in Hz'), ...
6363
arg_subtoggle({'regression','ArtifactRegression'},regression,@flt_eog,'Removal of artifacts based on reference channels.'), ...
6464
arg_subtoggle({'channels','BadChannelRemoval'},channels,@flt_clean_channels,'Rejection of channels with uncorrelated signals.'), ...
6565
arg_subtoggle({'dropouts','ChannelDropoutRepair'},dropouts,@flt_repair_channels,'Repair of channels that temporarily glitch out.'), ...

code/filters/flt_fir.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
n = length(state.b);
210210

211211
% use cepstral windowing to calculate a minimum-phase filter (note: the min-phase change applies
212-
if strcmp(ftype,'minimum-phase') && ~any(strcmp(fmode,{'highpass','hp'}))
212+
if strcmp(ftype,'minimum-phase')
213213
wnd = [1 2*ones(1,(n+mod(n,2))/2-1) ones(1,1-mod(n,2)) zeros(1,(n+mod(n,2))/2-1)];
214214
state.b = real(ifft(exp(fft(wnd.*real(ifft(log(abs(fft(state.b))+stopripple)))))));
215215
end

code/filters/flt_pipeline.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,9 @@
390390
found = [dir(env_translatepath('functions:/filters/flt_*.m'));
391391
dir(env_translatepath('functions:/dataset_editing/set_*.m'));
392392
dir(env_translatepath('functions:/filters/in_development/flt_*.m'));
393-
dir(env_translatepath('functions:/dataset_editing/in_development/set_*.m'))];
393+
dir(env_translatepath('functions:/dataset_editing/in_development/set_*.m'));
394+
dir(env_translatepath('home:/.bcilab/code/filters/flt_*.m'));
395+
dir(env_translatepath('home:/.bcilab/code/dataset_editing/set_*.m'))];
394396

395397
% get file names, function names, function handles, function tags (names without prefix)
396398
files = setdiff({found.name},{'flt_pipeline.m','set_new.m','set_chanid.m','set_infer_chanlocs.m'});

code/filters/flt_reref.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
arg({'ref_chn','ReferenceChannels','chn'}, [], [], 'Cell array of reference channels. The signal data is be referenced to these, defaults to average reference if empty.','type','cellstr','shape','row'),...
7373
arg({'exclude_chn','ExcludeChannels','exclude'}, [], [], 'Cell array of channels to exclude.','type','cellstr','shape','row'),...
7474
arg({'keepref','KeepReference'}, false, [], 'Keep the reference channel.'), ...
75-
arg({'ref_type','ReferenceType'}, 'mean', {'mean','median','huber'}, 'Type of reference. The traditional average reference operation uses the mean. If this is set to median, the median of the reference channels will be removed, and if set to huber the robust mean under the Huber loss will be removed (slower than median but closer to the mean).'), ...
75+
arg({'ref_type','ReferenceType'}, 'mean', {'mean','median','huber'}, 'Type of reference. The traditional average reference operation uses the mean. If this is set to median, the median of the reference channels will be removed, and if set to huber the robust mean under the Huber loss will be removed (slower than median but statistically a more efficient estimator).'), ...
7676
arg({'huber_cut','HuberCutoff'}, [], [], 'Cutoff for huber function. If left empty this is set to one (robust) standard deviation of the signal.','guru',true), ...
7777
arg({'huber_iters','HuberIterations'}, 100, [], 'Iterations for huber fitting. A larger number yields tolerance to larger outliers.','guru',true));
7878

code/gui/gui_batchanalysis.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ function gui_batchanalysis_OpeningFcn(hObject, eventdata, handles, varargin)
9292
end
9393

9494
% get all paradigm names
95-
paradir = env_translatepath('functions:/paradigms');
96-
para_files = dir([paradir filesep 'Paradigm*.m']);
95+
para_files = [];
96+
for p = {'functions:/paradigms', 'home:/.bcilab/code/paradigms'}
97+
para_files = [para_files dir([env_translatepath(p{1}) filesep 'Paradigm*.m'])]; end
9798
para_acronyms = cellfun(@(s)s(9:end-2),{para_files.name},'UniformOutput',false);
9899

99100
% populate the list of approaches with available in the workspace

code/gui/utils/gui_listapproaches.m

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@
2424
% --- aggregate all paradigms ---
2525
approaches = {};
2626

27-
paradir = env_translatepath('functions:/paradigms');
28-
para_files = dir([paradir filesep 'Paradigm*.m']);
29-
para_names = {para_files.name};
27+
para_paths = {};
28+
for p = {'functions:/paradigms', 'home:/.bcilab/code/paradigms'}
29+
rootpath = env_translatepath(p{1});
30+
files = dir([rootpath filesep 'Paradigm*.m']);
31+
para_paths = [para_paths cellfun(@(n)[rootpath filesep n],{files.name},'UniformOutput',false)];
32+
end
3033

31-
for p=1:length(para_names)
32-
filename = para_names{p};
34+
for p=1:length(para_paths)
35+
[paradir,filename,ext] = fileparts(para_paths{p});
36+
filename = [filename ext];
3337
tag = filename(1:end-2);
3438
try
3539
% try lookup from a tiny cache of approach descriptions

0 commit comments

Comments
 (0)