NeuroAnalyzer.jl documentation
This documentation has been generated using Documenter.jl.
NeuroAnalyzer
NeuroAnalyzer.na_info
— Methodna_info()
Show NeuroAnalyzer and imported packages versions.
NeuroAnalyzer.na_plugins_reload
— Methodna_plugins_reload()
Reload NeuroAnalyzer plugins.
NeuroAnalyzer.na_plugins_list
— Methodna_plugins_list()
List NeuroAnalyzer plugins.
NeuroAnalyzer.na_plugins_remove
— Methodna_plugins_remove(plugin)
Remove NeuroAnalyzer plugin
.
Arguments
plugin::String
: plugin name
NeuroAnalyzer.na_plugins_install
— Methodna_plugins_install(plugin)
Install NeuroAnalyzer plugin
.
Arguments
plugin::String
: plugin Git repository URL
NeuroAnalyzer.na_plugins_update
— Functionna_plugins_update(plugin)
Install NeuroAnalyzer plugin
.
Arguments
plugin::String
: plugin to update; if empty, update all
NeuroAnalyzer.na_set_use_cuda
— Methodna_set_use_cuda(use_cuda)
Change use_cuda
preference.
Arguments
use_cuda::Bool
: value
NeuroAnalyzer.na_set_progress_bar
— Methodna_set_progress_bar(progress_bar)
Change progress_bar
preference.
Arguments
progress_bar::Bool
: value
NeuroAnalyzer.na_set_prefs
— Methodna_set_prefs(use_cuda, plugins_path, progress_bar, verbose)
Save NeuroAnalyzer preferences.
Arguments
use_cuda::Bool
progress_bar::Bool
verbose::Bool
NeuroAnalyzer.na_set_verbose
— Methodna_set_verbose(verbose)
Change verbose
preference.
Arguments
verbose::Bool
: value
NeuroAnalyzer.na_version
— Methodna_version()
Convert NeuroAnalyzer version to string.
Returns
VER::String
Utils
NeuroAnalyzer.apply
— Methodapply(obj; ch, f)
Apply custom function.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsf::String
: function to be applied, e.g.f="mean(obj, dims=3)"; OBJ signal is given using variable
obj` here.
Returns
out::Array{Float64, 3}
NeuroAnalyzer.l1
— Methodl1(a1, a2)
Compare two arrays (e.g. two spectrograms), using L1 (Manhattan) distance.
Arguments
a1::AbstractArray
: first arraya2::AbstractArray
: second array
Returns
l1::Float64
NeuroAnalyzer.l2
— Methodl2(a1, a2)
Compare two arrays (e.g. two spectrograms), using L2 (Euclidean) distance.
Arguments
a1::AbstractArray
: first arraya2::AbstractArray
: second array
Returns
l2::Float64
NeuroAnalyzer.perm_cmp
— Methodperm_cmp(a1, a2; p, perm_n)
Compare two 3-dimensional arrays a1
and a2
(e.g. two spectrograms), using permutation based statistic.
Arguments
a1::Array{<:Real, 3}
: first arraya2::Array{<:Real, 3}
: second arrayp::Float64=0.05
: p-valueperm_n::Int64=1000
: number of permutations
Returns
Named tuple containing:
zmap::Array{Float64, 3}
: array of Z-valuesbm::Array{Float64, 3}
: binarized mask of statistically significant positions
NeuroAnalyzer.component_type
— Methodcomponent_type(obj, c)
Return component data type.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component name
Return
c_type::DataType
NeuroAnalyzer.rename_component
— Methodrename_component(obj, c_old, c_new)
Rename component.
Arguments
obj::NeuroAnalyzer.NEURO
c_old::Symbol
: old component namec_new::Symbol
: new component name
Return
obj_new::NEURO
NeuroAnalyzer.rename_component!
— Methodrename_component!(obj, c_old, c_new)
Rename component.
Arguments
obj::NeuroAnalyzer.NEURO
c_old::Symbol
: old component namec_new::Symbol
: new component name
NeuroAnalyzer.add_component
— Methodadd_component(obj; c, v)
Add component.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component namev::Any
: component value
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_component!
— Methodadd_component!(obj; c, v)
Add component.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component namev::Any
: component value
NeuroAnalyzer.list_component
— Methodlist_component(obj)
List component names.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
components::Vector{Symbol}
NeuroAnalyzer.extract_component
— Methodextract_component(obj, c)
Extract component values.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component name
Returns
c::Any
NeuroAnalyzer.delete_component
— Methoddelete_component(obj; c)
Delete component.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component name
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_component!
— Methoddelete_component!(obj; c)
Delete component.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component name
NeuroAnalyzer.reset_components
— Methodreset_components(obj)
Remove all components.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.reset_components!
— Methodreset_components!(obj)
Remove all components.
Arguments
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.fft0
— Functionfft0(x, n)
Zeros-padded FFT.
Arguments
x::AbstractVector
n::Int64
: number of zeros to add
Returns
fft0::Vector{ComplexF64}
NeuroAnalyzer.ifft0
— Functionifft0(x, n)
IFFT of zero-padded vector.
Arguments
x::AbstractVector
n::Int64
: number of zeros added tox
Returns
ifft0::Vector{Float64}
: real part of the signal trimmed to original length
NeuroAnalyzer.fft2
— Methodfft2(x)
Zeros-padded FFT, so the length of padded vector is a power of 2.
Arguments
x::AbstractVector
Returns
fft2::Vector{ComplexF64}
NeuroAnalyzer.nextpow2
— Methodnextpow2(x)
Return the next power of 2 for given number x
.
Argument
x::Int64
Returns
nextpow2::Int64
NeuroAnalyzer.dft
— Methoddft(signal; fs, pad)
Return FFT and DFT sample frequencies for a DFT.
Arguments
signal::AbstractVector
fs::Int64
: sampling ratepad::Int64=0
: number of zeros to add
Returns
Named tuple containing:
ft::Vector{ComplexF64}
: FFTf::Vector{Float64}
: sample frequencies
NeuroAnalyzer.dft
— Methoddft(obj; channel)
Return FFT and DFT sample frequencies for a DFT.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelspad::Int64=0
: number of zeros to add signal for FFT
Returns
Named tuple containing:
ft::Array{ComplexF64, 3}
: FFTf::Vector{Float64}
: sample frequencies
NeuroAnalyzer.findpeaks
— Methodfindpeaks(signal; d)
Find peaks.
Arguments
signal::AbstractVector
d::Int64=32
: distance between peeks in samples
Returns
p_idx::Vector{Int64}
NeuroAnalyzer.hz2rads
— Methodhz2rads(f)
Convert frequency f
in Hz to rad/s.
Arguments
f::Real
Returns
f_rads::Float64
NeuroAnalyzer.rads2hz
— Methodrads2hz(f)
Convert frequency f
in rad/s to Hz.
Arguments
f::Real
Returns
f_rads::Float64
NeuroAnalyzer.t2f
— Methodt2f(t)
Convert cycle length in ms to frequency.
Arguments
t::Real
: cycle length in ms
Returns
f::Float64
: frequency in Hz
NeuroAnalyzer.f2t
— Methodf2t(f)
Convert frequency to cycle length in ms.
Arguments
f::Real
: frequency in Hz
Returns
f::Float64
: cycle length in ms
NeuroAnalyzer.freqs
— Methodfreqs(t)
Return vector of frequencies and Nyquist frequency for time vector.
Arguments
t::AbstractVector, AbstractRange}
: time vector
Returns
hz::Vector{Float64}
nf::Float64
NeuroAnalyzer.freqs
— Methodfreqs(s, fs)
Return vector of frequencies and Nyquist frequency for signal.
Arguments
s::Vector{Float64}
fs::Int64
Returns
hz::Vector{Float64
: signal vectornf::Float64
NeuroAnalyzer.freqs
— Methodfreqs(obj)
Return vector of frequencies and Nyquist frequency.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
Named tuple containing:
hz::Vector{Float64}
nf::Float64
NeuroAnalyzer.generate_window
— Methodgenerate_window(type, n; even)
Return the n
-point long symmetric window type
.
Arguments
type::Symbol
: window type::hann
: Hann:bh
: Blackman-Harris:bohman
: Bohman:flat
: Flat-top window:bn
: Blackman-Nuttall:nutall
: Nuttall:triangle
: symmetric triangle (left half ↑, right half ↓):exp
: symmetric exponential (left half ↑, right half ↓)
n::Int64
: window lengtheven::Bool=false
: if true, make the window of even length (+1 for odd n)
Returns
w::Vector{Float64}
:: generated window
NeuroAnalyzer.generate_sine
— Functiongenerate_sine(f, t, a, p)
Generates sine wave.
Arguments
f::Real
: frequency [Hz]t::Union{AbstractVector, AbstractRange}
: time vectora::Real
: amplitudep::Real
: initial phase
Returns
- s::Vector{Float64}`
NeuroAnalyzer.generate_csine
— Functiongenerate_csine(f, t, a)
Generates complex sine wave.
Arguments
f::Real
: frequency [Hz]t::Union{AbstractVector, AbstractRange}
: time vectora::Real
: amplitude
Returns
- cs::Vector{ComplexF64}`
NeuroAnalyzer.generate_sinc
— Functiongenerate_sinc(t, f, peak, norm)
Generate sinc function.
Arguments
t::AbstractRange=-2:0.01:2
: timef::Real=10.0
: frequencypeak::Real=0
: sinc peak timenorm::Bool=true
: generate normalized function
Returns
s::Vector{Float64}
NeuroAnalyzer.generate_morlet
— Functiongenerate_morlet(fs, f, t; ncyc, complex)
Generate Morlet wavelet.
Arguments
fs::Int64
: sampling ratef::Real
: frequencyt::Real=1
: length = -t:1/fs:tncyc::Int64=5
: number of cyclescomplex::Bool=false
: generate complex Morlet
Returns
morlet::Union{Vector{Float64}, Vector{ComplexF64}}
NeuroAnalyzer.generate_gaussian
— Functiongenerate_gaussian(fs, f, t; ncyc, a)
Generate Gaussian wave.
Arguments
fs::Int64
: sampling ratef::Real
: frequencyt::Real=1
: length = -t:1/fs:tncyc::Int64
: : number of cycles, width, SD of the Gaussiana::Real=1
: peak amp
Returns
g::Vector{Float64}
NeuroAnalyzer.generate_noise
— Functiongenerate_noise(n, amp; type)
Generate noise.
Arguments
n::Int64
: length (in samples)amp::Real=1.0
: amplitude, signal amplitude will be in[-amp, +amp]
type::Symbol=:whiten
: noise type::whiten
: normal distributed:whiteu
: uniformly distributed:pink
Returns
s::Float64
NeuroAnalyzer.generate_morlet_fwhm
— Functiongenerate_morlet_fwhm(fs, f, t; h)
Generate Morlet wavelet using Mike X Cohen formula.
Arguments
fs::Int64
: sampling ratef::Real
: frequencyt::Real=1
: length = -t:1/fs:th::Float64=0.25
: full width at half-maximum in seconds (FWHM)
Returns
mw::Vector{ComplexF64}
Source
Cohen MX. A better way to define and describe Morlet wavelets for time-frequency analysis. NeuroImage. 2019 Oct;199:81–6.
NeuroAnalyzer.generate_square
— Functiongenerate_square(t, a, p, w, offset)
Generates square wave.
Arguments
t::Union{AbstractVector, AbstractRange}
: time vectora::Real
: amplitudep::Real
: duty cyclew::Real
: widthoffset::Real
: amplitude offset
Returns
- s::Vector{Float64}`
NeuroAnalyzer.generate_triangle
— Functiongenerate_triangle(t, a)
Generates triangle wave.
Arguments
t::Union{AbstractVector, AbstractRange}
: time vectora::Real
: amplitude
Returns
- s::Vector{Float64}`
NeuroAnalyzer.sr
— Methodsr(obj)
Return sampling rate.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
sr::Int64
NeuroAnalyzer.channel_n
— Methodchannel_n(obj; type)
Return number of channels of type
.
Arguments
obj::NeuroAnalyzer.NEURO
type::Vector{Symbol}=:all
: channel type (stored in the global channel_types constant variable)
Returns
ch_n::Int64
NeuroAnalyzer.epoch_n
— Methodepoch_n(obj)
Return number of epochs.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
ep_n::Int64
NeuroAnalyzer.signal_len
— Methodsignal_len(obj)
Return signal length.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
s_len::Int64
NeuroAnalyzer.epoch_len
— Methodepoch_len(obj)
Return epoch length.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
ep_len::Int64
NeuroAnalyzer.history
— Methodhistory(obj)
Show processing history.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
history::Vector{String}
NeuroAnalyzer.labels
— Methodlabels(obj)
Return channel labels.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
labels::Vector{String}
NeuroAnalyzer.info
— Methodinfo(obj)
Show info.
Arguments
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.channel_cluster
— Methodchannels_cluster(obj, cluster)
Return channels belonging to a cluster
of channels.
Arguments
obj::NeuroAnalyzer.NEURO
cluster::Symbol
: available clusters are::f1
: left frontal (F1, F3, F5, F7, AF3, AF7):f2
: right frontal (F2, F4, F6, F8, AF4, AF8):t1
: left temporal (C3, C5, T7, FC3, FC5, FT7):t2
: right temporal (C4, C6, T8, FC4, FC6, FT8):c1
: anterior central (Cz, C1, C2, FC1, FC2, FCz):c2
: posterior central (Pz, P1, P2, CP1, CP2, CPz):p1
: left parietal (P3, P5, P7, CP3, CP5, TP7):p2
: right parietal (P4, P6, P8, CP4, CP6, TP8):o
: occipital (Oz, O1, O2, POz, PO3, PO4)
Returns
ch::Vector{Int64}
: list of channel numbers belonging to a given cluster of channels
NeuroAnalyzer.band_frq
— Methodband_frq(obj, band)
Return frequency limits for a band
.
Arguments
obj::NeuroAnalyzer.NEURO
band::Symbol
: band range name::list
:total
:delta
:theta
:alpha
:beta
:beta_high
:gamma
:gamma_1
:gamma_2
:gamma_lower
:gamma_higher
.
Returns
band_frequency::Tuple{Real, Real}
NeuroAnalyzer.band_frq
— Methodband_frq(fs, band)
Return frequency limits of a band
.
Arguments
fs::Int64
: sampling rateband::Symbol
: band range name::list
:total
:delta
:theta
:alpha
:beta
:beta_high
:gamma
:gamma_1
:gamma_2
:gamma_lower
:gamma_higher
.
Returns
band_frq::Tuple{Real, Real}
NeuroAnalyzer.describe
— Methoddescribe(obj)
Return basic descriptive statistics of obj.data
.
Arguments
obj::NeuroAnalyzer.NEURO
Base.size
— Methodsize(obj)
Return size of the obj
data.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
size::Tuple{Int64, Int64, Int64}
NeuroAnalyzer.m_pad0
— Methodm_pad0(m)
Pad matrix with zeros to make it square.
Arguments
m::Matrix{<:Number}
Returns
m::Matrix{<:Number}
NeuroAnalyzer.m_sortperm
— Methodm_sortperm(m; rev=false, dims=1)
Generates sorting index for matrix m
by columns (dims
= 1) or by rows (dims
= 2).
Arguments
m::AbstractMatrix
rev::Bool
dims::Int64
Returns
idx::Matrix{Int64}
NeuroAnalyzer.m_sort
— Methodm_sort(m, m_idx; rev=false, dims=1)
Sorts matrix m
using sorting index m_idx
Arguments
m::Matrix
m_idx::Vector{Int64}
rev::Bool=false
dims::Int64=1
: sort by columns (dims=1
) or by rows (dims=2
)
Returns
m_sorted::Matrix
NeuroAnalyzer.m_norm
— Methodm_norm(m)
Normalize matrix.
Arguments
m::AbstractArray
Returns
m_norm::AbstractArray
NeuroAnalyzer.linspace
— Methodlinspace(start, stop, length)
Generates a sequence of evenly spaced numbers between start
and stop
.
Arguments
start::Number
stop::Number
n::Int64
: sequence length
Returns
range::Vector
NeuroAnalyzer.logspace
— Methodlogspace(start, stop, n)
Generates a sequence of log10-spaced numbers between start
and stop
.
Arguments
start::Number
stop::Number
n::Int64
: sequence length
Returns
range::Vector{<:Number}
NeuroAnalyzer.cmax
— Methodcmax(x)
Return maximum value of the complex vector.
Arguments
x::Vector{ComplexF64}
Returns
cmax::ComplexF64
NeuroAnalyzer.cmin
— Methodcmin(x)
Return minimum value of the complex vector.
Arguments
x::Vector{ComplexF64}
Returns
cmin::ComplexF64
NeuroAnalyzer.tuple_order
— Functiontuple_order(t, rev)
Order tuple elements in ascending or descending (rev=true
) order.
Arguments
t::Tuple{Real, Real}
rev::Bool=false
Returns
t::Tuple{Real, Real}
NeuroAnalyzer.cums
— Methodcums(signal)
Calculate cumulative sum.
Arguments
signal::Array{<:Real, 3}
Returns
signal_cs::Array{Float64, 3}
NeuroAnalyzer.f_nearest
— Methodf_nearest(m, pos)
Find nearest position tuple pos
in vector of positions m
.
Arguments
m::Matrix{Tuple{Float64, Float64}}
p::Tuple{Float64, Float64}
Returns
pos::Tuple{Int64, Int64}
: row and column in m
NeuroAnalyzer.view_note
— Methodview_note(obj)
Return recording note.
Arguments
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_note
— Methodadd_note(obj; note)
Add recording note.
Arguments
obj::NeuroAnalyzer.NEURO
note::String
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_note!
— Methodadd_note!(obj; note)
Add recording note.
Arguments
obj::NeuroAnalyzer.NEURO
note::String
NeuroAnalyzer.delete_note
— Methoddelete_note(obj)
Delete recording note.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_note!
— Methoddelete_note!(obj)
Delete recording note.
Arguments
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.pad0
— Methodpad0(x, n)
Pad vector / rows of matrix / array with zeros. Works with 1-, 2- and 3-dimensional arrays.
Arguments
x::Union{AbstractVector, AbstractArray
n::Int64
: number of zeros to add
Returns
pad0::Union{AbstractVector, AbstractArray
NeuroAnalyzer.pad2
— Methodpad2(x)
Pad vector / rows of matrix / array with zeros to the nearest power of 2 length.
Arguments
x::Union{AbstractVector, AbstractArray
Returns
pad2::Union{AbstractVector, AbstractArray
NeuroAnalyzer.phases
— Functionphases(s; pad)
Calculate phases.
Arguments
s::AbstractVector
pad::Int64=0
: number of zeros to add
Returns
phases::Vector{Float64}
NeuroAnalyzer.pick
— Methodpick(obj; p)
Return set of channel indices corresponding with p
of electrodes
Arguments
p::Vector{Symbol}
: pick of electrodes; picks may be combined, e.g.[:left, :frontal]
:list
:central
(or:c
):left
(or:l
):right
(or:r
):frontal
(or:f
):temporal
(or:t
):parietal
(or:p
):occipital
(or:o
)
Returns
channels::Vector{Int64}
: channel numbers
NeuroAnalyzer.t2s
— Methodt2s(t, fs)
Convert time to sample number.
Arguments
t::T
: time in sfs::Int64
: sampling rate
Returns
t2s::Int64
: sample number
NeuroAnalyzer.s2t
— Methods2t(s, fs)
Convert sample number to time.
Arguments
t::Int64
: sample numberfs::Int64
: sampling rate
Returns
s2t::Float64
: time in s
NeuroAnalyzer.t2s
— Methodt2s(obj; t)
Convert time in seconds to samples.
Arguments
obj::NeuroAnalyzer.NEURO
t::T
: time in seconds
Returns
t2s::Int64
: time in samples
NeuroAnalyzer.s2t
— Methods2t(obj; s)
Convert time in samples to seconds.
Arguments
obj::NeuroAnalyzer.NEURO
s::Int64
: time in samples
Returns
s2t::Float64
: time in seconds
NeuroAnalyzer.to_df
— Methodto_df(obj)
Export OBJ data to DataFrame.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
df::DataFrame
: DataFrame containing time points and channels
NeuroAnalyzer.vsearch
— Methodvsearch(y, x; acc)
Return the positions of the y
value in the vector x
.
Arguments
y::T
: value of interestx::AbstractVector
: vector to search withinacc::Bool=false
: if true, return the difference betweeny
andx[idx]
Returns
idx::Int64
d::Real
: the difference betweeny
andx[idx]
NeuroAnalyzer.vsearch
— Methodvsearch(y, x; acc)
Return the positions of the y
vector in the vector x
.
Arguments
y::AbstractVector
: vector of interestx::AbstractVector
: vector to search withinacc::Bool=false
: if true, return the difference betweeny
andx[idx:idx + length(y)]
Returns
idx::Int64
d::Real
: the difference betweeny
andx[idx:idx + length(y)]
NeuroAnalyzer.vsplit
— Functionvsplit(x, n)
Splits the vector x
into n
-long pieces.
Argument
x::AbstractVector
n::Int64
Returns
x::Vector{AbstractVector}
NeuroAnalyzer.view_header
— Methodheader(obj)
Show keys and values of OBJ header.
Arguments
obj::NeuroAnalyzer.NEURO
IO
NeuroAnalyzer.export_csv
— Methodexport_csv(obj; file_name, header, components, markers, overwrite)
Export NeuroAnalyzer.NEURO
object to CSV.
Arguments
obj::NeuroAnalyzer.NEURO
file_name::String
header::Bool=false
: export headerepoch_time::Bool=false
: export epoch time pointscomponents::Bool=false
: export componentsmarkers::Bool=false
: export event markerslocs::Bool=false
: export channel locationshistory::Bool=false
: export historyoverwrite::Bool=false
NeuroAnalyzer.export_locs
— Methodexport_locs(obj; file_name, overwrite)
Export channel locations data, format is based on file_name
extension (.ced, .locs or .tsv)
Arguments
obj::NeuroAnalyzer.NEURO
file_name::String
overwrite::Bool=false
NeuroAnalyzer.export_locs
— Methodexport_locs(locs; file_name, overwrite)
Export channel locations, format is based on file_name
extension (.ced, .locs, .tsv)
Arguments
locs::DataFrame
file_name::String
overwrite::Bool=false
Returns
success::Bool
NeuroAnalyzer.export_markers
— Methodexport_markers(obj; file_name, overwrite)
Export NeuroAnalyzer.NEURO
object markers to CSV.
Arguments
obj::NeuroAnalyzer.NEURO
file_name::String
overwrite::Bool=false
NeuroAnalyzer.import_recording
— Methodimport_recording(file_name; detect_type)
Load recording file and return NeuroAnalyzer.NEURO
object. Supported formats:
- EDF/EDF+
- BDF/BDF+
- GDF
- BrainVision
- CSV
- SET (EEGLAB dataset)
- NWB (Neurodata Without Borders)
- FIFF
- SNIRF
- NIRS
This is a meta-function that triggers appropriate import_*()
function. File format is detected based on file extension (.edf|.bdf|.gdf|.vhdr|.ahdr|.csv|.csv.gz|.set|.nwb|.fif|.fiff|.snirf|.nirs). Signal data type (e.g. EEG or MEG is auto-detected) and stored in the obj.header.recording[:data_type]
field.
Arguments
file_name::String
: name of the file to loaddetect_type::Bool=true
: detect channel type based on channel labeln::Int64=0
: subject number to extract in case of multi-subject file
Returns
::NeuroAnalyzer.NEURO
NeuroAnalyzer.import_alice4
— Methodimport_alice4(file_name; detect_type)
Load EDF exported from Alice 4 Polysomnography System and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to loaddetect_type::Bool=true
: detect channel type based on its label
Returns
obj::NeuroAnalyzer.NEURO
Notes
- EDF files exported from Alice 4 have incorrect value of
data_records
(-1) and multiple sampling rate; channels are upsampled to the highest rate.
NeuroAnalyzer.import_bdf
— Methodimport_bdf(file_name; default_type)
Load BDF/BDF+ file and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to loaddetect_type::Bool=true
: detect channel type based on channel label
Returns
obj::NeuroAnalyzer.NEURO
Notes
- sampling_rate = n.samples ÷ data.record.duration
- gain = (physical maximum - physical minimum) ÷ (digital maximum - digital minimum)
- value = (value - digital minimum ) × gain + physical minimum
Source
https://www.biosemi.com/faq/file_format.htm
NeuroAnalyzer.import_bv
— Methodimport_bv(file_name; detect_type)
Load BrainVision BVCDF file and return NeuroAnalyzer.NEURO
object. At least two files are required: .vhdr (header) and .eeg (signal data). If available, markers are loaded from .vmrk file.
Arguments
file_name::String
: name of the file to load, should point to .vhdr file.detect_type::Bool=true
: detect channel type based on its label
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.import_csv
— Methodimport_csv(file_name; detect_type)
Load CSV file (e.g. exported from EEGLAB) and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to loaddetect_type::Bool=true
: detect channel type based on its label
Returns
obj::NeuroAnalyzer.NEURO
Notes
CSV first row or first column must contain channel names. Shape of data array will be detected automatically. Sampling rate will be detected. If file is gzip-ed, it will be uncompressed automatically while reading.
NeuroAnalyzer.import_digitrack
— Methodimport_digitrack(file_name; detect_type)
Load Digitrack ASCII file and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to loaddetect_type::Bool=true
: detect channel type based on its label
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.import_edf
— Methodimport_edf(file_name; detect_type)
Load EDF/EDF+ file and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to loaddetect_type::Bool=true
: detect channel type based on its label
Returns
obj::NeuroAnalyzer.NEURO
Notes
- sampling_rate = n.samples ÷ data.record.duration
- gain = (physical maximum - physical minimum) ÷ (digital maximum - digital minimum)
- value = (value - digital minimum ) × gain + physical minimum
Source
- Kemp B, Varri A, Rosa AC, Nielsen KD, Gade J. A simple format for exchange of digitized polygraphic recordings. Electroencephalography and Clinical Neurophysiology. 1992 May;82(5):391–3.
- Kemp B, Olivan J. European data format ‘plus’(EDF+), an EDF alike standard format for the exchange of physiological data. Clinical Neurophysiology 2003;114:1755–61.
- https://www.edfplus.info/specs/
NeuroAnalyzer.import_edf_annotations
— Methodimport_edf_annotations(file_name; detect_type)
Load annotations from EDF+ file and return markers
DataFrame. This function is used for EDF+ files containing annotations only.
Arguments
file_name::String
: name of the file to load
Returns
markers::DataFrame
NeuroAnalyzer.import_fiff
— Methodimport_fiff(file_name; detect_type)
Load FIFF (Functional Image File Format) file and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to loaddetect_type::Bool=true
: detect channel type based on its label
Returns
obj::NeuroAnalyzer.NEURO
Source
Elekta Neuromag: Functional Image File Format Description. FIFF version 1.3. March 2011
NeuroAnalyzer.import_gdf
— Methodimport_gdf(file_name; detect_type)
Load GDF file and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to loaddetect_type::Bool=true
: detect channel type based on its label
Returns
obj::NeuroAnalyzer.NEURO
Notes
- sampling_rate = n.samples ÷ data.record.duration
- gain = (physical maximum - physical minimum) ÷ (digital maximum - digital minimum)
- value = (value - digital minimum ) × gain + physical minimum
Source
- Schlögl A, Filz O, Ramoser H, Pfurtscheller G. GDF - A General Dataformat for Biosignals Version 1.25. 1998
- Schlögl, A. GDF - A General Dataformat for Biosignals Version 2.12. 2009
- Schlögl, A. GDF - A General Dataformat for Biosignals Version 2.51. 2013
NeuroAnalyzer.import_locs
— Methodimport_locs(file_name; maximize)
Load channel locations. Supported formats:
- CED
- ELC
- LOCS
- TSV
- SFP
- CSD
- GEO
- MAT
This is a meta-function that triggers appropriate import_locs_*()
function. File format is detected based on file extension.
Arguments
file_name::String
: name of the file to loadmaximize::Bool=true
: maximize locations to a unit circle after importing
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_ced
— Methodimport_locs_ced(file_name; maximize)
Load channel locations from CED file.
Arguments
file_name::String
maximize::Bool=true
: maximize locations to a unit circle after importing
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_locs
— Methodimport_locs_locs(file_name; maximize)
Load channel locations from LOCS file.
Arguments
file_name::String
maximize::Bool=true
: maximize locations to a unit circle after importing
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_elc
— Methodimport_locs_elc(file_name; maximize)
Load channel locations from ELC file.
Arguments
file_name::String
maximize::Bool=true
: maximize locations to a unit circle after importing
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_tsv
— Methodimport_locs_tsv(file_name; maximize)
Load channel locations from TSV file.
Arguments
file_name::String
maximize::Bool=true
: maximize locations to a unit circle after importing
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_sfp
— Methodimport_locs_sfp(file_name; maximize)
Load channel locations from SFP file.
Arguments
file_name::String
maximize::Bool=true
: maximize locations to a unit circle after importing
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_csd
— Methodimport_locs_csd(file_name; maximize)
Load channel locations from CSD file.
Arguments
file_name::String
maximize::Bool=true
: maximize locations to a unit circle after importing
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_geo
— Methodimport_locs_geo(file_name; maximize)
Load channel locations from GEO file.
Arguments
file_name::String
maximize::Bool=true
: maximize locations to a unit circle after importing
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_mat
— Methodimport_locs_mat(file_name; maximize)
Load channel locations from MAT file.
Arguments
file_name::String
maximize::Bool=true
: maximize locations to a unit circle after importing
Returns
locs::DataFrame
NeuroAnalyzer.import_montage
— Methodimport_montage(file_name)
Load montage from a text file. The structure of the file is:
- first line: name of the montage, e.g.
BIP ||
- next lines: channel pairs or individual channels, e.g.
Fz-Cz
orFp1
Each channel/channel pair must be in a separate line
Arguments
file_name::String
: name of the file to load
Returns
Named tuple containing:
ref_list::Vector{String}
: list of channel pairsref_name::Vector{String}
: name of the montage
NeuroAnalyzer.import_nirs
— Methodimport_nirs(file_name)
Load NIRS file and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to load
Returns
obj::NeuroAnalyzer.NEURO
Source
https://github.com/BUNPC/Homer3/wiki/HOMER3-file-formats
NeuroAnalyzer.import_nirx
— Methodimport_nirx(file_name)
Load NIRX file and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to load, should point to .hdr file.
Returns
obj::NeuroAnalyzer.NEURO
Source
https://nirx.net/file-formats
NeuroAnalyzer.import_nwb
— Methodimport_nwb(file_name; detect_type)
Load Neurodata Without Borders (NWB) file and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to loaddetect_type::Bool=true
: detect channel type based on its label
Returns
obj::NeuroAnalyzer.NEURO
Source
- https://www.biorxiv.org/content/10.1101/523035v1
NeuroAnalyzer.import_set
— Methodimport_set(file_name; detect_type)
Load SET file (exported from EEGLAB) and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to loaddetect_type::Bool=true
: detect channel type based on its label
Returns
obj::NeuroAnalyzer.NEURO
Source
- https://eeglab.org/tutorials/ConceptsGuide/Data_Structures.html
NeuroAnalyzer.import_snirf
— Methodimport_snirf(file_name; n)
Load Shared Near Infrared Spectroscopy Format (SNIRF) file and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to loadn::Int64=0
: subject number to extract in case of multi-subject file
Returns
obj::NeuroAnalyzer.NEURO
Source
https://github.com/fNIRS/snirf/blob/v1.1/snirf_specification.md
NeuroAnalyzer.load_locs
— Methodload_locs(obj; file_name)
Load channel locations from file_name
and return NeuroAnalyzer.NEURO
object with locs
data frame.
Accepted formats:
- CED
- LOCS
- ELC
- TSV
- SFP
- CSD
- GEO
- MAT
Channel locations:
loc_theta
: planar polar angleloc_radius
: planar polar radiusloc_x
: spherical Cartesian xloc_y
: spherical Cartesian yloc_z
: spherical Cartesian zloc_radius_sph
: spherical radiusloc_theta_sph
: spherical horizontal angleloc_phi_sph
: spherical azimuth angle
Arguments
obj::NeuroAnalyzer.NEURO
file_name::String
: name of the file to loadmaximize::Bool=true
: maximize locations to a unit circle after importing
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.load_locs!
— Methodload_locs!(obj; file_name, maximize)
Load channel locations from file_name
and return NeuroAnalyzer.NEURO
object with locs
data frame.
Accepted formats:
- CED
- LOCS
- ELC
- TSV
- SFP
- CSD
- GEO
- MAT
Channel locations:
loc_theta
: planar polar angleloc_radius
: planar polar radiusloc_x
: spherical Cartesian xloc_y
: spherical Cartesian yloc_z
: spherical Cartesian zloc_radius_sph
: spherical radiusloc_theta_sph
: spherical horizontal angleloc_phi_sph
: spherical azimuth angle
Arguments
obj::NeuroAnalyzer.NEURO
file_name::String
maximize::Bool=true
: maximize locations after importing
NeuroAnalyzer.save
— Methodsave(obj; file_name, overwrite)
Save obj
to file_name
file (HDF5-based).
Arguments
obj::NeuroAnalyzer.NEURO
file_name::String
: name of the file to save tooverwrite::Bool=false
NeuroAnalyzer.load
— Methodload(file_name)
Load NeuroAnalyzer.NEURO
from file_name
file (HDF5-based).
Arguments
file_name::String
: name of the file to load
Returns
obj::NeuroAnalyzer.NEURO
Edit
NeuroAnalyzer.signal_channels
— Methodsignal_channels(obj)
Return all signal (e.g. EEG or MEG) channels; signal is determined by :data_type
variable in obj.header.recording
). For MEG data type, 'meg', grad
and mag
channels are returned.
Arguments
obj::NeuroAnalyzer.NEURO
:
Returns
chs::Vector{Int64}
NeuroAnalyzer.get_channel_bytype
— Methodget_channel_bytype(obj; type)
Return channel number(s) for channel of type
type.
Arguments
obj::NeuroAnalyzer.NEURO
type::Union{Symbol, Vector{Symbol}}=:all
: channel type
Returns
ch_idx::Vector{Int64}
NeuroAnalyzer.get_channel_bywl
— Methodget_channel_bywl(obj; wl)
Return NIRS channel number(s) for wavelength wl
.
Arguments
obj::NeuroAnalyzer.NEURO
wl::Real
: wavelength (in nm)
Returns
ch_idx::Vector{Int64}
NeuroAnalyzer.channel_type
— Methodchannel_type(obj; ch, type)
Change channel type.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, String}
type::String
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.channel_type!
— Methodchannel_type!(obj; ch, new_name)
Change channel type.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, String}
type::String
NeuroAnalyzer.get_channel
— Methodget_channel(obj; ch)
Return channel number (if provided by name) or name (if provided by number).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, String}
: channel number or name
Returns
ch_idx::Union{Int64, String}
: channel number or name
NeuroAnalyzer.rename_channel
— Methodrename_channel(obj; ch, name)
Rename channel.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, String}
: channel number or namename::String
: new name
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.rename_channel!
— Methodrename_channel!(obj; ch, name)
Rename channel.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, String}
: channel number or namename::String
: new name
NeuroAnalyzer.edit_channel
— Methodedit_channel(obj; ch, field, value)
Edit channel properties (:channel_type
or :labels
) in OBJ.header.recording
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Int64
field::Symbol
value::Any
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.edit_channel!
— Methodedit_channel!(obj; ch, field, value)
Edit channel properties (:channel_type
or :labels
) in OBJ.header.recording
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Int64
field::Symbol
value::Any
NeuroAnalyzer.replace_channel
— Methodreplace_channel(obj; ch, s)
Replace channel.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, String}
: channel number or names::Array{Float64, 3}
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.replace_channel!
— Methodreplace_channel!(obj; ch, s)
Replace channel.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, String}
: channel number or names::Array{Float64, 3}
: signal to replace with
NeuroAnalyzer.add_labels
— Methodadd_labels(obj; labels)
Add channel labels.
Arguments
obj::NeuroAnalyzer.NEURO
clabels::Vector{String}
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_labels!
— Methodadd_labels!(obj::NeuroAnalyzer.NEURO; clabels::Vector{String})
Add OBJ channel labels.
Arguments
obj::NeuroAnalyzer.NEURO
clabels::Vector{String}
NeuroAnalyzer.add_channel
— Methodadd_channel(obj; data, label, type)
Add channel(s) data to empty NeuroAnalyzer.NEURO
object.
Arguments
obj::NeuroAnalyzer.NEURO
data::Array{<:Number, 3}
: channel(s) datalabel::Union{String, Vector{String}}=string.(_c(size(data, 1)))
: channel(s) label(s)type::Union{Symbol, Vector{Symbol}}
: channel(s) type(s)
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_channel!
— Methodadd_channel!(obj; data, label, type)
Add channel(s) data to empty NeuroAnalyzer.NEURO
object.
Arguments
obj::NeuroAnalyzer.NEURO
data::Array{<:Number, 3}
: channel(s) datalabel::Union{String, Vector{String}}=string.(_c(size(data, 1)))
: channel(s) label(s)type::Union{Symbol, Vector{Symbol}}
: channel(s) type(s)
NeuroAnalyzer.create
— Methodcreate(; data_type)
Create an empty NeuroAnalyzer.NEURO
object.
Arguments
data_type::String
: data type of the new object ("eeg", "meg", "nirs", "ecog")
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.create_time
— Methodcreate_time(obj)
Create time points vector for NeuroAnalyzer.NEURO
object.
Arguments
obj::NeuroAnalyzer.NEURO
- `fs::Int64
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.create_time!
— Methodcreate_time!(obj)
Create time points vector for NeuroAnalyzer.NEURO
object.
Arguments
obj::NeuroAnalyzer.NEURO
- `fs::Int64
NeuroAnalyzer.delete_channel
— Methoddelete_channel(obj; ch)
Delete channel(s).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel number(s) to be removed
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_channel!
— Methoddelete_channel!(obj; ch)
Delete channel(s).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel number(s) to be removed
NeuroAnalyzer.keep_channel
— Methodkeep_channel(obj; ch)
Keep channel(s).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel number(s) to keep
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.keep_channel!
— Methodkeep_channel!(obj; ch)
Keep channel(s).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel number(s) to keep
NeuroAnalyzer.keep_channel_type
— Methodkeep_channel_type(obj; type)
Keep channel(s) of type
type.
Arguments
obj::NeuroAnalyzer.NEURO
type::Symbol=:eeg
: type of channels to keep
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.keep_channel_type!
— Methodkeep_channel_type!(obj; type)
Keep OBJ channels of type
type.
Arguments
obj::NeuroAnalyzer.NEURO
type::Symbol=:eeg
: type of channels to keep
NeuroAnalyzer.delete_epoch
— Methoddelete_epoch(obj; ep)
Remove epoch(s).
Arguments
obj::NeuroAnalyzer.NEURO
ep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch number(s) to be removed
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_epoch!
— Methoddelete_epoch!(obj; ep)
Remove epoch(s).
Arguments
obj::NeuroAnalyzer.NEURO
ep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch number(s) to be removed
NeuroAnalyzer.keep_epoch
— Methodkeep_epoch(obj; ep)
Keep epoch(s).
Arguments
obj::NeuroAnalyzer.NEURO
ep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch number(s) to keep
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.keep_epoch!
— Methodkeep_epoch!(obj; ep)
Keep OBJ epoch(s).
Arguments
obj::NeuroAnalyzer.NEURO
ep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch number(s) to keep
NeuroAnalyzer.detect_bad
— Methoddetect_bad(obj; method, ch_t)
Detect bad channels and epochs.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsmethod::Vector{Symbol}=[:flat, :rmse, :rmsd, :euclid, :p2p, :var]
: detection method::flat
: flat channel(s):p2p
: peak-to-peak amplitude; good for detecting transient artifacts:var
: mean signal variance outside of 95%CI and variance inter-quartile outliers:rmse
: RMSE vs average channel outside of 95%CI:rmsd
: RMSD:euclid
: Euclidean distance
w::Int64=10
: window width in samples (signal is averaged withinw
-width window)ftol::Float64=0.1
: tolerance (signal is flat within-tol
to+tol
),eps()
gives very low tolerancefr::Float64=0.3
: acceptable ratio (0.0 to 1.0) of flat segments within a channel before marking it as flatp::Float64=0.95
: probability threshold (0.0 to 1.0) for marking channel as bad; also threshold for:p2p
detection: abovemean + p * std
and belowmean - p * std
, here p (as percentile) will be converted to z-score (0.9 (90th percentile): 1.282, 0.95 (95th percentile): 1.645, 0.975 (97.5th percentile): 1.960, 0.99 (99th percentile): 2.326)tc::Float64=0.3
: threshold (0.0 to 1.0) of bad channels ratio to mark the epoch as bad
Returns
Named tuple containing:
bm::Matrix{Bool}
: matrix of bad channels × epochsbe::Vector{Int64}
: list of bad epochs
NeuroAnalyzer.epoch
— Methodepoch(obj; marker, offset, ep_n, ep_len)
Split OBJ into epochs. Return signal that is split either by markers (if specified), by epoch length or by number of epochs.
Arguments
obj::NeuroAnalyzer.NEURO
marker::String=""
: marker description to split atoffset::Real=0
: time offset (in seconds) for marker-based epoching (each epoch time will start atmarker time - offset
)ep_n::Union{Int64, Nothing}=nothing
: number of epochsep_len::Union{Real, Nothing}=nothing
: epoch length in seconds
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.epoch!
— Methodepoch!(obj; marker, offset, ep_n, ep_len)
Split OBJ into epochs. Return signal that is split either by markers (if specified), by epoch length or by number of epochs.
Arguments
obj::NeuroAnalyzer.NEURO
marker::String=""
: marker description to split atoffset::Real=0
: time offset (in seconds) for marker-based epoching (each epoch time will start atmarker time - offset
)ep_n::Union{Int64, Nothing}=nothing
: number of epochsep_len::Union{Real, Nothing}=nothing
: epoch length in seconds
NeuroAnalyzer.epoch_ts
— Methodepoch_ts(obj; ts)
Edit epochs time start.
Arguments
obj::NeuroAnalyzer.NEURO
ts::Real
: time start in seconds
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.epoch_ts!
— Methodepoch_ts!(obj; ts)
Edit OBJ epochs time start.
Arguments
obj::NeuroAnalyzer.NEURO
ts::Real
: time start in seconds
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.extract_channel
— Methodextract_channel(obj; ch)
Extract channel data.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, String}
: channel number or name
Returns
extract_channel::Vector{Float64}
NeuroAnalyzer.extract_epoch
— Methodextract_epoch(obj; ep)
Extract epoch.
Arguments
obj::NeuroAnalyzer.NEURO
ep::Int64
: epoch index
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.extract_epoch!
— Methodextract_epoch!(obj; ep)
Extract epoch.
Arguments
obj::NeuroAnalyzer.NEURO
ep::Int64
: epoch index
NeuroAnalyzer.extract_data
— Methodextract_data(obj; ch)
Extract data.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsep::Union{Int64, Vector{Int64}, <:AbstractRange}=1:epoch_n(obj)
: index of epochs, default is all epochstime::Bool=false
: return time vectoretime::Bool=false
: return epoch time vector
Returns
signal::Array{Float64, 3}
time::Vector{Float64}
etime::Vector{Float64}
NeuroAnalyzer.extract_time
— Methodextract_time(obj)
Extract time.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
tpts::Array{Float64, 3}
NeuroAnalyzer.extract_eptime
— Methodextract_eptime(obj)
Extract epochs time.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
et::Array{Float64, 3}
NeuroAnalyzer.join
— Methodjoin(obj1, obj2)
Join two NeuroAnalyzer objects. Each obj2
epoch are horizontally concatenated (along time) with respective obj1
epoch. Both objects must have the same data type, number of channels, epochs and sampling rate, but may differ in epoch lengths.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.join!
— Methodjoin!(obj1, obj2)
Join two NeuroAnalyzer objects. Each obj2
epoch are horizontally concatenated (along time) with respective obj1
epoch. Both objects must have the same data type, number of channels, epochs and sampling rate, but may differ in epoch lengths.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
NeuroAnalyzer.view_marker
— Methodview_marker(obj)
Show markers.
Arguments
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_marker
— Methoddelete_marker(obj; n)
Delete marker.
Arguments
obj::NeuroAnalyzer.NEURO
n::Int64
: marker number
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_marker!
— Methoddelete_marker!(obj; n)
Delete marker.
Arguments
obj::NeuroAnalyzer.NEURO
n::Int64
: marker number
NeuroAnalyzer.add_marker
— Methodadd_marker(obj; id, start, len, desc, ch)
Add marker.
Arguments
obj::NeuroAnalyzer.NEURO
id::String
: marker IDstart::Real
: marker time in secondslen::Real=1.0
: marker length in secondsdesc::String
: marker descriptionch::Int64=0
: channel number, if 0 then marker is related to all channels
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_marker!
— Methodadd_marker!(obj; id, start, len, desc, ch)
Add marker.
Arguments
obj::NeuroAnalyzer.NEURO
id::String
: marker IDstart::Real
: marker time in secondslen::Real=1.0
: marker length in secondsdesc::String
: marker descriptionch::Int64=0
: channel number, if 0 then marker is related to all channels
NeuroAnalyzer.edit_marker
— Methodedit_marker(obj; n, id, start, len, desc)
Edit marker.
Arguments
obj::NeuroAnalyzer.NEURO
n::Int64
: marker numberid::String
: marker IDstart::Real
: marker time in secondslen::Real=1.0
: marker length in secondsdesc::String
: marker descriptionch::Int64
: channel number, if 0 then marker is related to all channels
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.edit_marker!
— Methodedit_marker!(obj; n, id, start, len, desc)
Edit marker.
Arguments
obj::NeuroAnalyzer.NEURO
n::Int64
: marker numberid::String
: marker IDstart::Real
: marker time in secondslen::Real=1
: marker length in secondsdesc::String
: marker descriptionch::Int64
: channel number, if 0 then marker is related to all channels
NeuroAnalyzer.channel2marker
— Methodchannel2marker(obj; ch, v, id, desc)
Convert event channel to markers.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Int64
: event channel numberv::Real=1.0
: event channel value interpreted as an eventid::String
: prefix for marker ID; default is based on event channel name (e.g. "stim1_")desc::String=""
: marker description; default is based on event channel name (e.g. "stim1")
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.channel2marker!
— Methodchannel2marker!(obj; ch, v, id, desc)
Convert event channel to markers.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Int64
: event channel numberv::Real=1.0
: event channel value interpreted as an eventid::String
: prefix for marker ID; default is "mrk_"desc::String=""
: prefix for marker description; default is based on event channel name (e.g. "stim1_")
NeuroAnalyzer.reflect
— Methodreflect(obj; n)
Expand signal by adding reflected signal before the signal and after the signal, i.e. a signal 1234 becomes 432112344321. This may reduce edge artifacts, but will also affect amplitude of the filtered signal.
Arguments
obj::NeuroAnalyzer.NEURO
n::Int64=sr(obj)
: number of samples to add, default is 1 second
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.reflect!
— Methodreflect!(obj; n)
Expand signal by adding reflected signal before the signal and after the signal, i.e. a signal 1234 becomes 432112344321. This may reduce edge artifacts, but will also affect amplitude of the filtered signal.
Arguments
obj::NeuroAnalyzer.NEURO
n::Int64=sr(obj)
: number of samples to add, default is 1 second
NeuroAnalyzer.chop
— Methodchop(obj; n)
Reduce signal by removing reflected signal before the signal and after the signal, i.e. a signal 432112344321 becomes 1234.
Arguments
obj::NeuroAnalyzer.NEURO
n::Int64=sr(obj)
: number of samples to remove, default is 1 second
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.chop!
— Methodchop!(obj; v)
Reduce signal by removing reflected signal before the signal and after the signal, i.e. a signal 432112344321 becomes 1234.
Arguments
obj::NeuroAnalyzer.NEURO
n::Int64=sr(obj)
: number of samples to remove, default is 1 second
NeuroAnalyzer.trim
— Methodtrim(s; seg, inverse)
Remove segment from the signal.
Arguments
v::AbstractVector
seg::Tuple{Int64, Int64}
: segment (from, to) in samplesinverse::Bool=false
: if true, keep the segment
Returns
trim::Vector{Float64}
NeuroAnalyzer.trim
— Methodtrim(m; seg, inverse)
Remove segment from the signal.
Arguments
m::AbstractMatrix
seg::Tuple{Int64, Int64}
: segment (from, to) in samplesinverse::Bool=false
: if true, keep the segment
Returns
trim::Array{Float64}
NeuroAnalyzer.trim
— Methodtrim(a; seg, inverse)
Remove segment from the signal.
Arguments
a::AbstractArray
seg::Tuple{Int64, Int64}
: segment (from, to) in samplesinverse::Bool=false
: if true, keep the segment
Returns
trim::Array{Float64}
NeuroAnalyzer.trim
— Methodtrim(obj; seg, inverse, remove_epochs)
Trim signal by removing parts of the signal.
Arguments
obj::NeuroAnalyzer.NEURO
seg::Tuple{Real, Real}
: segment to be removed (from, to) in secondsinverse::Bool=false
: if true, keep the segmentremove_epochs::Bool=true
: if true, remove epochs containing signal to trim or remove signal and re-epoch trimmed signal
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.trim!
— Methodtrim!(obj; seg, inverse, remove_epochs)
Trim signal by removing parts of the signal.
Arguments
obj::NeuroAnalyzer.NEURO
seg::Tuple{Real, Real}
: segment to be removed (from, to) in secondsinverse::Bool=false
: if true, keep the segmentremove_epochs::Bool=true
: if true, remove epochs containing signal to trim or remove signal and re-epoch trimmed signal
NeuroAnalyzer.vch
— Methodvch(obj; f)
Calculate virtual channel using formula f
.
Arguments
obj::NeuroAnalyzer.NEURO
f::String
: channel calculation formula, e.g."cz / mean(fp1 + fp2)"
; case of labels in the formula is ignored, all standard Julia math operators are available, channel labels must be the same as of the OBJ object
Returns
vc::Array{Float64, 3}
: single channel × time × epochs
Process
NeuroAnalyzer.add_signal
— Methodadd_signal(s1, s2)
Add signal.
Arguments
s1::AbstractVector
: target signals2::AbstractVector
: signal to be added
Returns
s_noisy::AbstractVector
NeuroAnalyzer.add_signal
— Methodadd_signal(obj; ch, s)
Add signal.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelss::AbstractVector
: signal to be added to each channel
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_signal!
— Methodadd_signal!(obj; ch, n)
Add signal.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelss::AbstractVector
: signal to be added to each channel
NeuroAnalyzer.average
— Methodaverage(s)
Average all channels.
Arguments
s::AbstractArray
Returns
average::AbstractArray
NeuroAnalyzer.average
— Methodaverage(s1, s2)
Averages two signals.
Arguments
s1::AbstractArray
s2::AbstractArray
Returns
average::Vector{Float64}
NeuroAnalyzer.average
— Methodaverage(obj; ch)
Return the average signal of channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channels
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.average!
— Methodaverage!(obj; ch)
Return the average signal of channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channels
NeuroAnalyzer.average
— Methodaverage(obj1, obj2)
Return the average signal of all obj1
and obj2
channels.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.bpsplit
— Methodbpsplit(obj; ch, order, window)
Split signal into frequency bands using IIR band-pass filter.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsorder::Int64=8
: number of taps for FIR band-pass filterwindow::Union{Nothing, AbstractVector, Int64}=nothing
: window for:fir
filter; default is Hamming window, number of taps is calculated using Fred Harris' rule-of-thumb
Returns
Named tuple containing:
s::Array{Float64, 4}
: split signalbn::Vector{Symbol}
: band namesbf::Vector{Tuple{Real, Real}}
: band frequencies
NeuroAnalyzer.cbp
— Methodcbp(s; pad, frq, fs)
Perform convolution band-pass filtering.
Arguments
s::AbstractVector
pad::Int64
: pad withpad
zerosfrq::Real
: filter frequencyfs::Int64
: sampling rate
Returns
cbp::Vector{Float64}
NeuroAnalyzer.cbp
— Methodcbp(obj; ch, pad, frq)
Perform convolution bandpass filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelspad::Int64
: pad thesignal
withpad
zerosfrq::Real
: filter frequency
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.cbp!
— Methodcbp!(obj; ch, pad, frq)
Perform convolution bandpass filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelspad::Int64
: pad thesignal
withpad
zerosfrq::Tuple{Real, Real}
: filter frequency
NeuroAnalyzer.ch_zero
— Methodch_zero(obj)
Zero channels at the beginning and at the end.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.ch_zero!
— Methodch_zero!(obj)
Zero channels at the beginning and at the end.
Arguments
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.csd
— Methodcsd(obj; m, n, lambda)
Transform data using Current Source Density (CSD) transformation based on spherical spline surface Laplacian.
Arguments
obj::NeuroAnalyzer.NEURO
m::Int64=4
: positive integer constant that affects spherical spline flexibility, higherm
values mean increased rigidityn::Int64=8
: Legendre polynomial orderlambda::Float64=10^-5
: smoothing factor
Returns
obj_new::NeuroAnalyzer.NEURO
: withcsd
channel types andµV/m²
units
Source
Perrin F, Pernier J, Bertrand O, Echallier JF. Spherical splines for scalp potential and current density mapping. Electroencephalography and Clinical Neurophysiology. 1989;72(2):184-187 Kayser J, Tenke CE. Principal components analysis of Laplacian waveforms as a generic method for identifying ERP generator patterns: I. Evaluation with auditory oddball tasks. Clin Neurophysiol 2006;117(2):348-368
NeuroAnalyzer.csd!
— Methodcsd!(obj; m, n, lambda)
Transform data using Current Source Density (CSD) transformation based on spherical spline surface Laplacian.
Arguments
obj::NeuroAnalyzer.NEURO
m::Int64=4
: positive integer constant that affects spherical spline flexibility, higherm
values mean increased rigidityn::Int64=8
: Legendre polynomial orderlambda::Float64=10^-5
: smoothing factor
Returns
G::Matrix{Float64}
: transformation matrix (SP spline)H::Matrix{Float64}
: transformation matrix (CSD spline)
Source
Perrin F, Pernier J, Bertrand O, Echallier JF. Spherical splines for scalp potential and current density mapping. Electroencephalography and Clinical Neurophysiology. 1989;72(2):184-7
NeuroAnalyzer.gh
— Methodgh(locs; m, n)
Generate G and H matrices.
Arguments
locs::DataFrame
m::Int64=4
: positive integer constant that affects spherical spline flexibility, higherm
values mean increased rigidityn::Int64=8
: Legendre polynomial order
Returns
Named tuple containing:
G::Matrix{Float64}
: transformation matrix (SP spline)H::Matrix{Float64}
: transformation matrix (CSD spline)
Source
Perrin F, Pernier J, Bertrand O, Echallier JF. Spherical splines for scalp potential and current density mapping. Electroencephalography and Clinical Neurophysiology. 1989;72(2):184-7
NeuroAnalyzer.cw_trans
— Methodcw_trans(s; wt, type, l)
Perform continuous wavelet transformation (CWT).
Arguments
s::AbstractVector
wt<:CWT
: continuous wavelet, e.g.wt = wavelet(Morlet(π), β=2)
, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
ct::Array{Float64, 2}
: CWT coefficients (by rows)
NeuroAnalyzer.icw_trans
— Methodicw_trans(ct; wt, type)
Perform inverse continuous wavelet transformation (iCWT).
Arguments
ct::AbstractArray
: CWT coefficients (by rows)wt<:CWT
: continuous wavelet, e.g.wt = wavelet(Morlet(π), β=2)
, see ContinuousWavelets.jl documentation for the list of available waveletstype::Symbol=df
: inverse style type::nd
: NaiveDelta:pd
: PenroseDelta:df
: DualFrames
Returns
s::Vector{Float64}
: reconstructed signal
NeuroAnalyzer.cw_trans
— Methodcw_trans(s; wt)
Perform continuous wavelet transformation (CWT).
Arguments
s::AbstractArray
wt<:CWT
: continuous wavelet, e.g.wt = wavelet(Morlet(π), β=2)
, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
ct::Array{Float64, 4}
: CWT coefficients (by rows)
NeuroAnalyzer.cw_trans
— Methodcw_trans(obj; ch, wt)
Perform continuous wavelet transformation (CWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelswt<:CWT
: continuous wavelet, e.g.wt = wavelet(Morlet(π), β=2)
, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
ct::Array{Float64, 4}
: CWT coefficients (by rows)
NeuroAnalyzer.denoise_fft
— Methoddenoise_fft(s; pad, t)
Perform FFT denoising.
Arguments
s::AbstractVector
pad::Int64=0
: number of zeros to addt::Real=0
: PSD threshold for keeping frequency components; if 0, use mean signal power value
Returns
Named tuple containing:
s::Vector{Float64}
f_idx::BitVector
: index of components zeroed
NeuroAnalyzer.denoise_fft
— Methoddenoise_fft(s; pad, t)
Perform FFT denoising.
Arguments
s::AbstractArray
pad::Int64=0
: number of zeros to addt::Real=0
: PSD threshold for keeping frequency components; if 0, use mean signal power value
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.denoise_fft
— Methoddenoise_fft(obj; ch, pad, t)
Perform FFT denoising.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelspad::Int64=0
: number of zeros to add signal for FFTt::Int64=100
: PSD threshold for keeping frequency components
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.denoise_fft!
— Methoddenoise_fft!(obj; ch, pad, t)
Perform FFT denoising.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelspad::Int64=0
: number of zeros to add signal for FFTt::Int64=100
: PSD threshold for keeping frequency components
NeuroAnalyzer.denoise_wavelet
— Methoddenoise_wavelet(s; wt)
Perform wavelet denoising.
Arguments
s::AbstractVector
wt<:DiscreteWavelet
: discrete wavelet, e.g.wt = wavelet(WT.haar)
, see Wavelets.jl documentation for the list of available wavelets
Returns
s_new::Vector{Float64}
NeuroAnalyzer.denoise_wavelet
— Methoddenoise_wavelet(s; wt)
Perform wavelet denoising.
Arguments
s::AbstractArray
wt<:DiscreteWavelet
: discrete wavelet, e.g.wt = wavelet(WT.haar)
, see Wavelets.jl documentation for the list of available wavelets
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.denoise_wavelet
— Methoddenoise_wavelet(obj; ch, wt)
Perform wavelet denoising.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelswt<:DiscreteWavelet
: discrete wavelet, e.g.wt = wavelet(WT.haar)
, see Wavelets.jl documentation for the list of available wavelets
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.denoise_wavelet!
— Methoddenoise_wavelet!(obj; ch, wt)
Perform wavelet denoising.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelswt<:DiscreteWavelet
: discrete wavelet, e.g.wt = wavelet(WT.haar)
, see Wavelets.jl documentation for the list of available wavelets
NeuroAnalyzer.denoise_wien
— Methoddenoise_wien(s)
Perform Wiener deconvolution denoising.
Arguments
s::AbstractArray
Returns
s_new::Vector{Float64}
NeuroAnalyzer.denoise_wien
— Methoddenoise_wien(obj; ch)
Perform Wiener deconvolution denoising.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channels
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.denoise_wien!
— Methoddenoise_wien!(obj; ch)
Perform Wiener deconvolution denoising.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channels
NeuroAnalyzer.derivative
— Methodderivative(s)
Return derivative of the same length.
Arguments
s::AbstractVector
Returns
s_new::AbstractVector
NeuroAnalyzer.derivative
— Methodderivative(s)
Return derivative of the same length.
Arguments
s::AbstractArray
Returns
s_new::Array{Float64, 3}
NeuroAnalyzer.derivative
— Methodderivative(obj; ch)
Return derivative of the same length.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channels
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.derivative!
— Methodderivative!(obj; ch)
Return derivative of the same length.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channels
NeuroAnalyzer.detrend
— Methoddetrend(s; type, offset, order, span, fs)
Perform piecewise detrending.
Arguments
s::AbstractVector
type::Symbol=:ls
::loess
: fit and subtract loess approximation:poly
: polynomial oforder
is subtracted:constant
:offset
or the mean ofs
(ifoffset
= 0) is subtracted:linear
: linear trend is subtracted froms
:ls
: the result of a linear least-squares fit tos
is subtracted froms
offset::Real=0
: constant for :constant detrendingorder::Int64=1
: polynomial fitting orderf::Float64=1.0
: smoothing factor for:loess
or frequency for:hp
Returns
s_new::Vector{Float64}
NeuroAnalyzer.detrend
— Methoddetrend(s; type, offset, order, f)
Perform piecewise detrending.
Arguments
s::AbstractArray
type::Symbol=:linear
: detrending method:loess
: fit and subtract loess approximation:poly
: polynomial oforder
is subtracted:constant
:offset
or the mean ofs
(ifoffset
= 0) is subtracted:linear
: linear trend is subtracted froms
:ls
: the result of a linear least-squares fit tos
is subtracted froms
offset::Real=0
: constant for:constant
detrendingorder::Int64=1
: polynomial fitting orderf::Float64=1.0
: smoothing factor for:loess
or frequency for:hp
Returns
s_new::Array
{Float64, 3}
NeuroAnalyzer.detrend
— Methoddetrend(obj; ch, type, offset, order, f)
Perform piecewise detrending.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelstype::Symbol=:linear
: detrending method:loess
: fit and subtract loess approximation:poly
: polynomial oforder
is subtracted:constant
:offset
or the mean ofs
(ifoffset
= 0) is subtracted:linear
: linear trend is subtracted froms
:ls
: the result of a linear least-squares fit tos
is subtracted froms
offset::Real=0
: constant for:constant
detrendingorder::Int64=1
: polynomial fitting orderf::Float64=1.0
: smoothing factor for:loess
or frequency for:hp
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.detrend!
— Methoddetrend!(obj; ch, type, offset, order, span)
Perform piecewise detrending.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelstype::Symbol=:linear
: detrending method:loess
: fit and subtract loess approximation:poly
: polynomial oforder
is subtracted:constant
:offset
or the mean ofs
(ifoffset
= 0) is subtracted:linear
: linear trend is subtracted froms
:ls
: the result of a linear least-squares fit tos
is subtracted froms
offset::Real=0
: constant for :constant detrendingorder::Int64=1
: polynomial fitting orderf::Float64=1.0
: smoothing factor for:loess
or frequency for:hp
NeuroAnalyzer.dw_trans
— Methoddw_trans(s; wt, type, l)
Perform discrete wavelet transformation (DWT).
Arguments
s::AbstractVector
wt<:DiscreteWavelet
: discrete wavelet, e.g.wt = wavelet(WT.haar)
, see Wavelets.jl documentation for the list of available waveletstype::Symbol
: transformation type::sdwt
: Stationary Wavelet Transforms:acdwt
: Autocorrelation Wavelet Transforms
l::Int64=0
: number of levels, default maximum number of levels available or total transformation
Returns
dt::Array{Float64, 2}
: DWT coefficients cAl, cD1, ..., cDl (by rows)
NeuroAnalyzer.dw_trans
— Methoddw_trans(s; wt, type, l)
Perform discrete wavelet transformation (DWT).
Arguments
s::AbstractArray
wt<:DiscreteWavelet
: discrete wavelet, e.g.wt = wavelet(WT.haar)
, see Wavelets.jl documentation for the list of available waveletstype::Symbol
: transformation type::sdwt
: Stationary Wavelet Transforms:acdwt
: Autocorrelation Wavelet Transforms
l::Int64=0
: number of levels, default is maximum number of levels available or total transformation
Returns
dt::Array{Float64, 4}
: DWT coefficients cAl, cD1, ..., cDl (by rows)
NeuroAnalyzer.dw_trans
— Methoddw_trans(obj; ch, wt, type, l)
Perform discrete wavelet transformation (DWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelswt<:DiscreteWavelet
: discrete wavelet, e.g.wt = wavelet(WT.haar)
, see Wavelets.jl documentation for the list of available waveletstype::Symbol
: transformation type::sdwt
: Stationary Wavelet Transforms:acdwt
: Autocorrelation Wavelet Transforms
l::Int64=0
: number of levels, default is maximum number of levels available or total transformation
Returns
dt::Array{Float64, 4}
: DWT coefficients cAl, cD1, ..., cDl (by rows)
NeuroAnalyzer.idw_trans
— Methodidw_trans(dwt_coefs; wt, type)
Perform inverse discrete wavelet transformation (iDWT) of the dwt_coefs
.
Arguments
dwt_coefs::AbstractArray
: DWT coefficients cAl, cD1, ..., cDl (by rows)wt<:DiscreteWavelet
: discrete wavelet, e.g.wt = wavelet(WT.haar)
, see Wavelets.jl documentation for the list of available waveletstype::Symbol
: transformation type::sdwt
: Stationary Wavelet Transforms:acdwt
: Autocorrelation Wavelet Transforms
Returns
s_new::Vector{Float64}
: reconstructed signal
NeuroAnalyzer.dwtsplit
— Methoddwtsplit(obj; ch, wt, type, n)
Split into bands using discrete wavelet transformation (DWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64}
: channel numberwt<:DiscreteWavelet
: discrete wavelet, e.g.wt = wavelet(WT.haar)
, see Wavelets.jl documentation for the list of available waveletstype::Symbol
: transformation type::sdwt
: Stationary Wavelet Transforms:acdwt
: Autocorrelation Wavelet Transforms
n::Int64=0
: number of bands, default is maximum number of bands available or total transformation
Returns
b::Array{Float64, 4}
: bands from lowest to highest frequency (by rows)
NeuroAnalyzer.erp
— Methoderp(obj; bl)
Average epochs. Non-signal channels are removed. OBJ.header.recording[:data_type]
becomes erp
. First epoch is the ERP.
Arguments
obj::NeuroAnalyzer.NEURO
bl::Real=0
: baseline is the firstbl
seconds; ifbl
is greater than 0, DC value is calculated as mean of the firstbl
seconds and subtracted from the signal
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.erp!
— Methoderp!(obj; bl)
Average epochs. Non-signal channels are removed. OBJ.header.recording[:data_type]
becomes erp
. First epoch is the ERP.
Arguments
obj::NeuroAnalyzer.NEURO
bl::Real=0
: baseline is the firstbl
seconds; ifbl
is greater than 0, DC value is calculated as mean of the firstn
samples and subtracted from the signal
NeuroAnalyzer.fconv
— Methodfconv(s; kernel, norm)
Perform convolution in the frequency domain.
Arguments
s::AbstractVector
kernel::AbstractVector
pad::Int64=0
: number of zeros to addnorm::Bool=true
: normalize kernel
Returns
s_new::Vector{Float64}
NeuroAnalyzer.fconv
— Methodfconv(s; kernel, norm)
Perform convolution in the frequency domain.
Arguments
s::AbstractArray
kernel::Union{Vector{<:Real}, Vector{ComplexF64}}
: kernel for convolutionnorm::Bool=true
: normalize kernel to keep the post-convolution results in the same scale as the original datapad::Int64=0
: number of zeros to add signal for FFT
Returns
s_new::Array{Float64, 3}
: convoluted signal
NeuroAnalyzer.fconv
— Methodfconv(obj; ch, kernel, norm)
Perform convolution in the frequency domain.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelskernel::Union{Vector{<:Real}, Vector{ComplexF64}}
: kernel for convolutionnorm::Bool=true
: normalize kernel to keep the post-convolution results in the same scale as the original datapad::Int64=0
: number of zeros to add signal for FFT
Returns
obj_new::NeuroAnalyzer.NEURO
: convoluted signal
NeuroAnalyzer.fconv!
— Methodfconv!(obj; ch)
Perform convolution in the frequency domain.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelskernel::Union{Vector{<:Real}, Vector{ComplexF64}}
: kernel for convolutionnorm::Bool=true
: normalize kernel to keep the post-convolution results in the same scale as the original datapad::Int64=0
: number of zeros to add signal for FFT
NeuroAnalyzer.filter_create
— Methodfilter_create(signal; <keyword arguments>)
Create IIR or FIR filter.
Arguments
fprototype::Symbol
: filter prototype::butterworth
:chebyshev1
:chebyshev2
:elliptic
:fir
:iirnotch
: second-order IIR notch filter:remez
: Remez FIR filter
ftype::Union{Nothing, Symbol}=nothing
: filter type::lp
: low pass:hp
: high pass:bp
: band pass:bs
: band stop
cutoff::Union{Real, Tuple{Real, Real}}=0
: filter cutoff in Hz (tuple for:bp
and:bs
)n::Int64
: signal length in samplesfs::Int64
: sampling rateorder::Int64=8
: filter order (6 dB/octave), number of taps for:remez
, attenuation (× 4 dB) for:fir
filtersrp::Real=-1
: ripple amplitude in dB in the pass band; default: 0.0025 dB for:elliptic
, 2 dB for othersrs::Real=-1
: ripple amplitude in dB in the stop band; default: 40 dB for:elliptic
, 20 dB for othersbw::Real=-1
: bandwidth for:iirnotch
and :remez filterswindow::Union{Nothing, AbstractVector, Int64}=nothing
: window for:fir
filter; default is Hamming window, number of taps is calculated using Fred Harris' rule-of-thumb
Returns
flt::Union{Vector{Float64}, ZeroPoleGain{:z, ComplexF64, ComplexF64, Float64}, Biquad{:z, Float64}}
NeuroAnalyzer.filter_apply
— Methodfilter_apply(s; <keyword arguments>)
Apply IIR or FIR filter.
Arguments
s::AbstractVector
flt::Union{Vector{Float64}, ZeroPoleGain{:z, ComplexF64, ComplexF64, Float64}, Biquad{:z, Float64}}
: filterdir:Symbol=:twopass
: filter direction (for causal filter use:onepass
)::twopass
:onepass
:reverse
: one pass, reverse direction
Returns
s_filtered::Vector{Float64}
NeuroAnalyzer.filter
— Methodfilter(obj; <keyword arguments>)
Apply filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelsfprototype::Symbol
: filter prototype::butterworth
:chebyshev1
:chebyshev2
:elliptic
:fir
:iirnotch
: second-order IIR notch filter:remez
: Remez FIR filter
ftype::Union{Nothing, Symbol}=nothing
: filter type::lp
: low pass:hp
: high pass:bp
: band pass:bs
: band stop
cutoff::Union{Real, Tuple{Real, Real}}=0
: filter cutoff in Hz (tuple for:bp
and:bs
)rp::Real=-1
: ripple amplitude in dB in the pass band; default: 0.0025 dB for:elliptic
, 2 dB for othersrs::Real=-1
: ripple amplitude in dB in the stop band; default: 40 dB for:elliptic
, 20 dB for othersbw::Real=-1
: bandwidth for:iirnotch
and:remez
filtersdir:Symbol=:twopass
: filter direction (for causal filter use:onepass
)::twopass
:onepass
:reverse
: one pass, reverse direction
order::Int64=8
: filter order (6 dB/octave) for IIR filters, number of taps for:remez
filter, attenuation (× 4 dB) for:fir
filterwindow::Union{Nothing, AbstractVector, Int64}=nothing
: window length for:remez
and:fir
filterspreview::Bool=false
: plot filter response
Returns
obj::NeuroAnalyzer.NEURO
Notes
For :poly
filter order
and window
have to be set experimentally, recommended initial values are: order=4
and window=32
.
NeuroAnalyzer.filter!
— Methodfilter!(obj; <keyword arguments>)
Apply filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelsfprototype::Symbol
: filter prototype::butterworth
:chebyshev1
:chebyshev2
:elliptic
:fir
:iirnotch
: second-order IIR notch filter:remez
: Remez FIR filter
ftype::Union{Nothing, Symbol}=nothing
: filter type::lp
: low pass:hp
: high pass:bp
: band pass:bs
: band stop
cutoff::Union{Real, Tuple{Real, Real}}=0
: filter cutoff in Hz (tuple for:bp
and:bs
)rp::Real=-1
: ripple amplitude in dB in the pass band; default: 0.0025 dB for:elliptic
, 2 dB for othersrs::Real=-1
: ripple amplitude in dB in the stop band; default: 40 dB for:elliptic
, 20 dB for othersbw::Real=-1
: bandwidth for:iirnotch
and:remez
filtersdir:Symbol=:twopass
: filter direction (for causal filter use:onepass
)::twopass
:onepass
:reverse
: one pass, reverse direction
order::Int64=8
: filter order (6 dB/octave) for IIR filters, number of taps for:remez
filter, attenuation (× 4 dB) for:fir
filterwindow::Union{Nothing, AbstractVector, Int64}=nothing
: window length for:remez
and:fir
filterspreview::Bool=false
: plot filter response
Notes
For :poly
filter order
and window
have to be set experimentally, recommended initial values are: order=4
and window=32
.
NeuroAnalyzer.filter_g
— Methodfilter_g(s, fs, pad, f, gw)
Filter using Gaussian in the frequency domain.
Arguments
s::AbstractVector
fs::Int64
: sampling ratepad::Int64=0
: number of zeros to addf::Real
: filter frequencygw::Real=5
: Gaussian width in Hz
Returns
Named tuple containing:
s_filtered::Vector{Float64}
NeuroAnalyzer.filter_g
— Methodfilter_g(s; pad, f, gw)
Filter using Gaussian in the frequency domain.
Arguments
s::AbstractArray
fs::Int64
: sampling ratepad::Int64=0
: number of zeros to addf::Real
: filter frequencygw::Real=5
: Gaussian width in Hz
Returns
s_filtered::NeuroAnalyzer.NEURO
NeuroAnalyzer.filter_g
— Methodfilter_g(obj; ch, pad, f, gw)
Filter using Gaussian in the frequency domain.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelspad::Int64=0
: number of zeros to addf::Real
: filter frequencygw::Real=5
: Gaussian width in Hz
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.filter_g!
— Methodfilter_g!(obj; ch, pad, f, gw)
Filter using Gaussian in the frequency domain.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelspad::Int64=0
: number of zeros to addf::Real
: filter frequencygw::Real=5
: Gaussian width in Hz
NeuroAnalyzer.filter_mavg
— Methodfilter_mavg(s; <keyword arguments>)
Filter using moving average (FIR) filter (with threshold).
Arguments
s::AbstractVector
k::Int64=8
: window length is2 × k + 1
; for cut-off frequency f, k issqrt(0.196202 + f^2) / f
t::Real=0
: threshold (t = mean(s) - t * std(s):mean(s) + t * std(s)
); only samples below/above the threshold are being filteredwindow::Union{Nothing, AbstractVector}=nothing
: weighting window
Returns
s_filtered::Vector{Float64}
NeuroAnalyzer.filter_mavg
— Methodfilter_mavg(s; k, t, window)
Filter using moving average filter (with threshold).
Arguments
s::AbstractArray
k::Int64=8
: window length is2 × k + 1
; for cut-off frequency f, k issqrt(0.196202 + f^2) / f
t::Real=0
: threshold (t = mean(s) - t * std(s):mean(s) + t * std(s)
); only samples below/above the threshold are being filteredwindow::Union{Nothing, AbstractVector}=nothing
: weighting window
Returns
s_filtered::Array{Float64, 3}
: convoluted signal
NeuroAnalyzer.filter_mavg
— Methodfilter_mavg(obj; ch, k, t, window)
Filter using moving average filter (with threshold).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsk::Int64=8
: window length is2 × k + 1
; for cut-off frequency F, k issqrt(0.196202 + F^2) / F
, where F is a normalized frequency (F = f/fs
)t::Real=0
: threshold (t = mean(s) - t * std(s):mean(s) + t * std(s)
); only samples below/above the threshold are being filteredwindow::Union{Nothing, AbstractVector}=nothing
: weighting window
Returns
obj_new::NeuroAnalyzer.NEURO
: convoluted signal
Source
- https://dsp.stackexchange.com/questions/9966/what-is-the-cut-off-frequency-of-a-moving-average-filter
NeuroAnalyzer.filter_mavg!
— Methodfilter_mavg!(obj; ch, k, t, window)
Filter using moving average filter (with threshold).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsk::Int64=8
: window length is2 × k + 1
; for cut-off frequency f, k issqrt(0.196202 + f^2) / f
t::Real=0
: threshold (t = mean(s) - t * std(s):mean(s) + t * std(s)
)window::Union{Nothing, AbstractVector}=nothing
: weighting window
NeuroAnalyzer.filter_mmed
— Methodfilter_mmed(s; <keyword arguments>)
Filter using moving median filter (with threshold).
Arguments
s::AbstractVector
k::Int64=8
: window length is2 × k + 1
t::Real=0
: threshold (t = mean(s) - t * std(s):mean(s) + t * std(s)
); only samples below/above the threshold are being filteredwindow::Union{Nothing, AbstractVector}=nothing
: weighting window
Returns
s_filtered::Vector{Float64}
NeuroAnalyzer.filter_mmed
— Methodfilter_mmed(s; k, t, window)
Filter using moving median filter (with threshold).
Arguments
s::AbstractArray
k::Int64=8
: window length is2 × k + 1
t::Real=0
: threshold (t = mean(s) - t * std(s):mean(s) + t * std(s)
); only samples below/above the threshold are being filteredwindow::Union{Nothing, AbstractVector}=nothing
: weighting window
Returns
s_filtered::Array{Float64, 3}
: convoluted signal
NeuroAnalyzer.filter_mmed
— Methodfilter_mmed(obj; ch, k, t, window)
Filter using moving median filter (with threshold).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsk::Int64=8
: window length is2 × k + 1
t::Real=0
: threshold (t = mean(s) - t * std(s):mean(s) + t * std(s)
); only samples above the threshold are being filteredwindow::Union{Nothing, AbstractVector}=nothing
: weighting window
Returns
obj_new::NeuroAnalyzer.NEURO
: convoluted signal
NeuroAnalyzer.filter_mmed!
— Methodfilter_mmed!(obj; ch, k, t, window)
Filter using moving median filter (with threshold).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsk::Int64=8
: window length is2 × k + 1
t::Real=0
: threshold (t = mean(s) - t * std(s):mean(s) + t * std(s)
); only samples above the threshold are being filteredwindow::Union{Nothing, AbstractVector}=nothing
: weighting window
NeuroAnalyzer.filter_poly
— Methodfilter_poly(s; order, window)
Filter using polynomial filter.
Arguments
s::AbstractVector
order::Int64=8
: polynomial orderwindow::Int64=10
: window length
Returns
s_filtered::Vector{Float64}
NeuroAnalyzer.filter_poly
— Methodfilter_poly(s; order, window)
Filter using polynomial filter.
Arguments
s::AbstractArray
order::Int64=8
: polynomial orderwindow::Int64=10
: window length
Returns
s_filtered::Array{Float64, 3}
: convoluted signal
NeuroAnalyzer.filter_poly
— Methodfilter_poly(obj; ch, order, window)
Filter using polynomial filter.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsorder::Int64=8
: polynomial orderwindow::Int64=10
: window length
Returns
obj_new::NeuroAnalyzer.NEURO
: convoluted signal
NeuroAnalyzer.filter_poly!
— Methodfilter_poly!(obj; ch, order, window)
Filter using polynomial filter.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsorder::Int64=8
: polynomial orderwindow::Int64=10
: window length
NeuroAnalyzer.filter_sg
— Methodfilter_sg(s; order, window)
Filter using Savitzky-Golay filter.
Arguments
s::AbstractVector
order::Int64=6
: order of the polynomial used to fit the samples; must be less thanwindow
window::Int64=11
: length of the filter window (i.e., the number of coefficients); must be an odd number
Returns
s_filtered::Vector{Float64}
NeuroAnalyzer.filter_sg
— Methodfilter_sg(s; order, window)
Filter using Savitzky-Golay filter.
Arguments
s::AbstractArray
order::Int64=6
: order of the polynomial used to fit the samples; must be less thanwindow
window::Int64=11
: length of the filter window (i.e., the number of coefficients); must be an odd number
Returns
s_filtered::Array{Float64, 3}
: convoluted signal
NeuroAnalyzer.filter_sg
— Methodfilter_sg(obj; ch, order, window)
Filter using Savitzky-Golay filter.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsorder::Int64=6
: order of the polynomial used to fit the samples; must be less thanwindow
window::Int64=11
: length of the filter window (i.e., the number of coefficients); must be an odd number
Returns
obj_new::NeuroAnalyzer.NEURO
: convoluted signal
NeuroAnalyzer.filter_sg!
— Methodfilter_sg!(obj; ch, order, window)
Filter using Savitzky-Golay filter.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsorder::Int64=6
: order of the polynomial used to fit the samples; must be less thanwindow
window::Int64=11
: length of the filter window (i.e., the number of coefficients); must be an odd number
NeuroAnalyzer.ica_decompose
— Methodica_decompose(s; <keyword arguments>)
Calculate n
first Independent Components using FastICA algorithm.
Arguments
s::AbstractMatrix
n::Int64
: number of ICsiter::Int64=100
: maximum number of iterationsf::Symbol=:tanh
: neg-entropy functor::tanh
:gaus
Returns
Named tuple containing:
ic::Matrix{Float64}
: components IC(1)..IC(n) (W * data), components are sorted by decreasing varianceic_mw::Matrix{Float64}
: weighting matrix IC(1)..IC(n) (inv(W))
NeuroAnalyzer.ica_decompose
— Methodica_decompose(obj; <keyword arguments>)
Perform independent component analysis (ICA) using FastICA algorithm.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsn::Int64=length(ch)
: number of ICs, default is the number of channelsiter::Int64=100
: maximum number of iterationsf::Symbol=:tanh
: neg-entropy functor::tanh
:gaus
Returns
Named tuple containing:
ic::Matrix{Float64}
: components IC(1)..IC(n) (W * data), components are sorted by decreasing varianceic_mw::Matrix{Float64}
: weighting matrix IC(1)..IC(n) (inv(W))ic_var::Vector{Float64}
: variance of components
NeuroAnalyzer.ica_reconstruct
— Methodica_reconstruct(; ic, ic_mw, ic_idx)
Reconstruct signal using ICA components.
Arguments
ic::Matrix{Float64}
: components IC(1)..IC(n)ic_mw::Matrix{Float64}
: weighting matrix IC(1)..IC(n)- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove or keep
keep::Bool=false
: iftrue
, then the ICs are kept instead of removed
Returns
s_new::Matrix{Float64}
: reconstructed signal
NeuroAnalyzer.ica_reconstruct
— Methodica_reconstruct(obj; ch, ic_idx, keep)
Reconstruct signals using embedded ICA components (:ic
and :ic_mw
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsic_idx::Union{Int64, Vector{Int64}, <:AbstractRange}
: list of ICs to remove or keep or keepkeep::Bool=false
: iftrue
, then the ICs are kept instead of removed
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.ica_reconstruct!
— Methodica_reconstruct!(obj; ch, ic_idx, keep)
Reconstruct signals using embedded ICA components (:ic
and :ic_mw
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all channels- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove or keep
keep::Bool=false
: iftrue
, then the ICs are kept instead of removed
NeuroAnalyzer.ica_reconstruct
— Methodica_reconstruct(obj, ic, ic_mw; ch, ic_idx, keep)
Reconstruct signals using external ICA components.
Arguments
obj::NeuroAnalyzer.NEURO
ic::Matrix{Float64}
: components IC(1)..IC(n)ic_mw::Matrix{Float64}
: weighting matrix IC(1)..IC(n)ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove or keep
keep::Bool=false
: iftrue
, then the ICs are kept instead of removed
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.ica_reconstruct!
— Methodica_reconstruct!(obj, ic, ic_mw; ch, ic_idx, keep)
Reconstruct signals using external ICA components.
Arguments
obj::NeuroAnalyzer.NEURO
ic::Matrix{Float64}
: components IC(1)..IC(n)ic_mw::Matrix{Float64}
: weighting matrix IC(1)..IC(n)ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all channels- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove or keep
keep::Bool=false
: iftrue
, then the ICs are kept instead of removed
NeuroAnalyzer.ica_remove
— Methodica_remove(obj, ic, ic_mw; ch, ic_idx)
Remove external ICA components from the signal.
Arguments
obj::NeuroAnalyzer.NEURO
ic::Matrix{Float64}
: components IC(1)..IC(n)ic_mw::Matrix{Float64}
: weighting matrix IC(1)..IC(n)ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.ica_remove!
— Methodica_remove!(obj, ic, ic_mw; ch, ic_idx)
Remove external ICA components from the signal.
Arguments
obj::NeuroAnalyzer.NEURO
ic::Matrix{Float64}
: components IC(1)..IC(n)ic_mw::Matrix{Float64}
: weighting matrix IC(1)..IC(n)ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all channels- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove or keep
NeuroAnalyzer.ica_remove
— Methodica_remove(obj, ic; ch, ic_idx)
Remove embedded ICA components (:ic
and :ic_mw
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.ica_remove!
— Methodica_remove!(obj; ch, ic_idx)
Remove embedded ICA components (:ic
and :ic_mw
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all channels- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove or keep
NeuroAnalyzer.intensity2od
— Methodintensity2od(s)
Convert NIRS intensity (RAW data) to optical density (OD).
Arguments
s::AbstractArray
Returns
od::AbstractArray
NeuroAnalyzer.intensity2od
— Methodintensity2od(obj; ch)
Convert NIRS intensity (RAW data) to optical density (OD).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=get_channel_bytype(obj, type=:nirs_int))
: index of channels, default is NIRS intensity channels
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.intensity2od!
— Methodintensity2od!(obj; ch)
Convert NIRS intensity (RAW data) to optical density (OD).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=get_channel_bytype(obj, type=:nirs_int))
: index of channels, default is NIRS intensity channels
NeuroAnalyzer.invert_polarity
— Methodinvert_polarity(obj; ch)
Invert polarity.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channels
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.invert_polarity!
— Methodinvert_polarity!(obj; ch)
Invert polarity.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: channel(s) to invert
NeuroAnalyzer.lrinterpolate_channel
— Methodlrinterpolate_channel(obj; ch, ep)
Interpolate channel using linear regression.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel number to interpolateep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch number(s) within to interpolate
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.lrinterpolate_channel!
— Methodlrinterpolate_channel!(obj; ch, ep)
Interpolate channel using linear regression.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel number to interpolateep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch number(s) within to interpolate
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.normalize
— Functionnormalize(s, n; method)
Normalize.
Arguments
s::AbstractArray
m::Real=0.0
n::Real=1.0
method::Symbol
::zscore
: by z-score:minmax
: in [-1, +1]:log
: using log-transformation:log10
: using log10-transformation:neglog
: using -log-transformation:neglog10
: using -log10-transformation:neg
: in [0, -∞]:pos
: in [0, +∞]:perc
: in percentages:gauss
: to Gaussian:invroot
: in inverse root (1/sqrt(x)):n
: in [0, n1], default is [0, 1]; to normalize to [n1, n2], usenormalize_n(s) .* (n2 - n1) .+ n1
:none
Returns
normalized::Vector{Float64}
NeuroAnalyzer.normalize_zscore
— Methodnormalize_zscore(s)
Normalize (by z-score).
Arguments
s::AbstractArray
Returns
normalize_zscore::Vector{Float64}
NeuroAnalyzer.normalize_minmax
— Methodnormalize_minmax(s)
Normalize in [-1, +1].
Arguments
s::AbstractArray
Returns
normalize_minmax::AbstractArray
NeuroAnalyzer.normalize_n
— Functionnormalize_n(s, n)
Normalize in [0, n], default is [0, +1].
Arguments
s::AbstractArray
n::Real=1.0
Returns
normalize_n::AbstractArray
NeuroAnalyzer.normalize_log
— Methodnormalize_log(s)
Normalize using log-transformation.
Arguments
s::AbstractArray
Returns
normalize_log::AbstractArray
NeuroAnalyzer.normalize_gauss
— Functionnormalize_gauss(s, dims)
Normalize to Gaussian.
Arguments
s::AbstractArray
dims::Int64=1
: dimension for cumsum()
Returns
normalize_gauss::Vector{Float64}
NeuroAnalyzer.normalize_log10
— Methodnormalize_log10(s)
Normalize using log10-transformation.
Arguments
s::AbstractArray
Returns
normalize_log10::Vector{Float64}
NeuroAnalyzer.normalize_neglog
— Methodnormalize_neglog(s)
Normalize to using -log-transformation.
Arguments
s::AbstractArray
Returns
normalize_neglog::Vector{Float64}
NeuroAnalyzer.normalize_neglog10
— Methodnormalize_neglog10(s)
Normalize using -log10-transformation.
Arguments
s::AbstractArray
Returns
normalize_neglog::Vector{Float64}
NeuroAnalyzer.normalize_neg
— Methodnormalize_neg(s)
Normalize in [0, -∞].
Arguments
s::AbstractArray
Returns
normalize_neg::Vector{Float64}
NeuroAnalyzer.normalize_pos
— Methodnormalize_pos(s)
Normalize in [0, +∞].
Arguments
s::AbstractArray
Returns
normalize_pos::Vector{Float64}
NeuroAnalyzer.normalize_perc
— Methodnormalize_perc(s)
Normalize in percentages.
Arguments
s::AbstractArray
Returns
normalize_perc::Vector{Float64}
NeuroAnalyzer.normalize_invroot
— Methodnormalize_invroot(s)
Normalize in inverse root (1/sqrt(x)).
Arguments
s::AbstractArray
Returns
normalize_invroot::Vector{Float64}
NeuroAnalyzer.normalize
— Methodnormalize(obj; ch, method)
Normalize channel(s)
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelsmethod::Symbol
: method for normalization, seenormalize()
for details
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.normalize!
— Methodnormalize!(obj; ch, method)
Normalize channel(s)
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelsmethod::Symbol
: method for normalization, seenormalize()
for details
NeuroAnalyzer.npl
— Methodnpl(obj)
Calculate non-phase-locked signal.
Arguments
obj::NeuroAnalyzer.NEURO
: must be ERP object
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.npl!
— Methodnpl!(obj)
Calculate non-phase-locked signal.
Arguments
obj::NeuroAnalyzer.NEURO
: must be ERP object
NeuroAnalyzer.od2conc
— Methodod2conc(obj; ch, ppf)
Convert NIRS optical density (OD) to concentration (HbO, HbR, HbT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=get_channel_bytype(obj, type=:nirs_od))
: index of channels, default is NIRS intensity channelsppf::Vector{Real}=ones(length(obj.header.recording[:wavelengths]))
: Partial path length factors for each wavelength. This is a vector of factors per wavelength. Typical value is ~6 for each wavelength if the absorption change is uniform over the volume of tissue measured. To approximate the partial volume effect of a small localized absorption change within an adult human head, this value could be as small as 0.1. Convention is becoming to setppf=1
and to not divide by the source-detector separation such that the resultant "concentration" is in units of Molar mm (or Molar cm if those are the spatial units). This is becoming wide spread in the literature but there is no fixed citation. Use a value of 1 to choose this option.
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.od2conc!
— Methodod2conc(obj; ch, ppf)
Convert NIRS optical density (OD) to concentration (HbO, HbR, HbT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=get_channel_bytype(obj, type=:nirs_od))
: index of channels, default is NIRS intensity channelsppf::Vector{Real}=ones(length(obj.header.recording[:wavelengths]))
: Partial path length factors for each wavelength. This is a vector of factors per wavelength. Typical value is ~6 for each wavelength if the absorption change is uniform over the volume of tissue measured. To approximate the partial volume effect of a small localized absorption change within an adult human head, this value could be as small as 0.1. Convention is becoming to setppf=1
and to not divide by the source-detector separation such that the resultant "concentration" is in units of Molar mm (or Molar cm if those are the spatial units). This is becoming wide spread in the literature but there is no fixed citation. Use a value of 1 to choose this option.
NeuroAnalyzer.pca_decompose
— Methodpca_decompose(s, n)
Calculate n
first Primary Components (PCs).
Arguments
s::AbstractArray
n::Int64
: number of PCs
Returns
Named tuple containing:
pc::Array{Float64, 3}:
: PC(1)..PC(n) × epochpcv::Matrix{Float64}
: variance of PC(1)..PC(n) × epoch (% of total variance)pcm::PCA{Float64}
: PC meanpc_model::MultivariateStats.PCA{Float64}
: PC model
NeuroAnalyzer.pca_decompose
— Methodpca_decompose(obj; ch, n)
Calculate n
first Primary Components (PCs).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsn::Int64
: number of PCs to calculate
Returns
Named tuple containing:
pc::Array{Float64, 3}:
: PC(1)..PC(n) × epochpcv::Matrix{Float64}
: variance of PC(1)..PC(n) × epoch (% of total variance)pcm::Vector{Float64}
: PC meanpc_model::MultivariateStats.PCA{Float64}
: PC model
NeuroAnalyzer.pca_reconstruct
— Methodpca_reconstruct(s, pc, pca)
Reconstructs signal using PCA components.
Arguments
s::AbstractArray
pc::AbstractArray:
: IC(1)..IC(n) × epochpc_model::MultivariateStats.PCA{Float64}:
: PC model
Returns
s_new::Array{Float64, 3}
NeuroAnalyzer.pca_reconstruct
— Methodpca_reconstruct(obj; ch)
Reconstruct signal using embedded PCA components (:pc
) and model (:pc_model
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.pca_reconstruct!
— Methodpca_reconstruct!(obj; ch)
Reconstruct signal using embedded PCA components (:pc
) and model (:pc_model
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
NeuroAnalyzer.pca_reconstruct
— Methodpca_reconstruct(obj, pc, pc_model; ch)
Reconstruct signal using external PCA components (pc
and pca
).
Arguments
obj::NeuroAnalyzer.NEURO
pc::Array{Float64, 3}:
: PC(1)..PC(n) × epochpc_model::MultivariateStats.PCA{Float64}
: PC modelch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.pca_reconstruct!
— Methodpca_reconstruct!(obj, pc, pc_model; ch)
Reconstruct signals using external PCA components (pc
and pc_model
).
Arguments
obj::NeuroAnalyzer.NEURO
pc::Array{Float64, 3}:
: PC(1)..PC(n) × epochpc_model::MultivariateStats.PCA{Float64}
: PC modelch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
NeuroAnalyzer.plinterpolate_channel
— Methodplinterpolate_channel(obj; ch, ep, m, q)
Interpolate channel(s) using planar interpolation.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel number(s) to interpolateep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch number(s) within to interpolateimethod::Symbol=:sh
: interpolation method::sh
: Shepard:mq
: Multiquadratic:imq
: InverseMultiquadratic:tp
: ThinPlate:nn
: NearestNeighbour:ga
: Gaussian
interpolation_factor::Int64=100
: interpolation quality
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.plinterpolate_channel!
— Methodplinterpolate_channel!(obj; ch, ep, imethod, interpolation_factor)
Interpolate channel(s) using planar interpolation.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel number(s) to interpolateep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch number(s) within to interpolateimethod::Symbol=:sh
: interpolation method Shepard (:sh
), Multiquadratic (:mq
), InverseMultiquadratic (:imq
), ThinPlate (:tp
), NearestNeighbour (:nn
), Gaussian (:ga
)interpolation_factor::Int64=100
: interpolation quality
NeuroAnalyzer.reference_ch
— Methodreference_ch(obj; ch, med)
Reference to selected channel(s). Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}
: index of channels used as reference; if multiple channels are specified, their average is used as the referencemed::Bool=false
: use median instead of mean
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.reference_ch!
— Methodreference_ch!(obj; ch, med)
Reference to selected channel(s). Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}
: index of channels used as reference; if multiple channels are specified, their average is used as the referencemed::Bool=false
: use median instead of mean
NeuroAnalyzer.reference_car
— Methodreference_car(obj; exclude_fpo, exclude_current, med)
Reference to common average reference. Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
exclude_fpo::Bool=false
: exclude Fp1, Fp2, O1, O2 from CAR calculationexclude_current::Bool=true
: exclude current channel from CAR calculationmed::Bool=false
: use median instead of mean
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.reference_car!
— Methodreference_car!(obj; exclude_fpo, exclude_current, med)
Reference to common average reference. Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
exclude_fpo::Bool=false
: exclude Fp1, Fp2, O1, O2 from CAR mean calculationexclude_current::Bool=true
: exclude current channel from CAR mean calculationmed::Bool=false
: use median instead of mean
NeuroAnalyzer.reference_a
— Methodreference_a(obj; type, med)
Reference to auricular (A1, A2) channels. Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
type::Symbol=:l
::l
: linked - average of A1 and A2:i
: ipsilateral - A1 for left channels, A2 for right channels:c
: contraletral - A1 for right channels, A2 for left channels
med::Bool=false
: use median instead of mean
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.reference_a!
— Methodreference_a!(obj; type, med)
Reference to auricular (A1, A2) channels. Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
type::Symbol=:l
::l
: linked - average of A1 and A2:i
: ipsilateral - A1 for left channels, A2 for right channels:c
: contraletral - A1 for right channels, A2 for left channels
med::Bool=false
: use median instead of mean
NeuroAnalyzer.reference_m
— Methodreference_m(obj; type, med)
Reference to mastoid (M1, M2) channels. Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
type::Symbol=:l
::l
: linked - average of M1 and M2:i
: ipsilateral - M1 for left channels, M2 for right channels:c
: contraletral - M1 for right channels, M2 for left channels
med::Bool=false
: use median instead of mean
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.reference_m!
— Methodreference_m!(obj; type, med)
Reference to mastoid (M1, M2) channels. Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
type::Symbol=:l
::l
: linked - average of M1 and M2:i
: ipsilateral - M1 for left channels, M2 for right channels:c
: contraletral - M1 for right channels, M2 for left channels
med::Bool=false
: use median instead of mean
NeuroAnalyzer.reference_plap
— Methodreference_plap(obj; nn, weights)
Reference using planar Laplacian (using nn
adjacent electrodes). Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
nn::Int64=4
: usenn
adjacent electrodesweights::Bool=false
: use mean ofnn
nearest channels if false; if true, mean ofnn
nearest channels is weighted by distance to the referenced channelmed::Bool=false
: use median instead of mean
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.reference_plap!
— Methodreference_plap!(obj; nn, weights)
Reference using planar Laplacian (using nn
adjacent electrodes). Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
nn::Int64=4
: usenn
adjacent electrodesweights::Bool=false
: use distance weights; use mean of nearest channels if falsemed::Bool=false
: use median instead of mean
NeuroAnalyzer.reference_custom
— Methodreference_custom(obj; ref_list, ref_name)
Reference using custom montage. Only signal channels are processed. Custom montage may be imported using import_montage()
.
Arguments
obj::NeuroAnalyzer.NEURO
ref_list::Vector{String}=["Fz-Cz", "Cz-Pz", "Fp1-F7", "Fp1-F3", "F7-T3", "T3-T5", "T5-O1", "F3-C3", "C3-P3", "P3-O1", "Fp2-F8", "Fp2-F4", "F8-T4", "T4-T6", "T6-O2", "F4-C4", "C4-P4", "P4-O2"]
: list of channel pairsref_name::String="BIP ||"
: name of the montage
Returns
obj::NeuroAnalyzer.NEURO
Notes
If the reference contains a single channel (e.g. "Fz"), than the channel is copied to the referenced data. For each reference pair (e.g. "Fz-Cz"), the referenced channel is equal to the amplitude of channel 2 ("Cz") - amplitude of channel 1 ("Fz").
Examples of montages:
- bipolar transverse: ["Fp2-Fp1", "F8-Fp2", "F8-F4", "F4-Fz", "Fz-F3", "F3-F7", "Fp1-F7", "T4-C4", "C4-Cz", "Cz-C3", "C3-T3", "T6-P4", "P4-Pz", "Pz-P3", "P3-T5", "O2-O1"], "BIP ="
- bipolar longitudinal: ["Fz", "Cz", "Pz", "Fp1-F7", "Fp1-F3", "F7-T3", "T3-T5", "T5-O1", "F3-C3", "C3-P3", "P3-O1", "Fp2-F8", "Fp2-F4", "F8-T4", "T4-T6", "T6-O2", "F4-C4", "C4-P4", "P4-O2"], "BIP ||"
- bipolar longitudinal: ["Fp-Fz", "Fz-Cz", "Cz-Pz", "Pz-O", "Fp1-F7", "Fp1-F3", "F7-T7", "T7-P7", "P7-O1", "F3-C3", "C3-P3", "P3-O1", "Fp1-F7", "Fp2-F4", "F8-T8", "T8-P8", "P8-O2", "F4-C4", "C4-P4", "P4-O2"], "BIP ||"
NeuroAnalyzer.reference_custom!
— Methodreference_custom!(obj; ref_list, ref_name)
Reference using custom montage. Only signal channels are processed. Custom montage may be imported using import_montage()
.
Arguments
obj::NeuroAnalyzer.NEURO
ref_list::Vector{String}=["Fz-Cz", "Cz-Pz", "Fp1-F7", "Fp1-F3", "F7-T3", "T3-T5", "T5-O1", "F3-C3", "C3-P3", "P3-O1", "Fp2-F8", "Fp2-F4", "F8-T4", "T4-T6", "T6-O2", "F4-C4", "C4-P4", "P4-O2"]
: list of channel pairsref_name::String="BIP ||"
: name of the montage
Notes
If the reference contains a single channel (e.g. "Fz"), than the channel is copied to the referenced data. For each reference pair (e.g. "Fz-Cz"), the referenced channel is equal to the amplitude of channel 2 ("Cz") - amplitude of channel 1 ("Fz").
Examples of montages:
- bipolar transverse: ["Fp2-Fp1", "F8-Fp2", "F8-F4", "F4-Fz", "Fz-F3", "F3-F7", "Fp1-F7", "T4-C4", "C4-Cz", "Cz-C3", "C3-T3", "T6-P4", "P4-Pz", "Pz-P3", "P3-T5", "O2-O1"], "BIP ="
- bipolar longitudinal: ["Fz", "Cz", "Pz", "Fp1-F7", "Fp1-F3", "F7-T3", "T3-T5", "T5-O1", "F3-C3", "C3-P3", "P3-O1", "Fp2-F8", "Fp2-F4", "F8-T4", "T4-T6", "T6-O2", "F4-C4", "C4-P4", "P4-O2"], "BIP ||"
- bipolar longitudinal: ["Fp-Fz", "Fz-Cz", "Cz-Pz", "Pz-O", "Fp1-F7", "Fp1-F3", "F7-T7", "T7-P7", "P7-O1", "F3-C3", "C3-P3", "P3-O1", "Fp1-F7", "Fp2-F4", "F8-T8", "T8-P8", "P8-O2", "F4-C4", "C4-P4", "P4-O2"], "BIP ||"
NeuroAnalyzer.remove_dc
— Functionremove_dc(s, n)
Remove mean value (DC offset). If n
is greater than 0, mean value is calculated for the first n
samples.
Arguments
s::AbstractVector
n::Int64=0
: baseline is the firstn
samples
Returns
s_new::Vector{Float64}
NeuroAnalyzer.remove_dc
— Functionremove_dc(s; n)
Remove mean value (DC offset). If n
is greater than 0, mean value is calculated for the first n
samples.
Arguments
s::AbstractArray
n::Int64=0
: baseline is the firstn
samples
Returns
s::Array{Float64, 3}
NeuroAnalyzer.remove_dc
— Methodremove_dc(obj; ch, n)
Remove mean value (DC offset). If n
is greater than 0, mean value is calculated for the first n
samples.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelsn::Int64=0
: baseline is the firstn
samples
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.remove_dc!
— Methodremove_dc!(obj; ch, n)
Remove mean value (DC offset). If n
is greater than 0, mean value is calculated for the first n
samples.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelsn::Int64=0
: baseline is the firstn
samples
NeuroAnalyzer.remove_pops
— Methodremove_pops(s; r, repair)
Detect and repair electrode pops (rapid amplitude change). Signal is recovered within the segments starting and ending at zero-crossing. Only one pop is detected, signal length should be ≥2 seconds.
Arguments
s::AbstractVector
r::Int64=20
: detection segment length; pops are checked withinpop_location - r:pop_location + r
samplesrepair::Bool=true
: recover the segment iftrue
Returns
Named tuple containing:
s::Vector{Float64}
pop_location::Int64
: sample number in the signalleft_segment::Int64
: length of segment before the pop that starts when signal crosses 0right_segment::Int64
: length of segment after the pop that ends when signal crosses 0
NeuroAnalyzer.remove_pops
— Methodremove_pops(obj; <keyword arguments>)
Detect and repair electrode pops (rapid amplitude change). Signal is recovered within the segments starting and ending at zero-crossing. Only one pop is detected per segment, signal length should be ≈2 seconds.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsrepair::Bool=true
: recover the segment iftrue
window::Real=10.0
: window length (in seconds) in which the signal is scanned and repaired (windows are non-overlapping)r::Int64=sr(obj)÷2
: detection segment length; pops are checked within(pop_location - r):(pop_location + r)
samples
Returns
obj_new::NeuroAnalyzer.NEURO
: returned ifrepair=true
pop_loc::Vector{Vector{Int64}}
: location of pops: channel, epoch and sample number in the signall_seg::Vector{Int64}
: length of segment before the pop that starts when signal crosses 0r_seg::Vector{Int64}
: length of segment after the pop that ends when signal crosses 0
NeuroAnalyzer.remove_pops!
— Methodremove_pops!(obj; <keyword arguments>)
Detect and repair electrode pops (rapid amplitude change). Signal is recovered within the segments starting and ending at zero-crossing. Only one pop is detected, signal length should be ≈2 seconds.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsrepair::Bool=true
: recover the segment iftrue
window::Real=20.0
: window length (in seconds) in which the signal is scanned and repaired (windows are non-overlapping)r::Int64=sr(obj)÷2
: detection segment length; pops are checked withinpop_location - r:pop_location + r
samples
Returns
pop_loc::Vector{Vector{Int64}}
: location of pops: channel, epoch and sample number in the signall_seg::Vector{Int64}
: length of segment before the pop that starts when signal crosses 0r_seg::Vector{Int64}
: length of segment after the pop that ends when signal crosses 0
NeuroAnalyzer.remove_powerline
— Methodremove_powerline(obj; <keyword arguments>)
Remove power line noise and its peaks above power line frequency.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelspl_frq::Real=50
: power line frequencymethod::Symbol=:iir
: use IIR filterpr::Real=2.0
: prominence of noise peaks in dBd::Real=5.0
: minimum distance between peaks in Hzq::Real=0.1
: optimization step size
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.remove_powerline!
— Methodremove_powerline!(obj; <keyword arguments>)
Remove power line noise and harmonics.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelspl_frq::Real=50
: power line frequencymethod::Symbol=:iir
: use IIR filterpr::Real=2.0
: prominence of noise peaks in dBd::Real=5.0
: minimum distance between peaks in Hzq::Real=0.1
: optimization step size
NeuroAnalyzer.resample
— Methodresample(s; t, new_sr)
Resample to new_sr
sampling frequency.
Arguments
s::AbstractVector
old_sr::Int64
: old sampling ratenew_sr::Int64
: new sampling rate
Returns
s_new::Vector{Float64}
NeuroAnalyzer.resample
— Methodresample(s; old_sr::Int64, new_sr::Int64)
Resamples all channels and time vector t
to new_sr
sampling frequency.
Arguments
s::AbstractArray
old_sr::Int64
: old sampling ratenew_sr::Int64
: new sampling rate
Returns
s_new::Array{Float64, 3}
NeuroAnalyzer.resample
— Methodresample(obj; new_sr)
Resample (up- or down-sample).
Arguments
obj::NeuroAnalyzer.NEURO
old_sr::Int64
: old sampling rate -new_sr::Int64
: new sampling rate
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.resample!
— Methodresample!(obj; new_sr)
Resample (up- or down-sample).
Arguments
obj::NeuroAnalyzer.NEURO
new_sr::Int64
: new sampling rate
NeuroAnalyzer.upsample
— Methodupsample(obj; new_sr)
Upsample.
Arguments
obj::NeuroAnalyzer.NEURO
new_sr::Int64
: new sampling rate
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.upsample!
— Methodupsample!(obj; new_sr)
Upsample.
Arguments
obj::NeuroAnalyzer.NEURO
new_sr::Int64
: new sampling rate
NeuroAnalyzer.downsample
— Methoddownsample(obj; new_sr)
Downsample.
Arguments
obj::NeuroAnalyzer.NEURO
new_sr::Int64
: new sampling rate
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.downsample!
— Methoddownsample!(obj; new_sr)
Downsample.
Arguments
obj::NeuroAnalyzer.NEURO
new_sr::Int64
: new sampling rate
NeuroAnalyzer.scale
— Methodscale(obj; ch, factor)
Multiply channel(s) by factor
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelsfactor::Real
: signal is multiplied byfactor
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.scale!
— Methodscale!(obj; ch, factor)
Multiply channel(s) by factor
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelsfactor::Real
: signal is multiplied byfactor
NeuroAnalyzer.standardize
— Methodstandardize(s)
Standardize channels.
Arguments
s::AbstractArray
Returns
s_new::NeuroAnalyzer.NEURO
:scaler::Vector{Any}
: standardizing matrix
NeuroAnalyzer.standardize
— Methodstandardize(obj; ch)
Standardize channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
obj_new::NeuroAnalyzer.NEURO
scaler::Vector{Any}
: standardizing matrix
NeuroAnalyzer.standardize!
— Methodstandardize!(obj; ch)
Standardize channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
scaler::Matrix{Float64}
: standardizing matrix
NeuroAnalyzer.taper
— Methodtaper(signal; taper)
Taper the signal.
Arguments
signal::AbstractVector
t::Union{AbstractVector, Vector{ComplexF64}}
Returns
t::Vector{Union{Float64, ComplexF64}}
NeuroAnalyzer.taper
— Methodtaper(s; t)
Taper the signal.
Arguments
s::AbstractArray
t::Union{Vector{Real, Vector{ComplexF64}}
Returns
s::Array{Float64, 3
NeuroAnalyzer.taper
— Methodtaper(obj; channel, t)
Taper the signal.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelst::Union{Vector{Real, Vector{ComplexF64}}
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.taper!
— Methodtaper!(obj; ch, t)
Taper the signal.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelst::Union{Vector{<:Real}, Vector{ComplexF64}}
NeuroAnalyzer.tconv
— Methodtconv(signal; kernel)
Performs convolution in the time domain.
Arguments
s::AbstractVector
kernel::AbstractVector
Returns
s_new::Vector{Float64}
NeuroAnalyzer.tconv
— Methodtconv(s; kernel)
Perform convolution in the time domain.
Arguments
s::AbstractArray
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelskernel::Union{Vector{<:Real}, Vector{ComplexF64}}
: kernel used for convolution
Returns
s_new::Array{Float64, 3}
: convoluted signal
NeuroAnalyzer.tconv
— Methodtconv(obj; ch, kernel)
Perform convolution in the time domain.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelskernel::Union{Vector{<:Real}, Vector{ComplexF64}}
: kernel used for convolution
Returns
s_new::Array{Float64, 3}
: convoluted signal
NeuroAnalyzer.wbp
— Methodwbp(s; pad, frq, fs, ncyc)
Perform wavelet band-pass filtering.
Arguments
s::AbstractVector
pad::Int64
: pad withpad
zerosfrq::Real
: filter frequencyfs::Int64
: sampling ratencyc::Int64=6
: number of cycles for Morlet wavelet
Returns
s_new::Vector{Float64}
NeuroAnalyzer.wbp
— Methodwbp(s; ch, pad, frq, ncyc)
Perform wavelet band-pass filtering.
Arguments
s::AbstractArray
pad::Int64
: pad thesignal
withpad
zerosfrq::Real
: filter frequencyfs::Int64
: sampling ratencyc::Int64=6
: number of cycles for Morlet wavelet
Returns
s_new::Array{Float64, 3
NeuroAnalyzer.wbp
— Methodwbp(obj; ch, pad, frq, ncyc)
Perform wavelet band-pass filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelspad::Int64
: pad thesignal
withpad
zerosfrq::Real
: filter frequencyncyc::Int64=6
: number of cycles for Morlet wavelet
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.wbp!
— Methodwbp!(obj; ch, pad, frq, ncyc)
Perform wavelet band-pass filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: index of channels, default is all channelspad::Int64
: pad thesignal
withpad
zerosfrq::Real
: filter frequencyncyc::Int64=6
: number of cycles for Morlet wavelet
Locs
NeuroAnalyzer.add_locs
— Methodadd_locs(obj; locs)
Add electrode positions from locs
.
Electrode locations:
channel
channel numberlabels
channel labelloc_theta
planar polar angleloc_radius
planar polar radiusloc_x
spherical Cartesian xloc_y
spherical Cartesian yloc_z
spherical Cartesian zloc_radius_sph
spherical radiusloc_theta_sph
spherical horizontal angleloc_phi_sph
spherical azimuth angle
Arguments
obj::NeuroAnalyzer.NEURO
locs::DataFrame
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_locs!
— Methodadd_locs!(obj; locs)
Load electrode positions from locs
and return NeuroAnalyzer.NEURO
object with metadata: :channel_locations
, :loc_theta
, :loc_radius
, :loc_x
, :loc_x
, :loc_y
, :loc_radius_sph
, :loc_theta_sph
, :loc_phi_sph
.
Electrode locations:
channel
channel numberlabels
channel labelloc_theta
planar polar angleloc_radius
planar polar radiusloc_x
spherical Cartesian xloc_y
spherical Cartesian yloc_z
spherical Cartesian zloc_radius_sph
spherical radiusloc_theta_sph
spherical horizontal angleloc_phi_sph
spherical azimuth angle
Arguments
obj::NeuroAnalyzer.NEURO
locs::DataFrame
NeuroAnalyzer.cart2pol
— Methodcart2pol(x, y)
Convert Cartesian coordinates to polar.
Arguments
x::Real
y::Real
Returns
radius::Float64
theta::Float64
NeuroAnalyzer.pol2cart
— Methodpol2cart(radius, theta)
Convert polar coordinates to Cartesian.
Arguments
radius::Real
: polar radius, the distance from the origin to the point, in degreestheta::Real
: polar angle
Returns
x::Float64
y::Float64
NeuroAnalyzer.sph2cart
— Methodsph2cart(radius, theta, phi)
Convert spherical coordinates to Cartesian.
Arguments
radius::Real
: spherical radius, the distance from the origin to the pointtheta::Real
: spherical horizontal angle, the angle in the xy plane with respect to the x axis, in degreesphi::Real
: spherical azimuth angle, the angle with respect to the z axis (elevation), in degrees
Returns
x::Float64
y::Float64
z::Float64
NeuroAnalyzer.cart2sph
— Methodcart2sph(x, y, z)
Convert spherical coordinates to Cartesian.
Arguments
x::Real
y::Real
z::Real
Returns
radius::Float64
: spherical radius, the distance from the origin to the pointtheta::Float64
: spherical horizontal angle, the angle in the xy plane with respect to the x axis, in degreesphi::Float64
: spherical azimuth angle, the angle with respect to the z axis (elevation), in degrees
NeuroAnalyzer.sph2pol
— Methodsph2pol(radius, theta, phi)
Convert spherical coordinates to polar.
Arguments
radius::Real
: spherical radius, the distance from the origin to the pointtheta::Real
: spherical horizontal angle, the angle in the xy plane with respect to the x axis, in degreesphi::Real
: spherical azimuth angle, the angle with respect to the z axis (elevation), in degrees
Returns
radius::Float64
theta::Float64
NeuroAnalyzer.locs_pol2cart
— Methodlocs_pol2cart(locs)
Convert polar locations to Cartesian.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_pol2cart!
— Methodlocs_pol2cart!(locs)
Convert polar locations to Cartesian.
Arguments
locs::DataFrame
NeuroAnalyzer.locs_sph2cart
— Methodlocs_sph2cart(locs)
Convert spherical locations to Cartesian.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_sph2cart!
— Methodlocs_sph2cart!(locs)
Convert spherical locations to Cartesian.
Arguments
locs::DataFrame
NeuroAnalyzer.locs_cart2sph
— Methodlocs_cart2sph(locs)
Convert Cartesian locations to spherical.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_cart2sph!
— Methodlocs_cart2sph!(locs)
Convert Cartesian locations to spherical.
Arguments
locs::DataFrame
NeuroAnalyzer.locs_cart2pol
— Methodlocs_cart2pol(locs)
Convert Cartesian locations to polar.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_cart2pol!
— Methodlocs_cart2pol!(locs)
Convert Cartesian locations to polar.
Arguments
locs::DataFrame
NeuroAnalyzer.locs_sph2pol
— Methodlocs_sph2pol(locs)
Convert spherical locations to polar.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_sph2pol!
— Methodlocs_sph2pol!(locs)
Convert Cartesian locations to polar.
Arguments
locs::DataFrame
NeuroAnalyzer.locs_details
— Methodlocs_details(obj; ch, output)
Return locations of OBJ ch electrode.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, String}
: channel number or nameout::Bool=true
: print output if true
Returns
Named tuple containing:
ch::Int64
: channel numberlabel::String
: location labeltheta::Float64
: polar planar theta coordinateradius::Float64
: polar planar radius coordinatex::Float64
: Cartesian X spherical coordinatey::Float64
: Cartesian Y spherical coordinatez::Float64
: Cartesian Z spherical coordinatetheta_sph::Float64
: spherical horizontal angle, the angle in the xy plane with respect to the x-axis, in degreesradius_sph::Float64
: spherical radius, the distance from the origin to the pointphi_sph::Float64
: spherical azimuth angle, the angle with respect to the z-axis (elevation), in degrees
NeuroAnalyzer.edit_locs
— Methodedit_locs(obj; <keyword arguments>)
Edit electrode.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Int64}
: channel number or namex::Union{Real, Nothing}=nothing
: Cartesian X spherical coordinatey::Union{Real, Nothing}=nothing
: Cartesian Y spherical coordinatez::Union{Real, Nothing}=nothing
: Cartesian Z spherical coordinatetheta::Union{Real, Nothing}=nothing
: polar planar theta coordinateradius::Union{Real, Nothing}=nothing
: polar planar radius coordinatetheta_sph::Union{Real, Nothing}=nothing
: spherical horizontal angle, the angle in the xy plane with respect to the x-axis, in degreesradius_sph::Union{Real, Nothing}=nothing
: spherical radius, the distance from the origin to the pointphi_sph::Union{Real, Nothing}=nothing
: spherical azimuth angle, the angle with respect to the z-axis (elevation), in degreesname::String=""
: channel nametype::String=""
: channel type
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.edit_locs!
— Methodedit_locs!(obj; <keyword arguments>)
Edit electrode.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Int64}
: channel number or namex::Union{Real, Nothing}=nothing
: Cartesian X spherical coordinatey::Union{Real, Nothing}=nothing
: Cartesian Y spherical coordinatez::Union{Real, Nothing}=nothing
: Cartesian Z spherical coordinatetheta::Union{Real, Nothing}=nothing
: polar planar theta coordinateradius::Union{Real, Nothing}=nothing
: polar planar radius coordinatetheta_sph::Union{Real, Nothing}=nothing
: spherical horizontal angle, the angle in the xy plane with respect to the x-axis, in degreesradius_sph::Union{Real, Nothing}=nothing
: spherical radius, the distance from the origin to the pointphi_sph::Union{Real, Nothing}=nothing
: spherical azimuth angle, the angle with respect to the z-axis (elevation), in degreesname::String=""
: channel nametype::String=""
: channel type
NeuroAnalyzer.locs_flipy
— Methodlocs_flipy(locs; planar, spherical)
Flip channel locations along y axis.
Arguments
locs::DataFrame
planar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_flipy!
— Methodlocs_flipy!(locs; planar, spherical)
Flip channel locations along y axis.
Arguments
locs::DataFrame
planar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
NeuroAnalyzer.locs_flipx
— Methodlocs_flipx(locs; planar, spherical)
Flip channel locations along x axis.
Arguments
locs::DataFrame
planar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_flipx!
— Methodlocs_flipx!(locs; planar, spherical)
Flip channel locations along x axis.
Arguments
locs::DataFrame
planar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
NeuroAnalyzer.locs_flipz
— Methodlocs_flipz(locs)
Flip channel locations along z axis.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_flipz!
— Methodlocs_flipz!(locs)
Flip channel locations along z axis.
Arguments
locs::DataFrame
NeuroAnalyzer.locs_rotz
— Methodlocs_rotz(locs; a, planar, spherical)
Rotate channel locations around the z axis.
Arguments
locs::DataFrame
a::Real
: angle of rotation (in degrees)planar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_rotz!
— Methodlocs_rotz!(locs)
Rotate channel locations in the xy-plane.
Arguments
locs::DataFrame
a::Int64
: scaling factorplanar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
NeuroAnalyzer.locs_roty
— Methodlocs_roty(locs; a, planar, spherical)
Rotate channel locations in the xz-plane.
Arguments
locs::DataFrame
a::Real
: angle of rotation (in degrees)planar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_roty!
— Methodlocs_roty!(locs)
Rotate channel locations in the xz-plane.
Arguments
locs::DataFrame
a::Int64
: scaling factorplanar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
NeuroAnalyzer.locs_rotx
— Methodlocs_rotx(locs; a, planar, spherical)
Rotate channel locations in the yz-plane.
Arguments
locs::DataFrame
a::Real
: angle of rotation (in degrees)planar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_rotx!
— Methodlocs_rotx!(locs)
Rotate channel locations in the yz-plane.
Arguments
locs::DataFrame
a::Int64
: scaling factorplanar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
NeuroAnalyzer.locs_scale
— Methodlocs_scale(locs; r, planar, spherical)
Scale channel locations.
Arguments
locs::DataFrame
r::Real
: scaling factorplanar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_scale!
— Methodlocs_scale!(locs)
Scale channel locations.
Arguments
locs::DataFrame
r::Real
: scaling factorplanar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
NeuroAnalyzer.locs_maximize
— Methodlocs_maximize(locs; planar, spherical)
Maximize channel locations to the unit sphere.
Arguments
locs::DataFrame
planar::Bool=true
: modify planar coordinatesspherical::Bool=false
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_maximize!
— Methodlocs_maximize!(locs; planar, spherical)
Maximize channel locations to the unit sphere.
Arguments
locs::DataFrame
planar::Bool=true
: modify planar coordinatesspherical::Bool=false
: modify spherical coordinates
NeuroAnalyzer.locs_swapxy
— Methodlocs_swapxy(locs; planar, spherical)
Swap channel locations x and y axes.
Arguments
locs::DataFrame
planar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.locs_swapxy!
— Methodlocs_swapxy!(locs; planar, spherical)
Swap channel locations x and y axes.
Arguments
locs::DataFrame
planar::Bool=true
: modify planar coordinatesspherical::Bool=true
: modify spherical coordinates
Analyze
NeuroAnalyzer.acor
— Methodacor(s; l, demean)
Calculate auto-correlation
Arguments
s::AbstractVector
l::Int64=round(Int64, min(size(s[1, :, 1], 1) - 1, 10 * log10(size(s[1, :, 1], 1))))
: lags range is0:l
demean::Bool=true
: demean signal before computing auto-correlation
Returns
Named tuple containing:
ac::Matrix{Float64}
NeuroAnalyzer.acor
— Methodacor(s; l, demean)
Calculate auto-correlation
Arguments
s::AbstractMatrix
l::Int64=round(Int64, min(size(s[1, :, 1], 1) - 1, 10 * log10(size(s[1, :, 1], 1))))
: lags range is0:l
demean::Bool=true
: demean signal before computing auto-correlation
Returns
ac::Matrix{Float64}
NeuroAnalyzer.acor
— Methodacor(s; l, demean)
Calculate auto-correlation
Arguments
s::AbstractArray
l::Int64=round(Int64, min(size(s[1, :, 1], 1) - 1, 10 * log10(size(s[1, :, 1], 1))))
: lags range is0:l
demean::Bool=true
: demean signal before computing auto-correlation
Returns
ac::Matrix{Float64}
NeuroAnalyzer.acor
— Methodacor(obj; ch, lag, demean)
Calculate auto-correlation
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelslag::Real=1
: lags range is0:lag
[s]demean::Bool=true
: demean signal before computing auto-correlation
Returns
Named tuple containing:
ac::Array{Float64, 3}
lag::Vector{Float64}
: lags [s]
NeuroAnalyzer.acov
— Methodacov(s; l, demean)
Calculate auto-covariance.
Arguments
s::AbstractVector
l::Int64=round(Int64, min(size(s[1, :, 1], 1) - 1, 10 * log10(size(s[1, :, 1], 1))))
: lags range is0:l
demean::Bool=true
: demean signal before computing auto-covariance
Returns
ac::Matrix{Float64}
NeuroAnalyzer.acov
— Methodacov(s; l, demean)
Calculate auto-covariance.
Arguments
s::AbstractMatrix
l::Int64=round(Int64, min(size(s[1, :, 1], 1) - 1, 10 * log10(size(s[1, :, 1], 1))))
: lags range is0:l
demean::Bool=true
: demean signal before computing auto-covariance
Returns
ac::Matrix{Float64}
NeuroAnalyzer.acov
— Methodacov(s; l, demean)
Calculate auto-covariance.
Arguments
s::AbstractArray
l::Int64=round(Int64, min(size(s[1, :, 1], 1) - 1, 10 * log10(size(s[1, :, 1], 1))))
: lags range is0:l
demean::Bool=true
: demean signal before computing auto-covariance
Returns
ac::Matrix{Float64}
NeuroAnalyzer.acov
— Methodacov(obj; ch, lag, demean)
Calculate auto-covariance.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelslag::Real=1
: lags range is0:lag
[s]demean::Bool=true
: demean signal before computing auto-covariance
Returns
Named tuple containing:
ac::Array{Float64, 3}
lag::Vector{Float64}
: lags [s]
NeuroAnalyzer.ampdiff
— Methodampdiff(s; ch)
Calculate amplitude difference between each channel and mean amplitude of reference channels ch
.
Arguments
s::AbstractArray
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=size(s, 1)
: index of reference channels, default is all channels except the analyzed one
Returns
ad::Array{Float64, 3}
NeuroAnalyzer.ampdiff
— Methodampdiff(obj; ch)
Calculate amplitude difference between each channel and mean amplitude of reference channels ch
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of reference channels, default is all signal channels except the analyzed one
Returns
ad::Array{Float64, 3}
NeuroAnalyzer.band_mpower
— Methodband_mpower(s; fs, f)
Calculate mean and maximum band power and its frequency.
Arguments
s::AbstractVector
fs::Int64
: sampling ratef::Tuple{Real, Real}
: lower and upper frequency bounds
Returns
Named tuple containing:
mbp::Float64
: mean band powermaxfrq::Float64
: frequency of maximum band powermaxbp::Float64
: power at maximum band frequency
NeuroAnalyzer.band_mpower
— Methodband_mpower(s; fs, f, mt)
Calculate absolute band power between two frequencies.
Arguments
s::AbstractArray
fs::Int64
: sampling ratef::Tuple{Real, Real}
: lower and upper frequency boundsmt::Bool=false
: if true use multi-tapered periodogram
Returns
Named tuple containing:
mbp::Matrix{Float64}
: mean band power per channel per epochmaxfrq::Matrix{Float64}
: frequency of maximum band power per channel per epochmaxbp::Matrix{Float64}
: power at maximum band frequency per channel per epoch
NeuroAnalyzer.band_mpower
— Methodband_mpower(obj; ch, f, mt)
Calculate mean and maximum band power and its frequency.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsf::Tuple{Real, Real}
: lower and upper frequency boundsmt::Bool=false
: if true use multi-tapered periodogram
Returns
Named tuple containing:
mbp::Matrix{Float64}
: mean band power per channel per epochmaxfrq::Matrix{Float64}
: frequency of maximum band power per channel per epochmaxbp::Matrix{Float64}
: power at maximum band frequency per channel per epoch
NeuroAnalyzer.band_power
— Methodband_power(s; fs, f, mt)
Calculate absolute band power between two frequencies.
Arguments
s::AbstractVector
fs::Int64
: sampling ratef::Tuple{Real, Real}
: lower and upper frequency boundsmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
bp::Float64
: band power
NeuroAnalyzer.band_power
— Methodband_power(s; fs, f, mt)
Calculate absolute band power between two frequencies.
Arguments
s::AbstractArray
fs::Int64
: sampling ratef::Tuple{Real, Real}
: lower and upper frequency boundsmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
bp::Matrix{Float64}
: band power
NeuroAnalyzer.band_power
— Methodband_power(obj; ch, f, mt)
Calculate absolute band power between two frequencies.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsf::Tuple{Real, Real}
: lower and upper frequency boundsmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
bp::Matrix{Float64}
: band power
NeuroAnalyzer.corm
— Methodcorm(s; norm=true)
Calculate correlation matrix of s * s'
.
Arguments
s::AbstractVector
norm::Bool
: normalize correlation matrix
Returns
cm::Matrix{Float64}
NeuroAnalyzer.corm
— Methodcorm(s1, s2; norm=true)
Calculate correlation matrix of s1 * s2'
.
Arguments
s1::AbstractVector
s2::AbstractVector
norm::Bool
: normalize correlation matrix
Returns
cm::Matrix{Float64}
NeuroAnalyzer.corm
— Methodcorm(s; norm=true)
Calculate correlation matrix.
Arguments
s::AbstractArray
norm::Bool=false
: normalize covariance
Returns
cm::Array{Float64, 4}
NeuroAnalyzer.corm
— Methodcorm(obj; ch, norm)
Calculate correlation matrix.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Vector{Int64}, AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsnorm::Bool=true
: normalize matrix
Returns
cm::Array{Float64, 3}
: correlation matrix for each epoch
NeuroAnalyzer.covm
— Methodcovm(s; norm=true)
Calculate covariance matrix of s * s'
.
Arguments
s::AbstractVector
norm::Bool=false
: normalize covariance
Returns
cm::Matrix{Float64}
NeuroAnalyzer.covm
— Methodcovm(s1, s2; norm=true)
Calculate covariance matrix of s1 * s2'
.
Arguments
s1::AbstractVector
s2::AbstractVector
norm::Bool=false
: normalize covariance
Returns
cm::Matrix{Float64}
NeuroAnalyzer.covm
— Methodcovm(s; norm=true)
Calculate covariance matrix.
Arguments
s::AbstractArray
norm::Bool=false
: normalize covariance
Returns
cm::Matrix{Float64}
NeuroAnalyzer.covm
— Methodcovm(obj; ch, norm)
Calculate covariance matrix of signal * signal'
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Vector{Int64}, AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsnorm::Bool=false
: normalize matrix
Returns
cm::Array{Float64, 3}
: covariance matrix for each epoch
NeuroAnalyzer.cps
— Methodcps(s1, s2; fs)
Calculate cross power spectrum.
Arguments
s1::AbstractVector
s2::AbstractVector
fs::Int64
: sampling rate
Returns
Named tuple containing:
pw::Vector{Float64}
: cross power spectrum powerph::Vector{Float64}
: cross power spectrum phase (in radians)f::Vector{Float64}
: cross power spectrum frequencies
NeuroAnalyzer.cps
— Methodcps(s; fs)
Calculate cross power spectrum (channels vs channels).
Arguments
s::AbstractArray
fs::Int64
: sampling rate
Returns
Named tuple containing:
pw::Array{Float64, 4}
: cross power spectrum powerph::Array{Float64, 4}
: cross power spectrum phase (in radians)f::Vector{Float64}
: cross power spectrum frequencies
NeuroAnalyzer.cps
— Methodcps(s1, s2; fs)
Calculate cross power spectrum (channels of s1
vs channels of s2
).
Arguments
s1::AbstractArray
s2::AbstractArray
fs::Int64
: sampling rate
Returns
Named tuple containing:
pw::Array{Float64, 4}
: cross power spectrum powerph::Array{Float64, 4}
: cross power spectrum phase (in radians)f::Vector{Float64}
: cross power spectrum frequencies
NeuroAnalyzer.cps
— Methodcps(obj; ch)
Calculate cross power spectrum.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
Named tuple containing:
pw::Array{Float64, 4}
: cross power spectrum powerph::Array{Float64, 4}
: cross power spectrum phase (in radians)f::Vector{Float64, 4}
: cross power spectrum frequencies
NeuroAnalyzer.cps
— Methodcps(obj1, obj2; ch1, ch2, ep1, ep2, norm)
Calculate cross power spectrum.
Arguments
obj::NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj2))
: default use all epochs
Returns
Named tuple containing:
pw::Array{Float64, 3}
: cross power spectrum powerph::Array{Float64, 3}
: cross power spectrum phase (in radians)f::Vector{Float64, 3}
: cross power spectrum frequencies
NeuroAnalyzer.gfp
— Methodgfp(s)
Calculate GFP (Global Field Power).
Arguments
s::AbstractVector
Returns
gfp::Float64
NeuroAnalyzer.gfp_norm
— Methodgfp_norm(s)
Calculate signal normalized for GFP (Global Field Power).
Arguments
s::AbstractVector
Returns
gfp_norm::Float64
NeuroAnalyzer.diss
— Methoddiss(s1, s2)
Calculate DISS (global dissimilarity) and spatial correlation between s1
and s2
.
Arguments
s1::AbstractVector
s2::AbstractVector
Returns
Named tuple containing:
gd::Float64
: global dissimilaritysc::Float64
: spatial correlation
NeuroAnalyzer.diss
— Methoddiss(s)
Calculate DISS (global dissimilarity) and spatial correlation (channels vs channels).
Arguments
s::AbstractArray
Returns
Named tuple containing:
gd::Array{Float64, 3}
: global dissimilaritysc::Array{Float64, 3}
: spatial correlation
NeuroAnalyzer.diss
— Methoddiss(s1, s2)
Calculate DISS (global dissimilarity) and spatial correlation (channels vs channels).
Arguments
s1::AbstractArray
s2::AbstractArray
Returns
Named tuple containing:
gd::Array{Float64, 3}
: global dissimilaritysc::Array{Float64, 3}
: spatial correlation
NeuroAnalyzer.diss
— Methoddiss(obj; ch)
Calculate DISS (global dissimilarity) and spatial correlation (channels vs channels).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
Named tuple containing:
gd::Array{Float64, 3}
: global dissimilaritysc::Array{Float64, 3}
: spatial correlation
NeuroAnalyzer.diss
— Methoddiss(obj1, obj2; ch1, ch2, ep1, ep2)
Calculate DISS (global dissimilarity) and spatial correlation (ch1
of obj1
vs ch2
of obj2
)..
Arguments
obj::NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj2))
: default use all epochs
Returns
Named tuple containing:
gd::Array{Float64, 3}
: global dissimilaritysc::Array{Float64, 3}
: spatial correlation
NeuroAnalyzer.entropy
— Methodentropy(s)
Calculate entropy.
Arguments
s::AbstractVector
Returns
ent::Float64
sent::Float64
: Shanon entropyleent::Float64
: log energy entropy
NeuroAnalyzer.entropy
— Methodentropy(s)
Calculate entropy.
Arguments
s::AbstractArray
Returns
Named tuple containing:
ent::Array{Float64, 2}
sent::Array{Float64, 2}
: Shanon entropyleent::Array{Float64, 2}
: log energy entropy
NeuroAnalyzer.entropy
— Methodentropy(obj; ch)
Calculate entropy.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
Named tuple containing:
ent::Array{Float64, 2}
sent::Array{Float64, 2}
: Shanon entropyleent::Array{Float64, 2}
: log energy entropy
NeuroAnalyzer.negentropy
— Methodnegentropy(signal)
Calculate negentropy.
Arguments
signal::AbstractVector
Returns
negent::Float64
NeuroAnalyzer.negentropy
— Methodnegentropy(s)
Calculate negentropy.
Arguments
s::AbstractArray
Returns
ne::Array{Float64, 2}
NeuroAnalyzer.negentropy
— Methodnegentropy(obj; ch)
Calculate negentropy.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
ne::Array{Float64, 2}
NeuroAnalyzer.tenv
— Methodtenv(obj; ch, d)
Calculate temporal envelope (amplitude).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsd::Int64=32
: distance between peeks in samples, lower values get better envelope fit
Returns
Named tuple containing:
t_env::Array{Float64, 3}
: temporal envelopes_t::Vector{Float64}
: signal time
NeuroAnalyzer.tenv_mean
— Methodtenv_mean(obj; ch, dims, d)
Calculate temporal envelope (amplitude): mean and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsdims::Int64
: mean over channels (dims = 1), epochs (dims = 2) or channels and epochs (dims = 3)d::Int64=32
: distance between peeks in samples, lower values get better envelope fit
Returns
Named tuple containing:
t_env_m::Union{Vector{Float64}, Matrix{Float64}}
: temporal envelope: meant_env_u::Union{Vector{Float64}, Matrix{Float64}}
: temporal envelope: 95% CI upper boundt_env_l::Union{Vector{Float64}, Matrix{Float64}}
: temporal envelope: 95% CI lower bounds_t::Vector{Float64}
: signal time
NeuroAnalyzer.tenv_median
— Methodtenv_median(obj; ch, dims, d)
Calculate temporal envelope (amplitude): median and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsdims::Int64
: median over channels (dims = 1), epochs (dims = 2) or channels and epochs (dims = 3)d::Int64=32
: distance between peeks in samples, lower values get better envelope fit
Returns
Named tuple containing:
t_env_m::Union{Vector{Float64}, Matrix{Float64}}
: temporal envelope: mediant_env_u::Union{Vector{Float64}, Matrix{Float64}}
: temporal envelope: 95% CI upper boundt_env_l::Union{Vector{Float64}, Matrix{Float64}}
: temporal envelope: 95% CI lower bounds_t::Vector{Float64}
: signal time
NeuroAnalyzer.penv
— Methodpenv(obj; ch, d)
Calculate power (in dB) envelope.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsd::Int64=8
: distance between peeks in samples, lower values get better envelope fitmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
Named tuple containing:
p_env::Array{Float64, 3}
: power spectrum envelopep_env_frq::Vector{Float64}
: frequencies for each envelope
NeuroAnalyzer.penv_mean
— Methodpenv_mean(obj; ch, dims, d)
Calculate power (in dB) envelope: mean and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsdims::Int64
: mean over channels (dims = 1), epochs (dims = 2) or channels and epochs (dims = 3)d::Int64=8
: distance between peeks in samples, lower values get better envelope fitmt::Bool=false
: if true use multi-tapered periodogram
Returns
Named tuple containing:
p_env_m::Array{Float64, 3}
: power spectrum envelope: meanp_env_u::Array{Float64, 3}
: power spectrum envelope: 95% CI upper boundp_env_l::Array{Float64, 3}
: power spectrum envelope: 95% CI lower boundp_env_frq::Vector{Float64}
: power spectrum envelope (useful for plotting over PSD)
NeuroAnalyzer.penv_median
— Methodpenv_median(obj; ch, dims, d)
Calculate power (in dB) envelope: median and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsdims::Int64
: median over channels (dims = 1) or epochs (dims = 2)d::Int64=8
: distance between peeks in samples, lower values get better envelope fitmt::Bool=false
: if true use multi-tapered periodogram
Returns
Named tuple containing:
p_env_m::Array{Float64, 3}
: power spectrum envelope: medianp_env_u::Array{Float64, 3}
: power spectrum envelope: 95% CI upper boundp_env_l::Array{Float64, 3}
: power spectrum envelope: 95% CI lower boundp_env_frq::Vector{Float64}
: power spectrum envelope (useful for plotting over PSD)
NeuroAnalyzer.senv
— Methodsenv(obj; ch, d, mt, t)
Calculate spectral envelope.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsd::Int64=2
: distance between peeks in samples, lower values get better envelope fitmt::Bool=false
: if true use multi-tapered spectrogramt::Union{Real, Nothing}=nothing
: spectrogram threshold (maximize all powers > t)
Returns
Named tuple containing:
s_env::Array{Float64, 3}
: spectral envelopes_env_t::Vector{Float64}
: spectrogram time
NeuroAnalyzer.senv_mean
— Methodsenv_mean(obj; ch, dims, d, mt, t)
Calculate spectral envelope: mean and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsdims::Int64
: mean over channels (dims = 1), epochs (dims = 2) or channels and epochs (dims = 3)d::Int64=2
: distance between peeks in samples, lower values get better envelope fitmt::Bool=false
: if true use multi-tapered spectrogramt::Union{Real, Nothing}=nothing
: spectrogram threshold (maximize all powers > t)
Returns
Named tuple containing:
s_env_m::Array{Float64, 3}
: spectral envelope: means_env_u::Array{Float64, 3}
: spectral envelope: 95% CI upper bounds_env_l::Array{Float64, 3}
: spectral envelope: 95% CI lower bounds_env_t::Vector{Float64}
: spectral envelope (useful for plotting over spectrogram)
NeuroAnalyzer.senv_median
— Methodsenv_median(obj; ch, dims, d, mt)
Calculate spectral envelope: median and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsdims::Int64
: median over channels (dims = 1), epochs (dims = 2) or channels and epochs (dims = 3)d::Int64=2
: distance between peeks in samples, lower values get better envelope fitmt::Bool=false
: if true use multi-tapered spectrogramt::Union{Real, Nothing}=nothing
: spectrogram threshold (maximize all powers > t)
Returns
Named tuple containing:
s_env_m::Array{Float64, 3}
: spectral envelope: medians_env_u::Array{Float64, 3}
: spectral envelope: 95% CI upper bounds_env_l::Array{Float64, 3}
: spectral envelope: 95% CI lower bounds_env_t::Vector{Float64}
: spectral envelope (useful for plotting over spectrogram)
NeuroAnalyzer.henv
— Methodhenv(obj; ch, d)
Calculate Hilbert spectrum amplitude envelope.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsd::Int64=32
: distance between peeks in samples, lower values get better envelope fit
Returns
Named tuple containing:
h_env::Array{Float64, 3}
: Hilbert spectrum amplitude envelopes_t::Vector{Float64}
: signal time
NeuroAnalyzer.henv_mean
— Methodhenv_mean(obj; ch, dims, d)
Calculate Hilbert spectrum amplitude envelope: mean and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsdims::Int64
: mean over channels (dims = 1), epochs (dims = 2) or channels and epochs (dims = 3)d::Int64=32
: distance between peeks in samples, lower values get better envelope fit
Returns
Named tuple containing:
h_env_m::Union{Vector{Float64}, Matrix{Float64}}
: Hilbert spectrum amplitude envelope: meanh_env_u::Union{Vector{Float64}, Matrix{Float64}}
: Hilbert spectrum amplitude envelope: 95% CI upper boundh_env_l::Union{Vector{Float64}, Matrix{Float64}}
: Hilbert spectrum amplitude envelope: 95% CI lower bounds_t::Vector{Float64}
: signal time
NeuroAnalyzer.henv_median
— Methodhenv_median(obj; ch, dims, d)
Calculate Hilbert spectrum amplitude envelope of obj
: median and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsdims::Int64
: median over channels (dims = 1), epochs (dims = 2) or channels and epochs (dims = 3)d::Int64=32
: distance between peeks in samples, lower values get better envelope fit
Returns
Named tuple containing:
h_env_m::Union{Vector{Float64}, Matrix{Float64}}
: Hilbert spectrum amplitude envelope: medianh_env_u::Union{Vector{Float64}, Matrix{Float64}}
: Hilbert spectrum amplitude envelope: 95% CI upper boundh_env_l::Union{Vector{Float64}, Matrix{Float64}}
: Hilbert spectrum amplitude envelope: 95% CI lower bounds_t::Vector{Float64}
: signal time
NeuroAnalyzer.env_cor
— Methodenv_cor(obj1, obj2; type, ch1, ch2, ep1, ep2)
Calculate envelope correlation.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
type::Symbol=:amp
: envelope type::amp
: amplitude:pow
: power:spec
: spectrogram:hamp
: Hilbert spectrum amplitude
ch1::Int64
ch2::Int64
ep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj2))
: default use all epochs
Returns
Named tuple containing:
ec::Vector{Float64}
: power correlation valuep::Vector{Float64}
: p-value
NeuroAnalyzer.erop
— Methoderop(obj; <keyword arguments>)
Calculate ERO (Event-Related Oscillations) power-spectrum. If obj
is ERP, ero()
returns two epochs: ERP power-spectrum (ero_s[:, :, 1]
) and averaged power-spectra of all ERP epochs (ero_s[:, :, 2]
). Otherwise, ero()
returns averaged power-spectra of all obj
epochs (ero_s[:, :, 1]
)
Arguments
obj::NeuroAnalyzer.NEURO
ch::Int64
: channel to analyzemethod::Symbol=:standard
: method of calculating power-spectrum::standard
: standard:mt
: multi-tapered periodogram:mw
: Morlet wavelet convolution
nt::Int64=8
: number of Slepian taperspad::Int64=0
: number of zeros to addfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: frequency limitsfrq_n::Int64=_tlength(frq_lim)
: number of frequenciesnorm::Bool=true
: normalize powers to dBfrq::Symbol=:log
: linear (:lin
) or logarithmic (:log
) frequenciesncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet wavelet, for tuple a variable number o cycles is used per frequency:ncyc = logspace(log10(ncyc[1]), log10(ncyc[2]), frq_n)
forfrq = :log
orncyc = linspace(ncyc[1], ncyc[2], frq_n)
forfrq = :lin
Returns
Named tuple containing:
ero_p::Array{Float64, 3}
: powersero_f::Vector{Float64}
: frequencies
NeuroAnalyzer.eros
— Methoderos(obj; <keyword arguments>)
Calculate ERO (Event-Related Oscillations) spectrogram. If obj
is ERP, ero()
returns two epochs: ERP spectrogram (ero_s[:, :, 1]
) and averaged spectrograms of all ERP epochs (ero_s[:, :, 2]
). Otherwise, ero()
returns averaged spectrograms of all obj
epochs (ero_s[:, :, 1]
)
Arguments
obj::NeuroAnalyzer.NEURO
ch::Int64
: channel to analyzemethod::Symbol=:standard
: method of calculating spectrogram::standard
: standard:stft
: short-time Fourier transform:mt
: multi-tapered periodogram:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
pad::Int64=0
: number of zeros to addfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: frequency limitsfrq_n::Int64=_tlength(frq_lim)
: number of frequenciesnorm::Bool=true
: normalize powers to dBfrq::Symbol=:log
: linear (:lin
) or logarithmic (:log
) frequenciesgw::Real=5
: Gaussian width in Hzncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet wavelet, for tuple a variable number o cycles is used per frequency:ncyc = logspace(log10(ncyc[1]), log10(ncyc[2]), frq_n)
forfrq = :log
orncyc = linspace(ncyc[1], ncyc[2], frq_n)
forfrq = :lin
wt<:CWT=wavelet(Morlet(2π), β=2)
: continuous wavelet, e.g.wt = wavelet(Morlet(2π), β=2)
, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
ero_s::Array{Float64, 3}
: spectrogram(s)ero_f::Vector{Float64}
: frequenciesero_t::Vector{Float64}
: time
NeuroAnalyzer.erp_peaks
— Methoderp_peaks(obj)
Detect a pair of positive and negative peaks of ERP.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
p::Array{Int64, 2}
: peaks: channels × positive peak position, negative peak position
NeuroAnalyzer.amp_at
— Methodamp_at(obj; t)
Calculate amplitude at given time.
Arguments
obj::NeuroAnalyzer.NEURO
t::Real
: time in seconds
Returns
p::Matrix{Float64, 2}
: amplitude for each channel per epoch
NeuroAnalyzer.avgamp_at
— Methodavgamp_at(obj; t)
Calculate average amplitude at given time segment.
Arguments
obj::NeuroAnalyzer.NEURO
t::Tuple{Real, Real}
: time segment in seconds
Returns
p::Matrix{Float64, 2}
: mean amplitude for each channel per epoch
NeuroAnalyzer.maxamp_at
— Methodmaxamp_at(obj; t)
Calculate maximum amplitude at given time segment.
Arguments
obj::NeuroAnalyzer.NEURO
t::Tuple{Real, Real}
: time segment in seconds
Returns
p::Matrix{Float64, 2}
: maximum amplitude for each channel per epoch
NeuroAnalyzer.minamp_at
— Methodminamp_at(obj; t)
Calculate minimum amplitude at given time segment.
Arguments
obj::NeuroAnalyzer.NEURO
t::Tuple{Real, Real}
: time segment in seconds
Returns
p::Matrix{Float64, 2}
: minimum amplitude for each channel per epoch
NeuroAnalyzer.fcoherence
— Methodfcoherence(s; fs, frq_lim)
Calculate coherence (mean over all frequencies) and MSC (magnitude-squared coherence) between channels.
Arguments
s::AbstractMatrix
fs::Int64
: sampling ratefrq_lim::Union{Tuple{Real, Real}, Nothing}=nothing
: return coherence only for the given frequency range
Returns
Named tuple containing:
c::Array{Float64, 3}
: coherencemsc::Array{Float64, 3}
: MSCf::Vector{Float64}
: frequencies
NeuroAnalyzer.fcoherence
— Methodfcoherence(s1, s2; fs, frq_lim::Union{Tuple{Real, Real}, Nothing}=nothing)
Calculate coherence (mean over all frequencies) and MSC (magnitude-squared coherence) between channels of s1
and s2
.
Arguments
s1::AbstractMatrix
s2::AbstractMatrix
fs::Int64
frq_lim::Union{Tuple{Real, Real}, Nothing}=nothing
: return coherence only for the given frequency range
Returns
c::Array{Float64, 3}
: coherencemsc::Array{Float64, 3}
: MSCf::Vector{Float64}
: frequencies
NeuroAnalyzer.fcoherence
— Methodfcoherence(s1, s2; fs, frq_lim::Union{Tuple{Real, Real}, Nothing}=nothing)
Calculate coherence (mean over all frequencies) and MSC (magnitude-squared coherence) between channels of s1
and s2
.
Arguments
s1::AbstractArray
s2::AbstractArray
fs::Int64
frq_lim::Union{Tuple{Real, Real}, Nothing}=nothing
: return coherence only for the given frequency range
Returns
c::Array{Float64, 3}
: coherencemsc::Array{Float64, 3}
: MSCf::Vector{Float64}
: frequencies
NeuroAnalyzer.fcoherence
— Methodfcoherence(obj1, obj2; ch1, ch2, ep1, ep2, frq_lim)
Calculate coherence (mean over frequencies) and MSC (magnitude-squared coherence).
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj2))
: default use all epochsfrq_lim::Union{Tuple{Real, Real}, Nothing}=nothing
: return coherence only for the given frequency range
Returns
Named tuple containing:
c::Array{Float64, 3}
: coherencemsc::Array{Float64, 3}
: MSCf::Vector{Float64}
: frequencies
NeuroAnalyzer.frqinst
— Methodfrqinst(s; fs)
Calculate instantaneous frequency.
Arguments
s::AbstractVector
fs::Int64
Returns
f::Vector{Float64}
NeuroAnalyzer.frqinst
— Methodfrqinst(s; fs)
Calculate instantaneous frequency.
Arguments
s::AbstractVector
fs::Int64
Returns
f::Array{Float64, 2}
NeuroAnalyzer.frqinst
— Methodfrqinst(obj; channel)
Calculate instantaneous frequency.
Arguments
obj::NeuroAnalyzer.NEURO
channel::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
f::Array{Float64, 3}
NeuroAnalyzer.ged
— Methodged(s1, s2)
Perform generalized eigendecomposition.
Arguments
s1::AbstractArray
: signal to be analyzeds2::AbstractArray
: original signal
Returns
Named tuple containing:
sged::Matrix{Float64}
ress::Vector{Float64}
ress_norm::Vector{Float64}
: RESS normalized to -1..1
NeuroAnalyzer.ged
— Methodged(obj1, obj2; ch1, ch2, ep1, ep2)
Perform generalized eigendecomposition.
Arguments
obj1::NeuroAnalyzer.NEURO
: signal data to be analyzedobj2::NeuroAnalyzer.NEURO
: original signal datach1::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj2))
: default use all epochs
Returns
sged::Array{Float64, 3}
ress::Matrix{Float64}
ress_norm::Matrix{Float64}
NeuroAnalyzer.hrv_detect
— Methodhrv_detect(obj)
Detect heart rate variability (HRV). Requires ECG channel (which will be automatically detected based on channel_type
field).
Arguments
obj::NeuroAnalyzer.NEURO
Returns
nn_seg::Vector{Float64}
: list of NN segments [msec]r_idx::Vector{Float64}
: index of R peaks
NeuroAnalyzer.hrv_analyze
— Methodhrv_analyze(nn_seg)
Analyze heart rate variability (HRV).
Arguments
nn_seg::Vector{Float64}
: list of NN segments [msec]
Returns
Named tuple containing:
menn::Float64
: the mean of NN segmentsmdnn::Float64
: the median of NN segmentsvnn::Float64
: the variance of NN segmentssdnn::Float64
: the standard deviation of NN segmentsrmssd::Float64
: ("root mean square of successive differences"), the square root of the mean of the squares of the successive differences between adjacent NNssdsd::Float64
: ("standard deviation of successive differences"), the standard deviation of the successive differences between adjacent NNsnn50::Float64
: the number of pairs of successive NNs that differ by more than 50 mspnn50::Float64
, the proportion of NN50 divided by total number of NNsnn20::Float64
, the number of pairs of successive NNs that differ by more than 20 mspnn20::Float64
, the proportion of NN20 divided by total number of NNs
NeuroAnalyzer.ispc
— Methodispc(s1, s2)
Calculate ISPC (Inter-Site-Phase Clustering) between s1
and s2
.
Arguments
s1::AbstractVector
s2::AbstractVector
Returns
Named tuple containing:
ispc_value::Float64
: ISPC valueispc_angle::Float64
: ISPC angles_diff::Vector{Float64}
: signal difference (s2 - s1)ph_diff::Vector{Float64}
: phase difference (s2 - s1)s1_phase::Vector{Float64}
: signal 1 phases2_phase::Vector{Float64}
: signal 2 phase
NeuroAnalyzer.ispc
— Methodispc(obj; ch)
Calculate ISPCs (Inter-Site-Phase Clustering).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
ispc_value::Array{Float64, 3}
: ISPC value matrices over epochsispc_angle::Array{Float64, 3}
: ISPC angle matrices over epochs
NeuroAnalyzer.ispc
— Methodispc(obj1, obj2; ch1, ch2, ep1, ep2)
Calculate ISPC (Inter-Site-Phase Clustering).
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj2))
: default use all epochs
Returns
Named tuple containing:
ispc_value::Array{Float64, 2}
: ISPC valueispc_angle::Array{Float64, 2}
: ISPC angles_diff::Array{Float64, 3}
: signal difference (s2 - s1)ph_diff::Array{Float64, 3}
: phase difference (s2 - s1)s1_phase::Array{Float64, 3}
: signal 1 phases2_phase::Array{Float64, 3}
: signal 2 phase
NeuroAnalyzer.itpc
— Methoditpc(s; t)
Calculate ITPC (Inter-Trial-Phase Clustering) at sample number t
over epochs.
Arguments
s::AbstractArray
: one channel over epochst::Int64
: time point (sample number) at which ITPC is calculatedw::Union{AbstractVector, Nothing}
: optional vector of epochs/trials weights for wITPC calculation
Returns
Named tuple containing:
itpc_value::Float64
: ITPC valueitpcz_value::Float64
: Rayleigh's ITPC Z valueitpc_angle::Float64
: ITPC angleitpc_phases::Vector{Float64}
: phases at timet
averaged across trials/epochs
NeuroAnalyzer.itpc
— Methoditpc(obj; <keyword arguments>)
Calculate ITPC (Inter-Trial-Phase Clustering) at sample number t
over epochs.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelst::Int64
: time point (sample number) at which ITPC is calculatedw::Union{Vector{<:Real}, Nothing}=nothing
: optional vector of epochs/trials weights for wITPC calculation
Returns
Named tuple containing:
itpc_value::Vector{Float64}
: ITPC or wITPC valueitpcz_value::Vector{Float64}
: Rayleigh's ITPC Z valueitpc_angle::Vector{Float64}
: ITPC angleitpc_phases::Array{Float64, 2}
: phase difference (channel2 - channel1)
NeuroAnalyzer.itpc_spec
— Methoditpc_spec(obj; <keyword arguments>)
Calculate spectrogram of ITPC (Inter-Trial-Phase Clustering).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Int64
frq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: frequency bounds for the spectrogramfrq_n::Int64=_tlength(frq_lim)
: number of frequenciesfrq::Symbol=:log
: linear (:lin
) or logarithmic (:log
) frequenciesw::Union{Vector{<:Real}, Nothing}=nothing
: optional vector of epochs/trials weights for wITPC calculation
Returns
Named tuple containing:
itpc_s::Array{Float64, 3}
: spectrogram of ITPC valuesitpcz_s::Array{Float64, 3}
: spectrogram itpcz_value valuesitpc_f::Vector{Float64}
: frequencies list
NeuroAnalyzer.mdiff
— Methodmdiff(s1, s2; n, method)
Calculate mean difference and 95% confidence interval for 2 signals.
Arguments
s1::AbstractMatrix
s2::AbstractMatrix
n::Int64=3
: number of bootstrapsmethod::Symbol=:absdiff
::absdiff
: maximum difference:diff2int
: integrated area of the squared difference
Returns
Named tuple containing:
st::Vector{Float64}
sts::Float64
p::Float64
NeuroAnalyzer.mdiff
— Methodmdiff(s1, s2; n, method)
Calculate mean difference and its 95% CI between channels.
Arguments
s1::AbstractArray
s2::AbstractArray
n::Int64=3
: number of bootstrapsmethod::Symbol=:absdiff
:absdiff
: maximum difference:diff2int
: integrated area of the squared difference
Returns
Named tuple containing:
st::Matrix{Float64}
sts::Vector{Float64}
p::Vector{Float64}
NeuroAnalyzer.mdiff
— Methodmdiff(obj; ch, n, method)
Calculate mean difference and its 95% CI between channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsn::Int64=3
: number of bootstrapsmethod::Symbol=:absdiff
:absdiff
: maximum difference:diff2int
: integrated area of the squared difference
Returns
Named tuple containing:
st::Matrix{Float64}
sts::Vector{Float64}
p::Vector{Float64}
NeuroAnalyzer.mdiff
— Methodmdiff(obj1, obj2; channel1, channel2, epoch1, epoch2, n, method)
Calculates mean difference and 95% confidence interval for two channels.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2:NeuroAnalyzer.NEURO
channel1::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelschannel2::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsepoch1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj1))
: default use all epochsepoch2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj2))
: default use all epochsn::Int64
: number of bootstrapsmethod::Symbol[:absdiff, :diff2int]
:absdiff
: maximum difference:diff2int
: integrated area of the squared difference
Returns
Named tuple containing:
st::Matrix{Float64}
sts::Vector{Float64}
p::Vector{Float64}
NeuroAnalyzer.mutual_information
— Methodmutual_information(s1, s2)
Calculate mutual information.
Arguments
s1::AbstractVector
s2::AbstractVector
Returns
mutual_information::Float64
NeuroAnalyzer.mutual_information
— Methodmutual_information(s1, s2)
Calculate mutual information (channels of s1
vs channels of s2
).
Arguments
s1::AbstractArray
s2::AbstractArray
Returns
mutual_information::Array{Float64}
NeuroAnalyzer.mutual_information
— Methodmutual_information(s)
Calculate mutual information (channels vs channels).
Arguments
s::AbstractArray
Returns
NeuroAnalyzer.mutual_information
— Methodmutual_information(obj; channel)
Calculate mutual information between channels.
Arguments
obj::NeuroAnalyzer.NEURO
channel::Union{Vector{Int64}, AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
mutual_information::Array{Float64, 3}
NeuroAnalyzer.mutual_information
— Methodmutual_information(obj1, obj2; ch1, ch2, ep1, ep2)
Calculate mutual information between two channels.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj2))
: default use all epochs
Returns
m::Array{Float64, 3}
NeuroAnalyzer.msci95
— Methodmsci95(s; n, method)
Calculate mean, standard deviation and 95% confidence interval.
Arguments
s::AbstractVector
n::Int64=3
: number of bootstrapsmethod::Symbol=:normal
: use normal method (:normal
) orn
-times boostrapping (:boot
)
Returns
Named tuple containing:
sm::Float64
: meanss::Float64
: standard deviationsu::Float64
: upper 95% CIsl::Float64
: lower 95% CI
NeuroAnalyzer.msci95
— Methodmsci95(s; n, method)
Calculate mean, standard deviation and 95% confidence interval.
Arguments
s::AbstractMatrix
n::Int64=3
: number of bootstrapsmethod::Symbol=:normal
: use normal method (:normal
) orn
-times boostrapping (:boot
)
Returns
Named tuple containing:
sm::Vector{Float64}
: meanss::Vector{Float64}
: standard deviationsu::Vector{Float64}
: upper 95% CIsl::Vector{Float64}
: lower 95% CI
NeuroAnalyzer.msci95
— Methodmsci95(s; n, method)
Calculate mean, standard deviation and 95% confidence interval.
Arguments
s::AbstractArray
n::Int64=3
: number of bootstrapsmethod::Symbol=:normal
: use normal method (:normal
) orn
-times boostrapping (:boot
)
Returns
Named tuple containing:
sm::Array{Float64}
: meanss::Array{Float64}
: standard deviationsu::Array{Float64}
: upper 95% CIsl::Array{Float64}
: lower 95% CI
NeuroAnalyzer.msci95
— Methodmsci95(obj; ch, n, method)
Calculate mean, standard deviation and 95% confidence interval.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsn::Int64=3
: number of bootstrapsmethod::Symbol=:normal
: use normal (:normal
) method orn
-times bootstrapping (:boot
)
Returns
Named tuple containing:
sm::Matrix{Float64}
: meanss::Matrix{Float64}
: standard deviationsu::Matrix{Float64}
: upper 95% CIsl::Matrix{Float64}
: lower 95% CI
NeuroAnalyzer.msci95
— Methodmsci95(s1, s2)
Calculate mean difference, standard deviation and 95% confidence interval.
Arguments
s1::AbstractVector
s2::AbstractVector
Returns
Named tuple containing:
sm::Float64
: meanss::Float64
: standard deviationsu::Float64
: upper 95% CIsl::Float64
: lower 95% CI
NeuroAnalyzer.msci95
— Methodmsci95(s1, s2)
Calculate mean difference, standard deviation and 95% confidence interval.
Arguments
s1::AbstractArray
s2::AbstractArray
Returns
Named tuple containing:
sm::Array{Float64}
: meanss::Array{Float64}
: standard deviationsu::Array{Float64}
: upper 95% CIsl::Array{Float64}
: lower 95% CI
NeuroAnalyzer.msci95
— Methodmsci95(obj1, obj2; ch1, ch2, ep1, ep2)
Calculate mean difference, standard deviation and 95% confidence interval.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2:NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj2))
: default use all epochs
Returns
Named tuple containing:
sm::Matrix{Float64}
: meanss::Matrix{Float64}
: standard deviationsu::Matrix{Float64}
: upper 95% CI boundsl::Matrix{Float64}
: lower 95% CI bound
NeuroAnalyzer.phdiff
— Methodphdiff(s1, s2; pad, h)
Calculate phase difference between signals.
Arguments
s1::AbstractVector
s2::AbstractVector
pad::Int64=0
: number of zeros to addh::Bool=false
: use FFT or Hilbert transformation (if h=true)
Returns
Named tuple containing:
phd::Vector{Float64}
: phase differences in radians
NeuroAnalyzer.phdiff
— Methodphdiff(s; ch, pad, h)
Calculate phase difference between channels and mean phase of reference ch
.
Arguments
s::AbstractArray
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=size(s, 1)
: index of reference channels, default is all channels except the analyzed oneavg::Symbol=:phase
: method of averaging::phase
: phase is calculated for each reference channel separately and then averaged:signal
: signals are averaged prior to phase calculation
pad::Int64=0
: pad signals with 0sh::Bool=false
: use FFT or Hilbert transformation
Returns
phd::Array{Float64, 3}
NeuroAnalyzer.phdiff
— Methodphdiff(obj; ch, pad, h)
Calculate phase difference between channels and mean phase of reference ch
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of reference channels, default is all signal channels except the analyzed oneavg::Symbol=:phase
: method of averaging::phase
: phase is calculated for each reference channel separately and then averaged:signal
: signals are averaged prior to phase calculation
pad::Int64=0
: pad signals with 0sh::Bool=false
: use FFT or Hilbert transformation
Returns
phd::Array{Float64, 3}
NeuroAnalyzer.pli
— Methodpli(s1, s2)
Calculate PLI (Phase-Lag Index).
Arguments
s1::AbstractVector
s2::AbstractVector
Returns
Named tuple containing:
pv::Float64
: PLI valuesd::Vector{Float64}
: signal difference (s2 - s1)phd::Vector{Float64}
: phase difference (s2 - s1)s1ph::Vector{Float64}
: signal 1 phases2ph::Vector{Float64}
: signal 2 phase
NeuroAnalyzer.pli
— Methodpli(obj1, obj2; ch1, ch2, ep1, ep2)
Calculate PLI (Phase Lag Index).
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj2))
: default use all epochs
Returns
Named tuple containing:
pv::Array{Float64, 2}
: PLI valuesd::Array{Float64, 3}
: signal difference (s2 - s1)phd::Array{Float64, 3}
: phase difference (s2 - s1)s1ph::Array{Float64, 3}
: signal 1 phases2ph::Array{Float64, 3}
: signal 2 phase
NeuroAnalyzer.pli
— Methodpli(obj; channel)
Calculate PLIs (Phase Lag Index).
Arguments
obj::NeuroAnalyzer.NEURO
channel::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
pv::Array{Float64, 3}
: PLI value matrices over epochs
NeuroAnalyzer.psd
— Methodpsd(s; fs, norm, mt, nt)
Calculate power spectrum density.
Arguments
s::Vector{Float64}
fs::Int64
: sampling ratenorm::Bool=false
: normalize do dBmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
Named tuple containing:
pw::Vector{Float64}
: powerspf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd
— Methodpsd(s; fs, norm, mt, nt)
Calculate power spectrum density.
Arguments
s::AbstractMatrix
fs::Int64
: sampling ratenorm::Bool=false
: normalize do dBmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
Named tuple containing:
pw::Array{Float64, 2}
: powerspf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd
— Methodpsd(s; fs, norm, mt, nt)
Calculate power spectrum density.
Arguments
s::AbstractArray
fs::Int64
: sampling ratenorm::Bool=false
: normalize do dBmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
Named tuple containing:
pw::Array{Float64, 3}
: powerspf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd
— Methodpsd(obj; ch, norm, mt)
Calculate power spectrum density.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsnorm::Bool=false
: normalize do dBmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
Named tuple containing:
pw::Array{Float64, 3}
: powerspf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd_mw
— Methodpsd_mw(s; pad, norm, frq_lim, frq_n, frq, fs, ncyc)
Calculate power spectrum using Morlet wavelet convolution.
Arguments
s::AbstractVector
pad::Int64=0
: pad withpad
zerosnorm::Bool=true
: normalize powers to dBfs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}=(0, fs / 2)
: frequency bounds for the spectrogramfrq_n::Int64=length(frq_lim[1]:frq_lim[2])
: number of frequenciesfrq::Symbol=:log
: linear (:lin
) or logarithmic (:log
) frequenciesncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=logspace(log10(ncyc[1]), log10(ncyc[2]), frq_n)
forfrq = :log
orncyc=linspace(ncyc[1], ncyc[2], frq_n)
forfrq = :lin
Returns
Named tuple containing:
pw::Matrix{Float64}
: powerspf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd_mw
— Methodpsd_mw(s; pad, norm, frq_lim, frq_n, frq, fs, ncyc)
Calculate power spectrum using Morlet wavelet convolution.
Arguments
s::AbstractMatrix
pad::Int64=0
: pad withpad
zerosnorm::Bool=true
: normalize powers to dBfs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}=(0, fs / 2)
: frequency bounds for the spectrogramfrq_n::Int64=10
: number of frequenciesfrq::Symbol=:log
: linear (:lin
) or logarithmic (:log
) frequenciesncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc = logspace(log10(ncyc[1]), log10(ncyc[2]), frq_n)
forfrq = :log
orncyc = linspace(ncyc[1], ncyc[2], frq_n)
forfrq = :lin
Returns
Named tuple containing:
pw::Array{Float64, 2}
: powerspf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd_mw
— Methodpsd_mw(s; pad, norm, frq_lim, frq_n, frq, fs, ncyc)
Calculate power spectrum using Morlet wavelet convolution.
Arguments
s::AbstractArray
pad::Int64=0
: pad withpad
zerosnorm::Bool=true
: normalize powers to dBfs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}=(0, fs / 2)
: frequency bounds for the spectrogramfrq_n::Int64=10
: number of frequenciesfrq::Symbol=:log
: linear (:lin
) or logarithmic (:log
) frequenciesncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc = logspace(log10(ncyc[1]), log10(ncyc[2]), frq_n)
forfrq = :log
orncyc = linspace(ncyc[1], ncyc[2], frq_n)
forfrq = :lin
Returns
Named tuple containing:
pw::Array{Float64, 3}
: powerspf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd_mw
— Methodpsd_mw(obj; ch, pad, norm, frq_lim, frq_n, frq, ncyc)
Calculate power spectrum using Morlet wavelet convolution.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all s channelspad::Int64=0
: pad withpad
zerosnorm::Bool
=true: normalize powers to dBfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: frequency bounds for the spectrogramfrq_n::Int64=_tlength(frq_lim)
: number of frequenciesfrq::Symbol=:log
: linear (:lin
) or logarithmic (:log
) frequenciesncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=logspace(log10(ncyc[1]), log10(ncyc[2]), frq_n)
forfrq = :log
orncyc=linspace(ncyc[1], ncyc[2], frq_n)
forfrq = :lin
Returns
Named tuple containing:
pw::Array{Float64, 3}
: powerspf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd_rel
— Methodpsd_rel(s; fs, norm, mt, nt, f)
Calculate relative power spectrum density.
Arguments
s::AbstractVector
fs::Int64
: sampling ratenorm::Bool=false
: normalize do dBmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapersf::Union(Tuple{Real, Real}, Nothing)=nothing
: calculate power relative to frequency range or total power
Returns
Named tuple containing:
pw::Vector{Float64}
: powerspf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd_rel
— Methodpsd_rel(s; fs, norm, mt, nt, f)
Calculate relative power spectrum density.
Arguments
s::AbstractMatrix
fs::Int64
: sampling ratenorm::Bool=false
: normalize do dBmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapersf::Union(Tuple{Real, Real}, Nothing)=nothing
: calculate power relative to frequency range or total power
Returns
Named tuple containing:
pw::Array{Float64, 3}
: powerspf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd_rel
— Methodpsd_rel(s; fs, norm, mt, nt, f)
Calculate relative power spectrum density.
Arguments
s::AbstractArray
fs::Int64
: sampling ratenorm::Bool=false
: normalize do dBmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapersf::Union(Tuple{Real, Real}, Nothing)=nothing
: calculate power relative to frequency range or total power
Returns
Named tuple containing:
pw::Array{Float64, 3}
: powerspf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd_rel
— Methodpsd_rel(obj; ch, norm, mt, nt, f)
Calculate relative power spectrum density.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsnorm::Bool=false
: normalize do dBmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapersf::Union(Tuple{Real, Real}, Nothing)=nothing
: calculate power relative to frequency range or total power
Returns
Named tuple containing:
pw::Array{Float64, 3}
: powerspf::Array{Float64, 3}
: frequencies
NeuroAnalyzer.psd_slope
— Methodpsd_slope(s; fs, f, norm, mt, nt)
Calculate PSD linear fit and slope.
Arguments
s::AbstractVector
fs::Int64
: sampling ratef::Tuple{Real, Real}=(0, fs / 2)
: calculate slope of the total power (default) or frequency rangef[1]
tof[2]
norm::Bool=false
: normalize do dBmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
Named tuple containing:
lf::Vector{Float64}
: linear fitls::Float64
: slopes of linear fitpf::Vector{Float64}
: range of frequencies for the linear fit
NeuroAnalyzer.psd_slope
— Methodpsd_slope(s; fs, f, norm, mt, nt)
Calculate PSD linear fit and slope.
Arguments
s::AbstractArray
fs::Int64
: sampling ratef::Tuple{Real, Real}=(0, fs / 2)
: calculate slope of the total power (default) or frequency rangef[1]
tof[2]
norm::Bool=false
: normalize do dBmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
Named tuple containing:
lf::Matrix{Float64}
: linear fits::Vector{Float64}
: slope of linear fitpf::Vector{Float64}
: range of frequencies for the linear fit
NeuroAnalyzer.psd_slope
— Methodpsd_slope(obj; ch, f, norm, mt)
Calculate PSD linear fit and slope.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsf::Tuple{Real, Real}=(0, sr(obj) / 2)
: calculate slope of the total power (default) or frequency range f[1] to f[2]norm::Bool=false
: normalize do dBmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
Named tuple containing:
lf::Array{Float64, 3}
: linear fitls::Array{Float64, 2}
: slope of linear fitpf::Vector{Float64}
: range of frequencies for the linear fit
NeuroAnalyzer.rms
— Methodrms(s)
Calculate Root Mean Square.
Arguments
s::AbstractVector
Returns
rms::Float64
NeuroAnalyzer.rms
— Methodrms(s)
Calculate Root Mean Square.
Arguments
s::AbstractArray
Returns
r::Array{Float64, 2}
NeuroAnalyzer.rms
— Methodrms(obj; channel)
Calculate Root Mean Square.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
r::Array{Float64, 2}
NeuroAnalyzer.rmse
— Methodrmse(s1, s2)
Calculate Root Mean Square Error (RMSE).
Arguments
s1::AbstractVector
s2::AbstractVector
Returns
rmse::Float64
: RMSE
NeuroAnalyzer.rmse
— Methodrmse(s1, s2)
Calculate Root Mean Square Error (RMSE).
Arguments
s1::AbstractArray
s2::AbstractArray
Returns
r::Array{Float64, 2}
: RMSE
NeuroAnalyzer.rmse
— Methodrmse(obj1, obj2; ch1, ch2, ep1, ep2)
Calculate Root Mean Square Error (RMSE).
Arguments
obj::NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(epoch_n(obj2))
: default use all epochs
Returns
Named tuple containing:
r::Array{Float64, 3}
: RMSEcps_ph::Array{Float64, 3}
: cross power spectrum phase (in radians)cps_fq::Vector{Float64, 3}
: cross power spectrum frequencies
NeuroAnalyzer.snr
— Methodsnr(s)
Calculate mean-based SNR.
Arguments
s::AbstractVector
Returns
snr::Float64
: SNR
Source
D. J. Schroeder (1999). Astronomical optics (2nd ed.). Academic Press. ISBN 978-0-12-629810-9, p.278
NeuroAnalyzer.snr2
— Methodsnr2(s)
Calculate RMS-based SNR.
Arguments
s::AbstractVector
Returns
snr2::Float64
: SNR
NeuroAnalyzer.snr
— Methodsnr(s; t, type)
Calculate SNR.
Arguments
s::AbstractArray
t::Vector{Float64}
: epoch timetype::Symbol=:rms
: SNR type::mean
: mean-based:rms
: RMS-based
Returns
Named tuple containing:
s::Matrix(Float64)
: SNR for each channel over frequencies 1:Nyquistf::Vector(Float64)
: frequencies
NeuroAnalyzer.snr
— Methodsnr(obj; ch, type)
Calculate SNR.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelstype::Symbol=:rms
: SNR type::mean
: mean-based:rms
: RMS-based
Returns
Named tuple containing:
sn::Matrix(Float64)
: SNR for each channel over frequencies 1:Nyquistf::Vector(Float64)
: frequencies
NeuroAnalyzer.spec_seg
— Methodspec_seg(sp, st, sf; t, f)
Return spectrogram segment.
Arguments
sp::Matrix{Float64}
: spectrogram powersst::Vector{Float64}
: spectrogram timesf::Vector{Float64}
: spectrogram frequenciest::Tuple{Real, Real}
: time boundsf::Tuple{Real, Real}
: frequency bounds
Returns
Named tuple containing:
segp::Matrix{Float64}
: powerssegs::Vector{Tuple{Float64, Float64}}
: segment coordinates, for plotting should be converted byPlots.Shape(segs)
tidx::Tuple{Real, Real}
: time indicesfidx::Tuple{Real, Real}
: frequency indices
NeuroAnalyzer.spec_seg
— Methodspec_seg(sp, sf, st; ch, t, f)
Return spectrogram segment.
Arguments
sp::AbstractArray
: spectrogram powersst::AbstractVector
: spectrogram timesf::AbstractVector
: spectrogram frequenciesch::Int64
: channelt::Tuple{Real, Real}
: time boundsf::Tuple{Real, Real}
: frequency bounds
Returns
Named tuple containing:
segp::Array{Float64, 3}
: segment of powerssegs::Vector{Tuple{Float64, Float64}}
: segment coordinates, for plotting should be converted byPlots.Shape(segs)
tidx::Tuple{Real, Real}
: time indicesfidx::Tuple{Real, Real}
: frequency indices
NeuroAnalyzer.spectrogram
— Methodspectrogram(s; fs, norm, mt, st)
Calculate spectrogram.
Arguments
s::AbstractVector
fs::Int64
: sampling frequencynorm::Bool=true
: normalize powers to dBmt::Bool=false
: if true use multi-tapered spectrogramst::Bool=false
: if true use short time Fourier transform
Returns
Named tuple containing:
sp::Matrix{Float64}
: powerssf::Vector{Float64}
: frequenciesst::Vector{Float64}
: time
NeuroAnalyzer.wspectrogram
— Methodwspectrogram(s; pad, norm, fs, frq_lim, frq_n, frq, ncyc)
Calculate spectrogram using wavelet convolution.
Arguments
s::AbstractVector
pad::Int64
: pad withpad
zerosnorm::Bool=true
: normalize powers to dBfs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}=(0, fs / 2)
: frequency bounds for the spectrogramfrq_n::Int64=_tlength(frq_lim)
: number of frequenciesfrq::Symbol=:log
: linear (:lin
) or logarithmic (:log
) frequenciesncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet wavelet, for tuple a variable number o cycles is used per frequency:ncyc=logspace(log10(ncyc[1]), log10(ncyc[2]), frq_n)
forfrq = :log
orncyc=linspace(ncyc[1], ncyc[2], frq_n)
forfrq = :lin
Returns
Named tuple containing:
cs::Matrix(ComplexF64}
: convoluted signalsp::Matrix{Float64}
: powerssph::Matrix{Float64}
: phasessf::Vector{Float64}
: frequencies
NeuroAnalyzer.ghspectrogram
— Methodghspectrogram(s; fs, norm, frq_lim, frq_n, frq, fs)
Calculate spectrogram using Gaussian and Hilbert transform.
Arguments
s::AbstractVector
fs::Int64
: sampling ratenorm::Bool=true
: normalize powers to dBfrq_lim::Tuple{Real, Real}=(0, fs / 2)
: frequency bounds for the spectrogramfrq_n::Int64_tlength(frq_lim)
: number of frequenciesfrq::Symbol=:log
: linear (:lin
) or logarithmic (:log
) frequenciesgw::Real=5
: Gaussian width in Hz
Returns
Named tuple containing:
sp::Matrix{Float64}
: powerssph::Matrix{Float64}
: phasessf::Vector{Float64}
: frequencies
NeuroAnalyzer.cwtspectrogram
— Methodcwtspectrogram(s; wt, pad, norm, frq_lim, fs)
Calculate spectrogram using continuous wavelet transformation (CWT).
Arguments
s::AbstractVector
wt<:CWT
: continuous wavelet, e.g.wt = wavelet(Morlet(2π), β=2)
, see ContinuousWavelets.jl documentation for the list of available waveletsfs::Int64
: sampling ratenorm::Bool=true
: normalize powers to dBfrq_lim::Tuple{Real, Real}=(0, fs / 2)
: frequency bounds for the spectrogram
Returns
Named tuple containing:
sp::Matrix{Float64}
: powerssf::Vector{Float64}
: frequencies
NeuroAnalyzer.spectrogram
— Methodspectrogram(obj; ch, pad, frq_lim, frq_n, method, norm, frq, gw, ncyc, wt)
Calculate spectrogram.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsmethod::Symbol=:standard
: method of calculating spectrogram::standard
: standard:stft
: short-time Fourier transform:mt
: multi-tapered periodogram:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
pad::Int64=0
: number of zeros to addfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: frequency limitsfrq_n::Int64=_tlength(frq_lim)
: number of frequenciesnorm::Bool=true
: normalize powers to dBfrq::Symbol=:log
: linear (:lin
) or logarithmic (:log
) frequenciesgw::Real=5
: Gaussian width in Hzncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet wavelet, for tuple a variable number o cycles is used per frequency:ncyc = logspace(log10(ncyc[1]), log10(ncyc[2]), frq_n)
forfrq = :log
orncyc = linspace(ncyc[1], ncyc[2], frq_n)
forfrq = :lin
wt<:CWT=wavelet(Morlet(2π), β=2)
: continuous wavelet, e.g.wt = wavelet(Morlet(2π), β=2)
, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
sp::Array{Float64, 3}
sf::Vector{Float64}
st::Vector{Float64}
NeuroAnalyzer.spectrum
— Methodspectrum(s; pad)
Calculate FFT, amplitudes, powers and phases.
Arguments
s::AbstractVector
pad::Int64=0
: number of zeros to add at the end of the signalnorm::Bool=false
: normalize do dB
Returns
Named tuple containing:
ft::Vector{ComplexF64}
: Fourier transformssa::Vector{Float64}
: amplitudessp::Vector{Float64}
: powerssph::Vector{Float64}
: phases
NeuroAnalyzer.hspectrum
— Methodhspectrum(s; pad=0)
Calculate amplitudes, powers and phases using Hilbert transform.
Arguments
s::AbstractVector
pad::Int64
: number of zeros to add at the end of the signalnorm::Bool=true
: normalize do dB
Returns
Named tuple containing:
hc::Vector(ComplexF64}
: Hilbert componentssa::Vector{Float64}
: amplitudessp::Vector{Float64}
: powerssph::Vector{Float64}
: phases
NeuroAnalyzer.hspectrum
— Methodhspectrum(s; pad=0)
Calculate amplitudes, powers and phases using Hilbert transform.
Arguments
s::AbstractArray
pad::Int64
: number of zeros to add at the end of the signalnorm::Bool=true
: normalize do dB
Returns
Named tuple containing:
hc::Array(ComplexF64, 3}
: Hilbert componentssa::Array{Float64, 3}
: amplitudessp::Array{Float64, 3}
: powerssph::Array{Float64, 3}
: phases
NeuroAnalyzer.spectrum
— Methodspectrum(s; pad, h)
Calculate FFT/Hilbert transformation components, amplitudes, powers and phases.
Arguments
s::AbstractArray
pad::Int64=0
: number of zeros to add signal for FFTh::Bool=false
: use Hilbert transform for calculations instead of FFTnorm::Bool=false
: normalize do dB
Returns
Named tuple containing:
c::Array{ComplexF64, 3}
: Fourier or Hilbert componentssa::Array{Float64, 3}
: amplitudessp::Array{Float64, 3}
: powers- `sph::Array{Float64, 3}: phase angles
NeuroAnalyzer.spectrum
— Methodspectrum(obj; ch, pad, h)
Calculate FFT/Hilbert transformation components, amplitudes, powers and phases.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelspad::Int64=0
: number of zeros to add signal for FFTh::Bool=false
: use Hilbert transform for calculations instead of FFTnorm::Bool=false
: normalize do dB
Returns
Named tuple containing:
c::Array{ComplexF64, 3}
: Fourier or Hilbert componentssa::Array{Float64, 3}
: amplitudessp::Array{Float64, 3}
: powers- `sph::Array{Float64, 3}: phase angles
NeuroAnalyzer.stationarity_hilbert
— Methodstationarity_hilbert(s)
Calculate phase stationarity using Hilbert transformation.
Arguments
s::AbstractVector
Returns
stph::Vector{Float64}
NeuroAnalyzer.stationarity_mean
— Methodstationarity_mean(s; window)
Calculate mean stationarity. Signal is split into window
-long windows and averaged across windows.
Arguments
s::AbstractVector
window::Int64
: time window in samples
Returns
stm::Vector{Float64}
NeuroAnalyzer.stationarity_var
— Methodstationarity_var(s; window)
Calculate variance stationarity. Signal is split into window
-long windows and variance is calculated across windows.
Arguments
s::AbstractVector
window::Int64
: time window in samples
Returns
stv::Vector{Float64}
NeuroAnalyzer.stationarity
— Methodstationarity(obj; ch, window, method)
Calculate stationarity.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelswindow::Int64=10
: time window in samplesmethod::Symbol=:euclid
: stationarity method::mean
: mean acrosswindow
-long windows:var
: variance acrosswindow
-long windows:cov
: covariance stationarity based on Euclidean distance between covariance matrix of adjacent time windows:hilbert
: phase stationarity using Hilbert transformation:adf
: Augmented Dickey–Fuller test; returns ADF-test value and p-value (H0: signal is non-stationary; p-value < alpha means that signal is stationary)
Returns
stationarity::Array{Float64, 3}
NeuroAnalyzer.epoch_stats
— Methodepoch_stats(obj)
Calculate epochs statistics.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
Named tuple containing:
e_mean::Vector(Float64)
: meane_median::Vector(Float64)
: mediane_std::Vector(Float64)
: standard deviatione_var::Vector(Float64)
: variancee_kurt::Vector(Float64)
: kurtosise_skew::Vector(Float64)
: skewnesse_mean_diff::Vector(Float64)
: mean diff valuee_median_diff::Vector(Float64)
: median diff valuee_max_dif::Vector(Float64)
: max differencee_dev_mean::Vector(Float64)
: deviation from channel mean
NeuroAnalyzer.channel_stats
— Methodchannel_stats(obj)
Calculate channels statistics per epoch.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
Named tuple containing:
c_mean::Matrix(Float64)
: meanc_median::Matrix(Float64)
: medianc_std::Matrix(Float64)
: standard deviationc_var::Matrix(Float64)
: variancec_kurt::Matrix(Float64)
: kurtosisc_skew::Matrix(Float64)
: skewnessc_mean_diff::Matrix(Float64)
: mean diff valuec_median_diff::Matrix(Float64)
: median diff valuec_max_dif::Matrix(Float64)
: max differencec_dev_mean::Matrix(Float64)
: deviation from channel mean
NeuroAnalyzer.tcoherence
— Methodtcoherence(s1, s2; pad)
Calculate coherence (mean over time), IC (imaginary coherence) and MSC (magnitude-squared coherence).
Arguments
s1::AbstractVector
s2::AbstractVector
pad::Int64=0
: number of zeros to add
Returns
Named tuple containing:
c::Vector{Float64}
: coherencemsc::Vector{Float64}
: magnitude-squares coherenceic::Vector{Float64}
: imaginary part of coherence
NeuroAnalyzer.tcoherence
— Methodtcoherence(s1, s2; ch1, ch2, ep1, ep2)
Calculate coherence (mean over time), IC (imaginary coherence) and MSC (magnitude-squared coherence).
Arguments
s1::AbstractArray
s2::AbstractArray
pad::Int64=0
: number of zeros to add signal for FFT
Returns
Named tuple containing:
c::Array{Float64, 3}
: coherencemsc::Array{Float64, 3}
: MSCic::Array{Float64, 3}
: imaginary part of coherence
NeuroAnalyzer.tcoherence
— Methodtcoherence(obj1, obj2; ch1, ch2, ep1, ep2)
Calculate coherence (mean over time), IC (imaginary coherence) and MSC (magnitude-squared coherence).
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, AbstractRange}=_c(epoch_n(obj2))
: default use all epochspad::Int64=0
: number of zeros to add signal for FFT
Returns
Named tuple containing:
c::Array{Float64, 3}
: coherencemsc::Array{Float64, 3}
: MSCic::Array{Float64, 3}
: imaginary part of coherence
NeuroAnalyzer.tkeo
— Methodtkeo(s)
Calculate Teager-Kaiser energy-tracking operator: y(t) = x(t)^2 - x(t-1) × x(t+1)
Arguments
s::AbstractVector
Returns
t::Vector{Float64}
NeuroAnalyzer.tkeo
— Methodtkeo(s; channel)
Calculate Teager-Kaiser energy-tracking operator: y(t) = x(t)^2 - x(t-1) × x(t+1)
Arguments
s::AbstractArray
channel::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
t::Array{Float64, 3}
NeuroAnalyzer.tkeo
— Methodtkeo(obj; channel)
Calculate Teager-Kaiser energy-tracking operator: y(t) = x(t)^2 - x(t-1) × x(t+1)
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
t::Array{Float64, 3}
NeuroAnalyzer.total_power
— Methodtotal_power(s; fs, mt)
Calculate total power.
Arguments
s::AbstractVector
fs::Int64
: sampling ratemt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
tp::Float64
: total power
NeuroAnalyzer.total_power
— Methodtotal_power(s; fs, mt)
Calculate total power.
`# Arguments
s::AbstractArray
fs::Int64
: sampling ratemt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
tp::Matrix{Float64}
: total power
NeuroAnalyzer.total_power
— Methodtotal_power(obj, ch, mt)
Calculate total power.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(record)
: index of channels, default is all signal channelsmt::Bool=false
: if true use multi-tapered periodogramnt::Int64=8
: number of Slepian tapers
Returns
tp::Matrix{Float64}
: total power
NeuroAnalyzer.vartest
— Methodvartest(obj; ch)
Calculate variance F-test.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channels
Returns
Named tuple containing:
f::Array{Float64, 3}
p::Array{Float64, 3}
NeuroAnalyzer.vartest
— Methodvartest(obj1, obj2; ch1, ch2, ep1, ep2)
Calculate variance F-test.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, AbstractRange}=_c(epoch_n(obj2))
: default use all epochs
Returns
Named tuple containing:
f::Array{Float64, 3}
p::Array{Float64, 3}
NeuroAnalyzer.xcor
— Methodxcor(s1, s2; l, demean)
Calculate cross-correlation (a measure of similarity of two signals as a function of the displacement of one relative to the other).
Arguments
s1::AbstractMatrix
s2::AbstractMatrix
l::Int64=round(Int64, min(size(s1, 2), 10 * log10(size(s1, 2))))
demean::Bool=true
: demean signal before computing cross-correlation
Returns
xc::Array{Float64, 3}
NeuroAnalyzer.xcor
— Methodxcor(s1, s2; l, demean)
Calculate cross-correlation (a measure of similarity of two signals as a function of the displacement of one relative to the other).
Arguments
s1::AbstractArray
s2::AbstractArray
l::Int64=round(Int64, min(size(s1, 2), 10 * log10(size(s1, 2))))
demean::Bool=true
: demean signal before computing cross-correlation
Returns
xc::Array{Float64, 3}
NeuroAnalyzer.xcor
— Methodxcor(obj1, obj2; ch1, ch2, ep1, ep2, lag, norm)
Calculate cross-correlation (a measure of similarity of two signals as a function of the displacement of one relative to the other).
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, AbstractRange}=_c(epoch_n(obj2))
: default use all epochslag::Real=1
: lags range is-lag:lag
[s]demean::Bool=true
: demean signal before computing cross-correlation
Returns
Named tuple containing:
xc::Array{Float64, 3}
: cross-correlationlag::Vector{Float64}
: lags [s]
NeuroAnalyzer.xcov
— Methodxcov(s1, s2; l, demean)
Calculate cross-covariance (a measure of similarity of two signals as a function of the displacement of one relative to the other).
Arguments
s1::AbstractMatrix
s2::AbstractMatrix
l::Int64=round(Int64, min(size(s1, 2), 10 * log10(size(s1, 2))))
demean::Bool=true
: demean signal before computing cross-covariance
Returns
xc::Array{Float64, 3}
NeuroAnalyzer.xcov
— Methodxcov(s1, s2; l, demean)
Calculate cross-covariance (a measure of similarity of two signals as a function of the displacement of one relative to the other).
Arguments
s1::AbstractArray
s2::AbstractArray
l::Int64=round(Int64, min(size(s1, 2), 10 * log10(size(s1, 2))))
demean::Bool=true
: demean signal before computing cross-covariance
Returns
xc::Array{Float64, 3}
NeuroAnalyzer.xcov
— Methodxcov(obj1, obj2; ch1, ch2, ep1, ep2, lag, norm)
Calculate cross-covariance (a measure of similarity of two signals as a function of the displacement of one relative to the other).
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj1)
: index of channels, default is all signal channelsch2::Union{Int64, Vector{Int64}, AbstractRange}=signal_channels(obj2)
: index of channels, default is all signal channelsep1::Union{Int64, Vector{Int64}, AbstractRange}=_c(epoch_n(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, AbstractRange}=_c(epoch_n(obj2))
: default use all epochslag::Real=1
: lags range is-lag:lag
[s]demean::Bool=true
: demean signal before computing cross-covariance
Returns
Named tuple containing:
xc::Array{Float64, 3}
: cross-covariancelag::Vector{Float64}
: lags [s]
Plot
NeuroAnalyzer.iedit
— Methodiedit(obj; <keyword arguments>)
Interactive edit of continuous or epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: channel(s) to plot, default is all channelsmono::Bool=true
: use color or grey palettezoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.iedit
— Methodiedit(obj1, obj2; <keyword arguments>)
Interactive edit of two continuous or epoched signals.
Arguments
obj1::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO object (before) - drawn in blackobj2::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO object (after) - drawn in redch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj1))
: channel(s) to plot, default is all channelszoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.iedit_ep
— Methodiedit_ep(obj; <keyword arguments>)
Interactive edit of epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: channel(s) to plot, default is all channelsmono::Bool=true
: use color or grey palette
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.iedit_ep
— Methodiedit_ep(obj1, obj2; <keyword arguments>)
Interactive edit of epoched signal.
Arguments
obj1::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO object (before) - drawn in blackobj2::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO object (after) - drawn in redch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj1))
: channel(s) to plot, default is all channels
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.iedit_cont
— Methodiedit_cont(obj; <keyword arguments>)
Interactive edit of continuous signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: channel(s) to plot, default is all channelsmono::Bool=true
: use color or grey palettezoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.iedit_cont
— Methodiedit_cont(obj1, obj2; <keyword arguments>)
Interactive preview of two continuous signal.
Arguments
obj1::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO object (before) - drawn in blackobj2::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO object (after) - drawn in redch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj1))
: channel(s) to plot, default is all channelszoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.iplot
— Methodiplot(obj; <keyword arguments>)
Interactive plot of continuous or epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: channel(s) to plot, default is all channelszoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.iplot_cont
— Methodiplot_cont(obj; <keyword arguments>)
Interactive plot of continuous signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: channel(s) to plot, default is all channelszoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.iplot_ep
— Methodiplot_ep(obj; <keyword arguments>)
Interactive plot of epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: channel(s) to plot, default is all channelszoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.iplot_icatopo
— Methodiplot_icatopo(obj; <keyword arguments>)
Interactive topographical plot of embedded ICA components.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectic_idx::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: component(s) to plot, default is all componentsseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shortercb::Bool=false
: plot color barcb_label::String="[A.U.]"
: color bar labelamethod::Symbol=:mean
: averaging method::mean
:median
imethod::Symbol=:sh
: interpolation method::sh
: Shepard:mq
: Multiquadratic:imq
: InverseMultiquadratic:tp
: ThinPlate:nn
: NearestNeighbour:ga
: Gaussian
nmethod::Symbol=:minmax
: method for normalization, seenormalize()
plot_contours::Bools=true
: plot contours over topo plotplot_electrodes::Bools=true
: plot electrodes over topo plotkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.iplot_icatopo
— Methodiplot_icatopo(obj, ic, ic_mw; <keyword arguments>)
Interactive topographical plot of external ICA components.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectic::Matrix{Float64}
: components IC(1)..IC(n)ic_mw::Matrix{Float64}
: weighting matrix IC(1)..IC(n)ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: component(s) to plot, default is all componentsseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shortercb::Bool=false
: plot color barcb_label::String="[A.U.]"
: color bar labelamethod::Symbol=:mean
: averaging method::mean
:median
imethod::Symbol=:sh
: interpolation method::sh
: Shepard:mq
: Multiquadratic:imq
: InverseMultiquadratic:tp
: ThinPlate:nn
: NearestNeighbour:ga
: Gaussian
nmethod::Symbol=:minmax
: method for normalization, seenormalize()
plot_contours::Bools=true
: plot contours over topo plotplot_electrodes::Bools=true
: plot electrodes over topo plotkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.ipsd
— Methodipsd(obj; <keyword arguments>)
Interactive PSD of continuous or epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelszoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.ipsd_cont
— Methodipsd_cont(obj; <keyword arguments>)
Interactive PSD of continuous signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelszoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.ipsd_ep
— Methodipsd_ep(obj; <keyword arguments>)
Interactive PSD of epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelszoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.ispectrogram
— Methodispectrogram(obj; <keyword arguments>)
Interactive spectrogram of continuous or epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=1
: index of channels, default is all signal channelszoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.ispectrogram_cont
— Methodispectrogram_cont(obj; <keyword arguments>)
Interactive spectrogram of continuous signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=1
: index of channels, default is all signal channelszoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.ispectrogram_ep
— Methodispectrogram_ep(obj; <keyword arguments>)
Interactive spectrogram of epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}=1
: index of channels, default is all signal channelszoom::Int64=5
: how many seconds are displayed in one segment
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_compose
— Methodplot_compose(p; <keyword arguments>)
Compose a complex plot of various plots contained in vector p
using layout layout
. Layout scheme is:
(2, 2)
: 2 × 2 plots, regular layoutgrid(4, 1, heights=[0.6, 0.1, 0.1, 0.1]
: 4 × 1 plots, irregular layout@layout [a{0.2w} b{0.8w};_ c{0.6}]
: complex layout using Plots.jl@layout
macro
Arguments
p::Vector{Plots.Plot{Plots.GRBackend}}
: vector of plotslayout::Union(Matrix{Any}, Tuple{Int64, Int64}, Plots.GridLayout}
: layoutmono::Bool=false
: use color or grey palettekwargs
: optional arguments forp
vector plots
Returns
pc::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_empty
— Methodplot_empty()
Return an empty plot, useful for filling matrices of plots.
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_connections
— Methodplot_connections(obj; <keyword arguments>)
Plot weights at electrode positions.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsconnections::Matrix{<:Real}
: matrix of connections weightsthreshold::Real
: plot all connection above thresholdthreshold_type::Symbol=:g
: rule for thresholding: = (:eq
), ≥ (:geq
), ≤ (:leq
), > (:g
), < (:l
)weights::Bool=true
: weight line widths and alpha based on connection valuechannel_labels::Bool=false
: plot channel labelshead_labels::Bool=true
: plot head labelsmono::Bool=false
: use color or grey palettehead_details::Bool=true
: draw nose and earsplot_size::Int64=800
: plot dimensions in pixels (size × size)title::String=""
: plot titlecart::Bool=false
: if true, use Cartesian x and y coordinates, otherwise use polar radius and theta coordinateskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_connections
— Methodplot_connections(obj; <keyword arguments>)
Plot connections between channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Vector{Int64}, AbstractRange}
: channel(s) to plotconnections::Matrix{<:Real}
: matrix of connections weightsthreshold::Real
: plot all connection above thresholdthreshold_type::Symbol=:g
: rule for thresholding: = (:eq
), ≥ (:geq
), ≤ (:leq
), > (:g
), < (:l
)weights::Bool=true
: weight line widths and alpha based on connection valuechannel_labels::Bool=false
: plot channel labelshead_labels::Bool=true
: plot head labelsmono::Bool=false
: use color or grey palettehead_details::Bool=true
: draw nose and earsplot_size::Int64=800
: plot dimensions in pixels (size × size)cart::Bool=false
: if true, use Cartesian x and y coordinates, otherwise use polar radius and theta coordinateskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_dipole2d
— Methodplot_dipole2d(d; <keyword arguments>)
Plot dipole in 2D.
Arguments
d::NeuroAnalyzer.DIPOLE
Returns
p::GLMakie.Figure
Notes
Brain volume is within -1.0 to +1.0 (X-, Y- and Z-axis)
NeuroAnalyzer.plot_dipole3d
— Methodplot_dipole3d(d; <keyword arguments>)
Plot dipole in 3D.
Arguments
d::NeuroAnalyzer.DIPOLE
project::Bool=true
: plot lines projected onto X, Y and Z axes
Returns
p::GLMakie.Figure
Notes
Brain volume is within -1.0 to +1.0 (X-, Y- and Z-axis)
NeuroAnalyzer.plot_erp
— Methodplot_erp(t, s, bad; <keyword arguments>)
Plot ERP.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::AbstractVector
: data to plotxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteyrev::Bool=false
: reverse Y axiskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_erp_butterfly
— Methodplot_erp_butterfly(t, s; <keyword arguments>)
Butterfly plot of ERP.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::AbstractArray
: data to plotclabels::Vector{String}=[""]
: signal channel labels vectorxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteavg::Bool=false
: plot average ERPyrev::Bool=false
: reverse Y axiskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_erp_avg
— Methodplot_erp_avg(t, s; <keyword arguments>)
Plot ERP amplitude mean and ±95% CI.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::AbstractArray
: data to plotxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteyrev::Bool=false
: reverse Y axiskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_erp_topo
— Methodplot_erp_topo(locs, t, s; <keyword arguments>)
Plot topographical map ERPs.
Arguments
locs::DataFrame
: columns: channel, labels, loctheta, locradius, locx, locy, locz, locradiussph, locthetasph, locphi_spht::Vector{Float64}
: time vectors::Array{Float64, 2}
: ERPsch::Union{Vector{Int64}, AbstractRange}
: which channels to plotclabels::Vector{String}=[""]
: signal channel labels vectorxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titleyrev::Bool=false
: reverse Y axiscart::Bool=false
: if true, use Cartesian x and y coordinates, otherwise use polar radius and theta coordinatesmono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
fig::GLMakie.Figure
NeuroAnalyzer.plot_erp_stack
— Methodplot_erp_stack(s; <keyword arguments>)
Plot EPRs stacked by channels or by epochs.
Arguments
t::AbstractVector
: x-axis valuess::AbstractArray
clabels::Vector{String}=[""]
: signal channel labels vectorxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlecb::Bool=true
: plot color barcb_title::String=""
: color bar titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_erp
— Methodplot_erp(obj; <keyword arguments>)
Plot ERP.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel(s) to plottm::Union{Int64, Vector{Int64}}=0
: time markers (in miliseconds) to plot as vertical lines, useful for adding topoplots at these time pointsxlabel::String="default"
: x-axis label, default is Time [ms]ylabel::String="default"
: y-axis label, default is Amplitude [units]title::String="default"
: plot title, default is ERP amplitude [channel: 1, epochs: 1:2, time window: -0.5 s:1.5 s]cb::Bool=true
: plot color barcb_title::String="default"
: color bar title, default is Amplitude [units]mono::Bool=false
: use color or grey palettepeaks::Bool=true
: draw peakschannel_labels::Bool=true
: draw labels legend (using channel labels) for multi-channel:butterfly
plottype::Symbol=:normal
: plot type::normal
, butterfly plot (:butterfly
), topographical plot of ERPs (:topo
) or stacked epochs/channels (:stack
)yrev::Bool=false
: reverse Y axisavg::Bool=false
: plot average ERP for:butterfly
plotkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_filter_response
— Methodplot_filter_response(<keyword arguments>)
Plot filter response.
Arguments
fs::Int64
: sampling ratefprototype::Symbol
: filter prototype::butterworth
:chebyshev1
:chebyshev2
:elliptic
:fir
:iirnotch
: second-order IIR notch filter:remez
: Remez FIR filter
ftype::Union{Symbol, Nothing}=nothing
: filter type::lp
: low pass:hp
: high pass:bp
: band pass:bs
: band stop
cutoff::Union{Real, Tuple{Real, Real}}
: filter cutoff in Hz (tuple for:bp
and:bs
)n::Int64=2560
: signal length in samplesfs::Int64
: sampling rateorder::Int64=8
: filter order (6 dB/octave), number of taps for:remez
, attenuation (× 4 dB) for:fir
filtersrp::Real=-1
: ripple amplitude in dB in the pass band; default: 0.0025 dB for:elliptic
, 2 dB for othersrs::Real=-1
: ripple amplitude in dB in the stop band; default: 40 dB for:elliptic
, 20 dB for othersbw::Real=-1
: bandwidth for:iirnotch
and :remez filterswindow::Union{Nothing, AbstractVector, Int64}=nothing
: window for:fir
filter; default is Hamming window, number of taps is calculated using fred harris' rule-of-thumbmono::Bool=false
: use color or grey palette- `frq_lim::Tuple{Real, Real}=(0, 0): frequency limit for the Y-axis
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_locs
— Methodplot_locs(locs; <keyword arguments>)
Preview channel locations.
Arguments
locs::DataFrame
: columns: channel, labels, loctheta, locradius, locx, locy, locz, locradiussph, locthetasph, locphi_sphch::Union{Int64, Vector{Int64}, <:AbstractRange}=1:nrow(locs)
: channel(s) to plot, default is all channelsselected::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: selected channel(s) to plotch_labels::Bool=true
: plot channel labelshead::Bool=true
: draw headhead_labels::Bool=true
: plot head labelsmono::Bool=false
: use color or grey palettehead_details::Bool=true
: draw nose and earsgrid::Bool=false
: draw grid, useful for locating positionsplot_size::Int64=400
: plot dimensions in pixels (size × size)cart::Bool=false
: if true, use Cartesian x and y coordinates, otherwise use polar radius and theta coordinates
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_locs3d
— Methodplot_locs3d(locs; <keyword arguments>)
3D interactive preview of channel locations. It uses Cartesian :locx, :locy and :loc_z locations.
Arguments
locs::DataFrame
: columns: channel, labels, loctheta, locradius, locx, locy, locz, locradiussph, locthetasph, locphi_sphch::Union{Int64, Vector{Int64}, <:AbstractRange}=1:nrow(locs)
: channel(s) to plot, default is all channelsselected::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: selected channel(s) to plotch_labels::Bool=true
: plot channel labelshead_labels::Bool=true
: plot head labelsmono::Bool=false
: use color or grey paletteplot_size::Int64=800
: plot dimensions in pixels (plotsize×plotsize)cart::Bool=false
: if true, use Cartesian x, y and z coordinates, otherwise use spherical radius, theta and phi coordinates
Returns
fig::GLMakie.Figure
NeuroAnalyzer.plot_locs
— Methodplot_locs(obj; <keyword arguments>)
Preview of channel locations.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsselected::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: which channel should be highlightedch_labels::Bool=true
: plot channel labelssrc_labels::Bool=false
: plot source labelsdet_labels::Bool=false
: plot detector labelsopt_labels::Bool=false
: plot optode type (S for source, D for detector) and numberhead::Bool=true
: draw headhead_labels::Bool=false
: plot head labelsplot_size::Int64=400
: plot dimensions in pixels (plotsize×plotsize)head_details::Bool=true
: draw nose and earsmono::Bool=false
: use color or grey palettethreed::Bool=false
: 3-dimensional plotgrid::Bool=false
: draw grid, useful for locating positionscart::Bool=false
: if true, use polar coordinates, otherwise use Cartesian spherical x and y coordinateskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_locs_nirs
— Methodplot_locs_nirs(locs; <keyword arguments>)
Preview of NIRS optodes and channel locations. It uses Cartesian :loc_x
and :loc_y
locations.
Arguments
locs::DataFrame
: columns: channel, labels, loctheta, locradius, locx, locy, locz, locradiussph, locthetasph, locphi_sphch_pairs::Matrix{Int64}
: pairs of source and detectorsrc_n::Int64
: number of sourcesdet_n::Int64
: number of detectorsch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel(s) to plotselected::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: selected channel(s) to plotsrc_labels::Bool=false
: plot source labelsdet_labels::Bool=false
: plot detector labelsopt_labels::Bool=false
: plot optode type (S for source, D for detector) and numberhead_labels::Bool=true
: plot head labelsmono::Bool=false
: use color or grey palettehead_details::Bool=true
: draw nose and earsgrid::Bool=false
: draw grid, useful for locating positionsplot_size::Int64=400
: plot dimensions in pixels (size × size)
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_psd
— Methodplot_psd(sf, sp; <keyword arguments>)
Plot PSD (power spectrum density).
Arguments
sf::Vector{Float64}
: frequenciessp::Vector{Float64}
: powersnorm::Bool=true
: whether powers are normalized to dBfrq_lim::Tuple{Real, Real}=(sf[1], sf[end])
: frequency limit for the Y-axisxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
), linear-log10 (:linlog
), log10-log10 (:loglog)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_psd
— Methodplot_psd(sf, sp; <keyword arguments>)
Plot multi-channel PSD (power spectrum density).
Arguments
sf::Vector{Float64}
: frequenciessp::Matrix{Float64}
: powersclabels::Vector{String}=[""]
: signal channel labels vectornorm::Bool=true
: whether powers are normalized to dBfrq_lim::Tuple{Real, Real}=(sf[1], sf[end])
: frequency limit for the Y-axisxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
), linear-log10 (:linlog
), log10-log10 (:loglog)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_psd_avg
— Methodplot_psd_avg(sf, sp; <keyword arguments>)
Plot PSD mean and ±95% CI of averaged channels.
Arguments
sf::Vector{Float64}
: frequenciessp::Array{Float64, 3}
: powersxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
), linear-log10 (:linlog
), log10-log10 (:loglog)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_psd_butterfly
— Methodplot_psd_butterfly(sf, sp; <keyword arguments>)
Butterfly PSD plot.
Arguments
sf::Vector{Float64}
: frequenciessp::Array{Float64, 3}
: powersclabels::Vector{String}=[""]
: signal channel labels vectornorm::Bool=true
: whether powers are normalized to dB- `frq_lim::Tuple{Real, Real}=(sf[1], sf[end]): frequency limit for the x-axis
xlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
), linear-log10 (:linlog
), log10-log10 (:loglog)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_psd_3d
— Methodplot_psd_w3d(sf, sp; <keyword arguments>)
Plot 3-d waterfall PSD plot.
Arguments
sf::Vector{Float64}
: frequenciessp::Array{Float64, 3}
: powersclabels::Vector{String}=[""]
: signal channel labels vectornorm::Bool=true
: whether powers are normalized to dB- `frq_lim::Tuple{Real, Real}=(sf[1], sf[end]): frequency limit for the x-axis
xlabel::String=""
: x-axis labelylabel::String=""
: y-axis labelzlabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
), linear-log10 (:linlog
), log10-log10 (:loglog)variant::Symbol
: waterfall (:w
) or surface (:s
)kwargs
: optional arguments for plot() function
Returns
p::Union{Plots.Plot{Plots.GRBackend}, GLMakie.Figure}
NeuroAnalyzer.plot_psd_topo
— Methodplot_psd_topo(locs, sf, sp; <keyword arguments>)
Plot topographical map PSDs.
Arguments
locs::DataFrame
: columns: channel, labels, loctheta, locradius, locx, locy, locz, locradiussph, locthetasph, locphi_sphsf::Vector{Float64}
: frequenciessp::Array{Float64, 3}
: powersch::Union{Vector{Int64}, AbstractRange}
: which channels to plotclabels::Vector{String}=[""]
: signal channel labels vectornorm::Bool=true
: whether powers are normalized to dB- `frq_lim::Tuple{Real, Real}=(sf[1], sf[end]): frequency limit for the x-axis
xlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
), linear-log10 (:linlog
), log10-log10 (:loglog)cart::Bool=false
: if true, use Cartesian x and y coordinates, otherwise use polar radius and theta coordinateskwargs
: optional arguments for plot() function
Returns
fig::GLMakie.Figure
NeuroAnalyzer.plot_psd
— Methodplot_psd(obj; <keyword arguments>)
Plot power spectrum density.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shorterep::Int64=0
: epoch to displaych::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel(s) to plotnorm::Bool=true
: normalize powers to dBmethod::Symbol=:welch
: method of calculating PSD::welch
: Welch's periodogram:mt
: multi-tapered periodogram:mw
: Morlet wavelet convolution
nt::Int64=8
: number of Slepian tapersfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: x-axis limitncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet waveletref::Symbol=:abs
: type of PSD reference: absolute power (no reference) (:abs
) or relative to: total power (:total
),:delta
,:theta
,:alpha
,:beta
,:beta_high
,:gamma
,:gamma_1
,:gamma_2
,:gamma_lower
or:gamma_higher
ax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
), linear-log10 (:linlog
), log10-log10 (:loglog)xlabel::String="default"
: x-axis label, default is Frequency [Hz]ylabel::String="default"
: y-axis label, default is Power [dB] or Power [units^2/Hz]zlabel::String="default"
: z-axis label for 3-d plots, default is Power [dB] or Power [units^2/Hz]title::String="default"
: plot title, default is PSD [frequency limit: 0-128 Hz] [channel: 1, epoch: 1, time window: 0 ms:10 s]mono::Bool=false
: use color or grey palettetype::Symbol=:normal
: plot type::normal
,:butterfly
,:mean
, 3-d waterfall (:w3d
), 3-d surface (:s3d
), topographical (:topo
)kwargs
: optional arguments for plot() function
Returns
p::Union{Plots.Plot{Plots.GRBackend}, GLMakie.Figure}
NeuroAnalyzer.plot_psd
— Methodplot_psd(obj; <keyword arguments>)
Plot power spectrum density of embedded or external component.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectc::Union{Symbol, AbstractArray}
: component to plotseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shorterep::Int64=0
: epoch to displayc_idx::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: component channel to display, default is all component channelsnorm::Bool=true
: normalize powers to dBmethod::Symbol=:welch
: method of calculating PSD::welch
: Welch's periodogram:mt
: multi-tapered periodogram:mw
: Morlet wavelet convolution
nt::Int64=8
: number of Slepian tapersfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: x-axis limitref::Symbol=:abs
: type of PSD reference: absolute power (no reference) (:abs
) or relative to: total power (:total
),:delta
,:theta
,:alpha
,:beta
,:beta_high
,:gamma
,:gamma_1
,:gamma_2
,:gamma_lower
or:gamma_higher
ncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet waveletax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
), linear-log10 (:linlog
), log10-log10 (:loglog)xlabel::String="default"
: x-axis label, default is Frequency [Hz]ylabel::String="default"
: y-axis label, default is Power [dB] or Power [units^2/Hz]zlabel::String="default"
: z-axis label for 3-d plots, default is Power [dB] or Power [units^2/Hz]title::String="default"
: plot title, default is PSD [frequency limit: 0-128 Hz] [channel: 1, epoch: 1, time window: 0 ms:10 s]mono::Bool=false
: use color or grey palettetype::Symbol=:normal
: plot type::normal
,:butterfly
,:mean
, 3-d waterfall (:w3d
), 3-d surface (:s3d
), topographical (:topo
)units::String=""
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_save
— Methodplot_save(p; file_name::String)
Saves plot as file (PNG/PDF). File format is determined using file_name
extension.
Arguments
p::Union{Plots.Plot{Plots.GRBackend}, GLMakie.Figure}
file_name::String
NeuroAnalyzer.plot_signal
— Methodplot_signal(t, s; <keyword arguments>)
Plot amplitude of single- or multi-channel s
.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::Union{AbstractVector, AbstractArray}
: data to plotclabels::Vector{String}=[""]
: signal channel labels vectorxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey palettescale::Bool=true
: draw scaleunits::String=""
: units of the scalekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_signal
— Methodplot_signal(t, s, bad; <keyword arguments>)
Plot amplitude of single- or multi-channel s
.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::Union{AbstractVector, AbstractArray}
: data to plotnorm::Bool=false
: normalize signal for butterfly and averaged plotsbad::Vector{Bool}}
: list of bad channelsclabels::Vector{String}=[""]
: signal channel labels vectorxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey palettescale::Bool=true
: draw scaleunits::String=""
: units of the scalekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_signal_avg
— Methodplot_signal_avg(t, signal; <keyword arguments>)
Plot amplitude mean and ±95% CI of averaged signal
channels.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::AbstractArray
: data to plotxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey palettescale::Bool=true
: draw scaleunits::String=""
: units of the scalenorm::Bool=false
: normalize to -1 .. +1kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_signal_butterfly
— Methodplot_signal_butterfly(t, s; <keyword arguments>)
Butterfly plot of s
channels.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::AbstractArray
: data to plotclabels::Vector{String}=[""]
: signal channel labels vectorxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlescale::Bool=true
: draw scaleunits::String=""
: units of the scalemono::Bool=false
: use color or grey palettenorm::Bool=false
: normalize to -1 .. +1kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_2signals
— Methodplot_2signals(t, s1, s2; <keyword arguments>)
Plot amplitude of single- or multi-channel s1
and s2
.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s1::Union{AbstractVector, AbstractArray}
: data to plot (before) - drawn in blacks2::Union{AbstractVector, AbstractArray}
: data to plot (after) - drawn in redclabels::Vector{String}=[""]
: signal channel labels vectorxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlescale::Bool=true
: draw scaleunits::String=""
: units of the scalekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot
— Methodplot(obj; <keyword arguments>)
Plot signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectep::Union{Int64, AbstractRange}=0
: epoch to displaych::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj))
: channel(s) to plot, default is all channelsseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shorterxlabel::String="default"
: x-axis label, default is Time [s]ylabel::String="default"
: y-axis label, default is no labeltitle::String="default"
: plot title, default is Amplitude [channels: 1:2, epochs: 1:2, time window: 0 ms:20 s]mono::Bool=false
: use color or grey paletteemarkers::Bool
: draw epoch markers if availablemarkers::Bool
: draw markers if availablescale::Bool=true
: draw scaleunits::String=""
: units of the scaletype::Symbol=:normal
: plot type::normal
:mean
: mean ± 95%CI:butterfly
: butterfly plot
norm::Bool=false
: normalize signal for butterfly and averaged plotsbad::Union{Bool, Matrix{Bool}}=false
: list of bad channels; if not empty - plot bad channels using this lists_pos::Tuple{Real, Real}=(0, 0)
: draw segment borders if different than (0, 0), used byiedit()
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot
— Methodplot(obj, c; <keyword arguments>)
Plot embedded or external component.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectc::Union{Symbol, AbstractArray}
: component to plotep::Union{Int64, AbstractRange}=0
: epoch to displayc_idx::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: component channel to display, default is all component channelsseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shorterxlabel::String="default"
: x-axis label, default is Time [s]ylabel::String="default"
: y-axis label, default is no labeltitle::String="default"
: plot title, default is Amplitude [channels: 1:2, epochs: 1:2, time window: 0 ms:20 s]mono::Bool=false
: use color or grey paletteemarkers::Bool
: draw epoch markers if availablemarkers::Bool
: draw markers if availablescale::Bool=true
: draw scaleunits::String=""
: units of the scaletype::Symbol=:normal
: plot type::normal
:mean
: mean ± 95%CI:butterfly
: butterfly plot
norm::Bool=false
: normalize signal for butterfly and averaged plotskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot
— Methodplot(obj1, obj2; <keyword arguments>)
Plot two signals. This function is used to compare two signals, e.g. before and after ica_recovery()
. Both signals must have the same data type, dimensions and sampling rate.
Arguments
obj1::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO object (before) - drawn in blackobj2::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO object (after) - drawn in redep::Union{Int64, AbstractRange}=0
: epoch to displaych::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(channel_n(obj1))
: channel(s) to plot, default is all channelsseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shorterxlabel::String="default"
: x-axis label, default is Time [s]ylabel::String="default"
: y-axis label, default is no labeltitle::String="default"
: plot title, default is Amplitude [channels: 1:2, epochs: 1:2, time window: 0 ms:20 s]emarkers::Bool
: draw epoch markers if availablescale::Bool=true
: draw scaleunits::String=""
: units of the scalekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_spectrogram
— Methodplot_spectrogram(st, sf, sp; <keyword arguments>)
Plot single-channel spectrogram.
Arguments
st::Vector{Float64}
: timesf::Vector{Float64}
: frequenciessp::Array{Float64, 2}
: powersnorm::Bool=true
: whether powers are normalized to dB- `frq_lim::Tuple{Real, Real}=(0, 0): frequency limit for the Y-axis
xlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteunits::String=""
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_spectrogram
— Methodplot_spectrogram(sch, sf, sp; <keyword arguments>)
Plot multiple-channel spectrogram.
Arguments
sch::Vector{String}
: channel labelssf::Vector{Float64}
: frequenciessp::Array{Float64, 2}
: powersnorm::Bool=true
: whether powers are normalized to dB- `frq_lim::Tuple{Real, Real}=(0, 0): frequency limit for the Y-axis
xlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteunits::String=""
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_spectrogram
— Methodplot_spectrogram(obj; <keyword arguments>)
Plots spectrogram.
Arguments
obj::NeuroAnalyzer.NEURO
seg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shorterep::Int64=0
: epoch to displaych::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel(s) to plotnorm::Bool=true
: normalize powers to dBmethod::Symbol=:standard
: method of calculating spectrogram::standard
: standard:stft
: short-time Fourier transform:mt
: multi-tapered periodogram:mw
: Morlet wavelet convolution
nt::Int64=8
: number of Slepian tapersfrq_lim::Tuple{Real, Real}=(0, 0)
: y-axis limitsncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet waveletxlabel::String="default"
: x-axis label, default is Time [s]ylabel::String="default"
: y-axis label, default is Frequency [Hz]title::String="default"
: plot title, default is Spectrogram [frequency limit: 0-128 Hz]
[channel: 1, epoch: 1, time window: 0 ms:10 s]
mono::Bool=false
: use color or grey palettemarkers::Bool
: draw markers if availablekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_spectrogram
— Methodplot_spectrogram(obj, c; <keyword arguments>)
Plots spectrogram of embedded or external component.
Arguments
obj::NeuroAnalyzer.NEURO
c::Union{Symbol, AbstractArray}
: component to plotseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shorterep::Int64=0
: epoch to displayc_idx::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: component channel to display, default is all component channelsnorm::Bool=true
: normalize powers to dBmethod::Symbol=:standard
: method of calculating spectrogram::standard
: standard:stft
: short-time Fourier transform:mt
: multi-tapered periodogram:mw
: Morlet wavelet convolution
nt::Int64=8
: number of Slepian tapersfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: y-axis limitsncyc::Union{Int64, Tuple{Int64, Int64}}=6
: number of cycles for Morlet waveletxlabel::String="default"
: x-axis label, default is Time [s]ylabel::String="default"
: y-axis label, default is Frequency [Hz]title::String="default"
: plot title, default is Spectrogram [frequency limit: 0-128 Hz]
[component: 1, epoch: 1, time window: 0 ms:10 s]
mono::Bool=false
: use color or grey palettemarkers::Bool
: draw markers if availableunits::String=""
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_topo
— Methodplot_topo(c; <keyword arguments>)
Plot topographical view.
Arguments
s::Vector{<:Real}
: values to plot (one value per channel)ch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel(s) to plotlocs::DataFrame
: columns: channel, labels, loctheta, locradius, locx, locy, locz, locradiussph, locthetasph, locphi_sphcb::Bool=true
: plot color barcb_label::String="[A.U.]"
: color bar labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey paletteimethod::Symbol=:sh
: interpolation method::sh
: Shepard:mq
: Multiquadratic:imq
: InverseMultiquadratic:tp
: ThinPlate:nn
: NearestNeighbour:ga
: Gaussian
nmethod::Symbol=:minmax
: method for normalization, seenormalize()
plot_size::Int64=800
: plot dimensions in pixels (size × size)plot_contours::Bools=true
: plot contours over topo plotplot_electrodes::Bools=true
: plot electrodes over topo plothead_labels::Bool=false
: plot head labelshead_details::Bool=true
: draw nose and earscart::Bool=false
: if true, use Cartesian x and y coordinates, otherwise use polar radius and theta coordinateskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_topo
— Methodplot_topo(obj; <keyword arguments>)
Topographical plot.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectep::Union{Int64, AbstractRange}=0
: epoch to displaych::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shortertitle::String="default"
: plot title, default is Amplitude topographical plot [channels: 1:19, epoch: 1, time window: 0 ms:20 s]mono::Bool=false
: use color or grey palettecb::Bool=true
: plot color barcb_label::String="[A.U.]"
: color bar labelamethod::Symbol=:mean
: averaging method::mean
:median
imethod::Symbol=:sh
: interpolation method::sh
: Shepard:mq
: Multiquadratic:imq
: InverseMultiquadratic:tp
: ThinPlate:nn
: NearestNeighbour:ga
: Gaussian
nmethod::Symbol=:minmax
: method for normalization, seenormalize()
plot_size::Int64=800
: plot dimensions in pixels (size × size)plot_contours::Bools=true
: plot contours over topo plotplot_electrodes::Bools=true
: plot electrodes over topo plothead_labels::Bool=false
: plot head labelshead_details::Bool=true
: draw nose and earscart::Bool=false
: if true, use Cartesian x and y coordinates, otherwise use polar radius and theta coordinateskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_topo
— Methodplot_topo(obj; <keyword arguments>)
Topographical plot of embedded or external component.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectc::Union{Symbol, AbstractArray}
: component to plotep::Union{Int64, AbstractRange}=0
: epoch to displayc_idx::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: component channel to display, default is all component channelsseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shortertitle::String="default"
: plot title, default is Amplitude topographical plot [channels: 1:19, epoch: 1, time window: 0 ms:20 s]mono::Bool=false
: use color or grey palettecb::Bool=true
: plot color barcb_label::String="[A.U.]"
: color bar labelamethod::Symbol=:mean
: averaging method::mean
:median
imethod::Symbol=:sh
: interpolation method::sh
: Shepard:mq
: Multiquadratic:imq
: InverseMultiquadratic:tp
: ThinPlate:nn
: NearestNeighbour:ga
: Gaussian
nmethod::Symbol=:minmax
: method for normalization, seenormalize()
plot_size::Int64=800
: plot dimensions in pixels (size × size)plot_contours::Bools=true
: plot contours over topo plotplot_electrodes::Bools=true
: plot electrodes over topo plothead_labels::Bool=false
: plot head labelshead_details::Bool=true
: draw nose and earscart::Bool=false
: if true, use Cartesian x and y coordinates, otherwise use polar radius and theta coordinateskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_matrix
— Methodplot_matrix(m; <keyword arguments>)
Plot matrix.
Arguments
m::Array{<:Real, 2}
xlabels::Vector{String}
ylabels::Vector{String}
xlabel::String=""
ylabel::String=""
title::String=""
cb_title::String=""
: color bar titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_xac
— Methodplot_xac(m, lags; <keyword arguments>)
Plot cross/auto-covariance/correlation.
Arguments
m::Abstractvector
: covariance matrixlags::AbstractVector
: covariance lags, lags will be displayed in sxlabel::String="lag"
ylabel::String=""
title::String=""
cb_title::String=""
: color bar titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_histogram
— Methodplot_histogram(s; <keyword arguments>)
Plot histogram.
Arguments
s::AbstractVector
type::Symbol
: type of histogram: regular (:hist
) or kernel density (:kd
)bins::Union{Int64, Symbol, AbstractVector}=(length(s) ÷ 10)
: histogram bins: number of bins, range or:sturges
,:sqrt
,:rice
,:scott
or:fd
)label::String=""
: channel labelxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_bar
— Methodplot_bar(s; <keyword arguments>)
Bar plot.
Arguments
s::AbstractVector
xlabels::Vector{String}
: x-ticks labelsxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_line
— Methodplot_line(s; <keyword arguments>)
Line plot.
Arguments
s::AbstractVector
xlabels::Vector{String}
: x-ticks labelsxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_line
— Methodplot_line(s; <keyword arguments>)
Line plot.
Arguments
s::AbstractArray
rlabels::Vector{String}
: signal rows labelsxlabels::Vector{String}
: x-ticks labelsxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_box
— Methodplot_box(s; <keyword arguments>)
Box plot.
Arguments
s::AbstractArray
glabels::Vector{String}
: group labelsxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_violin
— Methodplot_violin(s; <keyword arguments>)
Violin plot.
Arguments
s::AbstractArray
glabels::Vector{String}
: group labelsxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_dots
— Methodplot_dots(s; <keyword arguments>)
Dots plot.
Arguments
s::Vector{Vector{Float64}}
glabels::Vector{String}
: group labelsxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_paired
— Methodplot_paired(signal; <keyword arguments>)
Plot paired data.
Arguments
signal::Vector{Vector{Float64}}
glabels::Vector{String}
: group labelsxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_polar
— Methodplot_polar(s; <keyword arguments>)
Polar plot.
Arguments
s::Union{AbstractVector, AbstractArray}
m::Tuple{Real, Real}=(0, 0)
: major value to plottitle::String=""
: plot titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_eros
— Methodplot_eros(s, f, t; <keyword arguments>)
Plot ERO (Event-Related Oscillations) spectrogram.
Arguments
s::AbstractArray
: ERO spectrogramf::AbstractVector
: ERO frequenciest::AbstractVector
: ERO timetm::Union{Int64, Vector{Int64}}=0
: time markers (in miliseconds) to plot as vertical lines, useful for adding topoplots at these time pointsxlabel::String="default"
ylabel::String="default"
title::String="default"
cb::Bool=true
: draw color barcb_title::String="Power [dB]"
: color bar titlemono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_erop
— Methodplot_erop(p, f; <keyword arguments>)
Plot ERO (Event-Related Oscillations) power-spectrum.
Arguments
p::AbstractArray
: ERO powersf::AbstractVector
: ERO frequenciesxlabel::String="default"
ylabel::String="default"
title::String="default"
mono::Bool=false
: use color or grey palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_icatopo
— Methodplot_icatopo(obj; <keyword arguments>)
Topographical plot of embedded ICA components.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectic_idx::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: component(s) to plot, default is all componentsseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shortercb::Bool=false
: plot color barcb_label::String="[A.U.]"
: color bar labelamethod::Symbol=:mean
: averaging method::mean
:median
imethod::Symbol=:sh
: interpolation method::sh
: Shepard:mq
: Multiquadratic:imq
: InverseMultiquadratic:tp
: ThinPlate:nn
: NearestNeighbour:ga
: Gaussian
nmethod::Symbol=:minmax
: method for normalization, seenormalize()
plot_contours::Bools=true
: plot contours over topo plotplot_electrodes::Bools=true
: plot electrodes over topo plotkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_icatopo
— Methodplot_icatopo(obj, ic, ic_mw; <keyword arguments>)
Topographical plot of external ICA components.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectic::Matrix{Float64}
: components IC(1)..IC(n)ic_mw::Matrix{Float64}
: weighting matrix IC(1)..IC(n)ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: component(s) to plot, default is all componentsseg::Tuple{Real, Real}=(0, 10)
: segment (from, to) in seconds to display, default is 10 seconds or less if single epoch is shortercb::Bool=false
: plot color barcb_label::String="[A.U.]"
: color bar labelamethod::Symbol=:mean
: averaging method::mean
:median
imethod::Symbol=:sh
: interpolation method::sh
: Shepard:mq
: Multiquadratic:imq
: InverseMultiquadratic:tp
: ThinPlate:nn
: NearestNeighbour:ga
: Gaussian
nmethod::Symbol=:minmax
: method for normalization, seenormalize()
plot_contours::Bools=true
: plot contours over topo plotplot_electrodes::Bools=true
: plot electrodes over topo plotkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_weights
— Methodplot_weights(locs; <keyword arguments>)
Plot weights at electrode positions.
Arguments
locs::DataFrame
: columns: channel, labels, loctheta, locradius, locx, locy, locz, locradiussph, locthetasph, locphi_sphch::Union{Int64, Vector{Int64}, <:AbstractRange}
: channel(s) to plotselected::Union{Int64, Vector{Int64}, <:AbstractRange}=0
: selected channel(s) to plotweights::Vector{<:Real}=[]
: weights vectorchannel_labels::Bool=true
: plot channel_labelshead_labels::Bool=true
: plot head labelsmono::Bool=false
: use color or grey palettehead_details::Bool=true
: draw nose and earsplot_size::Int64=400
: plot dimensions in pixels (size × size)cart::Bool=false
: if true, use Cartesian x and y coordinates, otherwise use polar radius and theta coordinates
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_weights
— Methodplot_weights(obj; <keyword arguments>)
Plot weights at electrode positions.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{Int64, Vector{Int64}, <:AbstractRange}=signal_channels(obj)
: index of channels, default is all signal channelsweights::Matrix{<:Real}
: matrix of weightschannel_labels::Bool=false
: plot channel_labelshead_labels::Bool=true
: plot head labelsmono::Bool=false
: use color or grey palettehead_details::Bool=true
: draw nose and earsplot_size::Int64=800
: plot dimensions in pixels (size × size)title::String=""
: plot titlecart::Bool=false
: if true, use Cartesian x and y coordinates, otherwise use polar radius and theta coordinateskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
Statistics
NeuroAnalyzer.cmp_test
— Methodcmp_test(seg1, seg2, paired, alpha, type, exact)
Compare two vectors; Kruskall-Wallis test is used first, next t-test (paired on non-paired) or non-parametric test (paired: Wilcoxon signed rank, non-paired: Mann-Whitney U test) is applied.
Arguments
s1::AbstractVector
s2::AbstractVector
paired::Bool
alpha::Float64=0.05
: confidence leveltype::Symbol=:auto
: choose test automatically (:auto
), permutation-based (:perm
) parametric (:p
) or non-parametric (:np
)exact::Bool=false
: if true, use exact Wilcoxon testnperm::Int64=1000
: number of permutation for:perm
method
Returns
Named tuple containing for type !== :perm
:
t
: test resultsts::Tuple{Float64, String}
: test statisticstc::Tuple{Float64, Float64}
: test statistics confidence intervaldf::Int64
: degrees of freedomp::Float64
: p-value
Named tuple containing for type === :perm
:
t::Tuple{perm_diff::Vector{Float64}, obs_diff::Float64}
: test results: (permutation difference, observed difference)p1::Float64
: one-sided p-valuep2::Float64
: two-sided p-value
NeuroAnalyzer.cor_test
— Methodcor_test(seg1, seg2)
Calculate correlation between two vectors.
Arguments
s1::AbstractVector
s2::AbstractVector
Returns
Named tuple containing:
t::CorrelationTest{Float64}
r::Float64
: correlation coefficientrc::Tuple{Float64, Float64}
: correlation coefficient confidence intervaltt::Tuple{Float64, String}
: t-statisticsdf::Int64
: degrees of freedomp::Float64
: p-value
NeuroAnalyzer.dprime
— Methoddprime(p1::Real, p2::Real)
Calculate d' and response bias for two proportions.
Arguments
p1::Real
p2::Real
Returns
Named tuple containing:
dprime::Float64
rb::Float64
: response bias
NeuroAnalyzer.effsize
— Methodeffsize(x1, x2)
Calculate Cohen's d and Hedges g effect sizes.
Arguments
x1::AbstractVector
x2::AbstractVector
Returns
Named tuple containing:
d::Float64
: Cohen's dg::Float64
: Hedges g
NeuroAnalyzer.hildebrand_rule
— Methodhildebrand_rule(x)
Calculate Hildebrand rule for vector x
. If H < 0.2 then the vector x
is symmetrical.
Arguments
x::AbstractVector
Returns
h::Float64
NeuroAnalyzer.jaccard_similarity
— Methodjaccard_similarity(x, y)
Calculate Jaccard similarity between two vectors x
and y
.
Arguments
x::AbstractVector
y::AbstractVector
Returns
j::Float64
NeuroAnalyzer.linreg
— Methodlinreg(x, y)
Linear regression between x
and y
.
Arguments
x::AbstractVector
y::AbstractVector
Notes
To predict, use: `newx = DataFrame(x = [3.5, 7]); predict(lr, newx)
Returns
Named tuple containing:
lr::StatsModels.TableRegressionModel
: modelradj::Flpoat64
: R^2c::Vector{Float64}
: coefficientsse::Vector{Float64}
: standard error for coefficientsaic::Float64
:: Akaike’s Information Criterion (AIC)bic::Float64
:: Bayesian Information Criterion (BIC)lf::Vector{Float64}
: linear fit (plot(x, lf))
NeuroAnalyzer.infcrit
— Methodinfcrit(m)
Calculate Akaike’s Information Criterion (AIC) and Bayesian Information Criterion (BIC) for a linear regression model m
.
Arguments
m::StatsModels.TableRegressionModel
: linear regression model
Returns
Named tuple containing:
aic::Float64
bic::Float64
NeuroAnalyzer.meang
— Methodmeang(x)
Calculate geometric mean.
Arguments
x::AbstractVector
Returns
m::Float64
NeuroAnalyzer.meanh
— Methodmeanh(x)
Calculate harmonic mean.
Arguments
x::AbstractVector
Returns
m::Float64
NeuroAnalyzer.meanw
— Methodmeanw(x, w)
Calculate weighted mean.
Arguments
x::AbstractVector
w::AbstractVector
: weights
Returns
m::Float64
NeuroAnalyzer.meanc
— Methodmeanc(x; rad)
Calculate circular mean.
Arguments
x::AbstractVector
: anglesrad::Bool=false
: angles in radians (rad=true
) or degrees (rad=false
)
Returns
m::Float64
NeuroAnalyzer.z_score
— Methodz_score(x)
Calculate Z-scores for each value of the vector x
.
Arguments
x::AbstractVector
Returns
z_score::Vector{Float64}
NeuroAnalyzer.k_categories
— Methodk_categories(n)
Calculate number of categories for a given sample size n
.
Arguments
n::Int64
Returns
Named tuple containing:
k1::Float64
: sqrt(n)k2::Float64
: 1 + 3.222 * log10(n)
NeuroAnalyzer.se
— Methodse(x)
Calculate standard error.
Arguments
x::AbstractVector
Returns
se::Float64
NeuroAnalyzer.rng
— Methodrng(x)
Calculate range.
Arguments
x::AbstractVector
Returns
rng::Float64
NeuroAnalyzer.rng
— Methodrng(x)
Calculate range.
Arguments
x::AbstractArray
Returns
rng::Float64
NeuroAnalyzer.moe
— Methodmoe(n)
Calculate margin of error for given sample size n
.
Arguments
n::Int64
Returns
moe::Float64
NeuroAnalyzer.cvar
— Methodcvar(se, s)
Calculate coefficient of variation for statistic s
.
Arguments
se::Real
: standard errors::Real
: statistics, e.g. mean value
Returns
cvar::Float64
NeuroAnalyzer.effsize
— Methodeffsize(p1, p2)
Calculate effect size for two proportions p1
and p2
.
Arguments
p1::Float64
: 1st proportion, e.g. 0.7p2::Float64
: 2nd proportion, e.g. 0.3
Returns
e::Float64
NeuroAnalyzer.binom_prob
— Methodbinom_prob(p, r, n)
Calculate probability of exactly r
successes in n
trials.
Arguments
p::Float64
: proportion of successesr::Int64
: number of successesn::Int64
: number of trials
Returns
binom_prob::Float64
: probability
NeuroAnalyzer.binom_stat
— Methodbinom_stat(p, n)
Calculate mean and standard deviation for probability p
.
Arguments
p::Float64
: proportion of successesn::Int64
: number of trials
Returns
Named tuple containing:
m::Float64
: means::Float64
: standard deviation
NeuroAnalyzer.cvar_mean
— Methodcvar_mean(x)
Calculate coefficient of variation for a mean.
Arguments
x::AbstractVector
Returns
cvar_mean::Float64
NeuroAnalyzer.cvar_median
— Methodcvar_median(x)
Calculate coefficient of variation for a median.
Arguments
x::AbstractVector
Returns
cvar_median::Float64
NeuroAnalyzer.mcc
— Methodmcc(tp, tn, fp, fn)
Assess performance of the classification model using Matthews correlation coefficient (MCC).
MCC’s value ranges from -1 to 1, depending on:
- a score of -1 denotes a complete discrepancy between expected and actual classes
- 0 is equivalent to making an entirely arbitrary guess
- total agreement between expected and actual classes is indicated by a score of 1
Arguments
tp::Int64
: number of true positivestn::Int64
: number of true negativesfp::Int64
: number of false positivesfn::Int64
: number of false negatives
Returns
mcc::Float64
Source
https://finnstats.com/index.php/2022/09/06/assess-performance-of-the-classification-model/
NeuroAnalyzer.norminv
— Methodnorminv(x::Real)
Convert probability to a normal distribution with a peak at 0.5.
Arguments
x::Real
Returns
norminv::Float64
NeuroAnalyzer.outlier_detect
— Methodoutlier_detect(x; method)
Detect outliers.
Arguments
x::AbstractVector
method::Symbol=iqr
: detecting methods::iqr
: interquartile range:z
: z-score:g
: Grubbs test
Returns
o::Vector{Bool}
: index of outliers
NeuroAnalyzer.grubbs
— Methodgrubbs(x; alpha, t)
Perform Grubbs test for outlier.
Arguments
x::AbstractVector
alpha::Float64=0.95
t::Int64=0
: test type:-1
: test whether the minimum value is an outlier0
: two-sided test1
: test whether the maximum value is an outlier
Returns
g::Bool
: true: outlier exists, false: there is no outlier
NeuroAnalyzer.pred_int
— Methodpred_int(n)
Calculates the prediction interval (95% CI adjusted for sample size)
Arguments
n::Int64
: sample size
Returns
pred_int::Float64
NeuroAnalyzer.prank
— Methodprank(x)
Calculate percentile rank.
Arguments
x::AbstractVector
: the vector to analyze
Returns
p::Vector{Float64}
: percentile ranks
NeuroAnalyzer.dranks
— Functiondranks(x, nbins)
Calculate ranks scaled in 0..nbins.
Arguments
x::AbstractArray
: some continuous variable such as reaction time (the time it takes to indicate the response)nbins::Int64
: number of bins, default is Sturges' formula
Returns
caf::Array{Float64}
NeuroAnalyzer.res_norm
— Functionres_norm(x, g)
Test normal distribution of residuals.
Arguments
x::AbstractVector
: data valuesg::Vector{Int64}
: group(s) to which each data value belongs
Returns
Named tuple containing:
adt_p::Vector{Float64}
: p-values for k-sample Anderson–Darling test vs normal distributionks_p::Vector{Float64}
: p-values for one-sample exact Kolmogorov–Smirnov test vs normal distribution
Notes
p-values are reported for each group and for the whole sample. If there is only one group, p-values are returned only for the whole sample p-values are reported.
NeuroAnalyzer.seg_mean
— Methodseg_mean(seg)
Calculate mean of a segment (e.g. spectrogram).
Arguments
seg::AbstractArray
Returns
seg_mean::Vector{Float64}
: averaged segment
NeuroAnalyzer.seg_mean
— Methodseg2_mean(seg1, seg2)
Calculate mean of two segments (e.g. spectrograms).
Arguments
seg1::AbstractArray
seg2::AbstractArray
Returns
Named tuple containing:
seg1::Vector{Float64}
: averaged segment 1seg2::Vector{Float64}
: averaged segment 2
NeuroAnalyzer.sem_diff
— Methodsem_diff(x::AbstractVector, y::AbstractVector)
Calculate SEM (standard error of the mean) for the difference of two means.
Arguments
x::AbstractVector
y::AbstractVector
Returns
sem_diff::Float64
Study
NeuroAnalyzer.create_study
— Methodstudy(obj, group)
Create NeuroAnalyzer STUDY object.
Arguments
obj::Vector{NeuroAnalyzer.NEURO}
group::Vector{Symbol}
Returns
study::NeuroAnalyzer.STUDY
NeuroAnalyzer.obj_n
— Methodobj_n(study)
Return number of NeuroAnalyzer NEURO objects in the study.
Arguments
study::NeuroAnalyzer.STUDY
Returns
n::Int64
NeuroAnalyzer.channel_n
— Methodchannel_n(study)
Return number of channels per NeuroAnalyzer NEURO object in the study.
Arguments
study::NeuroAnalyzer.STUDY
Returns
n::Int64
NeuroAnalyzer.epoch_n
— Methodepoch_n(study)
Return number of epochs per NeuroAnalyzer NEURO object in the study.
Arguments
study::NeuroAnalyzer.STUDY
Returns
n::Int64
NeuroAnalyzer.epoch_len
— Methodepoch_len(study)
Return length of epochs per NeuroAnalyzer NEURO object in the study.
Arguments
study::NeuroAnalyzer.STUDY
Returns
len::Int64
NeuroAnalyzer.sr
— Methodsr(study)
Return sampling rate of NeuroAnalyzer NEURO objects in the study.
Arguments
study::NeuroAnalyzer.STUDY
Returns
sr::Int64
NIBS
NeuroAnalyzer.ect_charge
— Methodect_charge(; pw, pint, pf, duration)
Calculate charge administered during ECT.
Arguments
pw::Real
: pulse width [ms]pint::Real
: pulse intensity [mA]pf::Real
: pulse frequency [Hz]duration::Real
: stimulation duration [s]
Returns
charge::Float64
: charge [mC]
NeuroAnalyzer.tes_dose
— Methodtes_dose(current, pad_area, duration)
Convert current
, pad_area
and stimulation duration
into charge
, current_density
and charge_ density
.
Arguments
current::Real
: stimulation current [mA]pad_area::Real
: electrode pad area [cm²]duration::Int64
: stimulation duration [s]
Returns
Named tuple containing:
charge::Float64
: charge [C]current_density::Float64
: current density [A/m²]charge_density::Float64
: delivered charge density [kC/m²]
Source
Chhatbar PY, George MS, Kautz SA, Feng W. Quantitative reassessment of safety limits of tDCS for two animal studies. Brain Stimulation. 2017;10(5):1011–2.
NeuroAnalyzer.tes_protocol
— Methodtes_protocol(; <keyword arguments>)
Create TES (tDCS/tACS/tRNS/tPCS) protocol.
Arguments
type::Symbol
: stimulation type (:tDCS
,:tACS
,:tRNS
,:tPCS
)hd::Bool
: protocol includes HD electrodescurrent::Real
: stimulation current [mA]frequency::Real=0
: stimulation frequency [mA]anode_size::Tuple{Int64, Int64}
: anode dimensions [mm]cathode_size::Tuple{Int64, Int64}
: cathode dimensions [mm]anode_loc::Symbol
: anode location (according to 10-20 Positioning System)cathode_loc::Symbol
: cathode location (according to 10-20 Positioning System)duration::Real
: stimulation duration [s]ramp_in::Real
: stimulation duration [s]ramp_out::Real
: stimulation duration [s]sham::Bool
: protocol includes sham stimulations
Returns
protocol::Dict
NeuroAnalyzer.tes_model
— Methodtes_model(; anode, cathode, anode_curr, cathode_curr)
Create model of TES stimulation.
Arguments
anode::String
: anode locationcathode::String
: cathode locationanode_curr::Real=2.0
: anode current [mA]cathode_curr::Real=-2.0
: cathode current [mA]
Returns
p::Plots.Plot{Plots.GRBackend}
Notes
This is a very initial version, simplified model – just superficial spread of the electric field
To do
Model spread of electric field at the cortical surface – reduce charge for skull resistance