Skip to content

ica_command

ica_command rejects independent components of the ICA currently loaded in AnyWave, or restores them. It does what you do by hand when you reject components in the ICA panel: AnyWave marks the components as rejected and rebuilds the signals.

aw.ica_command(cfg)

Note

The function is called ica_command in Python. In MATLAB the command is called ica.

cfg is a dict:

key content required
'labels' list of the labels of the components yes
'command' 'reject' (default) or 'undo' no

The labels of the components start with the modality: E_IC1, E_IC2... for EEG, S_IC1... for sEEG, M_IC1... for MEG and EMG_IC1... for EMG. The numbering starts at 1.

Examples

Reject components 10 and 15 of a MEG ICA:

import sys
import anywave as aw

aw.init(sys.argv)

aw.ica_command({'labels': ['M_IC10', 'M_IC15'], 'command': 'reject'})     # 'reject' is the default

Restore them:

aw.ica_command({'labels': ['M_IC10', 'M_IC15'], 'command': 'undo'})

Build the list of labels in your code:

rejected = [1, 4, 7]                                    # numbers of the components
aw.ica_command({'labels': ['E_IC%d' % k for k in rejected]})

Good to know

  • An ICA must be loaded in AnyWave. Without an ICA the command is accepted and nothing happens.
  • A single label may be given as a string: {'labels': 'E_IC1'} is the same as {'labels': ['E_IC1']}.
  • A label that is not a component of the loaded ICA (E_IC99, or M_IC1 when only an EEG ICA is loaded) is ignored, without any error: check the names of your labels.
  • The function returns None. The views are updated as when you reject or restore a component by hand, see Reject components.

Errors

When AnyWave refuses the request, ica_command raises an Exception with the message of AnyWave:

message cause
ERROR: labels key is not specified in struct/dict parameter. no 'labels' key
ERROR: labels is empty. 'labels' is an empty list
ERROR: command must be 'reject' or 'undo'. any other value for 'command'
ica_command: argument must be a dict the argument is not a dict