Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • D Documentation
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • anywave
  • Documentation
  • Wiki
  • MATLAB_get_data_ex

Last edited by Bruno Colombet Jun 06, 2024
Page history

MATLAB_get_data_ex

  • Introduction
  • Selecting channels
    • Scenario 1 (do not specify any options)
      • the flags defined in desc.txt will be applied
    • Scenario 2 (fine tune the channels you want to get data from)
      • Get current montage
      • Get current selection (only in GUI context)
      • Get raw channels
      • Pick channels
      • Get channels by their types
  • Selecting data chunks
    • I want data between time positions
    • I want several data chunks appended
    • I want several data chunks splitted
    • I want data chunks marked by markers
    • I want all data BUT artefacted/unused data chunks
    • I want marked data chunks AND avoid bad ones
  • Filtering data

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:

cfg = [];
cfg.channels_source = 'montage';  % default behavior anyway. 

Python:

cfg = dict()
cfg['channels_source'] = ['montage']

Get current selection (only in GUI context)

MATLAB:

cfg = [];
cfg.channels_source = 'selection';

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:

cfg = [];
cfg.channels_source = 'raw';

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:

cfg = [];
cfg.labels = {'Fp1', 'ECG', 'A1', 'A2-A3'};  

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:

cfg = [];
% only EEG 
cfg.types = {'EEG'};  
% EEG and ECG
cfg.types = {'EEG', 'ECG'};

Python:

cfg = dict()
# only EEG
cfg['types'] = ['EEG']
# EEG and ECG
cfg['types'] = ['EEG', 'ECG']

Selecting data chunks

I want data between time positions

cfg = [];
%  get 10s of data starting 1s after the beginning of the file
cfg.start = 1; 
cfg.duration  = 10;
output = anywave('get_data', cfg);
cfg = {'start': 1, 'duration' : 10}
output = anywave.get_data_ex(cfg)

I want several data chunks appended

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.
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:

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.
%%
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

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.
%%
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:

cfg = [];
cfg.skip_markers = { 'artefact', 'bad'};
output = anywave('get_data', cfg);  % data chunks appended 
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.

cfg = [];
cfg.use_markers = { 'section2', 'h2' ]; % the labels of markers
cfg.skip_markers = { 'artefact', 'bad'};
output = anywave('get_data', cfg);  % data chunks appended 
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

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;
Clone repository
  • Build_AnyWave
  • CLI
  • CLI_List
  • Changes
  • ExportData
  • MATLAB_API
  • MATLAB_BIDS
  • MATLAB_debug
  • MATLAB_functions
  • MATLAB_get_data
  • MATLAB_get_data_ex
  • MATLAB_get_markers
  • MATLAB_get_props
  • MATLAB_init
  • MATLAB_run
View All Pages