Reference Source

Function

Static Public Summary
public

addInfo(info: Object): Observable<Sample|Epoch|PSD>

Annotates stream with user-defined metadata

public

addSignalQuality(options: Object): Observable<Epoch>

public

alphaPower(): Observable<Array<number>>

Returns the average alpha power from a stream of PSDs

public

averageDeep(): Observable

public

averagePower(): Observable

Takes a stream of PSDs and returns a sream of arrays, containing the average power in each channel

public

bandpassFilter(options: Object): Observable<Sample|Epoch>

Applies a bandpass filter to EEG Data.

public

betaPower(): Observable<Array<number>>

Returns the average beta power from a stream of PSDs

public

bufferFFT(options: Object): Observable

Takes a stream of Samples and applies a Fast Fourier Transform to return a stream of PSDs (Power Spectral Density).

public

bufferToEpoch(options: Object): Observable<Epoch>

Takes an array or RxJS buffer of EEG Samples and returns an Epoch.

public

createEEG(objectPattern: {"channels": *, "samplingRate": *, "mock": *, "NaNRange": *, "sine": *, "csv": *})

public

createMockStream(options: {}): *

public

deltaPower(): Observable<Array<number>>

Returns the average delta power from a stream of PSDs

public

epoch(options: Object): Observable

Converts a stream of individual Samples of EEG data into a stream of Epochs of a given duration emitted at specified interval.

public

fft(options: Object): Observable<PSD>

Applies a Fast Fourier Transform to a stream of Epochs of EEG data and returns a stream of PSDs (Power Spectral Density).

public

gammaPower(): Observable<Array<number>>

Returns the average gamma power from a stream of PSDs

public

groupByChannel(samplesBuffer: Array<Sample>, dataProp: string): Array<Array<number>>

Get a 2D data array organized by channel from an array of Samples.

public

highpassFilter(options: Object): Observable<Sample|Epoch>

Applies a highpass filter to EEG Data.

public

isEpoch(eegObject: *)

public

lowpassFilter(options: Object): Observable<Sample|Epoch>

Applies a lowpass filter to EEG Data.

public

max(array: *)

A collection of useful statistics functions Adapted from Daniel Hug's gist: https://gist.github.com/Daniel-Hug/7273430

public

mean(array: *)

public

meanAbsoluteDeviation(array: *): *

public

min(array: *)

public

notchFilter(options: Object): Observable<Sample|Epoch>

Applies a notch filter to EEG Data.

public

pickChannels(options: Object): Observable

public

powerByBand(bands: Object): Observable<Array<number>>

Takes a stream of PSDs and returns the average power for each of the classic EEG bands (alpha, beta, theta, etc.).

public

range(array: *)

public

removeChannels(options: Object): Observable

public

sliceFFT(range: Array<number>): Observable<PSD>

Slices a stream of PSDs to a specific frequency range defined by a minimum and maximum frequency in Hz

public

standardDeviation(array: *)

public

sum(array: *): *

public

thetaPower(): Observable<Array<number>>

Returns the average theta power from a stream of PSDs

public

variance(array: *): *

public

voltsToMicrovolts(options: Object): Observable<Sample|Epoch>

Converts a stream of EEG data (either eegObjects or Epochs) from volts to microvolts

public

zeroPad(Array: *, number: *): *

ZeroPads inputs for FFTs of non base 2

Static Public

public addInfo(info: Object): Observable<Sample|Epoch|PSD> source

Annotates stream with user-defined metadata

Params:

NameTypeAttributeDescription
info Object

Info to be added to the EEG stream. Relevant info may include: samplingRate and channelNames

Return:

Observable<Sample|Epoch|PSD>

Example:

