Skip to content

← neural package

SpectrallyWeightedCommonSpatialPattern

Extract spatio-spectral signal components whose variance optimally discriminates between two conditions.

Spec-CSP generalizes the basic CSP method to include spectral filters, and like CSP it can be used as an adaptive preprocessing step for a multichannel signal, such as EEG, EMG, or MEG, whose variance shall subsequently be used in a classification setup (e.g., to predict some binary target variable, for instance in order to discriminate between two possible cognitive states). The resulting components will usually yield better spectral features than the raw channels, leading to better classification accuracy. This node will calibrate itself if it receives a non-streaming (offline) chunk that has a time, space, and instance axis, and which has a target value for each instance (similarly to how machine learning nodes operate). Instances correspond to labeled trials, the space axis represents the channels which are being filtered, and time are the time points of each trial segment. Spec-CSP should be preceded at least by a highpass or bandpass filter (e.g., FIR or IIR prior to segmentation). Spec-CSP only works for two classes. Spec-CSP is a state-of-the-art spatio-spectral filtering method, and has been shown to be on par with alternative methods such as CSSP and CSSSP. Another spectral alternative is Filter-Bank Common Spatial Patterns (FBCSP). Since the method learns a good spectral filter by itself, it can be used in cases where the relevant frequency band is not known, and as such it can be useful in settings where there is little established a priori knowledge on those bands, for instance EEG collected in non-traditional tasks. Tip: a continuous time series with markers can be segmented into multiple labeled trials / segments using the Assign Target Markers node followed by the Segmentation node. Version 1.0.0

Ports/Properties

data

Data to process.

  • verbose name: Data
  • default value: None
  • port type: DataPort
  • value type: Packet (can be None)
  • data direction: INOUT

cond_field

The name of the instance data field that contains the conditions to be discriminated. This parameter will be ignored if the packet has previously been processed by a DescribeStatisticalDesign node.

  • verbose name: Cond Field
  • default value: TargetValue
  • port type: StringPort
  • value type: str (can be None)

nof

Number of spatio-spectral pattern pairs to compute. This determines the number of output channels (which is 2x this value) and thus the dimensionality of the feature space. Typical values are 2-4; while one can generate more features (up to the number of input channels), these will be increasingly less useful to the classifier.

  • verbose name: Number Of Pattern Pairs
  • default value: 3
  • port type: IntPort
  • value type: int (can be None)

shrinkage

Shrinkage coefficient for covariance matrix estimation.

  • verbose name: Shrinkage
  • default value: 0
  • port type: FloatPort
  • value type: float (can be None)

prior_freq_range

A priori choice of relevant frequency band. The method will find optimal spectral weightings within that band.

  • verbose name: Frequency Band Limits
  • default value: [7, 30]
  • port type: ListPort
  • value type: list (can be None)

reg_param_p

Regularization parameter p. Can be tuned in the range -1..+1 if desired, but the default value is a good choice.

  • verbose name: Regularization Parameter P
  • default value: 0
  • port type: FloatPort
  • value type: float (can be None)

reg_param_q

Regularization parameter q. Can be tuned in the range 0..4 if desired, but the default value is a good choice.

  • verbose name: Regularization Parameter Q
  • default value: 1
  • port type: FloatPort
  • value type: float (can be None)

iterations

Number of iterations for spatio-spectral filter optimization. Should not be lower than 3, but higher values have not been shown to be effective.

  • verbose name: Iterations
  • default value: 3
  • port type: IntPort
  • value type: int (can be None)

spectrum_method

Method for calculating the spectral weighting. The Welch and Multitaper methods, respectively, allow for controlling the smoothness of the spectrum, which can yield better-behaved spectral filters.

  • verbose name: Spectrum Method
  • default value: Periodogram
  • port type: EnumPort
  • value type: str (can be None)

min_fft_size

Minimum size of the FFT used in spectrum calculation. The chosen value is the greater of this and the next power of 2 greater than the length of the signal.

  • verbose name: Min Fft Size
  • default value: 256
  • port type: IntPort
  • value type: int (can be None)

multitaper_time_halfbandwidth_product

Spectral smoothing parameter for multi-taper. Technically this is the time-halfbandwidth product, and typical values lie in the range of 2.5 to 5 (in increments of 0.5)

  • verbose name: Multitaper Spectral Smoothing
  • default value: 2.5
  • port type: FloatPort
  • value type: float (can be None)

multitaper_num_tapers

Number of tapers in multi-taper method. The default is 2 times the time-halfbandwidth product minus 1.

  • verbose name: Multitaper Num Tapers
  • default value: None
  • port type: IntPort
  • value type: int (can be None)

welch_window_length

Length of overlapped windows in case of Welch spectral estimation, can be either in samples or seconds. Using a smaller value (e.g., 1/4-1/8th of the chunk length) yields a smoother spectrum. The default is 1/2 of the chunk length.

  • verbose name: Welch Window Length
  • default value: None
  • port type: IntPort
  • value type: int (can be None)

welch_window_unit

Unit in which the window length is given.

  • verbose name: Welch Window Length Unit
  • default value: samples
  • port type: EnumPort
  • value type: str (can be None)

welch_overlap_length

Amount of overlap of successive windows in Welch method, it can be either in samples, seconds or even percentage of the window length. The default is half of the window length.

  • verbose name: Welch Overlap Length
  • default value: None
  • port type: IntPort
  • value type: int (can be None)

epsilon

Small value to prevent division by zero. This is only needed on challenging data.

  • verbose name: Epsilon
  • default value: 1e-15
  • port type: FloatPort
  • value type: float (can be None)

welch_overlap_unit

Unit in which the overlap window length is given.

  • verbose name: Overlap Window Length Unit
  • default value: samples
  • port type: EnumPort
  • value type: str (can be None)

initialize_once

Do not recalibrate on subsequent offline chunks, even if they include target labels. If False, this node will recalibrate itself on any offline chunk that has data plus target labels.

  • verbose name: Calibrate Only Once
  • default value: True
  • port type: BoolPort
  • value type: bool (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

  • verbose name: Set Breakpoint (Debug Only)
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

  • verbose name: Metadata
  • default value: {}
  • port type: DictPort
  • value type: dict (can be None)