|
|
|
[[_TOC_]]
|
|
|
|
# Introduction
|
|
|
|
|
|
|
|
There are different ways to get data from AnyWave depending on what you want to do in the plugin.
|
|
|
|
|
|
|
|
# Selecting channels
|
|
|
|
|
|
|
|
Depending on the context (AnyWave is running in GUI mode or in Command Line mode) you can tune your request to get data from the channels you want.
|
|
|
|
|
|
|
|
## Scenario 1 (do not specify any options)
|
|
|
|
|
|
|
|
### the flags defined in desc.txt will be applied
|
|
|
|
|
|
|
|
| input_flags | GUI mode | Command line mode |
|
|
|
|
| ------ | ------ | ------ |
|
|
|
|
| getcurrentmontage | get data from channels in the current montage | get data from channels in the current montage |
|
|
|
|
| getasrecordedchannels | get data from raw channels (skip montage) | get data from raw channels (skip montage) |
|
|
|
|
|
|
|
|
| modifiers_flags | GUI mode | Command line mode |
|
|
|
|
| ------ | ------ | ------ |
|
|
|
|
| acceptchannelselection | get data from selected channels (if there are) otherwise use the current montage | not applicable |
|
|
|
|
|
|
|
|
if there are no input_flags neither modifier_flags in desc.txt the default behavior is to provide data from the current montage by default.
|
|
|
|
|
|
|
|
## Scenario 2 (fine tune the channels you want to get data from)
|
|
|
|
This will override flags set in desc.txt file.
|
|
|
|
### Get current montage
|
|
|
|
MATLAB:
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
cfg.channels_source = 'montage'; % default behavior anyway.
|
|
|
|
````
|
|
|
|
|
|
|
|
Python:
|
|
|
|
````python
|
|
|
|
cfg = dict()
|
|
|
|
cfg['channels_source'] = ['montage']
|
|
|
|
````
|
|
|
|
### Get current selection (only in GUI context)
|
|
|
|
MATLAB:
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
cfg.channels_source = 'selection';
|
|
|
|
````
|
|
|
|
Python:
|
|
|
|
````python
|
|
|
|
cfg = dict()
|
|
|
|
cfg['channels_source'] = ['selection']
|
|
|
|
````
|
|
|
|
### Get raw channels
|
|
|
|
Raw channels are physical channels stored in the data file. This will skip the current montage and also all the virtual channels like ICA time courses.
|
|
|
|
MATLAB:
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
cfg.channels_source = 'raw';
|
|
|
|
````
|
|
|
|
Python:
|
|
|
|
````python
|
|
|
|
cfg = dict()
|
|
|
|
cfg['channels_source'] = ['raw']
|
|
|
|
````
|
|
|
|
### Pick channels
|
|
|
|
You can request for channels with or without using raw/selection/montage options by providing a list of electrode labels you want:
|
|
|
|
MATLAB:
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
cfg.labels = {'Fp1', 'ECG', 'A1', 'A2-A3'};
|
|
|
|
````
|
|
|
|
Python:
|
|
|
|
````python
|
|
|
|
cfg = dict()
|
|
|
|
cfg['labels'] = ['Fp1', 'ECG', 'A1', 'A2-A3']
|
|
|
|
````
|
|
|
|
Note: 'A2-A3' will request a bipolar channel, this will be applied on the fly by AnyWave.
|
|
|
|
|
|
|
|
Electrodes labels must exist or will be skipped. You may have errors or an empty variable as the result of the request.
|
|
|
|
### Get channels by their types
|
|
|
|
Get EEG channels or EEG and ECG for example:
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
% only EEG
|
|
|
|
cfg.types = {'EEG'};
|
|
|
|
% EEG and ECG
|
|
|
|
cfg.types = {'EEG', 'ECG'};
|
|
|
|
````
|
|
|
|
Python:
|
|
|
|
````python
|
|
|
|
cfg = dict()
|
|
|
|
# only EEG
|
|
|
|
cfg['types'] = ['EEG']
|
|
|
|
# EEG and ECG
|
|
|
|
cfg['types'] = ['EEG', 'ECG']
|
|
|
|
````
|
|
|
|
# Selecting data chunks
|
|
|
|
## I want data between time positions
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
% get 10s of data starting 1s after the beginning of the file
|
|
|
|
cfg.start = 1;
|
|
|
|
cfg.duration = 10;
|
|
|
|
output = anywave('get_data', cfg);
|
|
|
|
````
|
|
|
|
````python
|
|
|
|
cfg = {'start': 1, 'duration' : 10}
|
|
|
|
output = anywave.get_data_ex(cfg)
|
|
|
|
````
|
|
|
|
## I want several data chunks appended
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
cfg.data_chunks = [ 1 10 2 4 ]; % specify several time selections at once
|
|
|
|
output = anywave('get_data_ex', cfg); % data will be appended to the same output structure.
|
|
|
|
````
|
|
|
|
````python
|
|
|
|
cfg = {'data_chunks' : [0, 10, 2, 4] }
|
|
|
|
output = anywave.get_data_ex(cfg)
|
|
|
|
````
|
|
|
|
## I want several data chunks splitted
|
|
|
|
Sometimes you want to get data chunks and apply processing on each ones.
|
|
|
|
You must specify the split_data option when requesting data:
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
cfg.data_chunks = [ 1 10 2 4 ]; % specify several time selections at once
|
|
|
|
cfg.split_data = true; % key option to specify splitted data as result
|
|
|
|
output = anywave('get_data', cfg);
|
|
|
|
%%
|
|
|
|
% output is a struct array. The number of elements is the number of data chunks requested.
|
|
|
|
% As there are splitted each element contains the data and information of one data chunk.
|
|
|
|
%%
|
|
|
|
````
|
|
|
|
````python
|
|
|
|
cfg = {'data_chunks' : [0, 10, 2, 4], 'split_data' : True }
|
|
|
|
output = anywave.get_data_ex(cfg)
|
|
|
|
###
|
|
|
|
### output is a list of dict containing the data and information of each data chunks requested.
|
|
|
|
````
|
|
|
|
## I want data chunks marked by markers
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
cfg.use_markers = { 'section2', 'h2' ]; % the labels of markers
|
|
|
|
% the markers section2 and h2 must exist in the data file otherwise AnyWave will send back the whole data file...
|
|
|
|
output = anywave('get_data_ex', cfg); % the different data chunks marked are appended in one data matrix.
|
|
|
|
% use split_data to separate data chunks
|
|
|
|
cfg.split_data = true;
|
|
|
|
output = anywave('get_data', cfg);
|
|
|
|
%%
|
|
|
|
% output is a struct array. The number of elements is the number of data chunks requested.
|
|
|
|
% As there are splitted each element contains the data and information of one data chunk.
|
|
|
|
%%
|
|
|
|
````
|
|
|
|
````python
|
|
|
|
cfg = {'use_markers' : ['section2', 'h2'], 'split_data' : True }
|
|
|
|
output = anywave.get_data_ex(cfg) # data chunks will be splitted here
|
|
|
|
````
|
|
|
|
## I want all data BUT artefacted/unused data chunks
|
|
|
|
Getting all the data except chunks marked as bad is easy:
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
cfg.skip_markers = { 'artefact', 'bad'};
|
|
|
|
output = anywave('get_data', cfg); % data chunks appended
|
|
|
|
````
|
|
|
|
````python
|
|
|
|
cfg = {'skip_markers' : ['artefact', 'bad'], 'split_data' : True }
|
|
|
|
output = anywave.get_data_ex(cfg) # data chunks will be splitted here
|
|
|
|
````
|
|
|
|
## I want marked data chunks AND avoid bad ones
|
|
|
|
This can happen when you marked data chunk of interest but some samples are also marked as bad afterwards by other processing.
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
cfg.use_markers = { 'section2', 'h2' ]; % the labels of markers
|
|
|
|
cfg.skip_markers = { 'artefact', 'bad'};
|
|
|
|
output = anywave('get_data', cfg); % data chunks appended
|
|
|
|
````
|
|
|
|
````python
|
|
|
|
cfg = {'skip_markers' : ['artefact', 'bad'], 'use_markers' : ['section2', 'h2'], 'split_data' : True }
|
|
|
|
output = anywave.get_data_ex(cfg) # data chunks will be splitted here
|
|
|
|
````
|
|
|
|
|
|
|
|
# Filtering data
|
|
|
|
````matlab
|
|
|
|
cfg = [];
|
|
|
|
cfg.filters = [1 130]; % apply a 1Hz high pass and 130Hz low pass filter
|
|
|
|
...
|
|
|
|
cfg.filters = [ 0 0 50]; % apply a notch filter at 50Hz.
|
|
|
|
% filters values by order : High pass - Low Pass - Notch (optional)
|
|
|
|
% force getting raw data (do not use filters set in AnyWave)
|
|
|
|
cfg.raw_data = true;
|
|
|
|
|
|
|
|
````
|
|
|
|
|
|
|
|
|