eeg$.pipe(addinfo({ samplingRate: 256, channelNames: ["Af7", "Fp1", "Fp2", "Af8"] })

public addSignalQuality(options: Object): Observable<Epoch> source

Params:

NameTypeAttributeDescription
options Object

addSignalQuality options

options.dataProp string
  • optional
  • default: 'data

Name of key associated with eeg data

Return:

Observable<Epoch>

Example:

eeg$.pipe(addSignalQuality())

public alphaPower(): Observable<Array<number>> source

Returns the average alpha power from a stream of PSDs

Return:

Observable<Array<number>>

Example:

eeg$.pipe(epoch({ duration: 256, interval: 100, samplingRate: 256 }), fft({ bins: 256 }), alphaPower())

public averageDeep(): Observable source

Return:

Observable

average

public averagePower(): Observable source

Takes a stream of PSDs and returns a sream of arrays, containing the average power in each channel

Return:

Observable

band powers array

Example:

eeg$.pipe(epoch({ duration: 256, interval: 100, samplingRate: 256 }), fft({ bins: 256 }), sliceFFT(10, 20), averagePower())

public bandpassFilter(options: Object): Observable<Sample|Epoch> source

Applies a bandpass filter to EEG Data. Can be applied to both raw or epoched data

Params:

NameTypeAttributeDescription
options Object

Filter options

options.nbChannels number

Number of channels

options.cutoffFrequencies Array<number>
  • optional
  • default: [2,50]

Low and high cutoff frequencies in Hz

options.samplingRate number
  • optional
  • default: 250

Sampling rate of the EEG device

options.characteristic string
  • optional
  • default: 'butterworth'

Filter characteristic. Options are 'bessel' and 'butterworth'

options.order number
  • optional
  • default: 2

The number of 2nd order biquad filters applied to the signal

Return:

Observable<Sample|Epoch>

Example:

eeg$
.pipe(bandpassFilter({ cutoffFrequencies: [2, 50], nbChannels: 4 }))

public betaPower(): Observable<Array<number>> source

Returns the average beta power from a stream of PSDs

Return:

Observable<Array<number>>

Example:

eeg$.pipe(epoch({ duration: 256, interval: 100, samplingRate: 256 }), fft({ bins: 256 }), betaPower())

public bufferFFT(options: Object): Observable source

Takes a stream of Samples and applies a Fast Fourier Transform to return a stream of PSDs (Power Spectral Density). Note: this operator works by buffering the stream of samples into buffers that are as long as the supplied number of bins. Because it doesn't allow as much flexibility in terms of how often data is emitted we recommend using a combination of the epoch and fft operators instead.

Params:

NameTypeAttributeDescription
options Object

FFT options

options.bins number

Number of FFT bins. Must be a power of 2.

options.samplingRate number

Sampline rate of EEG siganl

options.dataProp string
  • optional
  • default: 'data

Name of the key associated with eeg data

Return:

Observable

Example:

eeg$.pipe(bufferFFT({ bins: 1024 }))

public bufferToEpoch(options: Object): Observable<Epoch> source

Takes an array or RxJS buffer of EEG Samples and returns an Epoch.

Params:

NameTypeAttributeDescription
options Object

Data structure options

options.samplingRate number
  • optional

Sampling rate

options.dataProp string
  • optional
  • default: 'data'

Name of the key associated with eeg data

Return:

Observable<Epoch>

Example:

eeg$.pipe(bufferTime(1000), bufferToEpoch({ samplingRate: 256 }))

public createEEG(objectPattern: {"channels": *, "samplingRate": *, "mock": *, "NaNRange": *, "sine": *, "csv": *}) source

import {createEEG} from '@neurosity/pipes/src/utils/createEEG.js'

Params:

NameTypeAttributeDescription
objectPattern {"channels": *, "samplingRate": *, "mock": *, "NaNRange": *, "sine": *, "csv": *}
  • optional
  • default: {}

public createMockStream(options: {}): * source

import {createMockStream} from '@neurosity/pipes/src/utils/createMockStream.js'

Params:

NameTypeAttributeDescription
options {}
  • optional
  • default: {}

Return:

*

public deltaPower(): Observable<Array<number>> source

Returns the average delta power from a stream of PSDs

Return:

Observable<Array<number>>

Example:

eeg$.pipe(epoch({ duration: 256, interval: 100, samplingRate: 256 }), fft({ bins: 256 }), deltaPower())

public epoch(options: Object): Observable source

Converts a stream of individual Samples of EEG data into a stream of Epochs of a given duration emitted at specified interval. This operator functions similarly to a circular buffer internally and allows overlapping Epochs of data to be emitted (e.g. emitting the last one second of data every 100ms).

Params:

NameTypeAttributeDescription
options Object

Epoching options

options.duration number
  • optional
  • default: 256

Number of samples to include in each epoch

options.interval number
  • optional
  • default: 100

Time (ms) between emitted Epochs

options.samplingRate number
  • optional
  • default: 256

Sampling rate

options.dataProp string
  • optional
  • default: 'data'

Name of the key associated with eeg data

Return:

Observable

Epoch

Example:

eeg$.pipe(epoch({ duration: 1024, interval: 100, samplingRate: 256 }))

public fft(options: Object): Observable<PSD> source

Applies a Fast Fourier Transform to a stream of Epochs of EEG data and returns a stream of PSDs (Power Spectral Density). Frequency resolution will be samplingRate / bins. If input Epoch duration is not equal to bins, data will be zero-padded or sliced so that is the same length as bins.

Params:

NameTypeAttributeDescription
options Object

FFT options

options.bins number

Number of FFT bins. Must be a power of 2.

options.dataProp string
  • optional
  • default: 'data

Name of the key associated with eeg data

Return:

Observable<PSD>

Example:

eeg$.pipe(epoch({ duration: 256, interval: 100, samplingRate: 256 }), fft({ bins: 256 }))

public gammaPower(): Observable<Array<number>> source

Returns the average gamma power from a stream of PSDs

Return:

Observable<Array<number>>

Example:

eeg$.pipe(epoch({ duration: 256, interval: 100, samplingRate: 256 }), fft({ bins: 256 }), gammaPower())

public groupByChannel(samplesBuffer: Array<Sample>, dataProp: string): Array<Array<number>> source

import {groupByChannel} from '@neurosity/pipes/src/utils/groupByChannel.js'

Get a 2D data array organized by channel from an array of Samples. Credit to Ken from Seattle's elegant transposition http://www.codesuck.com/2012/02/transpose-javascript-array-in-one-line.html

Params:

NameTypeAttributeDescription
samplesBuffer Array<Sample>

Array of Samples to be grouped

dataProp string
  • optional

Name of the key associated with EEG data

Return:

Array<Array<number>>

public highpassFilter(options: Object): Observable<Sample|Epoch> source

Applies a highpass filter to EEG Data. Can be applied to both raw or epoched data

Params:

NameTypeAttributeDescription
options Object

Filter options

options.nbChannels number

Number of channels

options.cutoffFrequency number
  • optional
  • default: 2

Cutoff frequency in Hz

options.samplingRate number
  • optional
  • default: 250

Sampling rate of the EEG device

options.characteristic string
  • optional
  • default: 'butterworth'

Filter characteristic. Options are 'bessel' and 'butterworth'

options.order number
  • optional
  • default: 2

The number of 2nd order biquad filters applied to the signal

Return:

Observable<Sample|Epoch>

Example:

eeg$
.pipe(highpassFilter({ cutoffFrequency: 2, nbChannels: 4 }))

public isEpoch(eegObject: *) source

Params:

NameTypeAttributeDescription
eegObject *

public lowpassFilter(options: Object): Observable<Sample|Epoch> source

Applies a lowpass filter to EEG Data. Can be applied to both raw or epoched data

Params:

NameTypeAttributeDescription
options Object

Filter options

options.nbChannels number

Number of channels

options.cutoffFrequency number
  • optional
  • default: 50

Cutoff frequency in Hz

options.samplingRate number
  • optional
  • default: 250

Sampling rate of the EEG device

options.characteristic string
  • optional
  • default: 'butterworth'

Filter characteristic. Options are 'bessel' and 'butterworth'

options.order number
  • optional
  • default: 2

The number of 2nd order biquad filters applied to the signal

Return:

Observable<Sample|Epoch>

Example:

eeg$
.pipe(lowpassFilter({ cutoffFrequency: 50, nbChannels: 4 }))

public max(array: *) source

A collection of useful statistics functions Adapted from Daniel Hug's gist: https://gist.github.com/Daniel-Hug/7273430

Params:

NameTypeAttributeDescription
array *

public mean(array: *) source

Params:

NameTypeAttributeDescription
array *

public meanAbsoluteDeviation(array: *): * source

import {meanAbsoluteDeviation} from '@neurosity/pipes/src/utils/stats.js'

Params:

NameTypeAttributeDescription
array *

Return:

*

public min(array: *) source

Params:

NameTypeAttributeDescription
array *

public notchFilter(options: Object): Observable<Sample|Epoch> source

Applies a notch filter to EEG Data. Can be applied to both raw or epoched data. Has the ability to filter out harmonics of line noise (e.g. 120Hz, 180Hz), though this is only needed for high-frequency devices with >= 1000hz sampling rate

Params:

NameTypeAttributeDescription
options Object

Filter options

options.nbChannels number

Number of channels

options.cutoffFrequency number
  • optional
  • default: 60

Cutoff frequency in Hz

options.bandWidth number
  • optional
  • default: 0.5

Width of the cutoff centered around the notched frequency. Larger values reduce filter out more of the notch frequency at the cost of also reducing nearby frequencies

options.filterHarmonics boolean
  • optional
  • default: false

Whether to filter harmonics of the notch frequency as well

options.samplingRate number
  • optional
  • default: 250

Sampling rate of the EEG device

options.characteristic string
  • optional
  • default: 'butterworth'

Filter characteristic. Options are 'bessel' and 'butterworth'

options.order number
  • optional
  • default: 2

Number of 2nd order biquad filters applied to the signal

Return:

Observable<Sample|Epoch>

Example:

eeg$
.pipe(notchFilter({ cutoffFrequency: 60, nbChannels: 10, samplingRate: 1000, filterHarmonics: true }))

public pickChannels(options: Object): Observable source

Params:

NameTypeAttributeDescription
options Object

Return:

Observable

sample

public powerByBand(bands: Object): Observable<Array<number>> source

Takes a stream of PSDs and returns the average power for each of the classic EEG bands (alpha, beta, theta, etc.). Classic EEG bands can be overridden by providing a custom bands object (e.g. { lowAlpha: [7.5, 10], highAlpha: [10, 12.5] })

Params:

NameTypeAttributeDescription
bands Object
  • optional

Custom bands object containing corresponding names and frequency ranges

Return:

Observable<Array<number>>

Example:

eeg$.pipe(epoch({ duration: 256, interval: 100, samplingRate: 256 }), fft({ bins: 256 }), powerByBand())

public range(array: *) source

Params:

NameTypeAttributeDescription
array *

public removeChannels(options: Object): Observable source

Params:

NameTypeAttributeDescription
options Object

Return:

Observable

sample

public sliceFFT(range: Array<number>): Observable<PSD> source

Slices a stream of PSDs to a specific frequency range defined by a minimum and maximum frequency in Hz

Params:

NameTypeAttributeDescription
range Array<number>

Array containing minimum and maximum frequencies

Return:

Observable<PSD>

Example:

eeg$.pipe(epoch({ duration: 256, interval: 100, samplingRate: 256 }), fft({ bins: 256 }), sliceFFT([2, 30]))

public standardDeviation(array: *) source

import {standardDeviation} from '@neurosity/pipes/src/utils/stats.js'

Params:

NameTypeAttributeDescription
array *

public sum(array: *): * source

Params:

NameTypeAttributeDescription
array *

Return:

*

public thetaPower(): Observable<Array<number>> source

Returns the average theta power from a stream of PSDs

Return:

Observable<Array<number>>

Example:

eeg$.pipe(epoch({ duration: 256, interval: 100, samplingRate: 256 }), fft({ bins: 256 }), thetaPower())

public variance(array: *): * source

import {variance} from '@neurosity/pipes/src/utils/stats.js'

Params:

NameTypeAttributeDescription
array *

Return:

*

public voltsToMicrovolts(options: Object): Observable<Sample|Epoch> source

Converts a stream of EEG data (either eegObjects or Epochs) from volts to microvolts

Params:

NameTypeAttributeDescription
options Object

Conversion options

options.useLog boolean
  • optional
  • default: false

Whether to use logarithmic conversion

options.dataProp string
  • optional
  • default: 'data'

Name of the key associated with eeg data

Return:

Observable<Sample|Epoch>

Example:

eeg&.pipe(toMicrovolts)

public zeroPad(Array: *, number: *): * source

ZeroPads inputs for FFTs of non base 2

Params:

NameTypeAttributeDescription
Array<number> *

bufferedData

number *

fftLength

Return:

*

Array<number>