run¶
run makes AnyWave run another plugin on a data file, exactly as if you launched it from the command line
(anywave --run ...). Any plugin that can run from the command line can be used: ICA, h2, Spectral, the artifact detectors...
anywave('run', cfg);
cfg is a struct:
| field | content | required |
|---|---|---|
plugin |
name of the plugin, as AnyWave lists it ('h2', 'Spectral', 'ICA'...) |
yes |
input_file |
path of the data file to process | yes |
| any other field | an option of the plugin: the name of the command line option without the -- |
depends on the plugin |
The options of every plugin are listed in its Command line page (h2, ICA,
Spectral...). The options common to all plugins also work: output_dir, output_prefix,
output_suffix, use_markers, skip_markers, marker_file, montage_file...
Example: compute h2 on the current file¶
function main(varargin)
args = anywave('init', varargin);
cfg = [];
cfg.plugin = 'h2';
cfg.input_file = args.data_path; % the file open in AnyWave
cfg.time_window = 2; % options of the h2 plugin (--time_window 2)
cfg.step = 1; % (--step 1)
cfg.max_lag = 0.1; % (--max_lag 0.1)
output_dir = fullfile(args.data_dir, 'h2_results');
mkdir(output_dir);
cfg.output_dir = output_dir; % where the result file goes (default: next to the data file)
anywave('run', cfg);
% the plugin wrote its result file in output_dir
files = dir(fullfile(output_dir, '*_algo-h2_*.mat'));
result = load(fullfile(files(1).folder, files(1).name));
end
How it works¶
- AnyWave starts another AnyWave process with the plugin and the options you gave, and
runwaits until it is finished. - The results are files, written in
output_dir(by default next to the data file).runreturns nothing: do not writeout = anywave('run', cfg), MATLAB would stop withOne or more output arguments not assigned during call to "anywave". - Choose the data with
use_markersorskip_markers, as in the command line:
cfg = [];
cfg.plugin = 'h2';
cfg.input_file = args.data_path;
cfg.time_window = 4; cfg.step = 1; cfg.max_lag = 0.1;
cfg.use_markers = {'H2'}; % compute only on the markers labeled H2
cfg.hp = 1; cfg.lp = 40; % band 1-40 Hz
anywave('run', cfg);
Errors¶
| message | cause |
|---|---|
run: bad arguments. Expected struct. |
the argument is not a struct |
ERROR: plugin key is not specified in struct/dict parameter. |
no plugin field (cfg.process of older documentations is not used) |
ERROR: Unable to find process plugin named ... |
wrong plugin name |
ERROR: the process is not compatible (must be able to run using the command line |
the plugin cannot run from the command line |
ERROR: ... is not available in the current version of AnyWave. |
this plugin is not part of your version of AnyWave |