Low-Level Function API

As well as providing convenient types for analysis. This package also provides low-level functions for dealing with data in its raw form. These low-level functions are described below.

Note: Currently sorting out the docs, so its a bit of a mess. Is there an automated way to list all functions using documenter?


Preprocessing

Filtering

Neuroimaging.compensate_for_filterFunction
compensate_for_filter(filter::FilterCoefficients, spectrum::AbstractArray, frequencies::AbstractArray, fs::Real)

Recover the spectrum of signal by compensating for filtering done.

Arguments

  • filter: The filter used on the spectrum
  • spectrum: Spectrum of signal
  • frequencies: Array of frequencies you want to apply the compensation to
  • fs: Sampling rate

Returns

Spectrum of the signal after comensating for the filter

source

Referencing

Neuroimaging.rereferenceFunction
rereference(signals::Array{T,2}, refChan::Union{Int,Array{Int}}) where {T<:AbstractFloat}
rereference(signals::Array{T,2}, refChan::Union{S,Array{S}}, chanNames::Vector{S}) where {S<:AbstractString}

Re reference a signals to specific signal channel by index, or by channel name from supplied list.

If multiple channels are specififed, their average is used as the reference.

Arguments

  • signals: Original signals to be modified
  • refChan: Index or name of channels to be used as reference.
  • chanNames: List of channel names associated with signals array

Returns

Rereferenced signals

source
rereference(a::EEG, refChan::Union{AbstractString, Array{AbstractString}}; kwargs...)

Reference data to specified channel(s).

Example

a = rereference(a, "Cz")
# or
a = rereference(a, ["P9", "P10"])
source
Neuroimaging.remove_templateFunction
remove_template(signals::Array{T,2}, template::AbstractVector{T})

Remove a template signal from each column of an array

Arguments

  • signals: Original signals to be modified (samples x channels)
  • template: Template to remove from each signal

Returns

Signals with template removed

source

Epoching

Neuroimaging.epoch_rejectionFunction
epoch_rejection(epochs::Array{T,3}, retain_percentage::AbstractFloat; rejection_method::Function = Neuroimaging.peak2peak) where {T<:Number}

Reject epochs based on the maximum peak to peak voltage within an epoch across all channels

Arguments

  • epochs: Array containing the epoch data in the format samples x epochs x channels
  • retain_percentage: The percentage of epochs to retain
  • rejection_method: Method to be used for epoch rejection (peak2peak)

Returns

  • An array with a reduced amount of entries in the epochs dimension
source
epoch_rejection(a::EEG; retain_percentage::Number = 0.95, kwargs...)

Reject epochs such that retain_percentage is retained.

source
Neuroimaging.peak2peakFunction
peak2peak(epochs::Array{T,3}) where {T<:Number}

Find the peak to peak value for each epoch to be returned to epoch_rejection()

source
Neuroimaging.extract_epochsFunction

Extract epoch data from array of channels.

Input

  • Array of raw data. Samples x Channels
  • Dictionary of trigger information
  • Vector of valid trigger numbers
  • Number of first triggers to remove
  • Number of end triggers to remove

Example

epochs = extract_epochs(data, triggers, [1,2], 0, 0)
source
function extract_epochs(a::SSR; valid_triggers::Union{AbstractArray,Int} = [1, 2], remove_first::Int = 0, remove_last::Int = 0, kwargs...)

Extract epoch data from SSR

Arguments

  • a: A SSR object
  • valid_triggers: Trigger numbers that are considered valid ([1,2])
  • remove_first: Remove the first n triggers (0)
  • remove_last: Remove the last n triggers (0)

Examples

epochs = extract_epochs(SSR, valid_triggers=[1,2])
source

Channels

Neuroimaging.match_sensorsFunction
match_sensors(sens::Array{S}, lbls::Array{AS}) where {AS<:AbstractString, S<:Sensor}

Match a set of electrodes to those provided

Examples

lf, valid = match_sensors(electrodes, sensor_labels)
source
Neuroimaging.channel_rejectionFunction
channel_rejection(sigs::Array{T}, threshold_abs::Number, threshold_var::Number) where {T<:Number}

Reject channels with too great a variance.

Rejection can be based on a threshold or dynamicly chosen based on the variation of all channels.

Arguments

  • signals: Array of data in format samples x channels
  • threshold_abs: Absolute threshold to remove channels with variance above this value
  • threshold_std: Reject channels with a variance more than n times the std of all channels

Returns

An array indicating the channels to be kept

source

Triggers

TODO: Make a type subsection similar to EEG and ASSR.

Neuroimaging.join_triggersFunction

Append the trigger information of one EEG type to another. Places the trigger information at the end of first file

Example

join_triggers(a, b)
source
Neuroimaging.validate_triggersFunction
validate_triggers(t::Dict)

Validate trigger channels have required keys and information.

Trigger information is stored in a dictionary containing three fields, all referenced in samples:

  • Index: Start of trigger
  • Code: Code of trigger
  • Duration: Duration of trigger
source
Neuroimaging.clean_triggersFunction
clean_triggers(t::Dict, valid_triggers::Array{Int}, min_epoch_length::Int, max_epoch_length::Int, remove_first::Int, max_epochs::Int)

Clean trigger channel information by removing specified epochs if they are too long or short. Can also remove the first trigger which often represent the start of a condition or measurement. Can also be used to limit the number of total epochs.

source

Dipoles

TODO: Make a type subsection similar to EEG and ASSR.

Neuroimaging.find_dipolesFunction

Find all dipole in an activity map.

Determines the local maxima in a 3 dimensional array

Input

  • s: Activity in 3d matrix
  • window: Windowing to use in each dimension for min max filter
  • x,y,z: Coordinates associated with s matrix

Output

  • dips: An array of dipoles
source