NeuroAnalyzer.jl documentation
This documentation has been generated using Documenter.jl.
Utils
Base.size
— Functionsize(A::AbstractArray, [dim])
Return a tuple containing the dimensions of A
. Optionally you can specify a dimension to just get the length of that dimension.
Note that size
may not be defined for arrays with non-standard indices, in which case axes
may be useful. See the manual chapter on arrays with custom indices.
See also: length
, ndims
, eachindex
, sizeof
.
Examples
julia> A = fill(1, (2,3,4));
julia> size(A)
(2, 3, 4)
julia> size(A, 2)
3
size(cb::CircularBuffer)
Return a tuple with the size of the buffer.
size(df::AbstractDataFrame[, dim])
Return a tuple containing the number of rows and columns of df
. Optionally a dimension dim
can be specified, where 1
corresponds to rows and 2
corresponds to columns.
Examples
julia> df = DataFrame(a=1:3, b='a':'c');
julia> size(df)
(3, 2)
julia> size(df, 1)
3
size(dfr::DataFrameRow[, dim])
Return a 1-tuple containing the number of elements of dfr
. If an optional dimension dim
is specified, it must be 1
, and the number of elements is returned directly as a number.
See also: length
Examples
julia> dfr = DataFrame(a=1:3, b='a':'c')[1, :]
DataFrameRow
Row │ a b
│ Int64 Char
─────┼─────────────
1 │ 1 a
julia> size(dfr)
(2,)
julia> size(dfr, 1)
2
size(p::Plan, [dim])
Return the size of the input of a plan p
, optionally at a specified dimenion dim
.
size(::AbstractPolynomial, [i])
Returns the size of the polynomials coefficients, along axis i
if provided.
size(s::Sampleable)
The size (i.e. shape) of each sample. Always returns ()
when s
is univariate, and (length(s),)
when s
is multivariate.
size(d::MultivariateDistribution)
Return the sample size of distribution d
, i.e (length(d),)
.
size(d::MatrixDistribution)
Return the size of each sample from distribution d
.
size(model::AbstractDimensionalityReduction, d::Int)
Returns the dimension of the input data if d == 1
, the dimension of the output data if d == 2
, otherwise throws error.
size(f)
Dimensions of the coefficient matrix of the whitening transform f
.
size(M)
Returns a tuple with the dimensions of input (the dimension of the observation space) and output (the dimension of the principal subspace).
size(M::PPCA)
Returns a tuple with values of the input dimension $d$, i.e the dimension of the observation space, and the output dimension $p$, i.e the dimension of the principal subspace.
size(M::KernelPCA)
Returns a tuple with the input dimension $d$, i.e the dimension of the observation space, and the output dimension $p$, i.e the dimension of the principal subspace.
size(M:CCA)
Return a tuple with the dimension of X
, Y
, and the output dimension.
size(M::MDS)
Returns tuple where the first value is the MDS model M
input dimension, i.e the dimension of the observation space, and the second value is the output dimension, i.e the dimension of the embedding.
size(M::MetricMDS)
Returns tuple where the first value is the MDS model M
input dimension, i.e the dimension of the observation space, and the second value is the output dimension, i.e the dimension of the embedding.
size(M::MulticlassLDA)
Get the input (i.e the dimension of the observation space) and output (i.e the dimension of the transformed features) dimensions of the model M
.
size(M)
Get the input (i.e the dimension of the observation space) and output (i.e the dimension of the subspace projection) dimensions of the model M
.
size(M::ICA)
Returns a tuple with the input dimension, i.e the number of observed mixtures, and the output dimension, i.e the number of independent components.
size(M::FactorAnalysis)
Returns a tuple with values of the input dimension $d$, i.e the dimension of the observation space, and the output dimension $p$, i.e the dimension of the principal subspace.
size(g, i)
Return the number of vertices in g
if i
=1 or i
=2, or 1
otherwise.
Examples
julia> using Graphs
julia> g = cycle_graph(4);
julia> size(g, 1)
4
julia> size(g, 2)
4
julia> size(g, 3)
1
size(m::MixedModel)
Returns the size of a mixed model as a tuple of length four: the number of observations, the number of (non-singular) fixed-effects parameters, the number of conditional modes (random effects), the number of grouping variables
size(obj)
Return size of the object data.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
s::Tuple{Int64, Int64, Int64}
size(obj, n)
Return size of the object data.
Arguments
obj::NeuroAnalyzer.NEURO
d::Int64
: compute size along dimensiond
Returns
s::Int64
NeuroAnalyzer.add_component
— Functionadd_component(obj; <keyword arguments>)
Add component.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component namev::Any
: component value
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_component!
— Functionadd_component!(obj; <keyword arguments>)
Add component.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component namev::Any
: component value
Returns
Nothing
NeuroAnalyzer.add_note
— Functionadd_note(obj; <keyword arguments>)
Add recording note to the object header.
Arguments
obj::NeuroAnalyzer.NEURO
note::String
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_note!
— Functionadd_note!(obj; <keyword arguments>)
Add recording note to the object header.
Arguments
obj::NeuroAnalyzer.NEURO
note::String
Returns
Nothing
NeuroAnalyzer.apply
— Functionapply(obj; <keyword arguments>)
Apply custom function.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesf::String
: function to be applied, e.g.f="mean(obj, dims=3)"
; OBJ signal is given using variableobj
here.
Returns
out::Array{Float64, 3}
NeuroAnalyzer.areduce
— Functionareduce(a, f; <keyword arguments>)
Reduce an array at indices of a vector being multiplications of a constant. Useful e.g. for simplifying values across frequencies, when the number of frequencies (and thus values) is high.
Arguments
a::AbstractArray
: e.g. signal dataf::AbstractVector
: e.g. frequenciesn::Float64=0.5
: reduce at multiplications of this value
Returns
a_new::Array{eltype(a), ndims(a)}
f_new::Vector{eltype(f)}
NeuroAnalyzer.arr2mat
— Functionarr2mat(x)
Reshape array into matrix.
Arguments
x::AbstractArray
Returns
m::AbstractMatrix
NeuroAnalyzer.band_frq
— Functionband_frq(obj, band)
Return band frequency limits.
Arguments
obj::NeuroAnalyzer.NEURO
band::Symbol
: band range name::list
:total
:delta
: 0.1 - 4.0 Hz:theta
: 4.0 - 8.0 Hz:alpha
: 8.0 - 13.0 Hz:alpha_lower
: 8.0 - 10.5 Hz:alpha_higher
: 10.5 - 13.0 Hz:beta
: 14.0 - 30.0 Hz:beta_lower
: 14.0 - 25.0 Hz:beta_higher
: 25.0 - 30.0 Hz:gamma
: 30.0 - 150.0 Hz:gamma_1
: 30.0 - 40.0 Hz:gamma_2
: 40.0 - 50.0 Hz:gamma_lower
: 30.0 - 80.0 Hz:gamma_higher
: 80.0 - 150.0 Hz
Returns
bf::Tuple{Float64, Float64}
band_frq(fs, band)
Return band frequency limits.
Arguments
fs::Int64
: sampling rateband::Symbol
: band range name::list
:total
:delta
: 0.1 - 4.0 Hz:theta
: 4.0 - 8.0 Hz:alpha
: 8.0 - 13.0 Hz:alpha_lower
: 8.0 - 10.5 Hz:alpha_higher
: 10.5 - 13.0 Hz:beta
: 14.0 - 30.0 Hz:beta_lower
: 14.0 - 25.0 Hz:beta_higher
: 25.0 - 30.0 Hz:gamma
: 30.0 - 150.0 Hz:gamma_1
: 30.0 - 40.0 Hz:gamma_2
: 40.0 - 50.0 Hz:gamma_lower
: 30.0 - 80.0 Hz:gamma_higher
: 80.0 - 150.0 Hz
Returns
bf::Tuple{Float64, Float64}
NeuroAnalyzer.cextrema
— Functioncextrema(x)
Return extreme values of the complex vector.
Arguments
x::Vector{ComplexF64}
Returns
Tuple containing:
cmax::ComplexF64
cmin::ComplexF64
NeuroAnalyzer.channel_cluster
— Functionchannels_cluster(obj; <keyword arguments>)
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{String}
: list of channel numbers belonging to a given cluster of channels
NeuroAnalyzer.channel_info
— Functionchannel_info(obj; <keyword arguments>)
Show channel info.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Int64
Returns
Nothing
NeuroAnalyzer.channel_order
— Functionchannel_order(obj)
Return channel order of the object.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
co::Vector{Int64}
NeuroAnalyzer.channel_pick
— Functionchannel_pick(obj; <keyword arguments>)
Return set of channel indices corresponding to a set of electrodes ("pick", e.g. left or frontal electrodes).
Arguments
obj::NeuroAnalyzer.NEURO
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
chs::Vector{Int64}
: channel numbers
NeuroAnalyzer.chtypes
— Functionchtypes(obj)
Return channel types.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
cht::Vector{String}
NeuroAnalyzer.cmax
— Functioncmax(x)
Return maximum value of the complex vector.
Arguments
x::Vector{ComplexF64}
Returns
cmax::ComplexF64
NeuroAnalyzer.cmin
— Functioncmin(x)
Return minimum value of the complex vector.
Arguments
x::Vector{ComplexF64}
Returns
cmin::ComplexF64
NeuroAnalyzer.component_type
— Functioncomponent_type(obj, c)
Return component data type.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component name
Return
c_type::DataType
NeuroAnalyzer.cums
— Functioncums(signal)
Calculate cumulative sum of a 3-dimensional array.
Arguments
signal::Array{<:Real, 3}
Returns
signal_cs::Array{Float64, 3}
NeuroAnalyzer.cwtfrq
— Functioncwtfrq(s; <keyword arguments>)
Return mean frequencies of a collection of analytic or real wavelets for a given signal.
Arguments
s::AbstractVector
fs::Int64
: sampling ratewt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
f::Vector{Float64}
: frequencies
cwtfrq(s; <keyword arguments>)
Return mean frequencies of a collection of analytic or real wavelets for a given signal.
Arguments
s::AbstractArray
fs::Int64
: sampling ratewt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
f::Vector{Float64}
: frequencies
cwtfrq(obj; <keyword arguments>)
Return mean frequencies of a collection of analytic or real wavelets for a given signal.
Arguments
obj::NeuroAnalyzer.NEURO
wt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
f::Vector{Float64}
: frequencies
NeuroAnalyzer.datatype
— Functiondatatype(obj)
Return data type of the object.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
dt::String
NeuroAnalyzer.delete_component
— Functiondelete_component(obj; <keyword arguments>)
Delete component.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component name
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_component!
— Functiondelete_component!(obj; <keyword arguments>)
Delete component.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component name
Returns
Nothing
NeuroAnalyzer.delete_note
— Functiondelete_note(obj)
Delete recording note from the object header.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_note!
— Functiondelete_note!(obj)
Delete recording note from the object header.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
Nothing
NeuroAnalyzer.delmean
— Functiondelmean(s)
Demean signal.
Arguments
s::AbstractArray
Returns
s_new::AbstractArray
NeuroAnalyzer.describe
— Functiondescribe(obj; <keyword arguments>)
Return basic descriptive statistics of the object data.
Arguments
obj::NeuroAnalyzer.NEURO
df::Bool=false
: if true, return statistics as a DataFrame
Returns
Union{Nothing, DataFrame}
NeuroAnalyzer.detector_labels
— Functiondetector_labels(obj)
Return NIRS detector labels.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
l::Vector{String}
NeuroAnalyzer.epoch_duration
— Functionepoch_duration(obj)
Return epoch length.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
ed::Float64
NeuroAnalyzer.epoch_len
— Functionepoch_len(obj)
Return epoch length.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
len::Int64
epoch_len(study)
Return length of epochs per NeuroAnalyzer NEURO object in the study.
Arguments
study::NeuroAnalyzer.STUDY
Returns
len::Int64
NeuroAnalyzer.extract_component
— Functionextract_component(obj, c)
Extract component values.
Arguments
obj::NeuroAnalyzer.NEURO
c::Symbol
: component name
Returns
c::Any
NeuroAnalyzer.f2t
— Functionf2t(f)
Convert frequency in Hz to cycle length in ms.
Arguments
f::Real
: frequency in Hz
Returns
f::Float64
: cycle length in ms
NeuroAnalyzer.fft0
— Functionfft0(x, n)
Perform zeros-padded FFT.
Arguments
x::AbstractVector
n::Int64
: number of zeros to add
Returns
fft0::Vector{ComplexF64}
NeuroAnalyzer.fft2
— Functionfft2(x)
Perform zeros-padded FFT, so the length of padded vector is a power of 2.
Arguments
x::AbstractVector
Returns
fft2::Vector{ComplexF64}
NeuroAnalyzer.fft_transform
— Functionfft_transform(x; <keyword arguments>)
Perform FFT transformation.
Arguments
x::AbstractVector
fs::Int64
: sampling ratewlen::Int64=fs
: window lengthwoverlap::Int64=round(Int64, wlen * 0.97)
:w::Bool=false
: if true, apply Hanning window per segmentdemean::Bool=false
: if true, demean each segmentnfft::Int64=0
: length of input vector to the FFT; if nfft > n_samples, then the input signal will be zero-padded until it is of length nfftmode::Symbol=:r
::r
: use one-sided FFT (rfft):f
: use two-sided FFT (fft)
Returns
mf::Vector{ComplexF64}
: Fourier coefficientsf::Vector{Float64}
: frequencies
NeuroAnalyzer.findpeaks
— Functionfindpeaks(signal; <keyword arguments>)
Find peaks.
Arguments
signal::AbstractVector
d::Int64=32
: distance between peeks in samples
Returns
p_idx::Vector{Int64}
NeuroAnalyzer.f_nearest
— Functionf_nearest(m, pos)
Find nearest position tuple in a matrix of positions.
Arguments
m::Matrix{Tuple{Float64, Float64}}
: matrix of positionsp::Tuple{Float64, Float64}
: position tuple
Returns
pos::Tuple{Int64, Int64}
: row and column in m
NeuroAnalyzer.freqs
— Functionfreqs(t)
Return vector of frequencies and Nyquist frequency for time vector.
Arguments
t::AbstractVector, AbstractRange}
: time vector
Returns
hz::Vector{Float64}
nf::Float64
freqs(s, fs)
Return vector of frequencies and Nyquist frequency for signal.
Arguments
s::AbstractVector
fs::Int64
Returns
hz::Vector{Float64
: signal vectornf::Float64
freqs(obj)
Return vector of frequencies and Nyquist frequency.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
Named tuple containing:
hz::Vector{Float64}
nf::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, sine amplitude will be in[-amp, +amp]
Returns
- cs::Vector{ComplexF64}`
NeuroAnalyzer.generate_gaussian
— Functiongenerate_gaussian(fs, f, t; <keyword arguments>)
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_morlet
— Functiongenerate_morlet(fs, f, t; <keyword arguments>)
Generate Morlet wavelet.
Arguments
fs::Int64
: sampling ratef::Real
: frequencyt::Real=1
: wavelet length is-t:1/fs:t
ncyc::Int64=5
: number of cyclescomplex::Bool=false
: generate complex Morlet
Returns
morlet::Union{Vector{Float64}, Vector{ComplexF64}}
NeuroAnalyzer.generate_morlet_fwhm
— Functiongenerate_morlet_fwhm(fs, f, t; <keyword arguments>)
Generate Morlet wavelet using FWHM (full width at half maximum) 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_noise
— Functiongenerate_noise(n, a; <keyword arguments>)
Generate noise.
Arguments
n::Int64
: length (in samples)a::Real=1.0
: amplitude, signal amplitude will be in[-amp, +amp]
type::Symbol=:whiten
: noise type::whiten
: normally distributed:whiteu
: uniformly distributed:pink
Returns
s::Vector{Float64}
NeuroAnalyzer.generate_signal
— Functiongenerate_signal(n, amp)
Generate signal based on normally distributed random noise.
Arguments
n::Int64
: length (in samples)a::Real=1.0
: amplitude, signal amplitude will be in[-amp, +amp]
Returns
s::Vector{Float64}
NeuroAnalyzer.generate_sinc
— Functiongenerate_sinc(t, f, peak, norm)
Generate sinc function.
Arguments
t::AbstractRange=-2:0.01:2
: time- `f::Real=1.0: frequency
peak::Real=0
: sinc peak timenorm::Bool=true
: generate normalized function
Returns
s::Vector{Float64}
NeuroAnalyzer.generate_sine
— Functiongenerate_sine(f, t, a, p)
Generates sine wave.
Arguments
f::Real
: frequency [Hz]t::Union{AbstractVector, AbstractRange}
: time vectora::Real
: amplitude, sine amplitude will be in[-amp, +amp]
p::Real
: initial phase [degrees]
Returns
- s::Vector{Float64}`
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.generate_window
— Functiongenerate_window(type, n; <keyword arguments>)
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 (increase length by 1 for odd value ofn
)
Returns
w::Vector{Float64}
:: generated window
NeuroAnalyzer.gradient
— Functiongradient(x; <keyword arguments>)
Calculate gradient of a 1-dimensional scalar field.
Arguments
x::AbstractVector
rev::Bool=false
: by default the direction of the gradient vector field is towards maximum value, ifrev=true
, the direction is towards the minimum value
Returns
Named tuple containing:
g::Vector{Vector{Float64}}
: vector field of gradientsg_len::Vector{Float64}
: scalar field of gradient lengths
gradient(x; <keyword arguments>)
Calculate gradient of a 2-dimensional scalar field.
Arguments
x::AbstractMatrix
rev::Bool=false
: by default the direction of the gradient vector field is towards maximum value, ifrev=true
, the direction is towards the minimum value
Returns
Named tuple containing:
g::Matrix{Vector{Float64}}
: vector field of gradientsg_len::Matrix{Float64}
: scalar field of gradient lengths
gradient(x; <keyword arguments>)
Calculate gradient of a ≥3-dimensional scalar field.
Arguments
x::AbstractArray
rev::Bool=false
: by default the direction of the gradient vector field is towards maximum value, ifrev=true
, the direction is towards the minimum value
Returns
Named tuple containing:
g::Array{Vector{Float64}, 3}
: vector field of gradientsg_len::Array{Float64, 3}
: scalar field of gradient lengths
NeuroAnalyzer.history
— Functionhistory(obj)
Show processing history.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
h::Vector{String}
NeuroAnalyzer.hz2rads
— Functionhz2rads(f)
Convert frequency in Hz to rad/s.
Arguments
f::Real
Returns
f_rads::Float64
NeuroAnalyzer.ifft0
— Functionifft0(x, n)
Perform IFFT of zero-padded vector.
Arguments
x::AbstractVector
n::Int64
: number of zeros added tox
Returns
ifft0::Vector{ComplexF64}
: reconstructed signal trimmed to original length
NeuroAnalyzer.info
— Functioninfo(obj; <keyword arguments>)
Show info.
Arguments
obj::NeuroAnalyzer.NEURO
df::Bool=false
: if true, return object data as a DataFrame containing time points and channels
Returns
Union{Nothing, DataFrame}
NeuroAnalyzer.l1
— Functionl1(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
— Functionl2(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.labels
— Functionlabels(obj)
Return channel labels.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
l::Vector{String}
NeuroAnalyzer.linspace
— Functionlinspace(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{Float64}
NeuroAnalyzer.list_component
— Functionlist_component(obj)
List component names.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
components::Vector{Symbol}
NeuroAnalyzer.logspace
— Functionlogspace(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{Float64}
NeuroAnalyzer.make_table
— Functionmake_table(; <keyword arguments>)
Display data as a table.
Arguments
header::Matrix{String}
: table header, e.g.header = ["Group" "A" "B"]
data::Matrix{Any}
: table data, e.g.data = ["var1" 1.0 2.0; "var2" 3.0 4.0]
Returns
Nothing
NeuroAnalyzer.maxat
— Functionmaxat(x, y)
Find maximum value of one vector and return value at its index from another vector.
Argument
x::AbstractVector
y::AbstractVector
Returns
value::Real
idx::Int64
NeuroAnalyzer.minat
— Functionminat(x, y)
Find minimum value of one vector and return value at its index from another vector.
Argument
x::AbstractVector
y::AbstractVector
Returns
value::Real
idx::Int64
NeuroAnalyzer.m_norm
— Functionm_norm(m)
Normalize matrix.
Arguments
m::AbstractArray
Returns
m_norm::AbstractArray
NeuroAnalyzer.m_pad0
— Functionm_pad0(m)
Pad matrix with zeros to make it square.
Arguments
m::AbstractMatrix
Returns
m::AbstractMatrix
NeuroAnalyzer.m_sort
— Functionm_sort(m, m_idx; <keyword arguments>)
Sorts matrix using sorting index.
Arguments
m::AbstractMatrix
m_idx::Vector{Int64}
: sorting indexrev::Bool=false
: reverse sortdims::Int64=1
: sort by columns (dims=1
) or by rows (dims=2
)
Returns
m_sorted::AbstractMatrix
NeuroAnalyzer.m_sortperm
— Functionm_sortperm(m; <keyword arguments>)
Generates matrix sorting index.
Arguments
m::AbstractMatrix
rev::Bool
: reverse sortdims::Int64=1
: sort by columns (dims=1
) or by rows (dims=2
)
Returns
idx::Matrix{Int64}
NeuroAnalyzer.na_info
— Functionna_info()
Show NeuroAnalyzer and imported packages versions.
Arguments
Nothing
Returns
Nothing
NeuroAnalyzer.na_plugins_install
— Functionna_plugins_install(plugin)
Install NeuroAnalyzer plugin from remote Git repository or from local .TAR.GZ/.ZIP archive (requires unzip or tar command to be available).
Arguments
plugin::String
: plugin Git repository URL or file name (with full path)
Returns
Nothing
NeuroAnalyzer.na_plugins_list
— Functionna_plugins_list()
List NeuroAnalyzer plugins.
Arguments
Nothing
Returns
Nothing
NeuroAnalyzer.na_plugins_reload
— Functionna_plugins_reload()
Reload NeuroAnalyzer plugins.
Arguments
Nothing
Returns
Nothing
NeuroAnalyzer.na_plugins_remove
— Functionna_plugins_remove(plugin)
Remove NeuroAnalyzer plugin.
Arguments
plugin::String
: plugin name
Returns
Nothing
NeuroAnalyzer.na_plugins_update
— Functionna_plugins_update(plugin)
Update NeuroAnalyzer plugin(s).
Arguments
plugin::String
: plugin to update; if empty, update all
Returns
Nothing
NeuroAnalyzer.na_set_prefs
— Functionna_set_prefs(use_cuda, progress_bar, verbose)
Save NeuroAnalyzer preferences.
Arguments
use_cuda::Bool
progress_bar::Bool
verbose::Bool
Returns
Nothing
NeuroAnalyzer.na_set_progress_bar
— Functionna_set_progress_bar(value)
Change progress_bar
preference.
Arguments
value::Bool
: value
Returns
Nothing
NeuroAnalyzer.na_set_use_cuda
— Functionna_set_use_cuda(value)
Change use_cuda
preference.
Arguments
value::Bool
: value
Returns
Nothing
NeuroAnalyzer.na_set_verbose
— Functionna_set_verbose(value)
Change verbose
preference.
Arguments
value::Bool
: value
Returns
Nothing
NeuroAnalyzer.na_version
— Functionna_version()
Convert NeuroAnalyzer version to string.
Arguments
Nothing
Returns
VER::String
NeuroAnalyzer.nchannels
— Functionnchannels(obj; <keyword arguments>)
Return number type
channels.
Arguments
obj::NeuroAnalyzer.NEURO
type::String="all"
: channel type (stored in the globalchannel_types
constant variable)
Returns
ch_n::Int64
nchannels(study)
Return number of channels per NeuroAnalyzer NEURO object in the study.
Arguments
study::NeuroAnalyzer.STUDY
Returns
n::Int64
NeuroAnalyzer.nepochs
— Functionnepochs(obj)
Return number of epochs.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
ep_n::Int64
nepochs(study)
Return number of epochs per NeuroAnalyzer NEURO object in the study.
Arguments
study::NeuroAnalyzer.STUDY
Returns
n::Int64
NeuroAnalyzer.nextpow2
— Functionnextpow2(x)
Return the next power of 2 for a given number.
Argument
x::Int64
Returns
nextpow2::Int64
NeuroAnalyzer.optode_labels
— Functionoptode_labels(obj)
Return optode labels.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
l::Vector{String}
NeuroAnalyzer.pad0
— Functionpad0(x, n)
Pad row(s) with zeros. Works with 1-, 2- and 3-dimensional arrays.
Arguments
x::Union{AbstractVector, AbstractArray}
n::Int64
: padding length (number of zeros to add)
Returns
pad0::Union{AbstractVector, AbstractArray}
NeuroAnalyzer.pad2
— Functionpad2(x)
Pad row(s) with zeros to the nearest power of 2 length. Works with 1-, 2- and 3-dimensional arrays.
Arguments
x::Union{AbstractVector, AbstractArray}
Returns
pad2::Union{AbstractVector, AbstractArray}
NeuroAnalyzer.padm
— Functionpadm(x, n)
Pad row(s) with mean value(s). Works with 1-, 2- and 3-dimensional arrays.
Arguments
x::Union{AbstractVector, AbstractArray}
n::Int64
: padding length (number of values to add)mode::Symbol=:row
: how the mean is calculated::all
: mean of all rows:row
: separate mean per each row
Returns
padm::Union{AbstractVector, AbstractArray}
NeuroAnalyzer.paired_labels
— Functionpaired_labels(l; <keyword arguments>)
Return paired labels.
Arguments
l::Vector{String}
unq::Bool=true
: if true, do not add pairs of the same labels, e.g. "label1-label1"
Returns
l_paired::Vector{String}
: paired labels
paired_labels(l1, l2)
Return paired labels.
Arguments
l1::Vector{String}
l2::Vector{String}
Returns
l_paired::Vector{String}
: paired labels
NeuroAnalyzer.perm_cmp
— Functionperm_cmp(a1, a2; <keyword arguments>)
Compare two 3-dimensional arrays (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::Matrix{Float64}
: array of Z-valuesbm::BitMatrix
: binarized mask of statistically significant positions
NeuroAnalyzer.phases
— Functionphases(s)
Calculate phases.
Arguments
s::AbstractVector
Returns
phases::Vector{Float64}
NeuroAnalyzer.play
— Functionplay(obj; <keyword arguments>)
Play channel signal as audio.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel nameseg::Tuple{Real, Real}
: time segment to playep::Int64
: epoch number
Returns
Nothing
NeuroAnalyzer.rads2hz
— Functionrads2hz(f)
Convert frequency in rad/s to Hz.
Arguments
f::Real
Returns
f_rads::Float64
NeuroAnalyzer.rename_component
— Functionrename_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::NeuroAnalyzer.NEURO
NeuroAnalyzer.rename_component!
— Functionrename_component!(obj, c_old, c_new)
Rename component.
Arguments
obj::NeuroAnalyzer.NEURO
c_old::Symbol
: old component namec_new::Symbol
: new component name
Returns
Nothing
NeuroAnalyzer.reset_components
— Functionreset_components(obj)
Remove all components.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.reset_components!
— Functionreset_components!(obj)
Remove all components.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
Nothing
NeuroAnalyzer.rfft0
— Functionrfft0(x, n)
Perform zeros-padded single-sided FFT.
Arguments
x::AbstractVector
n::Int64
: number of zeros to add
Returns
rfft0::Vector{ComplexF64}
NeuroAnalyzer.rfft2
— Functionrfft2(x)
Perform zeros-padded single-sided FFT, so the length of padded vector is a power of 2.
Arguments
x::AbstractVector
Returns
rfft2::Vector{ComplexF64}
NeuroAnalyzer.s2t
— Functions2t(s, fs)
Convert sample number to time in seconds.
Arguments
t::Int64
: sample numberfs::Int64
: sampling rate
Returns
s2t::Float64
: time in s
s2t(obj; <keyword arguments>)
Convert time in samples to seconds.
Arguments
obj::NeuroAnalyzer.NEURO
s::Int64
: time in samples
Returns
s2t::Float64
: time in seconds
NeuroAnalyzer.signal_duration
— Functionsignal_duration(obj)
Return signal duration.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
sd::Float64
NeuroAnalyzer.signal_len
— Functionsignal_len(obj)
Return signal length.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
sl::Int64
NeuroAnalyzer.source_labels
— Functionsource_labels(obj)
Return NIRS source labels.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
l::Vector{String}
NeuroAnalyzer.sr
— Functionsr(obj)
Return sampling rate.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
fs::Int64
sr(study)
Return sampling rate of NeuroAnalyzer NEURO objects in the study.
Arguments
study::NeuroAnalyzer.STUDY
Returns
sr::Int64
NeuroAnalyzer.t2f
— Functiont2f(t)
Convert cycle length in ms to frequency.
Arguments
t::Real
: cycle length in ms
Returns
f::Float64
: frequency in Hz
NeuroAnalyzer.t2s
— Functiont2s(t, fs)
Convert time in seconds to sample number.
Arguments
t::T
: time in sfs::Int64
: sampling rate
Returns
t2s::Int64
: sample number
t2s(obj; <keyword arguments>)
Convert time in seconds to sample number.
Arguments
obj::NeuroAnalyzer.NEURO
t::T
: time in seconds
Returns
t2s::Int64
: time in samples
NeuroAnalyzer.tavg
— Functiontavg(s)
Average signal across trials.
Arguments
s::AbstractArray
Returns
s_new::AbstractArray
NeuroAnalyzer.to_df
— Functionto_df(obj)
Export object data as DataFrame.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
df::DataFrame
: DataFrame containing time points and channels
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.vec2mat
— Functionvec2mat(x; <keyword arguments>)
Reshape vector into matrix using fixed segment length and overlapping.
Arguments
x::AbstractVector
wlen::Int64
: window length (in samples)woverlap::Int64
: overlap with the previous window (in samples)
Returns
m::AbstractMatrix
NeuroAnalyzer.view_header
— Functionheader(obj)
Show keys and values of the object header.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
Nothing
NeuroAnalyzer.view_note
— Functionview_note(obj)
Return the object recording note.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
note::String
NeuroAnalyzer.vreduce
— Functionvreduce(x, f; <keyword arguments>)
Reduce two vectors at indices of the second vector being multiplications of a constant. Useful e.g. for simplifying values across frequencies, when the number of frequencies (and thus values) is high.
Arguments
x::AbstractVector
: e.g. signal dataf::AbstractVector
: e.g. frequenciesn::Float64=0.5
: reduce at multiplications of this value
Returns
x_new::AbstractVector
f_new::AbstractVector
NeuroAnalyzer.vsearch
— Functionvsearch(y, x; <keyword arguments>)
Return the positions of the value in the vector.
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]
vsearch(y, x; <keyword arguments>)
Return the positions of the value in the vector.
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 vector into pieces.
Argument
x::AbstractVector
n::Int64
: length of one piece
Returns
x::Vector{AbstractVector}
IO
NeuroAnalyzer.export_csv
— Functionexport_csv(obj; <keyword arguments>)
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
Returns
Nothing
NeuroAnalyzer.export_locs
— Functionexport_locs(obj; <keyword arguments>)
Export channel locations data, format is based on file_name
extension (.csv, .ced, .locs or .tsv)
Arguments
obj::NeuroAnalyzer.NEURO
file_name::String
overwrite::Bool=false
Returns
Nothing
export_locs(locs; <keyword arguments>)
Export channel locations, format is based on file_name
extension (.ced, .locs, .tsv)
Arguments
locs::DataFrame
file_name::String
overwrite::Bool=false
Returns
Nothing
NeuroAnalyzer.export_markers
— Functionexport_markers(obj; <keyword arguments>)
Export NeuroAnalyzer.NEURO
object markers to CSV.
Arguments
obj::NeuroAnalyzer.NEURO
file_name::String
overwrite::Bool=false
Returns
Nothing
NeuroAnalyzer.import_alice4
— Functionimport_alice4(file_name; <keyword arguments>)
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
— Functionimport_bdf(file_name; <keyword arguments>)
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
— Functionimport_bv(file_name; <keyword arguments>)
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_cnt
— Functionimport_cnt(file_name; <keyword arguments>)
Load Neuroscan continuous signal 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 labeldata_format::Symbol=:i32
: Neuroscan stores data either in 16-bit (:i16
) or 32-bit (:i32
) representation, but does not say so in the file format
Returns
obj::NeuroAnalyzer.NEURO
Notes
Based on loadcnt.m by Sean Fitzgibbon and Arnaud Delorme (https://cnl.salk.edu/~arno/cntload/index.html)
NeuroAnalyzer.import_csv
— Functionimport_csv(file_name; <keyword arguments>)
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_dat
— Functionimport_dat(file_name)
Load Neuroscan DAT file.
Arguments
file_name::String
: name of the file to load
Returns
dat::DataFrame
NeuroAnalyzer.import_digitrack
— Functionimport_digitrack(file_name; <keyword arguments>)
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_duomag
— Functionimport_duomag(file_name)
Load DuoMAG TMS MEP recording file (.ascii or .m) and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to load
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.import_edf
— Functionimport_edf(file_name; <keyword arguments>)
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; 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
— Functionimport_edf_annotations(file_name; <keyword arguments>)
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
— Functionimport_fiff(file_name)
Load FIFF (Functional Image File Format) file and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to load
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.import_gdf
— Functionimport_gdf(file_name; <keyword arguments>)
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
— Functionimport_locs(file_name)
Load channel locations. Supported formats:
- CED
- ELC
- LOCS
- TSV
- SFP
- CSD
- GEO
- MAT
- TXT
- DAT
- ASC
- CSV
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 load
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_asc
— Functionimport_locs_asc(file_name)
Load channel locations from ASC file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_ced
— Functionimport_locs_ced(file_name)
Load channel locations from CED file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_csd
— Functionimport_locs_csd(file_name)
Load channel locations from CSD file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_csv
— Functionimport_locs_csv(file_name)
Load channel locations from CSV file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_dat
— Functionimport_locs_dat(file_name)
Load channel locations from DAT file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_elc
— Functionimport_locs_elc(file_name)
Load channel locations from ELC file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_geo
— Functionimport_locs_geo(file_name)
Load channel locations from GEO file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_locs
— Functionimport_locs_locs(file_name)
Load channel locations from LOCS file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_mat
— Functionimport_locs_mat(file_name)
Load channel locations from MAT file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_sfp
— Functionimport_locs_sfp(file_name)
Load channel locations from SFP file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_tsv
— Functionimport_locs_tsv(file_name)
Load channel locations from TSV file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_locs_txt
— Functionimport_locs_txt(file_name)
Load channel locations from TXT file.
Arguments
file_name::String
Returns
locs::DataFrame
NeuroAnalyzer.import_montage
— Functionimport_montage(file_name)
Load montage from a text file. Example montage files are located in the montages/
folder. The structure of the file is:
- first line: name of the montage, e.g.
longitudinal-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::String
: name of the montage
NeuroAnalyzer.import_ncs
— Functionimport_ncs(file_name)
Load Neuralinx Continuously Sampled Channels (CSC) and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to load
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.import_nirs
— Functionimport_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
— Functionimport_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_npy
— Functionimport_npy(file_name; <keyword arguments>)
Load NPY file (exported from MNE) and return NeuroAnalyzer.NEURO
object. Data type and channel types are set as is EEG.
Arguments
file_name::String
: name of the file to loadsampling_rate::Int64
: NPY file contains only signal data, therefore its sampling rate must be provided upon importing
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.import_nwb
— Functionimport_nwb(file_name; <keyword arguments>)
Load EEG data from 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_recording
— Functionimport_recording(file_name; <keyword arguments>)
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
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.import_set
— Functionimport_set(file_name; <keyword arguments>)
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
— Functionimport_snirf(file_name; <keyword arguments>)
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.import_thymatron
— Functionimport_thymatron(file_name)
Import scanned images of EEG printed by Thymatron ECT equipment and return NeuroAnalyzer.NEURO
object.
Usually there are three images: baseline, during seizure activity and after seizure activity. If more then one image is provided, images are added as consecutive channels in the same object.
Image properties:
- 100 DPI
- 490 x 100 px
- height 2.5 cm
- width 12.5 cm
Arguments
file_name::String
: name of the file to loaddpi::Int64=100
: DPI of the scanned images
Returns
obj::NeuroAnalyzer.NEURO
Source
Wysokiński A. EEG_ADC: Digitizer and Analyzer of Electroconvulsive Therapy Paper Electroencephalogram Recordings. JECT 2022; 4: 255-256
NeuroAnalyzer.import_xdf
— Functionimport_xdf(file_name)
Load Extensible Data Format (XDF) and return NeuroAnalyzer.NEURO
object.
Arguments
file_name::String
: name of the file to load
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.load
— Functionload(file_name)
Load NeuroAnalyzer.NEURO
object from file_name
file (HDF5-based).
Arguments
file_name::String
: name of the file to load
Returns
obj::NeuroAnalyzer.NEURO
NeuroAnalyzer.load_fiff
— Functionload_fiff(file_name)
Load FIFF (Functional Image File Format) file and return FIFF object.
Arguments
file_name::String
: name of the file to load
Returns
fiff::Dict{Symbol, Dict{Any, Any}}
fiff_object::Vector{Any}
fiff_blocks::Matrix{Int64}
Source
Elekta Neuromag: Functional Image File Format Description. FIFF version 1.3. March 2011
NeuroAnalyzer.load_locs
— Functionload_locs(obj; <keyword arguments>)
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
- TXT
- DAT
- ASC
- CSV
Channel locations:
loc_theta
: polar angleloc_radius
: 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 load
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.load_locs!
— Functionload_locs!(obj; <keyword arguments>)
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
- TXT
- DAT
- ASC
Channel locations:
loc_theta
: polar angleloc_radius
: 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
Return
Nothing
NeuroAnalyzer.load_study
— Functionload_study(file_name)
Load NeuroAnalyzer.STUDY
object from file_name
file (HDF5-based).
Arguments
file_name::String
: name of the file to load
Returns
obj::NeuroAnalyzer.STUDY
NeuroAnalyzer.save
— Functionsave(obj; <keyword arguments>)
Save NeuroAnalyzer.NEURO
object to file_name
file (HDF5-based).
Arguments
obj::NeuroAnalyzer.NEURO
file_name::String
: name of the file to save tooverwrite::Bool=false
Return
Nothing
NeuroAnalyzer.save_study
— Functionsave_study(obj; <keyword arguments>)
Save NeuroAnalyzer.STUDY
object to file_name
file (HDF5-based).
Arguments
obj::NeuroAnalyzer.STUDY
file_name::String
: name of the file to save tooverwrite::Bool=false
Return
Nothing
Edit
NeuroAnalyzer.add_channel
— Functionadd_channel(obj; <keyword arguments>)
Add channels data to an empty NeuroAnalyzer.NEURO
object.
Arguments
obj::NeuroAnalyzer.NEURO
data::Array{<:Number, 3}
: channels datalabel::Union{String, Vector{String}}
: channels labelstype::Union{String, Vector{String}}
: channels types
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_channel!
— Functionadd_channel!(obj; <keyword arguments>)
Add channels data to an empty NeuroAnalyzer.NEURO
object.
Arguments
obj::NeuroAnalyzer.NEURO
data::Array{<:Number, 3}
: channels datalabel::Union{String, Vector{String}}
: channels labelstype::Union{String, Vector{String}}
: channels types
Returns
Nothing
NeuroAnalyzer.add_label
— Functionadd_label(obj; <keyword arguments>)
Add channel labels.
Arguments
obj::NeuroAnalyzer.NEURO
clabels::Vector{String}
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_label!
— Functionadd_label!(obj; <keyword arguments>)
Add channel labels.
Arguments
obj::NeuroAnalyzer.NEURO
clabels::Vector{String}
Returns
Nothing
NeuroAnalyzer.add_marker
— Functionadd_marker(obj; <keyword arguments>)
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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_marker!
— Functionadd_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
Nothing
NeuroAnalyzer.channel2marker
— Functionchannel2marker(obj; <keyword arguments>)
Convert event channel to markers.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel namev::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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.channel2marker!
— Functionchannel2marker!(obj; <keyword arguments>)
Convert event channel to markers.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel namev::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_")
Returns
Nothing
NeuroAnalyzer.channel_type
— Functionchannel_type(obj; <keyword arguments>)
Get channel type.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel name
Returns
cht::String
NeuroAnalyzer.chop
— Functionchop(obj; <keyword arguments>)
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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.chop!
— Functionchop!(obj; <keyword arguments>)
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
Nothing
NeuroAnalyzer.create_data
— Functioncreate_data(obj; <keyword arguments>)
Create data, channel labels, types and units and time points for NeuroAnalyzer.NEURO
object.
Arguments
obj::NeuroAnalyzer.NEURO
data::Array{Float64, 3}
fs::Int64
type::String
: channel types of imported data channels
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.create_data!
— Functioncreate_data!(obj; <keyword arguments>)
Create data, channel labels, types and units and time points for NeuroAnalyzer.NEURO
object.
Arguments
obj::NeuroAnalyzer.NEURO
data::Array{Float64, 3}
fs::Int64
type::String
: channel types of imported data channels
Returns
Nothing
NeuroAnalyzer.create_object
— Functioncreate_object(; <keyword arguments>)
Create an empty NeuroAnalyzer.NEURO
object.
Arguments
data_type::String
: data type of the new object ("eeg", "ecog", "seeg", "meg", "nirs", "mep", "eda", "sensors")
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.create_time
— Functioncreate_time(obj; <keyword arguments>)
Create time points vector for NeuroAnalyzer.NEURO
object.
Arguments
obj::NeuroAnalyzer.NEURO
fs::Int64
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.create_time!
— Functioncreate_time!(obj; <keyword arguments>)
Create time points vector for NeuroAnalyzer.NEURO
object.
Arguments
obj::NeuroAnalyzer.NEURO
fs::Int64
Returns
Nothing
NeuroAnalyzer.delete_channel
— Functiondelete_channel(obj; <keyword arguments>)
Delete channel(s).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channels to be removeddel_opt::Bool=false
: for NIRS data is set astrue
if called fromremove_optode()
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_channel!
— Functiondelete_channel!(obj; <keyword arguments>)
Delete channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channels to be removeddel_opt::Bool=false
: for NIRS data is set astrue
if called fromremove_optode()
Returns
Nothing
NeuroAnalyzer.delete_epoch
— Functiondelete_epoch(obj; <keyword arguments>)
Remove epochs.
Arguments
obj::NeuroAnalyzer.NEURO
ep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch numbers to be removed
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_epoch!
— Functiondelete_epoch!(obj; <keyword arguments>)
Remove epochs.
Arguments
obj::NeuroAnalyzer.NEURO
ep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch numbers to be removed
Returns
Nothing
NeuroAnalyzer.delete_marker
— Functiondelete_marker(obj; <keyword arguments>)
Delete marker.
Arguments
obj::NeuroAnalyzer.NEURO
n::Int64
: marker number
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_marker!
— Functiondelete_marker!(obj; n)
Delete marker.
Arguments
obj::NeuroAnalyzer.NEURO
n::Int64
: marker number
Returns
Nothing
NeuroAnalyzer.delete_optode
— Functiondelete_optode(obj; <keyword arguments>)
Delete optodes) and channels associated with removed optodes.
Arguments
obj::NeuroAnalyzer.NEURO
opt::Union{Int64, Vector{Int64}, <:AbstractRange}
: optode number(s) to be removed
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.delete_optode!
— Functiondelete_optode!(obj; <keyword arguments>)
Delete optopode(s).
Arguments
obj::NeuroAnalyzer.NEURO
opt::Union{Int64, Vector{Int64}, <:AbstractRange}
: optopode number(s) to be removed
Returns
Nothing
NeuroAnalyzer.detect_bad
— Functiondetect_bad(obj; <keyword arguments>)
Detect bad channels and epochs.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesmethod::Union{Symbol, Vector{Symbol}}=[:flat, :rmse, :rmsd, :euclid, :var, :p2p, :tkeo, :kurt, :z, :ransac, :amp]
: detection method::flat
: flat channel(s):rmse
: RMSE vs average channel outside of 95% CI:rmsd
: RMSD:euclid
: Euclidean distance:var
: mean signal variance outside of 95% CI and variance inter-quartile outliers:p2p
: mark bad channels based on peak-to-peak amplitude; good for detecting transient artifacts:tkeo
: mark bad channels based on z-score TKEO value outside of 95% CI:kurt
: mark bad channels based on z-scores of kurtosis values:z
: mark bad channels based on their z-score of amplitude:ransac
: calculate each channel correlation to its nearest neighbor with outliers removed using random sample consensus (RANSAC) in successive 1-s segments; channel signals exhibiting low correlation to signals in neighboring scalp channels in individual windows (here, r <ransac_r
at more thanransac_tr
of the data points) are marked as bad:amp
: mark bad channels based on their amplitude
w::Int64=10
: window width in samples (signal is averaged withinw
-width window)flat_tol::Float64=0.1
: tolerance (signal is flat within-tol
to+tol
),eps()
gives very low toleranceflat_fr::Float64=0.3
: acceptable ratio (0.0 to 1.0) of flat segments within a channel before marking it as flatp::Float64=0.99
: probability threshold (0.0 to 1.0) for marking a 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); also threshold for:z
method: percentage of channel length per epoch for marking a channel as badtc::Float64=0.3
: threshold (0.0 to 1.0) of bad channels ratio to mark the epoch as badtkeo_method::Symbol=:pow
: method of calculating TKEO, seetkeo()
for detailsz::Real=3
: threshold number of z-scoresransac_r::Float64=0.8
: threshold (0.0 to 1.0) correlation between channelsransac_tr::Float64=0.4
: threshold (0.0 to 1.0) ratio of uncorrelated channelsransac_t::Float64=100.0
: threshold distance of a sample point to the regression hyperplane to determine if it fits the model wellamp_t::Float64=400.0
: two-sided rejection amplitude threshold (± 400 μV)
Returns
Named tuple containing:
bm::Matrix{Bool}
: matrix of bad channels × epochsbe::Vector{Int64}
: list of bad epochs
NeuroAnalyzer.detect_bad!
— Functiondetect_bad!(obj; <keyword arguments>)
Detect bad channels and epochs and update the :bad_channel
field in the OBJ header.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesmethod::Union{Symbol, Vector{Symbol}}=[:flat, :rmse, :rmsd, :euclid, :var, :p2p, :tkeo, :kurt, :z, :ransac, :amp]
: detection method::flat
: flat channel(s):rmse
: RMSE vs average channel outside of 95% CI:rmsd
: RMSD:euclid
: Euclidean distance:var
: mean signal variance outside of 95% CI and variance inter-quartile outliers:p2p
: mark bad channels based on peak-to-peak amplitude; good for detecting transient artifacts:tkeo
: mark bad channels based on z-score TKEO value outside of 95% CI:kurt
: mark bad channels based on z-scores of kurtosis values:z
: mark bad channels based on their z-score of amplitude:ransac
: calculate each channel correlation to its nearest neighbor with outliers removed using random sample consensus (RANSAC) in successive 1-s segments; channel signals exhibiting low correlation to signals in neighboring scalp channels in individual windows (here, r <ransac_r
at more thanransac_tr
of the data points) are marked as bad:amp
: mark bad channels based on their amplitude
w::Int64=10
: window width in samples (signal is averaged withinw
-width window)flat_tol::Float64=0.1
: tolerance (signal is flat within-tol
to+tol
),eps()
gives very low toleranceflat_fr::Float64=0.3
: acceptable ratio (0.0 to 1.0) of flat segments within a channel before marking it as flatp::Float64=0.99
: probability threshold (0.0 to 1.0) for marking a 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); also threshold for:z
method: percentage of channel length per epoch for marking a channel as badtc::Float64=0.3
: threshold (0.0 to 1.0) of bad channels ratio to mark the epoch as badtkeo_method::Symbol=:pow
: method of calculating TKEO, seetkeo()
for detailsz::Real=3
: threshold number of z-scoresransac_r::Float64=0.8
: threshold (0.0 to 1.0) correlation between channelsransac_tr::Float64=0.4
: threshold (0.0 to 1.0) ratio of uncorrelated channelsransac_t::Float64=100.0
: threshold distance of a sample point to the regression hyperplane to determine if it fits the model wellamp_t::Float64=400.0
: two-sided rejection amplitude threshold (± 400 μV)
Returns
Nothing
NeuroAnalyzer.edit_channel
— Functionedit_channel(obj; <keyword arguments>)
Edit channel properties (:channel_type
or :label
) in OBJ.header.recording
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel namefield::Symbol
value::String
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.edit_channel!
— Functionedit_channel!(obj; <keyword arguments>)
Edit channel properties (:channel_type
or :label
) in OBJ.header.recording
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel namefield::Symbol
value::String
Returns
Nothing
NeuroAnalyzer.edit_marker
— Functionedit_marker(obj; <keyword arguments>)
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=0
: channel number, if 0 then marker is related to all channels
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.edit_marker!
— Functionedit_marker!(obj; n, id, start, len, desc, ch)
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=0
: channel number, if 0 then marker is related to all channels
Returns
Nothing
NeuroAnalyzer.epoch
— Functionepoch(obj; <keyword arguments>)
Split 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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.epoch!
— Functionepoch!(obj; <keyword arguments>)
Split 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
Nothing
NeuroAnalyzer.epoch_ts
— Functionepoch_ts(obj; <keyword arguments>)
Edit epochs time start.
Arguments
obj::NeuroAnalyzer.NEURO
ts::Real
: time start in seconds
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.epoch_ts!
— Functionepoch_ts!(obj; <keyword arguments>)
Edit OBJ epochs time start.
Arguments
obj::NeuroAnalyzer.NEURO
ts::Real
: time start in seconds
Returns
Nothing
NeuroAnalyzer.extract_channel
— Functionextract_channel(obj; <keyword arguments>)
Extract channel data.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel name
Returns
d::Array{Float64, 3}
NeuroAnalyzer.extract_data
— Functionextract_data(obj; <keyword arguments>)
Extract data.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesep::Union{Int64, Vector{Int64}, <:AbstractRange}=1:nepochs(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_epoch
— Functionextract_epoch(obj; <keyword arguments>)
Extract epoch.
Arguments
obj::NeuroAnalyzer.NEURO
ep::Int64
: epoch index
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.extract_epoch!
— Functionextract_epoch!(obj; <keyword arguments>)
Extract epoch.
Arguments
obj::NeuroAnalyzer.NEURO
ep::Int64
: epoch index
Returns
Nothing
NeuroAnalyzer.extract_eptime
— Functionextract_eptime(obj)
Extract epochs time.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
et::Vector{Float64}
NeuroAnalyzer.extract_time
— Functionextract_time(obj)
Extract time.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
tpts::Vector{Float64}
NeuroAnalyzer.get_channel
— Functionget_channel(obj; <keyword arguments>)
Return list of channel names of specified type or their numbers if names are specified.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}=""
: channel name or list of channel namestype::Union{String, Vector{String}}="all"
: channels typeswl::Real
: return NIRS channels for wavelength (in nm)exclude::Union{String, Vector{String}}="bad"
: channel name or list of channel names to exclude from the list
Returns
ch::Union{Vector{String}, Vector{Int64}}
NeuroAnalyzer.join
— Functionjoin(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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.join!
— Functionjoin!(obj1, obj2)
Join two NeuroAnalyzer objects into the first object. 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
Nothing
NeuroAnalyzer.keep_channel
— Functionkeep_channel(obj; <keyword arguments>)
Keep channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channels to keep
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.keep_channel!
— Functionkeep_channel!(obj; <keyword arguments>)
Keep channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channels to keep
Returns
Nothing
NeuroAnalyzer.keep_epoch
— Functionkeep_epoch(obj; <keyword arguments>)
Keep epochs.
Arguments
obj::NeuroAnalyzer.NEURO
ep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch numbers to keep
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.keep_epoch!
— Functionkeep_epoch!(obj; <keyword arguments>)
Keep epochs.
Arguments
obj::NeuroAnalyzer.NEURO
ep::Union{Int64, Vector{Int64}, <:AbstractRange}
: epoch numbers to keep
Returns
Nothing
NeuroAnalyzer.reflect
— Functionreflect(obj; <keyword arguments>)
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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.reflect!
— Functionreflect!(obj; <keyword arguments>)
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
Nothing
NeuroAnalyzer.rename_channel
— Functionrename_channel(obj; <keyword arguments>)
Rename channel.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel namename::String
: new name
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.rename_channel!
— Functionrename_channel!(obj; <keyword arguments>)
Rename channel.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel namename::String
: new name
Returns
Nothing
NeuroAnalyzer.replace_channel
— Functionreplace_channel(obj; <keyword arguments>)
Replace channel.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel names::AbstractArray
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.replace_channel!
— Functionreplace_channel!(obj; <keyword arguments>)
Replace channel.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel names::Array{Float64, 3}
: signal to replace with
Returns
Nothing
NeuroAnalyzer.set_channel_type
— Functionset_channel_type(obj; <keyword arguments>)
Set channel type.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel nametype::String
: new type
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.set_channel_type!
— Functionset_channel_type!(obj; <keyword arguments>)
Set channel type.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel nametype::String
Returns
Nothing
NeuroAnalyzer.subepoch
— Functionsubepoch(obj; <keyword arguments>)
Extract sub-epochs with a reduced time range.
Arguments
obj::NeuroAnalyzer.NEURO
ep_start::Real
: sub-epoch startep_end::Real
: sub-epoch end
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.subepoch!
— Functionsubepoch!(obj; <keyword arguments>)
Extract sub-epochs with a reduced time range.
Arguments
obj::NeuroAnalyzer.NEURO
ep_start::Real
: sub-epoch startep_end::Real
: sub-epoch end
Returns
Nothing
NeuroAnalyzer.trim
— Functiontrim(s; <keyword arguments>)
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}
trim(m; <keyword arguments>)
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::Matrix{Float64}
trim(a; <keyword arguments>)
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, 3}
trim(obj; <keyword arguments>)
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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.trim!
— Functiontrim!(obj; <keyword arguments>)
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
Nothing
NeuroAnalyzer.vch
— Functionvch(obj; <keyword arguments>)
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
NeuroAnalyzer.view_marker
— Functionview_marker(obj)
Show markers.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
Nothing
Process
NeuroAnalyzer.add_signal
— Functionadd_signal(s1, s2)
Add signal.
Arguments
s1::AbstractVector
: target signals2::AbstractVector
: signal to be added
Returns
s_noisy::AbstractVector
add_signal(obj; <keyword arguments>)
Add signal.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namess::AbstractVector
: signal to be added to each channel
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.add_signal!
— Functionadd_signal!(obj; <keyword arguments>)
Add signal.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namess::AbstractVector
: signal to be added to each channel
Returns
Nothing
NeuroAnalyzer.average
— Functionaverage(s)
Average all channels.
Arguments
s::AbstractArray
Returns
average::AbstractArray
average(s1, s2)
Averages two signals.
Arguments
s1::AbstractArray
s2::AbstractArray
Returns
average::AbstractArray
average(obj; <keyword arguments>)
Return the average signal of channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
obj_new::NeuroAnalyzer.NEURO
average(obj1, obj2)
Return the average signal of two objects.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.average!
— Functionaverage!(obj; <keyword arguments>)
Return the average signal of channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Nothing
NeuroAnalyzer.average_epochs
— Functionaverage_epochs(obj; <keyword arguments>)
Average EEG/MEG epochs. Non-EEG/MEG channels are removed. OBJ.header.recording[:data_type]
becomes erp
(for EEG) or erf
for MEG. First epoch is the ERP/ERF.
Arguments
obj::NeuroAnalyzer.NEURO
bl::Tuple{Real, Real}=(0, 0)
: baseline is fromb[1]
tob[2]
seconds; ifbl
is greater than (0, 0), DC value is calculated as mean of theb[1]
tob[2]
seconds and subtracted from the signalblfirst::Bool=false
: if true, subtract the baseline segment prior to averaging
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.average_epochs!
— Functionaverage_epochs!(obj; <keyword arguments>)
Average EEG/MEG epochs. Non-EEG/MEG channels are removed. OBJ.header.recording[:data_type]
becomes erp
(for EEG) or erf
for MEG. First epoch is the ERP/ERF.
Arguments
obj::NeuroAnalyzer.NEURO
bl::Tuple{Real, Real}=(0, 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 signalblfirst::Bool=false
: if true, subtract the baseline segment prior to averaging
Returns
Nothing
NeuroAnalyzer.bpsplit
— Functionbpsplit(obj; <keyword arguments>)
Split signal into frequency bands using a FIR band-pass filter.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesorder::Int64=8
: number of taps for FIR band-pass filterw::Union{Nothing, AbstractVector, <:Real}=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
— Functioncbp(s; <keyword arguments>)
Perform convolution band-pass filtering.
Arguments
s::AbstractVector
pad::Int64
: pad withpad
zerosfrq::Real
: filter frequencyfs::Int64
: sampling rate
Returns
cbp::Vector{Float64}
cbp(obj; <keyword arguments>)
Perform convolution bandpass filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespad::Int64
: pad thesignal
withpad
zerosfrq::Real
: filter frequency
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.cbp!
— Functioncbp!(obj; <keyword arguments>)
Perform convolution bandpass filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespad::Int64
: pad thesignal
withpad
zerosfrq::Tuple{Real, Real}
: filter frequency
Returns
Nothing
NeuroAnalyzer.ch_zero
— Functionch_zero(obj)
Zero channels at the beginning and at the end.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.ch_zero!
— Functionch_zero!(obj)
Zero channels at the beginning and at the end.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
Nothing
NeuroAnalyzer.csd
— Functioncsd(obj; <keyword arguments>)
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!
— Functioncsd!(obj; <keyword arguments>)
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
Nothing
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
— Functioncw_trans(s; <keyword arguments>)
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::Matrix{Float64}
: CWT coefficients (by rows)
cw_trans(s; <keyword arguments>)
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)
cw_trans(obj; <keyword arguments>)
Perform continuous wavelet transformation (CWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel nameswt<: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_cwt
— Functiondenoise_cwt(s; <keyword arguments>)
Perform denoising using continuous wavelet transformation (iCWT).
Arguments
s::AbstractVector
fs::Int64
: sampling ratewt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletsnf::Real
: noise frequency in Hzw::Int64=5
: width (in Hz) of the area surrounding noise (fromnf - w
tonf + w
)type::Symbol=:nd
: inverse style type::pd
: PenroseDelta:nd
: NaiveDelta:df
: DualFrames
Returns
s_new::Vector{Float64}
denoise_cwt(s; <keyword arguments>)
Perform denoising using continuous wavelet transformation (CWT).
Arguments
s::AbstractArray
fs::Int64
: sampling ratewt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletsnf::Real
: noise frequency in Hzw::Int64=5
: width (in Hz) of the area surrounding noise (fromnf - w
tonf + w
)type::Symbol=:nd
: inverse style type::pd
: PenroseDelta:nd
: NaiveDelta:df
: DualFrames
Returns
s_new::Array{Float64, 3}
denoise_cwt(obj; <keyword arguments>)
Perform denoising using continuous wavelet transformation (CWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel nameswt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletsnf::Real
: noise frequency in Hzw::Int64=5
: width (in Hz) of the area surrounding noise (fromnf - w
tonf + w
)type::Symbol=:nd
: inverse style type::pd
: PenroseDelta:nd
: NaiveDelta:df
: DualFrames
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.denoise_cwt!
— Functiondenoise_cwt!(obj; <keyword arguments>)
Perform denoising using continuous wavelet transformation (CWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel nameswt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletsnf::Real
: noise frequency in Hzw::Int64=5
: width (in Hz) of the area surrounding noise (fromnf - w
tonf + w
)type::Symbol=:nd
: inverse style type::pd
: PenroseDelta:nd
: NaiveDelta:df
: DualFrames
Returns
Nothing
NeuroAnalyzer.denoise_dwt
— Functiondenoise_dwt(s; <keyword arguments>)
Perform denoising using 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 wavelets
Returns
s_new::Vector{Float64}
denoise_dwt(s; <keyword arguments>)
Perform denoising using 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 wavelets
Returns
s_new::Array{Float64, 3}
denoise_dwt(obj; <keyword arguments>)
Perform denoising using discrete wavelet transformation (DWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel nameswt<: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_dwt!
— Functiondenoise_dwt!(obj; <keyword arguments>)
Perform denoising using discrete wavelet transformation (DWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel nameswt<:DiscreteWavelet
: discrete wavelet, e.g.wt = wavelet(WT.haar)
, see Wavelets.jl documentation for the list of available wavelets
Returns
Nothing
NeuroAnalyzer.denoise_fft
— Functiondenoise_fft(s; <keyword arguments>)
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}
: denoised signalf_idx::BitVector
: index of components zeroed
denoise_fft(s; <keyword arguments>)
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
s_new::Array{Float64, 3}
denoise_fft(obj; <keyword arguments>)
Perform FFT denoising.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespad::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!
— Functiondenoise_fft!(obj; <keyword arguments>)
Perform FFT denoising.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespad::Int64=0
: number of zeros to add signal for FFTt::Int64=100
: PSD threshold for keeping frequency components
Returns
Nothing
NeuroAnalyzer.denoise_wien
— Functiondenoise_wien(s)
Perform Wiener deconvolution denoising.
Arguments
s::AbstractArray
Returns
s_new::AbstractArray
denoise_wien(obj; <keyword arguments>)
Perform Wiener deconvolution denoising.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.denoise_wien!
— Functiondenoise_wien!(obj; <keyword arguments>)
Perform Wiener deconvolution denoising.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Nothing
NeuroAnalyzer.derivative
— Functionderivative(s)
Return derivative (calculated using symmetric difference quotient) of a discrete signal of the same length.
Arguments
s::AbstractVector
Returns
s_new::AbstractVector
derivative(s)
Return derivative (calculated using symmetric difference quotient) of a discrete signal of the same length.
Arguments
s::AbstractArray
Returns
s_new::Array{Float64, 3}
derivative(obj; <keyword arguments>)
Return derivative (calculated using symmetric difference quotient) of a discrete signal of the same length.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.derivative!
— Functionderivative!(obj; <keyword arguments>)
Return derivative (calculated using symmetric difference quotient) of a discrete signal of the same length.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Nothing
NeuroAnalyzer.detect_powerline
— Functiondetect_powerline(s; <keyword arguments>)
Detect power line noise frequency.
Arguments
s::AbstractVector
fs::Int64
: sampling rate
Returns
noise_frq::Float64
: peak noise frequency in Hz
detect_powerline(obj)
Detect power line noise frequency.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
noise_frq::Array{Float64, 3}
: peak noise frequency in Hz
NeuroAnalyzer.detect_powerline!
— Functiondetect_powerline!(obj)
Detect power line noise frequency.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
Nothing
NeuroAnalyzer.detrend
— Functiondetrend(s; <keyword arguments>)
Perform piecewise detrending.
Arguments
s::AbstractVector
type::Symbol=:linear
::loess
: fit loess approximation and subtract it froms
:poly
: polynomial oforder
is subtracted froms
:mean
: the mean ofs
is subtracted froms
:constant
:offset
is subtracted froms
:ls
: the result of a linear least-squares fit tos
is subtracted froms
:linear
: linear trend (1st order polynomial) 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}
detrend(s; <keyword arguments>)
Perform piecewise detrending.
Arguments
s::AbstractArray
type::Symbol=:linear
: detrending method:loess
: fit loess approximation and subtract it froms
:poly
: polynomial oforder
is subtracted froms
:mean
: the mean ofs
is subtracted froms
:constant
:offset
is subtracted froms
:ls
: the result of a linear least-squares fit tos
is subtracted froms
:linear
: linear trend (1st order polynomial) 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}
detrend(obj; <keyword arguments>)
Perform piecewise detrending.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namestype::Symbol=:linear
: detrending method:loess
: fit loess approximation and subtract it froms
:poly
: polynomial oforder
is subtracted froms
:mean
: the mean ofs
is subtracted froms
:constant
:offset
is subtracted froms
:ls
: the result of a linear least-squares fit tos
is subtracted froms
:linear
: linear trend (1st order polynomial) 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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.detrend!
— Functiondetrend!(obj; <keyword arguments>)
Perform piecewise detrending.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namestype::Symbol=:linear
: detrending method:loess
: fit loess approximation and subtract it froms
:poly
: polynomial oforder
is subtracted froms
:mean
: the mean ofs
is subtracted froms
:constant
:offset
is subtracted froms
:ls
: the result of a linear least-squares fit tos
is subtracted froms
:linear
: linear trend (1st order polynomial) 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
Nothing
NeuroAnalyzer.downsample
— Functiondownsample(obj; <keyword arguments>)
Downsample.
Arguments
obj::NeuroAnalyzer.NEURO
new_sr::Int64
: new sampling rate
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.downsample!
— Functiondownsample!(obj; <keyword arguments>)
Downsample.
Arguments
obj::NeuroAnalyzer.NEURO
new_sr::Int64
: new sampling rate
Returns
Nothing
NeuroAnalyzer.dw_split
— Functiondw_split(obj; <keyword arguments>)
Split into bands using discrete wavelet transformation (DWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel namewt<: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, 3}
: bands from lowest to highest frequency (by rows)
NeuroAnalyzer.dw_trans
— Functiondw_trans(s; <keyword arguments>)
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::Matrix{Float64}
: DWT coefficients cAl, cD1, ..., cDl (by rows)
dw_trans(s; <keyword arguments>)
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)
dw_trans(obj; <keyword arguments>)
Perform discrete wavelet transformation (DWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel nameswt<: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.edit_montage
— Functionedit_montage(file_name; <keyword arguments>)
Edit montage file in the OS editor.
Arguments
file_name::String
: name of the file to load
Returns
Nothing
NeuroAnalyzer.fconv
— Functionfconv(s; <keyword arguments>)
Perform convolution in the frequency domain.
Arguments
s::AbstractVector
kernel::AbstractVector
norm::Bool=true
: normalize kernel to keep the post-convolution results in the same scale as the original data
Returns
s_new::Vector{ComplexF64}
: convoluted signal
fconv(s; <keyword arguments>)
Perform convolution in the frequency domain.
Arguments
s::AbstractArray
kernel::AbstractVector
: convolution kernelnorm::Bool=true
: normalize kernel to keep the post-convolution results in the same scale as the original data
Returns
s_new::Array{ComplexF64, 3}
: convoluted signal
fconv(obj; <keyword arguments>)
Perform convolution in the frequency domain.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel nameskernel::AbstractVector
: convolution kernelnorm::Bool=true
: normalize kernel to keep the post-convolution results in the same scale as the original data
Returns
s_new::Array{ComplexF64, 3}
: convoluted signal
NeuroAnalyzer.filter
— Functionfilter(obj; <keyword arguments>)
Apply filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesfprototype::Symbol
: filter prototype::butterworth
: IIR filter:chebyshev1
IIR filter:chebyshev2
IIR filter:elliptic
IIR filter:iirnotch
: second-order IIR notch filter:fir
: FIR filter:firls
: weighted least-squares FIR 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 (must be a pair of frequencies 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
filterw::Union{Nothing, AbstractVector, <:Real}=nothing
: window for:fir
filter (default is Hamming window, number of taps is calculated using Fred Harris' rule-of-thumb) or weights for:firls
filterpreview::Bool=false
: plot filter response
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.filter!
— Functionfilter!(obj; <keyword arguments>)
Apply filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesfprototype::Symbol
: filter prototype::butterworth
: IIR filter:chebyshev1
IIR filter:chebyshev2
IIR filter:elliptic
IIR filter:iirnotch
: second-order IIR notch filter:fir
: FIR filter:firls
: weighted least-squares FIR 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 (must be a pair of frequencies 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
filterw::Union{Nothing, AbstractVector, <:Real}=nothing
: window for:fir
filter (default is Hamming window, number of taps is calculated using Fred Harris' rule-of-thumb) or weights for:firls
filterpreview::Bool=false
: plot filter response
Returns
Nothing
NeuroAnalyzer.filter_apply
— Functionfilter_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_new::Vector{Float64}
NeuroAnalyzer.filter_create
— Functionfilter_create(; <keyword arguments>)
Create IIR or FIR filter.
Arguments
fprototype::Symbol
: filter prototype::butterworth
: IIR filter:chebyshev1
IIR filter:chebyshev2
IIR filter:elliptic
IIR filter:iirnotch
: second-order IIR notch filter:fir
: FIR filter:firls
: weighted least-squares FIR 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 (must be a pair of frequencies 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 filtersw::Union{Nothing, AbstractVector, <:Real}=nothing
: window for:fir
filter (default is Hamming window, number of taps is calculated using Fred Harris' rule-of-thumb) or weights for:firls
filter
Returns
flt::Union{Vector{Float64}, ZeroPoleGain{:z, ComplexF64, ComplexF64, Float64}, Biquad{:z, Float64}}
NeuroAnalyzer.filter_g
— Functionfilter_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
s_new::Vector{Float64}
filter_g(s; <keyword arguments>)
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_new::Array{Float64, 3}
filter_g(obj; <keyword arguments>)
Filter using Gaussian in the frequency domain.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespad::Int64=0
: number of zeros to addf::Real
: filter frequencygw::Real=5
: Gaussian width in Hz
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.filter_g!
— Functionfilter_g!(obj; <keyword arguments>)
Filter using Gaussian in the frequency domain.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespad::Int64=0
: number of zeros to addf::Real
: filter frequencygw::Real=5
: Gaussian width in Hz
Returns
Nothing
NeuroAnalyzer.filter_mavg
— Functionfilter_mavg(s; <keyword arguments>)
Filter using moving average 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}
filter_mavg(s; <keyword arguments>)
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}
filter_mavg(obj; <keyword arguments>)
Filter using moving average filter (with threshold).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesk::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
Source
- https://dsp.stackexchange.com/questions/9966/what-is-the-cut-off-frequency-of-a-moving-average-filter
NeuroAnalyzer.filter_mavg!
— Functionfilter_mavg!(obj; <keyword arguments>)
Filter using moving average filter (with threshold).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesk::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
Returns
Nothing
NeuroAnalyzer.filter_mmed
— Functionfilter_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}
filter_mmed(s; <keyword arguments>)
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}
filter_mmed(obj; <keyword arguments>)
Filter using moving median filter (with threshold).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesk::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
NeuroAnalyzer.filter_mmed!
— Functionfilter_mmed!(obj; <keyword arguments>)
Filter using moving median filter (with threshold).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesk::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
Nothing
NeuroAnalyzer.filter_poly
— Functionfilter_poly(s; <keyword arguments>)
Filter using polynomial filter.
Arguments
s::AbstractVector
order::Int64=8
: polynomial orderwindow::Int64=10
: window length
Returns
s_filtered::Vector{Float64}
filter_poly(s; <keyword arguments>)
Filter using polynomial filter.
Arguments
s::AbstractArray
order::Int64=8
: polynomial orderwindow::Int64=10
: window length
Returns
s_filtered::Array{Float64, 3}
: convoluted signal
filter_poly(obj; <keyword arguments>)
Filter using polynomial filter.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesorder::Int64=8
: polynomial orderwindow::Int64=10
: window length
Returns
obj_new::NeuroAnalyzer.NEURO
: convoluted signal
NeuroAnalyzer.filter_poly!
— Functionfilter_poly!(obj; <keyword arguments>)
Filter using polynomial filter.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesorder::Int64=8
: polynomial orderwindow::Int64=10
: window length
Returns
Nothing
NeuroAnalyzer.filter_sg
— Functionfilter_sg(s; <keyword arguments>)
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}
filter_sg(s; <keyword arguments>)
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
filter_sg(obj; <keyword arguments>)
Filter using Savitzky-Golay filter.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesorder::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
NeuroAnalyzer.filter_sg!
— Functionfilter_sg!(obj; <keyword arguments>)
Filter using Savitzky-Golay filter.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesorder::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
Nothing
NeuroAnalyzer.gh
— Functiongh(locs; <keyword arguments>)
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.ica_decompose
— Functionica_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))
ica_decompose(obj; <keyword arguments>)
Perform independent component analysis (ICA) using FastICA algorithm.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesn::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
— Functionica_reconstruct(; <keyword arguments>)
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
ica_reconstruct(obj; <keyword arguments>)
Reconstruct signals using embedded ICA components (:ic
and :ic_mw
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesic_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_new::NeuroAnalyzer.NEURO
ica_reconstruct(obj, ic, ic_mw; <keyword arguments>)
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{String, Vector{String}}
: channel name or list of channel names- `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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.ica_reconstruct!
— Functionica_reconstruct!(obj; <keyword arguments>)
Reconstruct signals using embedded ICA components (:ic
and :ic_mw
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names, 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
Returns
Nothing
ica_reconstruct!(obj, ic, ic_mw; <keyword arguments>)
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{String, Vector{String}}
: channel name or list of channel names, 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
Returns
Nothing
NeuroAnalyzer.ica_remove
— Functionica_remove(obj, ic, ic_mw; <keyword arguments>)
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{String, Vector{String}}
: channel name or list of channel names- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove
Returns
obj_new::NeuroAnalyzer.NEURO
ica_remove(obj, ic; <keyword arguments>)
Remove embedded ICA components (:ic
and :ic_mw
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.ica_remove!
— Functionica_remove!(obj, ic, ic_mw; <keyword arguments>)
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{String, Vector{String}}
: channel name or list of channel names, default is all channels- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove or keep
Returns
Nothing
ica_remove!(obj; <keyword arguments>)
Remove embedded ICA components (:ic
and :ic_mw
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names, default is all channels- `ic_idx::Union{Int64, Vector{Int64}, <:AbstractRange} - list of ICs to remove or keep
Returns
Nothing
NeuroAnalyzer.icw_trans
— Functionicw_trans(ct; <keyword arguments>)
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=:pd
: inverse style type::pd
: PenroseDelta:nd
: NaiveDelta:df
: DualFrames
Returns
s::AbstractArray
: reconstructed signal
NeuroAnalyzer.idw_trans
— Functionidw_trans(dwt_coefs; <keyword arguments>)
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::AbstractArray
: reconstructed signal
NeuroAnalyzer.intensity2od
— Functionintensity2od(s)
Convert NIRS intensity (RAW data) to optical density (OD).
Arguments
s::AbstractArray
Returns
od::AbstractArray
intensity2od(obj; <keyword arguments>)
Convert NIRS intensity (RAW data) to optical density (OD).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}=get_channel(obj, type="nirs_int"))
: list of channels, default is NIRS intensity channels
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.intensity2od!
— Functionintensity2od!(obj; <keyword arguments>)
Convert NIRS intensity (RAW data) to optical density (OD).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}=get_channel(obj, type="nirs_int"))
: list of channels, default is NIRS intensity channels
Returns
Nothing
NeuroAnalyzer.invert_polarity
— Functioninvert_polarity(obj; <keyword arguments>)
Invert polarity.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.invert_polarity!
— Functioninvert_polarity!(obj; <keyword arguments>)
Invert polarity.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel(s) to invert
Returns
Nothing
NeuroAnalyzer.lrinterpolate_channel
— Functionlrinterpolate_channel(obj; <keyword arguments>)
Interpolate channel using linear regression.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel to interpolateep::Int64
: epoch number(s) within to interpolateep_ref::Union{Int64, Vector{Int64}, AbstractRange}=setdiff(_c(nepochs(obj)), ep)
: reference epoch(s), default is all epochs except the interpolated one
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.lrinterpolate_channel!
— Functionlrinterpolate_channel!(obj; <keyword arguments>)
Interpolate channel using linear regression.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel to interpolateep::Int64
: epoch number(s) within to interpolateep_ref::Union{Int64, Vector{Int64}, AbstractRange}=setdiff(_c(nepochs(obj)), ep)
: reference epoch(s), default is all epochs except the interpolated one
Returns
Nothing
NeuroAnalyzer.mlinterpolate_channel
— Functionmlinterpolate_channel(obj; <keyword arguments>)
Interpolate channel using a machine-learning model.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel to interpolateep::Int64
: epoch number within to interpolateep_ref::Union{Int64, Vector{Int64}, AbstractRange}=setdiff(_c(nepochs(obj)), ep)
: reference epoch(s), default is all epochs except the interpolated onemodel<:MLJ.Model
: MLJ regressor model
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.mlinterpolate_channel!
— Functionmlinterpolate_channel!(obj; <keyword arguments>)
Interpolate channel using linear regression.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel to interpolateep::Int64
: epoch number within to interpolateep_ref::Union{Int64, Vector{Int64}, AbstractRange}=setdiff(_c(nepochs(obj)), ep)
: reference epoch(s), default is all epochs except the interpolated onemodel::T where T <: DataType
: MLJ regressor model
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.normalize
— Functionnormalize(s, n; <keyword arguments>)
Normalize.
Arguments
s::AbstractVector
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
: to inverse root: 1/sqrt(x):n
: in [0, n], default is [0, 1]; <keyword arguments>) .+ n1`:softmax
: using softmax function: exp(x_i) / sum(exp(x)):sigmoid
: using sigmoid function: 1 / 1 + exp(-x_i):mad
: by MAD:rank
: using tiedranks:none
Returns
normalized::AbstractVector
normalize(s, n; <keyword arguments>)
Normalize.
Arguments
s::AbstractArray
n::Real=1.0
bych::Bool=false
: if true, normalize each channel separatelymethod::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
: to inverse root: 1/sqrt(x):n
: in [0, n], default is [0, 1]; <keyword arguments>) .+ n1`:softmax
: using softmax function: exp(x_i) / sum(exp(x)):sigmoid
: using sigmoid function: 1 / 1 + exp(-x_i):none
Returns
sn::AbstractArray
normalize(obj; <keyword arguments>)
Normalize channel(s).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesmethod::Symbol
: method for normalization, seenormalize()
for detailsbych::Bool=false
: if true, normalize each channel separately
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.normalize!
— Functionnormalize!(obj; <keyword arguments>)
Normalize channel(s).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesmethod::Symbol
: method for normalization, seenormalize()
for detailsbych::Bool=false
: if true, normalize each channel separately
Returns
Nothing
NeuroAnalyzer.normalize_fisher
— Functionnormalize_fisher(s)
Normalize using Fisher z-transform. Converts uniform distribution into normal distribution.
Arguments
s::AbstractVector
Returns
sn::AbstractVector
normalize_fisher(s; <keyword arguments>)
Normalize using Fisher z-transform. Converts uniform distribution into normal distribution.
Arguments
s::AbstractArray
bych::Bool=false
: ignored
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_gauss
— Functionnormalize_gauss(s)
Normalize to Gaussian.
Arguments
s::AbstractVector
Returns
sn::AbstractVector
normalize_gauss(s; <keyword arguments>)
Normalize to Gaussian.
Arguments
s::AbstractArray
bych::Bool=false
: if true, normalize each channel separately
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_invroot
— Functionnormalize_invroot(s)
Normalize in inverse root (1/sqrt(x)).
Arguments
s::AbstractVector
Returns
sn::AbstractVector
normalize_invroot(s; <keyword arguments>)
Normalize in inverse root (1/sqrt(x)).
Arguments
s::AbstractArray
bych::Bool=false
: if true, normalize each channel separately
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_log
— Functionnormalize_log(s)
Normalize using log-transformation.
Arguments
s::AbstractVector
Returns
sn::AbstractVector
normalize_log(s; <keyword arguments>)
Normalize using log-transformation.
Arguments
s::AbstractArray
bych::Bool=false
: if true, normalize each channel separately
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_log10
— Functionnormalize_log10(s)
Normalize using log10-transformation.
Arguments
s::AbstractVector
Returns
sn::AbstractVector
normalize_log10(s; <keyword arguments>)
Normalize using log10-transformation.
Arguments
s::AbstractArray
bych::Bool=false
: if true, normalize each channel separately
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_mad
— Functionnormalize_mad(s)
Normalize by MAD.
Arguments
s::AbstractVector
Returns
sn::AbstractVector
normalize_mad(s; <keyword arguments>)
Arguments
s::AbstractArray
bych::Bool=false
: if true, normalize each channel separately
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_minmax
— Functionnormalize_minmax(s)
Normalize in [-1, +1]. If all elements are the same, they are normalized to +1.0.
Arguments
s::AbstractVector
Returns
sn::AbstractVector
NeuroAnalyzer.normalize_n
— Functionnormalize_n(s, n)
Normalize in [0, n], default is [0, +1].
Arguments
s::AbstractVector
n::Real=1.0
Returns
sn::AbstractVector
normalize_n(s, n; <keyword arguments>)
Normalize in [0, n], default is [0, +1].
Arguments
s::AbstractArray
n::Real=1.0
bych::Bool=false
: if true, normalize each channel separately
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_neg
— Functionnormalize_neg(s)
Normalize in [-∞, 0].
Arguments
s::AbstractVector
Returns
sn::AbstractVector
normalize_neg(s)
Normalize in [-∞, 0].
Arguments
s::AbstractArray
bych::Bool=false
: if true, normalize each channel separately
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_neglog
— Functionnormalize_neglog(s; <keyword arguments>)
Normalize to using -log-transformation.
Arguments
s::AbstractArray
bych::Bool=false
: ignored
Returns
sn::Vector{Float64}
NeuroAnalyzer.normalize_neglog10
— Functionnormalize_neglog10(s; <keyword arguments>)
Normalize using -log10-transformation.
Arguments
s::AbstractArray
bych::Bool=false
: ignored
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_perc
— Functionnormalize_perc(s)
Normalize in percentages.
Arguments
s::AbstractVector
Returns
sn::AbstractVector
normalize_perc(s; <keyword arguments>)
Normalize in percentages.
Arguments
s::AbstractArray
bych::Bool=false
: if true, normalize each channel separately
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_pos
— Functionnormalize_pos(s)
Normalize in [0, +∞].
Arguments
s::AbstractVector
Returns
sn::AbstractVector
normalize_pos(s; <keyword arguments>)
Normalize in [0, +∞].
Arguments
s::AbstractArray
bych::Bool=false
: if true, normalize each channel separately
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_rank
— Functionnormalize_rank(s)
Normalize using tiedranks.
Arguments
s::AbstractVector
Returns
sn::AbstractVector
normalize_rank(s; <keyword arguments>)
Normalize using tiedranks.
Arguments
s::AbstractArray
bych::Bool=false
: if true, normalize each channel separately
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_sigmoid
— Functionnormalize_sigmoid(s; <keyword arguments>)
Normalize using sigmoid function: 1 / (1 + e^-x_i)
Arguments
s::AbstractArray
bych::Bool=false
: ignored
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_softmax
— Functionnormalize_softmax(s; <keyword arguments>)
Softmax normalize: exp(x_i) / sum(exp(x))
Arguments
s::AbstractArray
bych::Bool=false
: ignored
Returns
sn::AbstractArray
NeuroAnalyzer.normalize_zscore
— Functionnormalize_zscore(s)
Normalize by z-score.
Arguments
s::AbstractVector
Returns
sn::AbstractVector
normalize_zscore(s; <keyword arguments>)
Arguments
s::AbstractArray
bych::Bool=false
: if true, normalize each channel separately
Returns
sn::AbstractArray
NeuroAnalyzer.normpower
— Functionnormpower(s)
Return a signal with normalized power (amplitudes divided by the root-mean-squared value of the entire signal).
Arguments
s::AbstractVector
Returns
s_new::Vector{Float64}
normpower(s)
Return a signal with normalized power (amplitudes divided by the root-mean-squared value of the entire signal).
Arguments
s::AbstractArray
Returns
s_new::Array{Float64, 3}
normpower(obj; <keyword arguments>)
Return a signal with normalized power (amplitudes divided by the root-mean-squared value of the entire signal).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.normpower!
— Functionnormpower!(obj; <keyword arguments>)
Return a signal with normalized power (amplitudes divided by the root-mean-squared value of the entire signal).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Nothing
NeuroAnalyzer.npl
— Functionnpl(obj)
Calculate non-phase-locked signal.
Arguments
obj::NeuroAnalyzer.NEURO
: must be ERP object
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.npl!
— Functionnpl!(obj)
Calculate non-phase-locked signal.
Arguments
obj::NeuroAnalyzer.NEURO
: must be ERP object
Returns
Nothing
NeuroAnalyzer.od2conc
— Functionod2conc(obj; <keyword arguments>)
Convert NIRS optical density (OD) to concentration (HbO, HbR, HbT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}=get_channel(obj, type="nirs_od"))
: list 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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.od2conc!
— Functionod2conc!(obj; <keyword arguments>)
Convert NIRS optical density (OD) to concentration (HbO, HbR, HbT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}=get_channel(obj, type="nirs_od"))
: list 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
Nothing
NeuroAnalyzer.pca_decompose
— Functionpca_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::Vector{Float64}
: PC meanpc_model::MultivariateStats.PCA{Float64}
: PC model
pca_decompose(obj; <keyword arguments>)
Calculate n
first Primary Components (PCs).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesn::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
— Functionpca_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}
pca_reconstruct(obj; <keyword arguments>)
Reconstruct signal using embedded PCA components (:pc
) and model (:pc_model
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
obj_new::NeuroAnalyzer.NEURO
pca_reconstruct(obj, pc, pc_model; <keyword arguments>)
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{String, Vector{String}}
: channel name or list of channel names
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.pca_reconstruct!
— Functionpca_reconstruct!(obj; <keyword arguments>)
Reconstruct signal using embedded PCA components (:pc
) and model (:pc_model
).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Nothing
pca_reconstruct!(obj, pc, pc_model; <keyword arguments>)
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{String, Vector{String}}
: channel name or list of channel names
Returns
Nothing
NeuroAnalyzer.plinterpolate
— Functionplinterpolate(s; <keyword arguments>)
Interpolate channel using planar interpolation.
Arguments
s::Matrix{Float64}
: values to plot (one value per channel)locs::DataFrame
: columns: channel, labels, locradius, loctheta, locx, locy, locz, locradiussph, locthetasph, locphi_sphch::Int64
: channel to interpolateimethod::Symbol=:sh
: interpolation method::sh
: Shepard:mq
: Multiquadratic:imq
: InverseMultiquadratic:tp
: ThinPlate:nn
: NearestNeighbour:ga
: Gaussian
nmethod::Symbol=:minmax
: method for normalization, seenormalize()
cart::Bool=false
: if true, use Cartesian coordinates, otherwise use polar coordinates for XY plane and spherical coordinates for XZ and YZ planesifactor::Int64=100
: interpolation quality
Returns
Named tuple containing:
int_s::Matrix{Float64}
: interpolated signalint_x::Vector{Float64}
: X-axis coordinatesint_y::Vector{Float64}
: Y-axis coordinates
NeuroAnalyzer.plinterpolate_channel
— Functionplinterpolate_channel(obj; <keyword arguments>)
Interpolate channel using planar interpolation.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel 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
ifactor::Int64=100
: interpolation quality
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.plinterpolate_channel!
— Functionplinterpolate_channel!(obj; <keyword arguments>)
Interpolate channel using planar interpolation.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel 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
)ifactor::Int64=100
: interpolation quality
Returns
Nothing
NeuroAnalyzer.reference_a
— Functionreference_a(obj; <keyword arguments>)
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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.reference_a!
— Functionreference_a!(obj; <keyword arguments>)
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
Nothing
NeuroAnalyzer.reference_avg
— Functionreference_avg(obj; <keyword arguments>)
Reference to averaged reference. Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
exclude_fpo::Bool=false
: exclude Fp1, Fp2 (due to eye blinks), O1, O2 (due to head movements) from CAR calculationexclude_current::Bool=false
: exclude current channel from CAR calculationaverage::Bool=true
: average reference channels prior to subtracting, otherwise add all reference channelsmed::Bool=false
: use median instead of meanweighted::Bool=false
: use weighted reference channels (weights depend on the distance from the current electrode)
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.reference_avg!
— Functionreference_avg!(obj; <keyword arguments>)
Reference to averaged reference. Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
exclude_fpo::Bool=false
: exclude Fp1, Fp2 (due to eye blinks), O1, O2 (due to head movements) from CAR calculationexclude_current::Bool=false
: exclude current channel from CAR mean calculationaverage::Bool=true
: average reference channels prior to subtracting, otherwise add all reference channelsmed::Bool=false
: use median instead of meanweighted::Bool=false
: use weighted reference channels (weights depend on the distance from the current electrode)
Returns
Nothing
NeuroAnalyzer.reference_ce
— Functionreference_ce(obj; <keyword arguments>)
Reference to common electrode(s). Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names used as reference; if multiple channels are specified, their average is used as the referencemed::Bool=false
: use median instead of mean
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.reference_ce!
— Functionreference_ce!(obj; <keyword arguments>)
Reference to common electrode(s). Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names used as reference; if multiple channels are specified, their average is used as the referencemed::Bool=false
: use median instead of mean
Returns
Nothing
NeuroAnalyzer.reference_custom
— Functionreference_custom(obj; <keyword arguments>)
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="longitudinal-BIP"
: name of the montage
Returns
obj_new::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"], "transverse-BIP"
- bipolar longitudinal: ["Fz-Cz", "Cz-Pz", "Pz-Oz", "Fp1-F7", "Fp1-F3", "F7-T7", "F7-T3", "T7-P7", "T7-T5", "T3-P7", "T3-T5", "P7-O1", "T5-O1", "F3-C3", "C3-P3", "P3-O1", "Fp2-F8", "F8-T8", "F8-T4", "T8-P8", "T8-T6", "T4-P8", "T4-T6", "T6-O2", "P8-O2", "Fp2-F4", "F4-C4", "C4-P4", "P4-O2"], "longitudinal-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"], "longitudinal-BIP"
- bipolar longitudinal: ["FPz-Fz", "Fz-Cz", "Cz-Pz", "Pz-Oz", "Fp1-F7", "Fp1-F3", "F7-T7", "F7-T3", "T7-P7", "T7-T5", "T3-P7", "T3-T5", "P7-O1", "T5-O1", "F3-C3", "C3-P3", "P3-O1", "Fp2-F8", "F8-T8", "F8-T4", "T8-P8", "T8-T6", "T4-P8", "T4-T6", "T6-O2", "P8-O2", "Fp2-F4", "F4-C4", "C4-P4", "P4-O2"], "longitudinal-BIP"
NeuroAnalyzer.reference_custom!
— Functionreference_custom!(obj; <keyword arguments>)
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 ||"
Returns
Nothing
NeuroAnalyzer.reference_m
— Functionreference_m(obj; <keyword arguments>)
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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.reference_m!
— Functionreference_m!(obj; <keyword arguments>)
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
Nothing
NeuroAnalyzer.reference_plap
— Functionreference_plap(obj; <keyword arguments>)
Reference using planar Laplacian (using nn
adjacent electrodes). Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
nn::Int64=4
: usenn
adjacent electrodesweighted::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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.reference_plap!
— Functionreference_plap!(obj; <keyword arguments>)
Reference using planar Laplacian (using nn
adjacent electrodes). Only signal channels are processed.
Arguments
obj::NeuroAnalyzer.NEURO
nn::Int64=4
: usenn
adjacent electrodesweighted::Bool=false
: use distance weights; use mean of nearest channels if falsemed::Bool=false
: use median instead of mean
Returns
Nothing
NeuroAnalyzer.remove_cwt
— Functionremove_cwt(s, t; <keyword arguments>)
Remove artifacts using continuous wavelet transformation (CWT).
Arguments
s::AbstractVector
t::AbstractVector
: time pointsfs::Int64
: sampling ratewt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletstseg::Tuple{Real, Real}
: artifact time locationfseg::Tuple{Real, Real}
: artifact frequency locationtype::Symbol=:nd
: inverse style type::pd
: PenroseDelta:nd
: NaiveDelta:df
: DualFrames
Returns
s_new::Vector{Float64}
remove_cwt(obj; <keyword arguments>)
Remove artifacts using continuous wavelet transformation (CWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel nameep::Int64
wt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletstseg::Tuple{Real, Real}
: artifact time locationfseg::Tuple{Real, Real}
: artifact frequency locationtype::Symbol=:nd
: inverse style type::pd
: PenroseDelta:nd
: NaiveDelta:df
: DualFrames
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.remove_cwt!
— Functionremove_cwt!(obj; <keyword arguments>)
Remove artifacts using continuous wavelet transformation (CWT).
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel nameep::Int64
wt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletstseg::Tuple{Real, Real}
: artifact time locationfseg::Tuple{Real, Real}
: artifact frequency locationtype::Symbol=:nd
: inverse style type::pd
: PenroseDelta:nd
: NaiveDelta:df
: DualFrames
NeuroAnalyzer.remove_dc
— Functionremove_dc(s, n)
Remove mean value (DC offset).
Arguments
s::AbstractVector
n::Union{Int64, Tuple{Int64, Int64}}=0
: ifn
is greater than 0, mean value is calculated for the firstn
samples or ifn
is a tuple greater than (0, 0), mean value is calculated forn[1]
ton[2]
samples
Returns
s_new::Vector{Float64}
remove_dc(s, n)
Remove mean value (DC offset).
Arguments
s::AbstractArray
n::Union{Int64, Tuple{Int64, Int64}}=0
: ifn
is greater than 0, mean value is calculated for the firstn
samples or ifn
is a tuple greater than (0, 0), mean value is calculated forn[1]
ton[2]
samples
Returns
s::Array{Float64, 3}
remove_dc(obj; <keyword arguments>)
Remove mean value (DC offset).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesn::Union{Int64, Tuple{Int64, Int64}}=0
: ifn
is greater than 0, mean value is calculated for the firstn
samples or ifn
is a tuple greater than (0, 0), mean value is calculated forn[1]
ton[2]
samples
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.remove_dc!
— Functionremove_dc!(obj; <keyword arguments>)
Remove mean value (DC offset).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesn::Union{Int64, Tuple{Int64, Int64}}=0
: ifn
is greater than 0, mean value is calculated for the firstn
samples or ifn
is a tuple greater than (0, 0), mean value is calculated forn[1]
ton[2]
samples
Returns
Nothing
NeuroAnalyzer.remove_pops
— Functionremove_pops(s; <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
s::AbstractVector
r::Int64=20
: detection segment length; pops are checked withinpop_loc - r:pop_loc + r
samplesrepair::Bool=true
: recover the segment iftrue
Returns
Named tuple containing:
s::Vector{Float64}
pop_loc::Int64
: sample number in the signall_seg::Int64
: length of segment before the pop that starts when signal crosses 0r_seg::Int64
: length of segment after the pop that ends when signal crosses 0
remove_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{String, Vector{String}}
: channel name or list of channel namesrepair::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_loc - r):(pop_loc + 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!
— Functionremove_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{String, Vector{String}}
: channel name or list of channel namesrepair::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_loc - r:pop_loc + 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
— Functionremove_powerline(obj; <keyword arguments>)
Remove power line noise and its peaks above power line frequency.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespl_frq::Real=obj.header.recording[:line_frequency]
: power line frequency, default is read from the OBJ headermethod::Symbol=:iir
::iir
: use IIR filter
pr::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
df::DataFrame
: list of peaks detected
NeuroAnalyzer.remove_powerline!
— Functionremove_powerline!(obj; <keyword arguments>)
Remove power line noise and harmonics.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespl_frq::Real=obj.header.recording[:line_frequency]
: power line frequency, default is read from the OBJ headermethod::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
df::DataFrame
: list of peaks detected
NeuroAnalyzer.resample
— Functionresample(s; <keyword arguments>)
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}
resample(s; <keyword arguments>)
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}
resample(obj; <keyword arguments>)
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!
— Functionresample!(obj; <keyword arguments>)
Resample (up- or down-sample).
Arguments
obj::NeuroAnalyzer.NEURO
new_sr::Int64
: new sampling rate
Returns
Nothing
NeuroAnalyzer.scale
— Functionscale(obj; <keyword arguments>)
Multiply channel(s) by factor
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesfactor::Real
: signal is multiplied byfactor
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.scale!
— Functionscale!(obj; <keyword arguments>)
Multiply channel(s) by factor
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesfactor::Real
: signal is multiplied byfactor
Returns
Nothing
NeuroAnalyzer.sort_epochs
— Functionsort_epochs(obj; <keyword arguments>)
Sort epochs.
Arguments
obj::NeuroAnalyzer.NEURO
s::Vector{Int64}
: vector of sorting indices
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.sort_epochs!
— Functionsort_epochs(obj; <keyword arguments>)
Sort epochs.
Arguments
obj::NeuroAnalyzer.NEURO
s::Vector{Int64}
: vector of sorting indices
Returns
Nothing
NeuroAnalyzer.standardize
— Functionstandardize(s)
Standardize channels.
Arguments
s::AbstractArray
Returns
s_new::Array{Float64, 3}
:scaler::Vector{ZScoreTransform{Float64, Vector{Float64}}}
standardize(obj; <keyword arguments>)
Standardize channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
obj_new::NeuroAnalyzer.NEURO
scaler::Vector{ZScoreTransform{Float64, Vector{Float64}}}
NeuroAnalyzer.standardize!
— Functionstandardize!(obj; <keyword arguments>)
Standardize channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
scaler::Vector{ZScoreTransform{Float64, Vector{Float64}}}
NeuroAnalyzer.taper
— Functiontaper(s; <keyword arguments>)
Taper the signal.
Arguments
s::AbstractVector
t::Vector{<:Real}
Returns
s_new::Vector{Float64}
taper(s; <keyword arguments>)
Taper the signal.
Arguments
s::AbstractArray
t::Vector{<:Real}
Returns
s_new::Array{Float64, 3}
taper(obj; <keyword arguments>)
Taper the signal.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namest::Vector{<:Real}
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.taper!
— Functiontaper!(obj; <keyword arguments>)
Taper the signal.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namest::Vector{<:Real}
Returns
Nothing
NeuroAnalyzer.tconv
— Functiontconv(s; <keyword arguments>)
Performs convolution in the time domain.
Arguments
s::AbstractVector
kernel::AbstractVector
Returns
s_new::Vector{Float64}
: convoluted signal
tconv(s; <keyword arguments>)
Perform convolution in the time domain.
Arguments
s::AbstractArray
kernel::AbstractVector
: convolution kernel
Returns
s_new::Array{Float64, 3}
: convoluted signal
tconv(obj; <keyword arguments>)
Perform convolution in the time domain.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel nameskernel::AbstractVector
: convolution kernel
Returns
Union{NeuroAnalyzer.NEURO, Array{ComplexF64, 3}}
: convoluted signal
NeuroAnalyzer.tconv!
— Functiontconv!(obj; <keyword arguments>)
Perform convolution in the time domain.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel nameskernel::AbstractVector
: convolution kernel
NeuroAnalyzer.upsample
— Functionupsample(obj; <keyword arguments>)
Upsample.
Arguments
obj::NeuroAnalyzer.NEURO
new_sr::Int64
: new sampling rate
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.upsample!
— Functionupsample!(obj; <keyword arguments>)
Upsample.
Arguments
obj::NeuroAnalyzer.NEURO
new_sr::Int64
: new sampling rate
Returns
Nothing
NeuroAnalyzer.wbp
— Functionwbp(s; <keyword arguments>)
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}
wbp(s; <keyword arguments>)
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}
wbp(obj; <keyword arguments>)
Perform wavelet band-pass filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespad::Int64
: pad thesignal
withpad
zerosfrq::Real
: filter frequencyncyc::Int64=6
: number of cycles for Morlet wavelet
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.wbp!
— Functionwbp!(obj; <keyword arguments>)
Perform wavelet band-pass filtering.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespad::Int64
: pad thesignal
withpad
zerosfrq::Real
: filter frequencyncyc::Int64=6
: number of cycles for Morlet wavelet
Returns
Nothing
Locs
NeuroAnalyzer.add_locs
— Functionadd_locs(obj; <keyword arguments>)
Add electrode positions from locs
.
Electrode locations:
labels
channel labelloc_theta
polar angleloc_radius
polar radiusloc_x
Cartesian xloc_y
Cartesian yloc_z
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!
— Functionadd_locs!(obj; <keyword arguments>)
Load electrode positions from locs
and return NeuroAnalyzer.NEURO
object attached with channel locations data.
Electrode locations:
labels
: channel labelloc_theta
: polar angleloc_radius
: polar radiusloc_x
: Cartesian Xloc_y
: Cartesian Yloc_z
: Cartesian Zloc_radius_sph
: spherical radiusloc_theta_sph
: spherical horizontal angleloc_phi_sph
: spherical azimuth angle
Arguments
obj::NeuroAnalyzer.NEURO
locs::DataFrame
Returns
Nothing
NeuroAnalyzer.cart2pol
— Functioncart2pol(x, y)
Convert Cartesian coordinates to polar.
Arguments
x::Real
y::Real
Returns
radius::Float64
theta::Float64
NeuroAnalyzer.cart2sph
— Functioncart2sph(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.edit_locs
— Functionedit_locs(obj; <keyword arguments>)
Edit electrode.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel 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 angleradius::Union{Real, Nothing}=nothing
: polar radiustheta_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_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.edit_locs!
— Functionedit_locs!(obj; <keyword arguments>)
Edit electrode.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: 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 angleradius::Union{Real, Nothing}=nothing
: polar radiustheta_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
Nothing
NeuroAnalyzer.locs_cart2pol
— Functionlocs_cart2pol(locs)
Convert Cartesian coordinates to polar.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_cart2pol!
— Functionlocs_cart2pol!(locs)
Convert Cartesian coordinates to polar.
Arguments
locs::DataFrame
Returns
Nothing
NeuroAnalyzer.locs_cart2sph
— Functionlocs_cart2sph(locs)
Convert Cartesian coordinates to spherical.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_cart2sph!
— Functionlocs_cart2sph!(locs)
Convert Cartesian coordinates to spherical.
Arguments
locs::DataFrame
Returns
Nothing
NeuroAnalyzer.locs_center
— Functionlocs_center(locs; <keyword arguments>)
Center locs at (0, 0).
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_center!
— Functionlocs_center!(locs; <keyword arguments>)
Center locs at X=0.
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
Nothing
NeuroAnalyzer.locs_details
— Functionlocs_details(obj; <keyword arguments>)
Return channel location details.
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel nameout::Bool=true
: if true, print details
Returns
Named tuple containing:
label::String
: location labeltheta_pl::Float64
: polar angleradius_pl::Float64
: polar radiusx::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.locs_flipx
— Functionlocs_flipx(locs; <keyword arguments>)
Flip channel locations along x axis.
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_flipx!
— Functionlocs_flipx!(locs; <keyword arguments>)
Flip channel locations along x axis.
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
Nothing
NeuroAnalyzer.locs_flipy
— Functionlocs_flipy(locs; <keyword arguments>)
Flip channel locations along y axis.
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_flipy!
— Functionlocs_flipy!(locs; <keyword arguments>)
Flip channel locations along y axis.
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
Nothing
NeuroAnalyzer.locs_flipz
— Functionlocs_flipz(locs; <keyword arguments>)
Flip channel locations along z axis.
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_flipz!
— Functionlocs_flipz!(locs; <keyword arguments>)
Flip channel locations along z axis.
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
Nothing
NeuroAnalyzer.locs_generate
— Functionlocs_generate(locs)
Generate spherical coordinates according to 10/10 system.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
locs_generate(obj)
Generate spherical coordinates according to 10/5 system.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.locs_generate!
— Functionlocs_generate!(locs)
Generate spherical coordinates according to 10/5 system.
Arguments
locs::DataFrame
Returns
Nothing
locs_generate!(obj)
Generate spherical coordinates according to 10/5 system.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
Nothing
NeuroAnalyzer.locs_normalize
— Functionlocs_normalize(locs; <keyword arguments>)
Normalize channel locations to fit the unit sphere.
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_normalize!
— Functionlocs_normalize!(locs; <keyword arguments>)
Normalize channel locations to fit the unit sphere.
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
Nothing
NeuroAnalyzer.locs_pol2cart
— Functionlocs_pol2cart(locs)
Convert polar coordinates to Cartesian.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_pol2cart!
— Functionlocs_pol2cart!(locs)
Convert polar coordinates to Cartesian.
Arguments
locs::DataFrame
Returns
Nothing
NeuroAnalyzer.locs_pol2sph
— Functionlocs_pol2sph(locs)
Convert polar coordinates to spherical.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_pol2sph!
— Functionlocs_pol2sph!(locs)
Convert polar coordinates to spherical.
Arguments
locs::DataFrame
Returns
Nothing
NeuroAnalyzer.locs_rotx
— Functionlocs_rotx(locs; <keyword arguments>)
Rotate channel locations around the X axis (in the YZ-plane).
Arguments
locs::DataFrame
a::Real
: angle of rotation (in degrees); positive angle rotates anti-clockwisepolar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_rotx!
— Functionlocs_rotx!(locs; <keyword arguments>)
Rotate channel locations around the X axis (in the YZ-plane).
Arguments
locs::DataFrame
a::Real
: angle of rotation (in degrees); positive angle rotates anti-clockwisepolar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
Nothing
NeuroAnalyzer.locs_roty
— Functionlocs_roty(locs; <keyword arguments>)
Rotate channel locations around the Y axis (in the XZ-plane).
Arguments
locs::DataFrame
a::Real
: angle of rotation (in degrees); positive angle rotates clockwisepolar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_roty!
— Functionlocs_roty!(locs; <keyword arguments>)
Rotate channel locations around the Y axis (in the XZ-plane).
Arguments
locs::DataFrame
a::Real
: angle of rotation (in degrees); positive angle rotates clockwisepolar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
Nothing
NeuroAnalyzer.locs_rotz
— Functionlocs_rotz(locs; <keyword arguments>)
Rotate channel locations around the Z axis.
Arguments
locs::DataFrame
a::Real
: angle of rotation (in degrees); positive angle rotates anti-clockwisepolar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_rotz!
— Functionlocs_rotz!(locs; <keyword arguments>)
Rotate channel locations in the xy-plane.
Arguments
locs::DataFrame
a::Real
: angle of rotation (in degrees); positive angle rotates anti-clockwisepolar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
Nothing
NeuroAnalyzer.locs_scale
— Functionlocs_scale(locs; <keyword arguments>)
Scale channel locations.
Arguments
locs::DataFrame
r::Real
: scaling factorpolar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_scale!
— Functionlocs_scale!(locs, r, polar, cart, spherical)
Scale channel locations.
Arguments
locs::DataFrame
r::Real
: scaling factorpolar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
Nothing
NeuroAnalyzer.locs_sph2cart
— Functionlocs_sph2cart(locs)
Convert spherical coordinates to Cartesian.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_sph2cart!
— Functionlocs_sph2cart!(locs)
Convert spherical coordinates to Cartesian.
Arguments
locs::DataFrame
Returns
Nothing
NeuroAnalyzer.locs_sph2pol
— Functionlocs_sph2pol(locs)
Convert spherical coordinates to polar.
Arguments
locs::DataFrame
Returns
locs_new::DataFrame
NeuroAnalyzer.locs_sph2pol!
— Functionlocs_sph2pol!(locs)
Convert Cartesian coordinates to polar.
Arguments
locs::DataFrame
Returns
Nothing
NeuroAnalyzer.locs_swapxy
— Functionlocs_swapxy(locs; <keyword arguments>)
Swap channel locations x and y axes.
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.locs_swapxy!
— Functionlocs_swapxy!(locs; <keyword arguments>)
Swap channel locations x and y axes.
Arguments
locs::DataFrame
polar::Bool=true
: modify polar coordinatescart::Bool=true
: modify Cartesian coordinatesspherical::Bool=true
: modify spherical coordinates
Returns
Nothing
NeuroAnalyzer.pol2cart
— Functionpol2cart(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.pol2sph
— Functionpol2sph(radius, theta)
Convert polar coordinates to spherical.
Arguments
radius::Real
: polar radius, the distance from the origin to the point, in degreestheta::Real
: polar angle
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.sph2cart
— Functionsph2cart(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.sph2pol
— Functionsph2pol(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::Real
: polar radius, the distance from the origin to the pointtheta::Real
: polar horizontal angle, the angle in the xy plane with respect to the x axis, in degrees
Analyze
NeuroAnalyzer.acor
— Functionacor(s; <keyword arguments>)
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 is-l:l
demean::Bool=true
: demean signal before computing auto-correlationbiased::Bool=true
: calculate biased or unbiased autocovariancemethod::Symbol=:sum
: method of calculating auto-correlation::sum
:acf = Σ(s[1:end - l] .* s[1+l:end]) ./ var(s)
:cor
:acf = cor(s[1:end - l], s[1+l:end])
,biased
value is ignored:stat
: use StatsBaseautocor()
,biased
value is ignored
Returns
ac::Array{Float64, 3}
acor(s; <keyword arguments>)
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 is-l:l
demean::Bool=true
: demean signal before computing auto-correlationbiased::Bool=true
: calculate biased or unbiased autocovariancemethod::Symbol=:sum
: method of calculating auto-correlation::sum
:acf = Σ(s[1:end - l] .* s[1+l:end]) ./ var(s)
:cor
:acf = cor(s[1:end - l], s[1+l:end])
,biased
value is ignored:stat
: use StatsBaseautocor()
,biased
value is ignored
Returns
ac::Array{Float64, 3}
acor(s; <keyword arguments>)
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 is-l:l
demean::Bool=true
: demean signal before computing auto-correlationbiased::Bool=true
: calculate biased or unbiased autocovariancemethod::Symbol=:sum
: method of calculating auto-correlation::sum
:acf = Σ(s[1:end - l] .* s[1+l:end]) ./ var(s)
:cor
:acf = cor(s[1:end - l], s[1+l:end])
,biased
value is ignored:stat
: use StatsBaseautocor()
,biased
value is ignored
Returns
ac::Array{Float64, 3}
acor(obj; <keyword arguments>)
Calculate auto-correlation. For ERP return trial-averaged auto-correlation.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesl::Real=1
: lags range is-l:l
demean::Bool=true
: demean signal before computing auto-correlationbiased::Bool=true
: calculate biased or unbiased autocovariancemethod::Symbol=:sum
: method of calculating auto-correlation::sum
:acf = Σ(s[1:end - l] .* s[1+l:end]) ./ var(s)
:cor
:acf = cor(s[1:end - l], s[1+l:end])
,biased
value is ignored:stat
: use StatsBaseautocor()
,biased
value is ignored
Returns
Named tuple containing:
ac::Array{Float64, 3}
l::Vector{Float64}
: lags [s]
NeuroAnalyzer.acov
— Functionacov(s; <keyword arguments>)
Calculate autocovariance.
Arguments
s::AbstractVector
l::Int64=round(Int64, min(size(s[1, :, 1], 1) - 1, 10 * log10(size(s[1, :, 1], 1))))
: lags range is-l:l
demean::Bool=true
: demean signal before computing autocovariancebiased::Bool=true
: calculate biased or unbiased autocovariancemethod::Symbol=:sum
: method of calculating autocovariance::sum
:acf = Σ(s[1:end - l] .* s[1+l:end])
:cov
:acf = cov(s[1:end - l], s[1+l:end])
:stat
: use StatsBaseautocov()
,biased
value is ignored
Returns
ac::Array{Float64, 3}
acov(s; <keyword arguments>)
Calculate autocovariance.
Arguments
s::AbstractMatrix
l::Int64=round(Int64, min(size(s[1, :, 1], 1) - 1, 10 * log10(size(s[1, :, 1], 1))))
: lags range is-l:l
demean::Bool=true
: demean signal before computing autocovariancebiased::Bool=true
: calculate biased or unbiased autocovariancemethod::Symbol=:sum
: method of calculating autocovariance::sum
:acf = Σ(s[1:end - l] .* s[1+l:end])
:cor
:acf = cov(s[1:end - l], s[1+l:end])
:stat
: use StatsBaseautocor()
,biased
value is ignored
Returns
ac::Array{Float64, 3}
acov(s; <keyword arguments>)
Calculate autocovariance.
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 autocovariancebiased::Bool=true
: calculate biased or unbiased autocovariancemethod::Symbol=:sum
: method of calculating autocovariance::sum
:acf = Σ(s[1:end - l] .* s[1+l:end])
:cor
:acf = cov(s[1:end - l], s[1+l:end])
:stat
: use StatsBaseautocor()
,biased
value is ignored
Returns
ac::Array{Float64, 3}
acov(obj; <keyword arguments>)
Calculate autocovariance. For ERP return trial-averaged autocovariance.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesl::Int64=1
: lags range is0:lag
[samples]demean::Bool=true
: demean signal before computing autocovariancebiased::Bool=true
: calculate biased or unbiased autocovariancemethod::Symbol=:sum
: method of calculating autocovariance::sum
:acf = Σ(s[1:end - l] .* s[1+l:end])
:cor
:acf = cov(s[1:end - l], s[1+l:end])
:stat
: use StatsBaseautocor()
,biased
value is ignored
Returns
Named tuple containing:
ac::Array{Float64, 3}
l::Vector{Float64}
: lags [s]
NeuroAnalyzer.amp
— Functionamp(s)
Calculate amplitudes.
Arguments
s::AbstractVector
Returns
Named tuple containing:
p::Float64
: peak amplituder::Float64
: RMS amplitudep2p::Float64
: peak-to-peak amplitudesemi_p2p::Float64
: half of the peak-to-peak amplitudemsa::Float64
: mean square amplitudermsa::Float64
: root mean square amplitudeenergy::Float64
: total signal energyrms::Float64
: root mean square
amp(s)
Calculate amplitudes.
Arguments
s::AbstractArray
Returns
Named tuple containing:
p::Matrix{Float64}
: peak amplituder::Matrix{Float64}
: RMS amplitudep2p::Matrix{Float64}
: peak-to-peak amplitudesemi_p2p::Matrix{Float64}
: half of the peak-to-peak amplitudemsa::Matrix{Float64}
: mean square amplitudermsa::Matrix{Float64}
: root mean square amplitudeenergy::Matrix{Float64}
: total signal energy
amp(obj; <keyword arguments>)
Calculate amplitudes.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Named tuple containing:
p::Matrix{Float64}
: peak amplituder::Matrix{Float64}
: RMS amplitudep2p::Matrix{Float64}
: peak-to-peak amplitudesemi_p2p::Matrix{Float64}
: half of the peak-to-peak amplitudemsa::Matrix{Float64}
: mean square amplitudermsa::Matrix{Float64}
: root mean square amplitudeenergy::Matrix{Float64}
: total signal energy
NeuroAnalyzer.amp_at
— Functionamp_at(obj; <keyword arguments>)
Calculate amplitude at given time.
Arguments
obj::NeuroAnalyzer.NEURO
t::Real
: time in seconds
Returns
p::Matrix{Float64}
: amplitude for each channel per epoch
NeuroAnalyzer.ampdiff
— Functionampdiff(s; <keyword arguments>)
Calculate amplitude difference between each channel and mean amplitude of reference channels.
Arguments
s::AbstractArray
ch::Union{Int64, Vector{Int64}}=size(s, 1)
: index of reference channels, default is all channels except the analyzed one
Returns
ad::Array{Float64, 3}
ampdiff(obj; <keyword arguments>)
Calculate amplitude difference between each channel and mean amplitude of reference channels.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: index of reference channels
Returns
ad::Array{Float64, 3}
NeuroAnalyzer.avgamp_at
— Functionavgamp_at(obj; <keyword arguments>)
Calculate average amplitude at given time segment.
Arguments
obj::NeuroAnalyzer.NEURO
t::Tuple{Real, Real}
: time segment in seconds
Returns
p::Matrix{Float64}
: mean amplitude for each channel per epoch
NeuroAnalyzer.axc2frq
— Functionaxc2frq(c, l)
Detect peaks in auto-/cross- correlation/covariance and transform them into frequencies.
Arguments
c::AbstractVector
: auto-/cross- correlation/covariance valuesl::AbstractVector
: lags
Returns
frq::Vector{Float64}
: list of frequencies dominating in the auto-/cross- correlation/covariance
NeuroAnalyzer.band_asymmetry
— Functionband_asymmetry(obj; <keyword arguments>)
Calculate band asymmetry: ln(channel 1 band power) - ln(channel 2 band power).
Arguments
obj::NeuroAnalyzer.NEURO
ch1::Union{String, Vector{String}}
: list of channels, e.g. left frontal channelsch2::Union{String, Vector{String}}
: list of channels, e.g. right frontal channelsfrq_lim::Tuple{Real, Real}
: lower and upper frequency boundsmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
ba::Float64
: band asymmetryba_norm::Float64
: normalized band asymmetry
NeuroAnalyzer.band_mpower
— Functionband_mpower(s; <keyword arguments>)
Calculate mean and maximum band power and its frequency.
Arguments
s::AbstractVector
fs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}
: lower and upper frequency boundsmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
mbp::Float64
: mean band powermaxfrq::Float64
: frequency of maximum band powermaxbp::Float64
: power at maximum band frequency
band_mpower(s; <keyword arguments>)
Calculate absolute band power between two frequencies.
Arguments
s::AbstractArray
fs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}
: lower and upper frequency boundsmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
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
band_mpower(obj; <keyword arguments>)
Calculate mean and maximum band power and its frequency.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesfrq_lim::Tuple{Real, Real}
: lower and upper frequency boundsmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
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
— Functionband_power(s; <keyword arguments>)
Calculate absolute band power between two frequencies.
Arguments
s::AbstractVector
fs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}
: lower and upper frequency boundsmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
bp::Float64
: band power
band_power(s; <keyword arguments>)
Calculate absolute band power between two frequencies.
Arguments
s::AbstractArray
fs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}
: lower and upper frequency boundsmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
bp::Matrix{Float64}
: band power
band_power(obj; <keyword arguments>)
Calculate absolute band power between two frequencies.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesfrq_lim::Tuple{Real, Real}
: lower and upper frequency boundsmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
bp::Matrix{Float64}
: band power
NeuroAnalyzer.coherence
— Functioncoherence(s1, s2; <keyword arguments>)
Calculate coherence and MSC (magnitude-squared coherence).
Arguments
s1::AbstractVector
s2::AbstractVector
method::Symbol=:mt
: method used to calculate CPSD::mt
: multi-tapered cross-power spectra:fft
: fast Fourier transformation
fs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}=(0, fs / 2)
: frequency boundsdemean::Bool=false
: if true, the channel-wise mean will be subtracted from the input signals before the cross spectral powers are computednt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning window
Returns
Named tuple containing:
coh::Vector{Float64}
: coherencemscoh::Vector{Float64}
: magnitude-squared coherencef::Vector{Float64}
: frequencies
coherence(s1, s2; <keyword arguments>)
Calculate coherence and MSC (magnitude-squared coherence).
Arguments
s1::AbstractArray
s2::AbstractArray
method::Symbol=:mt
: method used to calculate CPSD::mt
: multi-tapered cross-power spectra:fft
: fast Fourier transformation
fs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}=(0, fs / 2)
: frequency boundsdemean::Bool=false
: if true, the channel-wise mean will be subtracted from the input signals before the cross spectral powers are computednt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning window
Returns
coh::Array{Float64, 3}
: coherencemscoh::Array{Float64, 3}
: magnitude-squared coherencef::Vector{Float64}
: frequencies
coherence(obj1, obj2; <keyword arguments>)
Calculate coherence and MSC (magnitude-squared coherence).
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{String, Vector{String}}
: list of channelsch2::Union{String, Vector{String}}
: list of channelsep1::Union{Int64, Vector{Int64}, AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, AbstractRange}=_c(nepochs(obj2))
: default use all epochsmethod::Symbol=:mt
: method used to calculate CPSD::mt
: multi-tapered cross-power spectra:fft
: fast Fourier transformation
fs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}=(0, fs / 2)
: frequency boundsdemean::Bool=false
: if true, the channel-wise mean will be subtracted from the input signals before the cross spectral powers are computednt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning window
Returns
coh::Array{Float64, 3}
: coherencemscoh::Array{Float64, 3}
: magnitude-squared coherencef::Vector{Float64}
: frequencies
NeuroAnalyzer.corm
— Functioncorm(s; <keyword arguments>)
Calculate correlation matrix of s * s'
.
Arguments
s::AbstractVector
norm::Bool
: normalize correlation matrix
Returns
cm::Matrix{Float64}
corm(s1, s2; <keyword arguments>)
Calculate correlation matrix of s1 * s2'
.
Arguments
s1::AbstractVector
s2::AbstractVector
norm::Bool
: normalize correlation matrix
Returns
cm::Matrix{Float64}
corm(s; <keyword arguments>)
Calculate correlation matrix.
Arguments
s::AbstractArray
norm::Bool=false
: normalize covariance
Returns
cm::Array{Float64, 4}
corm(obj; <keyword arguments>)
Calculate correlation matrix.
Arguments
obj::NeuroAnalyzer.NEURO
- `ch::Union{String, Vector{String}}: list of channels
norm::Bool=true
: normalize matrix
Returns
cm::Array{Float64, 4}
: correlation matrix for each epoch
NeuroAnalyzer.covm
— Functioncovm(s; <keyword arguments>)
Calculate covariance matrix of s * s'
.
Arguments
s::AbstractVector
norm::Bool=false
: normalize covariance
Returns
cm::Matrix{Float64}
: covariance matrix
covm(s1, s2; <keyword arguments>)
Calculate covariance matrix of s1 * s2'
.
Arguments
s1::AbstractVector
s2::AbstractVector
norm::Bool=false
: normalize covariance
Returns
cm::Matrix{Float64}
: covariance matrix
covm(s; <keyword arguments>)
Calculate covariance matrix.
Arguments
s::AbstractArray
norm::Bool=false
: normalize covariance
Returns
cm::Array{Float64, 4}
: covariance matrix
covm(obj; <keyword arguments>)
Calculate covariance matrix of signal * signal'
.
Arguments
obj::NeuroAnalyzer.NEURO
- `ch::Union{String, Vector{String}}: list of channels
norm::Bool=false
: normalize matrix
Returns
cm::Array{Float64, 4}
: covariance matrix for each epoch
NeuroAnalyzer.cph
— Functioncph(s1, s2; <keyword arguments>)
Calculate cross-phases.
Arguments
s1::AbstractVector
s2::AbstractVector
fs::Int64
: sampling rate
Returns
Named tuple containing:
ph::Vector{Float64}
: cross-power spectrum phase (in radians)f::Vector{Float64}
: cross-power spectrum frequencies
cph(s; <keyword arguments>)
Calculate cross-phases.
Arguments
s::AbstractArray
fs::Int64
: sampling rate
Returns
Named tuple containing:
ph::Array{Float64, 4}
: cross-power spectrum phase (in radians)f::Vector{Float64}
: cross-power spectrum frequencies
cph(s1, s2; <keyword arguments>)
Calculate cross-phases.
Arguments
s1::AbstractArray
s2::AbstractArray
fs::Int64
: sampling rate
Returns
Named tuple containing:
ph::Array{Float64, 3}
: cross-power spectrum phase (in radians)f::Vector{Float64}
: cross-power spectrum frequencies
cph(obj; <keyword arguments>)
Calculate cross-phases.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Named tuple containing:
ph::Array{Float64, 4}
: cross-power spectrum phase (in radians)f::Vector{Float64}
: cross-power spectrum frequencies
cph(obj1, obj2; <keyword arguments>)
Calculate cross-phases.
Arguments
obj::NeuroAnalyzer.NEURO
- `ch1::Union{String, Vector{String}}: list of channels
- `ch2::Union{String, Vector{String}}: list of channels
ep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj2))
: default use all epochs
Returns
Named tuple containing:
ph::Array{Float64, 3}
: cross-power spectrum phase (in radians)f::Vector{Float64}
: cross-power spectrum frequencies
NeuroAnalyzer.cpsd
— Functioncpsd(s1, s2; <keyword arguments>)
Calculate cross power spectral density (CPSD).
Arguments
s1::AbstractVector
s2::AbstractVector
method::Symbol=:mt
: method used to calculate CPSD::mt
: multi-tapered cross-power spectra:fft
: fast Fourier transformation
fs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}=(0, fs / 2)
: frequency boundsdemean::Bool=false
: if true, the channel-wise mean will be subtracted from the input signals before the cross spectral powers are computednt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowdb::Bool=false
: normalize do dB
Returns
Named tuple containing:
pxy::Vector{Float64}
: cross-power spectrumf::Vector{Float64}
: frequencies
cpsd(s1, s2; <keyword arguments>)
Calculate cross power spectral density (CPSD).
Arguments
s1::AbstractArray
s2::AbstractArray
method::Symbol=:mt
: method used to calculate CPSD::mt
: multi-tapered cross-power spectra:fft
: fast Fourier transformation
fs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}=(0, fs / 2)
: frequency boundsdemean::Bool=false
: if true, the channelwise mean will be subtracted from the input signals before the cross spectral powers are computednt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowdb::Bool=false
: normalize do dB
Returns
Named tuple containing:
pxy::Array{Float64, 3}
: cross-power spectrumf::Vector{Float64}
: frequencies
cpsd(obj1, obj2; <keyword arguments>)
Calculate cross power spectral density (CPSD).
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{String, Vector{String}}
: list of channelsch2::Union{String, Vector{String}}
: list of channelsep1::Union{Int64, Vector{Int64}, AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, AbstractRange}=_c(nepochs(obj2))
: default use all epochsmethod::Symbol=:mt
: method used to calculate CPSD::mt
: multi-tapered cross-power spectra:fft
: fast Fourier transformation
frq_lim::Tuple{Real, Real}=(0, sr(obj1) / 2)
: frequency boundsdemean::Bool=false
: if true, the channelwise mean will be subtracted from the input signals before the cross spectral powers are computednt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj1)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowdb::Bool=false
: normalize do dB
Returns
Named tuple containing:
pxy::Array{Float64, 3}
: cross-power spectrumf::Vector{Float64}
: frequencies
NeuroAnalyzer.cwtpsd
— Functioncwtpsd(s; <keyword arguments>)
Calculate power spectrum using continuous wavelet transformation (CWT).
Arguments
s::AbstractVector
fs::Int64
: sampling ratewt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available waveletsnorm::Bool=true
: normalize scaleogram to the signal scale so the amplitudes of wavelet coefficients agree with the amplitudes of oscillatory components in a signal
Returns
Named tuple containing:
p::Vector{Float64}
: powersf::Vector{Float64}
: frequencies
NeuroAnalyzer.cwtspectrogram
— Functioncwtspectrogram(s; <keyword arguments>)
Calculate scaleogram using continuous wavelet transformation (CWT).
Arguments
s::AbstractVector
fs::Int64
: sampling ratewt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available waveletsnorm::Bool=true
: normalize scaleogram to the signal scale so the amplitudes of wavelet coefficients agree with the amplitudes of oscillatory components in a signal
Returns
Named tuple containing:
p::Matrix{Float64}
: powersf::Vector{Float64}
: frequenciest::Vector{Float64}
: time
NeuroAnalyzer.diss
— Functiondiss(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
diss(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
diss(s1, s2)
Calculate DISS (global dissimilarity) and spatial correlation (channels vs channels).
Arguments
s1::AbstractArray
s2::AbstractArray
Returns
Named tuple containing:
gd::Matrix{Float64}
: global dissimilaritysc::Matrix{Float64}
: spatial correlation
diss(obj; <keyword arguments>)
Calculate DISS (global dissimilarity) and spatial correlation (channels vs channels).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Named tuple containing:
gd::Array{Float64, 3}
: global dissimilaritysc::Array{Float64, 3}
: spatial correlation
diss(obj1, obj2; <keyword arguments>)
Calculate DISS (global dissimilarity) and spatial correlation (ch1
of obj1
vs ch2
of obj2
)..
Arguments
obj::NeuroAnalyzer.NEURO
- `ch1::Union{String, Vector{String}}: list of channels
- `ch2::Union{String, Vector{String}}: list of channels
ep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj2))
: default use all epochs
Returns
Named tuple containing:
gd::Array{Float64, 3}
: global dissimilaritysc::Array{Float64, 3}
: spatial correlation
NeuroAnalyzer.entropy
— Functionentropy(s)
Calculate entropy.
Arguments
s::AbstractVector
Returns
Named tuple containing:
ent::Float64
sent::Float64
: Shanon entropyleent::Float64
: log energy entropy
entropy(s)
Calculate entropy.
Arguments
s::AbstractArray
Returns
Named tuple containing:
ent::Matrix{Float64}
sent::Matrix{Float64}
: Shanon entropyleent::Matrix{Float64}
: log energy entropy
entropy(obj; <keyword arguments>)
Calculate entropy.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Named tuple containing:
ent::Matrix{Float64}
sent::Matrix{Float64}
: Shanon entropyleent::Matrix{Float64}
: log energy entropy
NeuroAnalyzer.env_cor
— Functionenv_cor(env1, env2)
Calculate envelope correlation.
Arguments
env1::Array{Float64, 3}
env2::Array{Float64, 3}
Returns
Named tuple containing:
ec::Vector{Float64}
: power correlation valuep::Vector{Float64}
: p-value
NeuroAnalyzer.env_lo
— Functionenv_lo(s, x; <keyword arguments>)
Calculate lower envelope.
Arguments
s::AbstractVector
: signalx::AbstractVector
: x-axis pointsd::Int64=32
: distance between peeks in points, lower values get better envelope fit
Returns
e::Vector{Float64}
: envelope
NeuroAnalyzer.env_up
— Functionenv_up(s, x; <keyword arguments>)
Calculate upper envelope.
Arguments
s::AbstractVector
: signalx::AbstractVector
: x-axis pointsd::Int64=32
: distance between peeks in points, lower values get better envelope fit
Returns
e::Vector{Float64}
: envelope
NeuroAnalyzer.erop
— Functionerop(obj; <keyword arguments>)
Calculate ERO (Event-Related Oscillations) power-spectrum. If obj
is ERP, erop()
returns two epochs: ERP power-spectrum (s[:, 1]
) and averaged power-spectra of all ERP epochs (s[:, 2]
). Otherwise, erop()
returns averaged power-spectra of all obj
epochs (s[:, 1]
)
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel to analyzemethod::Symbol=:welch
: method of calculating power-spectrum::welch
: Welch's periodogram:stft
: short time Fourier transform:mt
: multi-tapered periodogram:fft
: Fast Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowdb::Bool=true
: normalize powers to dBncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
p::Matrix{Float64}
: powersf::Vector{Float64}
: frequencies
NeuroAnalyzer.eros
— Functioneros(obj; <keyword arguments>)
Calculate ERO (Event-Related Oscillations) spectrogram. If obj
is ERP, eros()
returns two epochs: ERP spectrogram (s[:, :, 1]
) and averaged spectrograms of all ERP epochs (s[:, :, 2]
). Otherwise, eros()
returns averaged spectrograms of all obj
epochs (s[:, :, 1]
)
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel to analyzemethod::Symbol=:stft
: method of calculating spectrogram::stft
: short-time Fourier transform:mt
: multi-tapered periodogram:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length, default is 4 secondswoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowpad::Int64=0
: number of zeros to adddb::Bool=true
: normalize powers to dBgw::Real=5
: Gaussian width in Hzncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
wt<:CWT=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, e.g.wt = wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
s::Array{Float64, 3}
: spectrogram(s)f::Vector{Float64}
: frequenciest::Vector{Float64}
: time
NeuroAnalyzer.erp_peaks
— Functionerp_peaks(obj)
Detect a pair of positive and negative peaks of ERP.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
p::Matrix{Int64}
: peaks: channels × positive peak position, negative peak position
NeuroAnalyzer.frqinst
— Functionfrqinst(s; <keyword arguments>)
Calculate instantaneous frequency.
Arguments
s::AbstractVector
Returns
f::Vector{Float64}
frqinst(s; <keyword arguments>)
Calculate instantaneous frequency.
Arguments
s::AbstractVector
Returns
f::Array{Float64, 3}
frqinst(obj; <keyword arguments>)
Calculate instantaneous frequency.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
f::Array{Float64, 3}
NeuroAnalyzer.ged
— Functionged(s1, s2)
Perform generalized eigendecomposition.
Arguments
s1::AbstractMatrix
: signal to be analyzeds2::AbstractMatrix
: original signal
Returns
Named tuple containing:
sged::Matrix{Float64}
ress::Vector{Float64}
ress_norm::Vector{Float64}
: RESS normalized to -1..1
ged(obj1, obj2; <keyword arguments>)
Perform generalized eigendecomposition.
Arguments
obj1::NeuroAnalyzer.NEURO
: signal data to be analyzedobj2::NeuroAnalyzer.NEURO
: original signal data- `ch1::Union{String, Vector{String}}: list of channels
- `ch2::Union{String, Vector{String}}: list of channels
ep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj2))
: default use all epochs
Returns
Named tuple containing:
sged::Array{Float64, 3}
ress::Matrix{Float64}
ress_norm::Matrix{Float64}
: RESS normalized to -1..1
NeuroAnalyzer.gfp
— Functiongfp(s)
Calculate GFP (Global Field Power).
Arguments
s::AbstractVector
Returns
gfp::Float64
NeuroAnalyzer.gfp_norm
— Functiongfp_norm(s)
Calculate signal normalized for GFP (Global Field Power).
Arguments
s::AbstractVector
Returns
gfp_norm::Vector{Float64}
NeuroAnalyzer.ghpsd
— Functionghpsd(s; <keyword arguments>)
Calculate power spectrum using Gaussian and Hilbert transform.
Arguments
s::AbstractVector
fs::Int64
: sampling ratedb::Bool=true
: normalize powers to dBgw::Real=5
: Gaussian width in Hzw::Bool=true
: if true, apply Hanning window
Returns
Named tuple containing:
p::Vector{Float64}
: powersf::Vector{Float64}
: frequencies
NeuroAnalyzer.ghspectrogram
— Functionghspectrogram(s; <keyword arguments>)
Calculate spectrogram using Gaussian and Hilbert transform.
Arguments
s::AbstractVector
fs::Int64
: sampling ratedb::Bool=true
: normalize powers to dBgw::Real=5
: Gaussian width in Hzw::Bool=true
: if true, apply Hanning window
Returns
Named tuple containing:
p::Matrix{Float64}
: powersph::Matrix{Float64}
: phasesf::Vector{Float64}
: frequenciest::Vector{Float64}
: time
NeuroAnalyzer.henv
— Functionhenv(obj; <keyword arguments>)
Calculate Hilbert spectrum amplitude envelope.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesd::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_lo
— Functionhenv_lo(s)
Calculate lower envelope using Hilbert transform.
Arguments
s::AbstractVector
: signal
Returns
e::Vector{Float64}
: envelope
NeuroAnalyzer.henv_mean
— Functionhenv_mean(obj; <keyword arguments>)
Calculate Hilbert spectrum amplitude envelope: mean and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesdims::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
— Functionhenv_median(obj; <keyword arguments>)
Calculate Hilbert spectrum amplitude envelope of obj
: median and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesdims::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.henv_up
— Functionhenv_up(s)
Calculate upper envelope using Hilbert transform.
Arguments
s::AbstractVector
: signal
Returns
e::Vector{Float64}
: envelope
NeuroAnalyzer.hjorth
— Functionhjorth(s)
Calculate Hjorths parameters.
Arguments
s::AbstractVector
Returns
Named tuple containing:
h_act::Float64
: activityh_mob::Float64
: mobilityh_comp::Float64
: complexity
Notes:
- Activity: the total power of the signal
- Mobility: an estimate of the mean frequency
- Complexity: indicates the similarity of the shape of the signal to a pure sine wave
hjorth(s)
Calculate Hjorths parameters.
Arguments
s::AbstractArray
Returns
Named tuple containing:
h_act::Matrix{Float64}
: activityh_mob::Matrix{Float64}
: mobilityh_comp::Matrix{Float64}
: complexity
Notes:
- Activity: the total power of the signal
- Mobility: an estimate of the mean frequency
- Complexity: indicates the similarity of the shape of the signal to a pure sine wave
hjorth(obj)
Calculate Hjorths parameters.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Named tuple containing:
h_act::Matrix{Float64}
: activityh_mob::Matrix{Float64}
: mobilityh_comp::Matrix{Float64}
: complexity
Notes:
- Activity: the total power of the signal
- Mobility: an estimate of the mean frequency
- Complexity: indicates the similarity of the shape of the signal to a pure sine wave
NeuroAnalyzer.hrv_analyze
— Functionhrv_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.hrv_detect
— Functionhrv_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
Named tuple containing:
nn_seg::Vector{Float64}
: list of NN segments [msec]r_idx::Vector{Float64}
: index of R peaks
NeuroAnalyzer.hspectrum
— Functionhspectrum(s; <keyword arguments>)
Calculate amplitudes, powers and phases using Hilbert transform.
Arguments
s::AbstractVector
pad::Int64
: number of zeros to add at the end of the signaldb::Bool=false
: normalize powers to dB
Returns
Named tuple containing:
c::Vector{ComplexF64}
: Hilbert componentsa::Vector{Float64}
: amplitudesp::Vector{Float64}
: powersph::Vector{Float64}
: phases
hspectrum(s; <keyword arguments>)
Calculate amplitudes, powers and phases using Hilbert transform.
Arguments
s::AbstractArray
pad::Int64
: number of zeros to add at the end of the signaldb::Bool=false
: normalize powers to dB
Returns
Named tuple containing:
c::Array{ComplexF64, 3}
: Hilbert componentsa::Array{Float64, 3}
: amplitudesp::Array{Float64, 3}
: powersph::Array{Float64, 3}
: phases
NeuroAnalyzer.ispc
— Functionispc(s1, s2)
Calculate ISPC (Inter-Site-Phase Clustering) between s1
and s2
.
Arguments
s1::AbstractVector
s2::AbstractVector
Returns
Named tuple containing:
ispc_val::Float64
: ISPC valueispc_ang::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
ispc(obj; <keyword arguments>)
Calculate ISPCs (Inter-Site-Phase Clustering).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Named tuple containing:
ispc_val::Array{Float64, 3}
: ISPC value matrices over epochsispc_ang::Array{Float64, 3}
: ISPC angle matrices over epochs
ispc(obj1, obj2; <keyword arguments>)
Calculate ISPC (Inter-Site-Phase Clustering).
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
- `ch1::Union{String, Vector{String}}: list of channels
- `ch2::Union{String, Vector{String}}: list of channels
ep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj2))
: default use all epochs
Returns
Named tuple containing:
ispc_val::Matrix{Float64}
: ISPC valueispc_ang::Matrix{Float64}
: 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
— Functionitpc(s; <keyword arguments>)
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_val::Float64
: ITPC valueitpcz_val::Float64
: Rayleigh's ITPC z valueitpc_ang::Float64
: ITPC angleitpc_ph::Vector{Float64}
: phases at timet
averaged across trials/epochs
itpc(obj; <keyword arguments>)
Calculate ITPC (Inter-Trial-Phase Clustering) at sample number t
over epochs.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namest::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_val::Vector{Float64}
: ITPC or wITPC valueitpcz_val::Vector{Float64}
: Rayleigh's ITPC z valueitpc_ang::Vector{Float64}
: ITPC angleitpc_ph::Matrix{Float64}
: phase difference (channel2 - channel1)
NeuroAnalyzer.itpc_spec
— Functionitpc_spec(s; <keyword arguments>)
Calculate spectrogram of ITPC (Inter-Trial-Phase Clustering).
Arguments
s::AbstractArray
: one channel over epochsw::Union{AbstractVector, Nothing}
: optional vector of epochs/trials weights for wITPC calculation
Returns
Named tuple containing:
itpc_val::Vector{Float64}
: ITPC valuesitpcz_val::Vector{Float64}
: Rayleigh's ITPC z valuesitpc_ang::Vector{Float64}
: ITPC anglesitpc_ph::Matrix{Float64}
: phases at timet
averaged across trials/epochs
itpc_spec(obj; <keyword arguments>)
Calculate spectrogram of ITPC (Inter-Trial-Phase Clustering).
Arguments
obj::NeuroAnalyzer.NEURO
ch::String
: channel to analyzefrq_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
) frequencies scalingw::Union{Vector{<:Real}, Nothing}=nothing
: optional vector of epochs/trials weights for wITPC calculation
Returns
Named tuple containing:
itpc_s::Matrix{Float64}
: spectrogram of ITPC valuesitpcz_s::Matrix{Float64}
: spectrogram of ITPCZ valuesitpc_f::Vector{Float64}
: frequencies list
NeuroAnalyzer.maxamp_at
— Functionmaxamp_at(obj; <keyword arguments>)
Calculate maximum amplitude at given time segment.
Arguments
obj::NeuroAnalyzer.NEURO
t::Tuple{Real, Real}
: time segment in seconds
Returns
p::Matrix{Float64}
: maximum amplitude for each channel per epoch
NeuroAnalyzer.mep_peaks
— Functionmep_peaks(obj)
Detect a pair of positive and negative peaks of MEP.
Arguments
obj::NeuroAnalyzer.NEURO
Returns
p::Matrix{Int64}
: peaks: channels × positive peak position, negative peak position
NeuroAnalyzer.minamp_at
— Functionminamp_at(obj; <keyword arguments>)
Calculate minimum amplitude at given time segment.
Arguments
obj::NeuroAnalyzer.NEURO
t::Tuple{Real, Real}
: time segment in seconds
Returns
p::Matrix{Float64}
: minimum amplitude for each channel per epoch
NeuroAnalyzer.mutual_information
— Functionmutual_information(s1, s2)
Calculate mutual information.
Arguments
s1::AbstractVector
s2::AbstractVector
Returns
mutual_information::Float64
mutual_information(s1, s2)
Calculate mutual information (channels of s1
vs channels of s2
).
Arguments
s1::AbstractArray
s2::AbstractArray
Returns
m::Matrix{Float64}
mutual_information(s)
Calculate mutual information (channels vs channels).
Arguments
s::AbstractArray
Returns
m::Array{Float64, 3}
mutual_information(obj; <keyword arguments>)
Calculate mutual information between channels.
Arguments
obj::NeuroAnalyzer.NEURO
- `ch::Union{String, Vector{String}}: list of channels
Returns
m::Array{Float64, 3}
mutual_information(obj1, obj2; <keyword arguments>)
Calculate mutual information between two channels.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
- `ch1::Union{String, Vector{String}}: list of channels
- `ch2::Union{String, Vector{String}}: list of channels
ep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj2))
: default use all epochs
Returns
m::Matrix{Float64}
NeuroAnalyzer.mwpsd
— Functionmwpsd(s; <keyword arguments>)
Calculate power spectrum using Morlet wavelet convolution.
Arguments
s::AbstractVector
pad::Int64=0
: pad withpad
zerosdb::Bool=true
: normalize powers to dBfs::Int64
: sampling ratencyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
w::Bool=true
: if true, apply Hanning window
Returns
Named tuple containing:
p::Vector{Float64}
: powersf::Vector{Float64}
: frequencies
NeuroAnalyzer.mwspectrogram
— Functionmwspectrogram(s; <keyword arguments>)
Calculate spectrogram using wavelet convolution.
Arguments
s::AbstractVector
pad::Int64
: pad withpad
zerosdb::Bool=true
: normalize powers to dBfs::Int64
: sampling ratencyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
w::Bool=true
: if true, apply Hanning window
Returns
Named tuple containing:
cs::Matrix{ComplexF64}
: convoluted signalp::Matrix{Float64}
: powersph::Matrix{Float64}
: phasesf::Vector{Float64}
: frequenciest::Vector{Float64}
: time
NeuroAnalyzer.negentropy
— Functionnegentropy(signal)
Calculate negentropy.
Arguments
signal::AbstractVector
Returns
negent::Float64
negentropy(s)
Calculate negentropy.
Arguments
s::AbstractArray
Returns
ne::Matrix{Float64}
negentropy(obj; <keyword arguments>)
Calculate negentropy.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
ne::Matrix{Float64}
NeuroAnalyzer.pacor
— Functionpacor(s; <keyword arguments>)
Calculate partial 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 is-l:l
demean::Bool=true
: demean signal before computing auto-correlationmethod::Symbol=:yw
: method of calculating auto-correlation::yw
: computes the partial autocorrelations using the Yule-Walker equations:reg
: computes the partial autocorrelations via successive regression models
Returns
pac::Array{Float64, 3}
Notes
If you get ERROR: PosDefException: matrix is not positive definite; Cholesky factorization failed.
, try lowering l
value or change method to :yw
.
pacor(s; <keyword arguments>)
Calculate partial 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 is-l:l
demean::Bool=true
: demean signal before computing auto-correlationmethod::Symbol=:yw
: method of calculating auto-correlation::yw
: computes the partial autocorrelations using the Yule-Walker equations:reg
: computes the partial autocorrelations via successive regression models
Returns
pac::Array{Float64, 3}
pacor(s; <keyword arguments>)
Calculate partial 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 is-l:l
demean::Bool=true
: demean signal before computing auto-correlationmethod::Symbol=:yw
: method of calculating auto-correlation::yw
: computes the partial autocorrelations using the Yule-Walker equations:reg
: computes the partial autocorrelations via successive regression models
Returns
pac::Array{Float64, 3}
pacor(obj; <keyword arguments>)
Calculate partial auto-correlation. For ERP return trial-averaged auto-correlation.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesl::Real=1
: lags range is-l:l
demean::Bool=true
: demean signal before computing auto-correlationmethod::Symbol=:yw
: method of calculating auto-correlation::yw
: computes the partial autocorrelations using the Yule-Walker equations:reg
: computes the partial autocorrelations via successive regression models
Returns
Named tuple containing:
pac::Array{Float64, 3}
l::Vector{Float64}
: lags [s]
NeuroAnalyzer.peak_frq
— Functionpeak_frq(s; <keyword arguments>)
Calculate peak frequency in a band.
Arguments
s::AbstractVector
fs::Int64
: sampling ratef::Tuple{Real, Real}
: lower and upper frequency boundsmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
Returns
pf::Float64
: peak frequency
peak_frq(s; <keyword arguments>)
Calculate peak frequency in a band.
Arguments
s::AbstractArray
fs::Int64
: sampling ratef::Tuple{Real, Real}
: lower and upper frequency boundsmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
Returns
pf::Matrix{Float64}
: peak frequency
peak_frq(obj; <keyword arguments>)
Calculate peak frequency in a band.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesf::Tuple{Real, Real}
: lower and upper frequency boundsmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
Returns
pf::Matrix{Float64}
: peak frequency
NeuroAnalyzer.penv
— Functionpenv(obj; <keyword arguments>)
Calculate power (in dB) envelope.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesd::Int64=8
: distance between peeks in samples, lower values get better envelope fitmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
Returns
Named tuple containing:
p_env::Array{Float64, 3}
: power spectrum envelopep_env_frq::Vector{Float64}
: frequencies for each envelope
NeuroAnalyzer.penv_mean
— Functionpenv_mean(obj; <keyword arguments>)
Calculate power (in dB) envelope: mean and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesdims::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 fitmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
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
— Functionpenv_median(obj; <keyword arguments>)
Calculate power (in dB) envelope: median and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesdims::Int64
: median over channels (dims = 1) or epochs (dims = 2)d::Int64=8
: distance between peeks in samples, lower values get better envelope fitmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
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.phdiff
— Functionphdiff(s1, s2; <keyword arguments>)
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
phdiff(s; <keyword arguments>)
Calculate phase difference between channels and mean phase of reference ch
.
Arguments
s::AbstractArray
ch::Union{Int64, Vector{Int64}}=_c(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}
phdiff(obj; <keyword arguments>)
Calculate phase difference between channels and mean phase of reference ch
.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: index of reference channelsavg::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.phsd
— Functionphsd(s; <keyword arguments>)
Calculate phase spectral density.
Arguments
s::Vector{Float64}
fs::Int64
: sampling rate
Returns
Named tuple containing:
ph::Vector{Float64}
: phasesf::Vector{Float64}
: frequencies
phsd(s; <keyword arguments>)
Calculate phase spectral density.
Arguments
s::AbstractMatrix
fs::Int64
: sampling rate
Returns
Named tuple containing:
ph::Matrix{Float64}
: phasesf::Vector{Float64}
: frequencies
phsd(s; <keyword arguments>)
Calculate phase spectral density.
Arguments
s::AbstractArray
fs::Int64
: sampling rate
Returns
Named tuple containing:
ph::Array{Float64, 3}
: phasesf::Vector{Float64}
: frequencies
phsd(obj; <keyword arguments>)
Calculate phase spectral density.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Named tuple containing:
ph::Array{Float64, 3}
: phasesf::Vector{Float64}
: frequencies
NeuroAnalyzer.pli
— Functionpli(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
pli(obj1, obj2; <keyword arguments>)
Calculate PLI (Phase Lag Index).
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
- `ch1::Union{String, Vector{String}}: list of channels
- `ch2::Union{String, Vector{String}}: list of channels
ep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj2))
: default use all epochs
Returns
Named tuple containing:
pv::Matrix{Float64}
: 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
pli(obj; <keyword arguments>)
Calculate PLIs (Phase Lag Index).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
pv::Array{Float64, 3}
: PLI value matrices over epochs
NeuroAnalyzer.psd
— Functionpsd(s; <keyword arguments>)
Calculate power spectrum density. Default method is Welch's periodogram.
Arguments
s::Vector{Float64}
fs::Int64
: sampling ratedb::Bool=false
: normalize do dB; for CWT power spectrum: normalize to the signal scale so the amplitudes of wavelet coefficients agree with the amplitudes of oscillatory components in a signalmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
p::Vector{Float64}
: powersf::Vector{Float64}
: frequencies
psd(s; <keyword arguments>)
Calculate power spectrum density. Default method is Welch's periodogram.
Arguments
s::AbstractMatrix
fs::Int64
: sampling ratedb::Bool=false
: normalize do dBmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
wt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
p::Matrix{Float64}
: powersf::Vector{Float64}
: frequencies
psd(s; <keyword arguments>)
Calculate power spectrum density. Default method is Welch's periodogram.
Arguments
s::AbstractArray
fs::Int64
: sampling ratedb::Bool=false
: normalize do dBmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
p::Array{Float64, 3}
: powersf::Vector{Float64}
: frequencies
psd(obj; <keyword arguments>)
Calculate power spectrum density. Default method is Welch's periodogram.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesdb::Bool=false
: normalize do dBmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
p::Array{Float64, 3}
: powersf::Vector{Float64}
: frequencies
NeuroAnalyzer.psd_rel
— Functionpsd_rel(s; <keyword arguments>)
Calculate relative power spectrum density. Default method is Welch's periodogram.
Arguments
s::AbstractVector
fs::Int64
: sampling ratedb::Bool=false
: normalize do dBfrq_lim::Union{Tuple{Real, Real}, Nothing}=nothing
: frequency range to calculate relative power to; if nothing, than calculate relative to total powermethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
pw::Vector{Float64}
: powerspf::Vector{Float64}
: frequencies
psd_rel(s; <keyword arguments>)
Calculate relative power spectrum density. Default method is Welch's periodogram.
Arguments
s::AbstractMatrix
fs::Int64
: sampling ratedb::Bool=false
: normalize do dBfrq_lim::Union{Tuple{Real, Real}, Nothing}=nothing
: frequency range to calculate relative power to; if nothing, than calculate relative to total powermethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
pw::Array{Float64, 3}
: powerspf::Vector{Float64}
: frequencies
psd_rel(s; <keyword arguments>)
Calculate relative power spectrum density. Default method is Welch's periodogram.
Arguments
s::AbstractArray
fs::Int64
: sampling ratedb::Bool=false
: normalize do dBfrq_lim::Union{Tuple{Real, Real}, Nothing}=nothing
: frequency range to calculate relative power to; if nothing, than calculate relative to total powermethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
pw::Array{Float64, 3}
: powerspf::Vector{Float64}
: frequencies
psd_rel(obj::NeuroAnalyzer.NEURO; <keyword arguments>) where {T <: CWT}
Calculate relative power spectrum density. Default method is Welch's periodogram.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesdb::Bool=false
: normalize do dBfrq_lim::Union{Tuple{Real, Real}, Nothing}=nothing
: frequency range to calculate relative power to; if nothing, than calculate relative to total powermethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
pw::Array{Float64, 3}
: powerspf::Array{Float64, 3}
: frequencies
NeuroAnalyzer.psd_slope
— Functionpsd_slope(s; <keyword arguments>)
Calculate PSD linear fit and slope. Default method is Welch's periodogram.
Arguments
s::AbstractVector
fs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}=(0, fs / 2)
: calculate slope of the total power (default) or frequency rangefrq_lim[1]
tofrq_lim[2]
db::Bool=false
: normalize do dBmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
lf::Vector{Float64}
: linear fitls::Float64
: slopes of linear fitpf::Vector{Float64}
: range of frequencies for the linear fit
psd_slope(s; <keyword arguments>)
Calculate PSD linear fit and slope. Default method is Welch's periodogram.
Arguments
s::AbstractArray
fs::Int64
: sampling ratefrq_lim::Tuple{Real, Real}=(0, fs / 2)
: calculate slope of the total power (default) or frequency rangefrq_lim[1]
tofrq_lim[2]
db::Bool=false
: normalize do dBmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
lf::Matrix{Float64}
: linear fits::Vector{Float64}
: slope of linear fitpf::Vector{Float64}
: range of frequencies for the linear fit
psd_slope(obj; <keyword arguments>)
Calculate PSD linear fit and slope. Default method is Welch's periodogram.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: calculate slope of the total power (default) or frequency range frqlim[1] to frqlim[2]db::Bool=false
: normalize do dBmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)ncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
Named tuple containing:
lf::Array{Float64, 3}
: linear fitls::Matrix{Float64}
: slope of linear fitpf::Vector{Float64}
: range of frequencies for the linear fit
NeuroAnalyzer.rmse
— Functionrmse(s1, s2)
Calculate Root Mean Square Error (RMSE).
Arguments
s1::AbstractVector
s2::AbstractVector
Returns
r::Float64
: RMSE
rmse(s1, s2)
Calculate Root Mean Square Error (RMSE).
Arguments
s1::AbstractArray
s2::AbstractArray
Returns
r::Matrix{Float64}
: RMSE
rmse(obj1, obj2; <keyword arguments>)
Calculate Root Mean Square Error (RMSE).
Arguments
obj::NeuroAnalyzer.NEURO
- `ch1::Union{String, Vector{String}}: list of channels
- `ch2::Union{String, Vector{String}}: list of channels
ep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj2))
: default use all epochs
Returns
r::Matrix{Float64}
: RMSE
NeuroAnalyzer.sef
— Functionsef(s; <keyword arguments>)
Calculate spectral edge frequency (SEF) – the frequency below which x percent of the total power of a given signal are located; typically, x is in the range 75 to 95.
Arguments
s::AbstractVector
x::Float64=0.95
: thresholdfs::Int64
: sampling ratef::Tuple{Real, Real}=(0, fs / 2)
: lower and upper frequency bounds, default is total powermethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
Returns
sef_frq::Float64
: spectral edge frequency
sef(s; <keyword arguments>)
Calculate spectral edge frequency (SEF) – the frequency below which x percent of the total power of a given signal are located; typically, x is in the range 75 to 95.
Arguments
s::AbstractArray
x::Float64=0.95
: thresholdfs::Int64
: sampling ratef::Tuple{Real, Real}=(0, fs / 2)
: lower and upper frequency bounds, default is total powermethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
Returns
sef_frq::Matrix{Float64}
: spectral edge frequency
sef(obj; <keyword arguments>)
Calculate spectral edge frequency (SEF) – the frequency below which x percent of the total power of a given signal are located; typically, x is in the range 75 to 95.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesx::Float64=0.95
: thresholdf::Tuple{Real, Real}=(0, sr(obj) / 2)
: lower and upper frequency bounds, default is total powermethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
Returns
sef_frq::Matrix{Float64}
: spectral edge frequency
NeuroAnalyzer.senv
— Functionsenv(obj; <keyword arguments>)
Calculate spectral envelope.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesd::Int64=2
: distance between peeks in samples, lower values get better envelope fitt::Union{Real, Nothing}=nothing
: spectrogram threshold (maximize all powers > t)method::Symbol=:stft
: method of calculating spectrogram::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 adddb::Bool=true
: normalize powers to dBnt::Int64=7
: number of Slepian tapersgw::Real=5
: Gaussian width in Hzncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
wt<:CWT=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, e.g.wt = wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning window
Returns
Named tuple containing:
s_env::Array{Float64, 3}
: spectral envelopes_env_t::Vector{Float64}
: spectrogram time
NeuroAnalyzer.senv_mean
— Functionsenv_mean(obj; <keyword arguments>)
Calculate spectral envelope: mean and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesdims::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 fitt::Union{Real, Nothing}=nothing
: spectrogram threshold (maximize all powers > t)method::Symbol=:stft
: method of calculating spectrogram::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 adddb::Bool=true
: normalize powers to dBnt::Int64=7
: number of Slepian tapersgw::Real=5
: Gaussian width in Hzncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
wt<:CWT=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, e.g.wt = wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning window
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
— Functionsenv_median(obj; <keyword arguments>)
Calculate spectral envelope: median and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesdims::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 fitt::Union{Real, Nothing}=nothing
: spectrogram threshold (maximize all powers > t)method::Symbol=:stft
: method of calculating spectrogram::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 adddb::Bool=true
: normalize powers to dBnt::Int64=7
: number of Slepian tapersgw::Real=5
: Gaussian width in Hzncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
wt<:CWT=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, e.g.wt = wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning window
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.snr
— Functionsnr(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
snr(s; <keyword arguments>)
Calculate SNR.
Arguments
s::AbstractArray
t::Vector{Float64}
: epoch timetype::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
snr(obj; <keyword arguments>)
Calculate SNR.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namestype::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.snr2
— Functionsnr2(s)
Calculate RMS-based SNR.
Arguments
s::AbstractVector
Returns
snr2::Float64
: SNR
NeuroAnalyzer.spectrogram
— Functionspectrogram(s; <keyword arguments>)
Calculate spectrogram. Default method is short time Fourier transform.
Arguments
s::AbstractVector
fs::Int64
: sampling frequencydb::Bool=true
: normalize powers to dBmethod::Symbol=:stft
: method used to calculate PSD::stft
: short time Fourier transform:mt
: multi-tapered periodogram
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length, default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning window
Returns
Named tuple containing:
p::Matrix{Float64}
: powersf::Vector{Float64}
: frequenciest::Vector{Float64}
: time
spectrogram(obj; <keyword arguments>)
Calculate spectrogram. Default method is short time Fourier transform.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespad::Int64=0
: number of zeros to addmethod::Symbol=:stft
: method of calculating spectrogram::stft
: short-time Fourier transform:mt
: multi-tapered periodogram:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
db::Bool=true
: normalize powers to dB; for CWT scaleogram: normalize to the signal scale so the amplitudes of wavelet coefficients agree with the amplitudes of oscillatory components in a signalnt::Int64=7
: number of Slepian tapersgw::Real=5
: Gaussian width in Hzncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
wt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available waveletswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning window
Returns
Named tuple containing:
p::Array{Float64, 4}
: powersf::Vector{Float64}
: frequenciest::Vector{Float64}
: time points
NeuroAnalyzer.spectrum
— Functionspectrum(s; <keyword arguments>)
Calculate FFT, amplitudes, powers and phases.
Arguments
s::AbstractVector
pad::Int64=0
: number of zeros to add at the end of the signaldb::Bool=false
: normalize powers to dB
Returns
Named tuple containing:
ft::Vector{ComplexF64}
: Fourier transformsa::Vector{Float64}
: amplitudesp::Vector{Float64}
: powersph::Vector{Float64}
: phases
spectrum(s; <keyword arguments>)
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 FFTdb::Bool=false
: normalize powers to dB
Returns
Named tuple containing:
c::Array{ComplexF64, 3}
: Fourier or Hilbert componentsa::Array{Float64, 3}
: amplitudesp::Array{Float64, 3}
: powers- `ph::Array{Float64, 3}: phase angles
spectrum(obj; <keyword arguments>)
Calculate FFT/Hilbert transformation components, amplitudes, powers and phases.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namespad::Int64=0
: number of zeros to add signal for FFTh::Bool=false
: use Hilbert transform for calculations instead of FFTdb::Bool=false
: normalize powers to dB
Returns
Named tuple containing:
c::Array{ComplexF64, 3}
: Fourier or Hilbert componentsa::Array{Float64, 3}
: amplitudesp::Array{Float64, 3}
: powers- `ph::Array{Float64, 3}: phase angles
NeuroAnalyzer.stationarity
— Functionstationarity(obj; <keyword arguments>)
Calculate stationarity.
Arguments
obj::NeuroAnalyzer.NEURO
- `ch::Union{String, Vector{String}}: list of channels
window::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
s::Union{Matrix{Float64}, Array{Float64, 3}}
NeuroAnalyzer.stationarity_hilbert
— Functionstationarity_hilbert(s)
Calculate phase stationarity using Hilbert transformation.
Arguments
s::AbstractVector
Returns
stph::Vector{Float64}
NeuroAnalyzer.stationarity_mean
— Functionstationarity_mean(s; <keyword arguments>)
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
— Functionstationarity_var(s; <keyword arguments>)
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.symmetry
— Functionsymmetry(s)
Calculate signal symmetry (ratio of positive to negative amplitudes). Perfectly symmetrical signal has symmetry of 1.0. Symmetry above 1.0 indicates there are more positive amplitudes.
Arguments
s::AbstractVector
Returns
sym::Float64
: signal symmetry
symmetry(s)
Calculate signal symmetry (ratio of positive to negative amplitudes). Perfectly symmetrical signal has symmetry of 1.0. Symmetry above 1.0 indicates there are more positive amplitudes.
Arguments
s::AbstractArray
Returns
sym::Matrix{Float64}
: signal symmetry
symmetry(obj; <keyword arguments>)
Calculate signal symmetry (ratio of positive to negative amplitudes). Perfectly symmetrical signal has symmetry of 1.0. Symmetry above 1.0 indicates there are more positive amplitudes.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
sym::Matrix{Float64}
: signal symmetry
NeuroAnalyzer.tenv
— Functiontenv(obj; <keyword arguments>)
Calculate temporal envelope (amplitude).
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesd::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
— Functiontenv_mean(obj; <keyword arguments>)
Calculate temporal envelope (amplitude): mean and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesdims::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
— Functiontenv_median(obj; <keyword arguments>)
Calculate temporal envelope (amplitude): median and 95% CI.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesdims::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.tkeo
— Functiontkeo(s, t; <keyword arguments>)
Calculate Teager-Kaiser energy-tracking operator.
Arguments
s::AbstractVector
: signalt::AbstractVector=collect(1:length(s))
: time pointsmethod::Symbol=:pow
::pow
: TKEO = x(t)^2 - x(t-1) × x(t+1):der
: TKEO = f'(t) - f(t) × f''(t):amp
: TKEO = envelope(amplitude)^2
Returns
tk::Vector{Float64}
tkeo(s, t; <keyword arguments>)
Calculate Teager-Kaiser energy-tracking operator
Arguments
s::AbstractArray
: signalt::AbstractArray=collect(1:length(s))
: time pointsmethod::Symbol=:pow
::pow
: TKEO = x(t)^2 - x(t-1) × x(t+1):der
: TKEO = f'(t) - f(t) × f''(t):amp
: TKEO = envelope(amplitude)^2
Returns
tk::Array{Float64, 3}
tkeo(obj; <keyword arguments>)
Calculate Teager-Kaiser energy-tracking operator.
Arguments
obj::NeuroAnalyzer.NEURO
- `ch::Union{String, Vector{String}}: list of channels
method::Symbol=:pow
::pow
: TKEO = x(t)^2 - x(t-1) × x(t+1):der
: TKEO = f'(t) - f(t) × f''(t):amp
: TKEO = envelope(amplitude)^2
Returns
tk::Array{Float64, 3}
NeuroAnalyzer.total_power
— Functiontotal_power(s; <keyword arguments>)
Calculate total power.
Arguments
s::AbstractVector
fs::Int64
: sampling ratemethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
tp::Float64
: total power
total_power(s; <keyword arguments>)
Calculate total power.
`# Arguments
s::AbstractArray
fs::Int64
: sampling ratemethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(fs / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
tp::Matrix{Float64}
: total power
total_power(obj, ch, method, nt, wlen, woverlap, w, ncyc, gw, wt)
Calculate total power.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available wavelets
Returns
tp::Matrix{Float64}
: total power
NeuroAnalyzer.xcor
— Functionxcor(s1, s2; <keyword arguments>)
Calculate cross-correlation.
Arguments
s1::AbstractVector
s2::AbstractVector
l::Int64=round(Int64, min(length(s1) - 1, 10 * log10(length(s1))))
: lags range is-l:l
demean::Bool=true
: demean signal before computing cross-correlationbiased::Bool=true
: calculate biased or unbiased cross-correlationmethod::Symbol=:sum
: method of calculating cross-correlation::sum
:acf = Σ(s1[1:end - l] .* s1[1+l:end]) ./ (std(s1) × std(s2))
:cor
:acf = cor(s1[1:end - l], s2[1+l:end])
,biased
value is ignored:stat
: use StatsBasecrosscor()
,biased
value is ignored
Returns
xc::Array{Float64, 3}
xcor(s1, s2; <keyword arguments>)
Calculate cross-correlation.
Arguments
s1::AbstractMatrix
s2::AbstractMatrix
l::Int64=round(Int64, min(size(s1[1, :, 1], 1) - 1, 10 * log10(size(s1[1, :, 1], 1))))
: lags range is-l:l
demean::Bool=true
: demean signal before computing cross-correlationbiased::Bool=true
: calculate biased or unbiased cross-correlationmethod::Symbol=:sum
: method of calculating cross-correlation::sum
:acf = Σ(s1[1:end - l] .* s1[1+l:end]) ./ var(s)
:cor
:acf = cor(s1[1:end - l], s2[1+l:end])
:stat
: use StatsBasecrosscor()
,biased
value is ignored
Returns
xc::Array{Float64, 3}
xcor(s1, s2; <keyword arguments>)
Calculate cross-correlation.
Arguments
s1::AbstractArray
s2::AbstractArray
l::Int64=round(Int64, min(size(s1[1, :, 1], 1) - 1, 10 * log10(size(s1[1, :, 1], 1))))
: lags range is-l:l
demean::Bool=true
: demean signal before computing cross-correlationbiased::Bool=true
: calculate biased or unbiased cross-correlationmethod::Symbol=:sum
: method of calculating cross-correlation::sum
:acf = Σ(s1[1:end - l] .* s1[1+l:end]) ./ var(s)
:cor
:acf = cor(s1[1:end - l], s2[1+l:end])
:stat
: use StatsBasecrosscor()
,biased
value is ignored
Returns
xc::Array{Float64, 3}
xcor(obj1, obj2; <keyword arguments>)
Calculate cross-correlation. For ERP return trial-averaged cross-correlation.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{String, Vector{String}}
: list of channelsch2::Union{String, Vector{String}}
: list of channelsep1::Union{Int64, Vector{Int64}, AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, AbstractRange}=_c(nepochs(obj2))
: default use all epochsl::Real=1
: lags range is-l:l
demean::Bool=true
: demean signal before computing cross-correlationbiased::Bool=true
: calculate biased or unbiased cross-correlationmethod::Symbol=:sum
: method of calculating cross-correlation::sum
:acf = Σ(s1[1:end - l] .* s1[1+l:end]) ./ var(s)
:cor
:acf = cor(s1[1:end - l], s2[1+l:end])
:stat
: use StatsBasecrosscor()
,biased
value is ignored
Returns
Named tuple containing:
xc::Array{Float64, 3}
: cross-correlationl::Vector{Float64}
: lags [s]
NeuroAnalyzer.xcov
— Functionxcov(s1, s2; <keyword arguments>)
Calculate cross-covariance.
Arguments
s1::AbstractVector
s2::AbstractVector
l::Int64=round(Int64, min(length(s1) - 1, 10 * log10(length(s1))))
: lags range is-l:l
demean::Bool=true
: demean signal before computing cross-covariancebiased::Bool=true
: calculate biased or unbiased cross-covariancemethod::Symbol=:sum
: method of calculating cross-covariance::sum
:xcf = Σ(s[1:end - l] .* s[1+l:end])
:cov
:xcf = cov(s[1:end - l], s[1+l:end])
:stat
: use StatsBasecrosscov()
,biased
value is ignored
Returns
xc::Array{Float64, 3}
xcov(s1, s2; <keyword arguments>)
Calculate cross-covariance.
Arguments
s1::AbstractMatrix
s2::AbstractMatrix
l::Int64=round(Int64, min(size(s1, 2), 10 * log10(size(s1, 2))))
: lags range is-l:l
demean::Bool=true
: demean signal before computing cross-covariancebiased::Bool=true
: calculate biased or unbiased cross-covariancemethod::Symbol=:sum
: method of calculating cross-covariance::sum
:xcf = Σ(s[1:end - l] .* s[1+l:end])
:cov
:xcf = cov(s[1:end - l], s[1+l:end])
:stat
: use StatsBasecrosscov()
,biased
value is ignored
Returns
xc::Array{Float64, 3}
xcov(s1, s2; <keyword arguments>)
Calculate cross-covariance.
Arguments
s1::AbstractArray
s2::AbstractArray
l::Int64=round(Int64, min(size(s1, 2), 10 * log10(size(s1, 2))))
: lags range is-l:l
demean::Bool=true
: demean signal before computing cross-covariancebiased::Bool=true
: calculate biased or unbiased cross-covariancemethod::Symbol=:sum
: method of calculating cross-covariance::sum
:xcf = Σ(s[1:end - l] .* s[1+l:end])
:cov
:xcf = cov(s[1:end - l], s[1+l:end])
:stat
: use StatsBasecrosscov()
,biased
value is ignored
Returns
xc::Array{Float64, 3}
xcov(obj1, obj2; <keyword arguments>)
Calculate cross-covariance. For ERP return trial-averaged cross-covariance.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{String, Vector{String}}
: list of channelsch2::Union{String, Vector{String}}
: list of channelsep1::Union{Int64, Vector{Int64}, AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, AbstractRange}=_c(nepochs(obj2))
: default use all epochsl::Real=1
: lags range is-l:l
demean::Bool=true
: demean signal before computing cross-covariancebiased::Bool=true
: calculate biased or unbiased cross-covariancemethod::Symbol=:sum
: method of calculating cross-covariance::sum
:xcf = Σ(s[1:end - l] .* s[1+l:end])
:cov
:xcf = cov(s[1:end - l], s[1+l:end])
:stat
: use StatsBasecrosscov()
,biased
value is ignored
Returns
Named tuple containing:
xc::Array{Float64, 3}
: cross-covariancel::Vector{Float64}
: lags [s]
Plot
NeuroAnalyzer.add_plot_locs
— Functionadd_plot_locs(p1, p2; <keyword arguments>)
Add locations to a plot. Locations are placed in the top right corner. If file_name
is provided, the plot is saved as PNG file.
Arguments
p1::Plots.Plot{Plots.GRBackend}
: signal plotp2::Plots.Plot{Plots.GRBackend}
: locations plotview::Bool=true
: view the output imagefile_name::String=""
: output image filename
Returns
c::Cairo.CairoSurfaceBase{UInt32}
NeuroAnalyzer.add_to_canvas
— Functionadd_to_canvas(c1, c2; <keyword arguments>)
Place CairoSurfaceBase at another canvas at x, y
. If file_name
is provided, the plot is saved as PNG file.
Arguments
c1::Cairo.CairoSurfaceBase{UInt32}
c2::Cairo.CairoSurfaceBase{UInt32}
x::Int64
y::Int64
title::String=""
: title of the subplotview::Bool=true
: view the output imagefile_name::String=""
: output image filename
Returns
c::Cairo.CairoSurfaceBase{UInt32}
NeuroAnalyzer.add_topmargin_canvas
— Functionadd_topmargin_canvas(c1, c2)
Resize CairoSurfaceBase to make space for another canvas
Arguments
c1::Cairo.CairoSurfaceBase{UInt32}
c2::Cairo.CairoSurfaceBase{UInt32}
Returns
c::Cairo.CairoSurfaceBase{UInt32}
NeuroAnalyzer.plot
— Functionplot(obj; <keyword arguments>)
Plot signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectep::Union{Int64, AbstractRange}=0
: epoch to displaych::Union{String, Vector{String}}
: channel name or list of channel namesseg::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 titlemono::Bool=false
: use color or gray paletteemarkers::Bool
: draw epoch markers if availablemarkers::Bool
: draw markers if availablescale::Bool=true
: draw scaletype::Symbol=:normal
: plot type::normal
:mean
: mean ± 95%CI:butterfly
: butterfly plot
avg::Bool=false
: plot average EDAbad::Bool=false
: plot bad channelss_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}
plot(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 titlemono::Bool=false
: use color or gray paletteemarkers::Bool
: draw epoch markers if availablescale::Bool=true
: draw scaletype::Symbol=:normal
: plot type::normal
:mean
: mean ± 95%CI:butterfly
: butterfly plot
avg::Bool=false
: plot average EDAkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot(obj1, obj2; <keyword arguments>)
Plot signal.
Arguments
obj1::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectobj2::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectep::Union{Int64, AbstractRange}=0
: epoch to displaych::Union{String, Vector{String}}
: channel name or list of channel namesseg::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 titlescale::Bool=true
: draw scalekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot2canvas
— Functionplot2canvas(c)
Convert Plots.Plot to CairoSurfaceBase.
Arguments
p::Plots.Plot{Plots.GRBackend}
Returns
c::Cairo.CairoSurfaceBase{UInt32}
NeuroAnalyzer.plot_bar
— Functionplot_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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_box
— Functionplot_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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_ci
— Functionplot_ci(s, s_ci_l, s_ci_h; <keyword arguments>)
Dots plot.
Arguments
s::AbstractVector
: signals_l::AbstractVector
: CI lower bounds_u::AbstractVector
: CI upper boundt::AbstractVector
: time pointsxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_coherence
— Functionplot_coherence(coh, f; <keyword arguments>)
Plot coherence.
Arguments
coh::Vector{Float64}
: coherencef::Vector{Float64}
: frequenciesfrq_lim::Tuple{Real, Real}=(f[1], f[end])
: frequency limit for the X-axisxlabel::String="Frequency [Hz]"
: x-axis labelylabel::String="Coherence"
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray paletteax::Symbol=:linlin
: type of axes scaling::linlin
: linear-linear:loglin
: log10-linear
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_coherence(coh, f; <keyword arguments>)
Plot multi-channel coherence.
Arguments
coh::Matrix{Float64}
: coherencef::Vector{Float64}
: frequenciesclabels::Vector{String}=[""]
: channel pairs labels vectorfrq_lim::Tuple{Real, Real}=(f[1], f[end])
: frequency limit for the X-axisxlabel::String="Frequency [Hz]"
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray paletteax::Symbol=:linlin
: type of axes scaling::linlin
: linear-linear:loglin
: log10-linear
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_coherence_avg
— Functionplot_coherence_avg(coh, f; <keyword arguments>)
Plot coherence mean and ±95% CI of averaged channels.
Arguments
coh::Matrix{Float64}
: coherencef::Vector{Float64}
: frequenciesclabels::Vector{String}=[""]
: channel pairs labels vectorfrq_lim::Tuple{Real, Real}=(f[1], f[end])
: frequency limit for the X-axisxlabel::String="Frequency [Hz]"
: x-axis labelylabel::String="Coherence"
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray paletteax::Symbol=:linlin
: type of axes scaling::linlin
: linear-linear:loglin
: log10-linear
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_coherence_butterfly
— Functionplot_coherence_butterfly(coh, f; <keyword arguments>)
Butterfly PSD plot.
Arguments
coh::Array{Float64, 3}
: coherencef::Vector{Float64}
: frequenciesclabels::Vector{String}=[""]
: signal channel labels vector- `frq_lim::Tuple{Real, Real}=(f[1], f[end]): frequency limit for the x-axis
xlabel::String="Frequency [Hz]"
: x-axis labelylabel::String="Coherence"
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray paletteax::Symbol=:linlin
: type of axes scaling::linlin
: linear-linear:loglin
: log10-linear
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_compose
— Functionplot_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 gray palettekwargs
: optional arguments forp
vector plots
Returns
pc::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_dipole2d
— Functionplot_dipole2d(d; <keyword arguments>)
Plot dipole in 2D.
Arguments
d::NeuroAnalyzer.DIPOLE
Returns
p::Plots.Plot{Plots.GRBackend}
Notes
Brain volume is within -1.0 to +1.0 (X-, Y- and Z-axis)
NeuroAnalyzer.plot_dipole3d
— Functionplot_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::Plots.Plot{Plots.GRBackend}
Notes
Brain volume is within -1.0 to +1.0 (X-, Y- and Z-axis)
NeuroAnalyzer.plot_dots
— Functionplot_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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_eda
— Functionplot_eda(t, s, bad; <keyword arguments>)
Plot EDA.
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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_eda(t, s, bad; <keyword arguments>)
Plot EDA.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::AbstractMatrix
: 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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_eda_avg
— Functionplot_eda_avg(t, s; <keyword arguments>)
Plot EDA 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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_eda_butterfly
— Functionplot_eda_butterfly(t, s; <keyword arguments>)
Butterfly plot of EDA.
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 gray paletteavg::Bool=false
: plot average EDAkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_empty
— Functionplot_empty()
Return an empty plot, useful for filling matrices of plots.
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_erop
— Functionplot_erop(p, f; <keyword arguments>)
Plot ERO (Event-Related Oscillations) power-spectrum.
Arguments
p::AbstractArray
: ERO powersf::AbstractVector
: ERO frequenciesdb::Bool=true
: whether ERO powers are normalized to dBxlabel::String="default"
ylabel::String="default"
title::String="default"
frq_lim::Tuple{Real, Real}=(f[1], f[end])
: frequency limit for the Y-axisax::Symbol=:linlin
: type of axes scaling::linlin
: linear-linear:loglin
: log10-linear:linlog
: linear-log10:loglog
: log10-log10
units::String="μV"
mono::Bool=false
: use color or gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_eros
— Functionplot_eros(s, f, t; <keyword arguments>)
Plot ERO (Event-Related Oscillations) spectrogram.
Arguments
s::AbstractArray
: ERO spectrogramf::AbstractVector
: ERO frequenciest::AbstractVector
: ERO timedb::Bool=true
: whether ERO powers are normalized to dBfrq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingfrq_lim::Tuple{Real, Real}=(f[1], f[end])
: frequency limit for the Y-axistm::Union{Int64, Vector{Int64}}=0
: time markers (in milliseconds) to be 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 barmono::Bool=false
: use color or gray paletteunits::String="μV"
smooth::Bool=false
: smooth the image using Gaussian blurn::Int64=3
: kernel size of the Gaussian blur (larger kernel means more smoothing)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_erp
— Functionplot_erp(t, s, bad; <keyword arguments>)
Plot ERP/ERF.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::AbstractVector
: data to plotrt::Union{Nothing, Real}=nothing
:: response time valuexlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray paletteyrev::Bool=false
: reverse Y axiskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_erp(obj; <keyword arguments>)
Plot ERP/ERF.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{String, Vector{String}}
: channel name or list of channel namestm::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 gray 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
: butterfly plot:topo
: topographical plot of ERPs:stack
: stacked epochs/channels
yrev::Bool=false
: reverse Y axisavg::Bool=false
: plot average ERP for:butterfly
plotsmooth::Bool=false
: smooth the image using Gaussian blurn::Int64=3
: kernel size of the Gaussian blur (larger kernel means more smoothing)rt::Union{Nothing, Real, AbstractVector}=nothing
: response time for each epoch; if provided, the response time line will be plotted over the:stack
plotsort_epochs::Bool=false
:: sort epochs by rt vectorkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_erp_avg
— Functionplot_erp_avg(t, s; <keyword arguments>)
Plot ERP/ERF amplitude mean and ±95% CI.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::AbstractArray
: data to plotrt::Union{Nothing, Real}=nothing
:: response time valuexlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray paletteyrev::Bool=false
: reverse Y axiskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_erp_butterfly
— Functionplot_erp_butterfly(t, s; <keyword arguments>)
Butterfly plot of ERP.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::AbstractArray
: data to plotrt::Union{Nothing, Real}=nothing
:: response time valueclabels::Vector{String}=[""]
: signal channel labels vectorxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray 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_stack
— Functionplot_erp_stack(s; <keyword arguments>)
Plot EPRs stacked by channels or by epochs.
Arguments
t::AbstractVector
: x-axis valuess::AbstractArray
rt::Union{Nothing, AbstractVector}=nothing
: response time for each epoch; if provided, the response time line will be plotted over the:stack
plotclabels::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 gray palettesmooth::Bool=false
: smooth the image using Gaussian blurn::Int64=3
: kernel size of the Gaussian blur (larger kernel means more smoothing)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_erp_topo
— Functionplot_erp_topo(locs, t, s; <keyword arguments>)
Plot topographical map ERPs.
Arguments
locs::DataFrame
: columns: channel, labels, locradius, loctheta, locx, locy, locz, locradiussph, locthetasph, locphi_spht::Vector{Float64}
: time vectors::Matrix{Float64}
: 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 coordinates, otherwise use polar coordinates for XY plane and spherical coordinates for XZ and YZ planesmono::Bool=false
: use color or gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_filter_response
— Functionplot_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 filtersw::Union{Nothing, AbstractVector, Int64}=nothing
: window for:fir
filter (default is Hamming window, number of taps is calculated using Fred Harris' rule-of-thumb) or weights for:firls
filtermono::Bool=false
: use color or gray 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_histogram
— Functionplot_histogram(s; <keyword arguments>)
Plot histogram.
Arguments
s::AbstractVector
x::Union{Nothing, Real}=nothing
: value to plot against the histogramtype::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 gray palettedraw_mean::Bool=true
draw_median::Bool=true
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_icatopo
— Functionplot_icatopo(obj; <keyword arguments>)
Topographical plot of embedded ICA components.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{String, Vector{String}}
: channel name or list of channel namesic_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}
plot_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)ch::Union{String, Vector{String}}
: channel name or list of channel namesic_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_line
— Functionplot_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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_locs
— Functionplot_locs(locs; <keyword arguments>)
Preview channel locations.
Arguments
locs::DataFrame
: columns: channel, labels, locradius, loctheta, locx, locy, locz, locradiussph, locthetasph, locphi_sphch::Union{Int64, Vector{Int64}, AbstractRange}=1:nrow(locs)
: list of locations to plot, default is all locationsselected::Union{Int64, Vector{Int64}, AbstractRange}=0
: which channels should be highlightedch_labels::Bool=true
: plot locations labelshead::Bool=true
: draw headhead_labels::Bool=false
: plot head labelsmono::Bool=false
: use color or gray palettegrid::Bool=false
: draw grid, useful for locating positionslarge::Bool=true
: draw large (size of electrodes area 600×600 px, more details) or small (size of electrodes area 240×240 px, less details) plotcart::Bool=false
: if true, use Cartesian coordinates, otherwise use polar coordinates for XY plane and spherical coordinates for XZ and YZ planesplane::Symbol=:xy
: which plane to plot::xy
: horizontal (top):xz
: coronary (front):yz
: sagittal (side)
transparent::Bool=false
: if true, do not paint the backgroundconnections::Matrix{<:Real}=[0 0; 0 0]
: matrix of connections weights (channels by channels)threshold::Real=0
: threshold for plotting, see belowthreshold_type::Symbol=:neq
: rule for thresholding::eq
: plot if connection weight is equal to threshold:neq
: plot if connection weight is not equal to threshold:geq
: plot if connection weight is ≥ to threshold:leq
: plot if connection weight is ≤ to threshold:g
: plot if connection weight is > to threshold:l
: plot if connection weight is < to threshold
weights::Union{Bool, Vector{<:Real}}=true
: weight line widths and alpha based on connection value, if false connections values will be drawn or vector of weights
Returns
p::Plots.Plot{Plots.GRBackend}
plot_locs(obj; <keyword arguments>)
Preview of channel locations.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesselected::Union{String, Vector{String}}
: which channels 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 labelsthreed::Bool=false
: 3-dimensional plotmono::Bool=false
: use color or gray palettegrid::Bool=false
: draw grid, useful for locating positionslarge::Bool=true
: draw large (size of electrodes area 600×600 px, more details) or small (size of electrodes area 240×240 px, less details) plotcart::Bool=false
: if true, use Cartesian coordinates, otherwise use polar coordinates for XY plane and spherical coordinates for XZ and YZ planesplane::Symbol=:xy
: which plane to plot::xy
: horizontal (top):xz
: coronary (front):yz
: sagittal (side)
interactive::Bool=true
: if true, use interactive 3-dimensional plottransparent::Bool=false
: if true, do not paint the backgroundconnections::Matrix{<:Real}=[0 0; 0 0]
: matrix of connections weights (channels by channels)threshold::Real=0
: threshold for plotting, see belowthreshold_type::Symbol=:neq
: rule for thresholding::eq
: plot if connection weight is equal to threshold:neq
: plot if connection weight is not equal to threshold:geq
: plot if connection weight is ≥ to threshold:leq
: plot if connection weight is ≤ to threshold:g
: plot if connection weight is > to threshold:l
: plot if connection weight is < to threshold
weights::Union{Bool, Vector{<:Real}}=true
: weight line widths and alpha based on connection value, if false connections values will be drawn or vector of weights
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_locs3d
— Functionplot_locs3d(locs; <keyword arguments>)
3D preview of channel locations.
Arguments
locs::DataFrame
: columns: channel, labels, locradius, loctheta, locx, locy, locz, locradiussph, locthetasph, locphi_sphch::Union{Int64, Vector{Int64}}=1:nrow(locs)
: list of channels, default is all channelsselected::Union{Int64, Vector{Int64}, AbstractRange}=0
: which channel should be highlightedch_labels::Bool=true
: plot channel labelshead_labels::Bool=true
: plot head labelsmono::Bool=false
: use color or gray palettecart::Bool=false
: if true, use Cartesian coordinates, otherwise use spherical coordinatescamera::Tuple{Real, Real}=(20, 45)
: camera position – (XY plane angle, XZ plane angle)
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_locs_nirs
— Functionplot_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: labels, locradius, loctheta, locx, locy, locz, locradiussph, locthetasph, locphi_sphopt_pairs::Matrix{Int64}
: pairs of source and detectorsrc_n::Int64
: number of sourcesdet_n::Int64
: number of detectorsch::Union{String, Vector{String}}
: channel name or list of channel namesselected::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 gray palettegrid::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_matrix
— Functionplot_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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_mep
— Functionplot_mep(t, s, bad; <keyword arguments>)
Plot MEP.
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 gray paletteyrev::Bool=false
: reverse Y axiskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_mep(obj; <keyword arguments>)
Plot MEP.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{String, Vector{String}}
: channel name or list of channel namestm::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 MEP 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 gray palettepeaks::Bool=true
: draw peakspeaks_detect::Bool=true
: if true, detect MEP peaks, otherwise use embeddedchannel_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 MEP for:butterfly
plotkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_mep_avg
— Functionplot_mep_avg(t, s; <keyword arguments>)
Plot MEP 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 gray paletteyrev::Bool=false
: reverse Y axiskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_mep_butterfly
— Functionplot_mep_butterfly(t, s; <keyword arguments>)
Butterfly plot of MEP.
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 gray paletteavg::Bool=false
: plot average MEPyrev::Bool=false
: reverse Y axiskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_mep_stack
— Functionplot_mep_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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_paired
— Functionplot_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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_phsd
— Functionplot_phsd(sf, sp; <keyword arguments>)
Plot PHSD (phase spectral density).
Arguments
sf::Vector{Float64}
: frequenciessp::Vector{Float64}
:phasesfrq_lim::Tuple{Real, Real}=(sf[1], sf[end])
: frequency limit for the X-axisxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_phsd(sf, sp; <keyword arguments>)
Plot multi-channel PHSD (phase spectral density).
Arguments
sf::Vector{Float64}
: frequenciessp::Matrix{Float64}
:phasesclabels::Vector{String}=[""]
: signal channel labels vectorfrq_lim::Tuple{Real, Real}=(sf[1], sf[end])
: frequency limit for the X-axisxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_phsd(obj; <keyword arguments>)
Plot phase spectral 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{String, Vector{String}}
: channel name or list of channel namesfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: frequency boundsax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
)xlabel::String="default"
: x-axis label, default is Frequency [Hz]ylabel::String="default"
: y-axis label, default is Phase [rad]zlabel::String="default"
: z-axis label for 3-d plots, default is Phase [rad]title::String="default"
: plot title, default is PHSD [frequency limit: 0-128 Hz] [channel: 1, epoch: 1, time window: 0 ms:10 s]mono::Bool=false
: use color or gray 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::Plots.Plot{Plots.GRBackend}
plot_phsd(obj; <keyword arguments>)
Plot phase spectral 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 channelsfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: frequency boundsax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
)xlabel::String="default"
: x-axis label, default is Frequency [Hz]ylabel::String="default"
: y-axis label, default is Phase [rad]zlabel::String="default"
: z-axis label for 3-d plots, default is Phase [rad]title::String="default"
: plot title, default is PHSD [frequency limit: 0-128 Hz] [channel: 1, epoch: 1, time window: 0 ms:10 s]mono::Bool=false
: use color or gray 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_phsd_3d
— Functionplot_phsd_w3d(sf, sp; <keyword arguments>)
Plot 3-d waterfall PHSD plot.
Arguments
sf::Vector{Float64}
: frequenciessp::Array{Float64, 3}
:phasesclabels::Vector{String}=[""]
: signal channel labels vector- `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 gray paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
)variant::Symbol
: waterfall (:w
) or surface (:s
)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_phsd_avg
— Functionplot_phsd_avg(sf, sp; <keyword arguments>)
Plot PHSD mean and ±95% CI of averaged channels.
Arguments
sf::Vector{Float64}
: frequenciessp::Array{Float64, 3}
:phasesxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_phsd_butterfly
— Functionplot_phsd_butterfly(sf, sp; <keyword arguments>)
Butterfly PHSD plot.
Arguments
sf::Vector{Float64}
: frequenciessp::Array{Float64, 3}
:phasesclabels::Vector{String}=[""]
: signal channel labels vector- `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 gray paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_phsd_topo
— Functionplot_phsd_topo(locs, sf, sp; <keyword arguments>)
Plot topographical map PHSDs.
Arguments
locs::DataFrame
: columns: channel, labels, locradius, loctheta, locx, locy, locz, locradiussph, locthetasph, locphi_sphsf::Vector{Float64}
: frequenciessp::Array{Float64, 3}
:phasesch::Union{Vector{Int64}, AbstractRange}
: which channels to plotclabels::Vector{String}=[""]
: signal channel labels vector- `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 gray paletteax::Symbol=:linlin
: type of axes scaling: linear-linear (:linlin
), log10-linear (:loglin
)cart::Bool=false
: if true, use Cartesian coordinates, otherwise use polar coordinates for XY plane and spherical coordinates for XZ and YZ planeskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_polar
— Functionplot_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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_psd
— Functionplot_psd(sf, sp; <keyword arguments>)
Plot PSD (power spectrum density).
Arguments
sf::Vector{Float64}
: frequenciessp::Vector{Float64}
: powersdb::Bool=true
: whether powers are normalized to dBfrq_lim::Tuple{Real, Real}=(sf[1], sf[end])
: frequency limit for the X-axisxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray palettefrq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_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 vectordb::Bool=true
: whether powers are normalized to dBfrq_lim::Tuple{Real, Real}=(sf[1], sf[end])
: frequency limit for the X-axisxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray palettefrq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_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{String, Vector{String}}
: channel name or list of channel namesdb::Bool=true
: normalize powers to dBmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: frequency boundsncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available waveletsref::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
frq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingxlabel::String="default"
: x-axis label, default is Frequency [Hz]ylabel::String="default"
: y-axis label, default isPower [dB units^2/Hz] or Power [units^2/Hz]
zlabel::String="default"
: z-axis label for 3-d plots, default isPower [dB units^2/Hz] 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 gray palettetype::Symbol=:normal
: plot type::normal
:butterfly
:mean
:w3d
: 3-d waterfall:s3d
: 3-d surface:topo
: topographical
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_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 channelsdb::Bool=true
: normalize powers to dBmethod::Symbol=:welch
: method used to calculate PSD::welch
: Welch's periodogram:fft
: fast Fourier transform:mt
: multi-tapered periodogram:stft
: short time Fourier transform:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=fs
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: frequency boundsncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
gw::Real=5
: Gaussian width in Hzwt::T where {T <: CWT}=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, see ContinuousWavelets.jl documentation for the list of available waveletsref::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
frq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingxlabel::String="default"
: x-axis label, default is Frequency [Hz]ylabel::String="default"
: y-axis label, default isPower [dB units^2/Hz] or Power [units^2/Hz]
zlabel::String="default"
: z-axis label for 3-d plots, default isPower [dB units^2/Hz] 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 gray palettetype::Symbol=:normal
: plot type::normal
:butterfly
:mean
:w3d
: 3-d waterfall:s3d
: 3-d surface:topo
: topographical
kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_psd_3d
— Functionplot_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 vectordb::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 gray palettefrq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingvariant::Symbol
: waterfall (:w
) or surface (:s
)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_psd_avg
— Functionplot_psd_avg(sf, sp; <keyword arguments>)
Plot PSD mean and ±95% CI of averaged channels.
Arguments
sf::Vector{Float64}
: frequenciessp::Matrix{Float64}
: powersdb::Bool=true
: whether powers are normalized to dBfrq_lim::Tuple{Real, Real}=(sf[1], sf[end])
: frequency limit for the X-axisxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray palettefrq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_psd_butterfly
— Functionplot_psd_butterfly(sf, sp; <keyword arguments>)
Butterfly PSD plot.
Arguments
sf::Vector{Float64}
: frequenciessp::Array{Float64, 3}
: powersclabels::Vector{String}=[""]
: signal channel labels vectordb::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 gray palettefrq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_psd_topo
— Functionplot_psd_topo(locs, sf, sp; <keyword arguments>)
Plot topographical map PSDs.
Arguments
locs::DataFrame
: columns: channel, labels, locradius, loctheta, 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 vectordb::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 gray palettefrq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingcart::Bool=false
: if true, use Cartesian coordinates, otherwise use polar coordinates for XY plane and spherical coordinates for XZ and YZ planeskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_save
— Functionplot_save(p; <keyword arguments>)
Saves plot as file (PNG/PDF). File format is determined using file_name
extension.
Arguments
p::Plots.Plot{Plots.GRBackend}
file_name::String
Returns
Nothing
NeuroAnalyzer.plot_signal
— Functionplot_signal(t, s; <keyword arguments>)
Plot amplitude of single-channel signal.
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 titlebad::Bool=false
: is this a bad channelkwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_signal(t, s; <keyword arguments>)
Plot amplitude of multi-channel signal.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s::AbstractArray
: data to plotclabels::Vector{String}=repeat([""], size(s, 1))
: channel labelsctypes:::Vector{String}=repeat([""], size(s, 1))
: channel typescunits::Vector{String}=repeat([""], size(s, 1))
: channel unitsxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray palettescale::Bool=true
: draw scalebad::Vector{Bool}=zeros(Bool, size(s, 1))
: list of bad channelskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_signal(t, s1, s2; <keyword arguments>)
Plot amplitude of single-channel signal.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s1::AbstractVector
: data to plots2::AbstractVector
: data to plotxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_signal(t, s1, s2; <keyword arguments>)
Plot amplitude of multi-channel signals.
Arguments
t::Union{AbstractVector, AbstractRange}
: x-axis values (usually time)s1::AbstractArray
: data to plots2::AbstractArray
: data to plotclabels::Vector{String}=repeat([""], size(s1, 1))
: channel labelsctypes:::Vector{String}=repeat([""], size(s1, 1))
: channel typescunits::Vector{String}=repeat([""], size(s1, 1))
: channel unitsxlabel::String=""
: x-axis labelylabel::String=""
: y-axis labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray palettescale::Bool=true
: draw scalekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_signal_avg
— Functionplot_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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_signal_butterfly
— Functionplot_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 titleavg::Bool=false
: plot average channelsmono::Bool=false
: use color or gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_spectrogram
— Functionplot_spectrogram(st, sf, sp; <keyword arguments>)
Plot single-channel spectrogram.
Arguments
st::Vector{Float64}
: timesf::Vector{<:Real}
: frequenciessp::Matrix{Float64}
: powersdb::Bool=true
: whether powers are normalized to dBfrq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingfrq_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 gray paletteunits::String=""
smooth::Bool=false
: smooth the image using Gaussian blurn::Int64=3
: kernel size of the Gaussian blur (larger kernel means more smoothing)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_spectrogram(sch, sf, sp; <keyword arguments>)
Plot multiple-channel spectrogram.
Arguments
sch::Vector{String}
: channel labelssf::Vector{<:Real}
: frequenciessp::Matrix{Float64}
: powersdb::Bool=true
: whether powers are normalized to dBfrq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingfrq_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 gray paletteunits::String=""
smooth::Bool=false
: smooth the image using Gaussian blurn::Int64=3
: kernel size of the Gaussian blur (larger kernel means more smoothing)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_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{String, Vector{String}}
: channel name or list of channel namesdb::Bool=true
: normalize powers to dB; for CWT scaleogram: normalize to the signal scale so the amplitudes of wavelet coefficients agree with the amplitudes of oscillatory components in a signalmethod::Symbol=:stft
: method of calculating spectrogram::stft
: short-time Fourier transform:mt
: multi-tapered periodogram:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowgw::Real=5
: Gaussian width in Hzncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
wt<:CWT=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, e.g.wt = wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletsfrq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: y-axis limitsxlabel::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 gray palettemarkers::Bool
: draw markers if availablesmooth::Bool=false
: smooth the image using Gaussian blurn::Int64=3
: kernel size of the Gaussian blur (larger kernel means more smoothing)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_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 channelsdb::Bool=true
: normalize powers to dB; for CWT scaleogram: normalize to the signal scale so the amplitudes of wavelet coefficients agree with the amplitudes of oscillatory components in a signalmethod::Symbol=:stft
: method of calculating spectrogram::stft
: short-time Fourier transform:mt
: multi-tapered periodogram:mw
: Morlet wavelet convolution:gh
: Gaussian and Hilbert transform:cwt
: continuous wavelet transformation
nt::Int64=7
: number of Slepian taperswlen::Int64=sr(obj)
: window length (in samples), default is 1 secondwoverlap::Int64=round(Int64, wlen * 0.97)
: window overlap (in samples)w::Bool=true
: if true, apply Hanning windowgw::Real=5
: Gaussian width in Hzncyc::Union{Int64, Tuple{Int64, Int64}}=32
: number of cycles for Morlet wavelet, for tuple a variable number of cycles is used per frequency:ncyc=linspace(ncyc[1], ncyc[2], frq_n)
, wherefrq_n
is the length of0:(sr(obj) / 2)
wt<:CWT=wavelet(Morlet(2π), β=32, Q=128)
: continuous wavelet, e.g.wt = wavelet(Morlet(2π), β=32, Q=128)
, see ContinuousWavelets.jl documentation for the list of available waveletsfrq::Symbol=:lin
: linear (:lin
) or logarithmic (:log
) frequencies scalingfrq_lim::Tuple{Real, Real}=(0, sr(obj) / 2)
: y-axis limitsxlabel::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 gray palettemarkers::Bool
: draw markers if availableunits::String=""
smooth::Bool=false
: smooth the image using Gaussian blurn::Int64=3
: kernel size of the Gaussian blur (larger kernel means more smoothing)kwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_topo
— Functionplot_topo(c; <keyword arguments>)
Plot topographical view.
Arguments
s::Vector{<:Real}
: values to plot (one value per channel)locs::DataFrame
: columns: channel, labels, locradius, loctheta, locx, locy, locz, locradiussph, locthetasph, locphi_sphch::Union{Int64, Vector{Int64}}=1:nrow(locs)
: list of channels, default is all channelscb::Bool=true
: plot color barcb_label::String="[A.U.]"
: color bar labeltitle::String=""
: plot titlemono::Bool=false
: use color or gray 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_contours::Bools=true
: plot contours over topo plotplot_electrodes::Bools=true
: plot electrodes over topo plotlarge::Bool=true
: draw large (size of electrodes area 600×600 px, more details) or small (size of electrodes area 240×240 px, less details) plothead::Bool=true
: draw headcart::Bool=false
: if true, use Cartesian coordinates, otherwise use polar coordinates for XY plane and spherical coordinates for XZ and YZ planeskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_topo(obj; <keyword arguments>)
Topographical plot.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectep::Union{Int64, AbstractRange}=0
: epoch to displaych::Union{String, Vector{String}}
: channel name or list of channel namesseg::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 gray 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_contours::Bools=true
: plot contours over topo plotplot_electrodes::Bools=true
: plot electrodes over topo plotlarge::Bool=true
: draw large (size of electrodes area 600×600 px, more details) or small (size of electrodes area 240×240 px, less details) plothead::Bool=true
: draw headcart::Bool=false
: if true, use Cartesian coordinates, otherwise use polar coordinates for XY plane and spherical coordinates for XZ and YZ planeskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
plot_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 gray 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_contours::Bools=true
: plot contours over topo plotplot_electrodes::Bools=true
: plot electrodes over topo plotlarge::Bool=true
: draw large (size of electrodes area 600×600 px, more details) or small (size of electrodes area 240×240 px, less details) plothead::Bool=true
: draw headcart::Bool=false
: if true, use Cartesian coordinates, otherwise use polar coordinates for XY plane and spherical coordinates for XZ and YZ planeskwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_violin
— Functionplot_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 gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.plot_xac
— Functionplot_xac(m, lags; <keyword arguments>)
Plot cross/auto-covariance/correlation.
Arguments
m::Abstractvector
: covariance matrixlags::AbstractVector
: covariance lagsxlabel::String="lag"
ylabel::String=""
title::String=""
cb_title::String=""
: color bar titlemono::Bool=false
: use color or gray palettekwargs
: optional arguments for plot() function
Returns
p::Plots.Plot{Plots.GRBackend}
NeuroAnalyzer.resize_canvas
— Functionresize_canvas(c; <keyword arguments>)
Resize CairoSurfaceBase by a factor.
Arguments
c::Cairo.CairoSurfaceBase{UInt32}
r::Real
: resizing factor
Returns
c_new::Cairo.CairoSurfaceBase{UInt32}
GUI
NeuroAnalyzer.iedit
— Functioniedit(obj; <keyword arguments>)
Interactive edit signal channels properties and locations.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::String
: initial channel
Returns
Nothing
NeuroAnalyzer.iplot_locs3d
— Functioniplot_locs3d(locs; <keyword arguments>)
3D interactive preview of channel locations.
Arguments
locs::DataFrame
: columns: channel, labels, locradius, loctheta, locx, locy, locz, locradiussph, locthetasph, locphi_sphch::Union{Int64, Vector{Int64}}=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 gray palettecart::Bool=false
: if true, use Cartesian coordinates, otherwise use spherical coordinatescamera::Tuple{Real, Real}=(20, 45)
: camera position – (XY plane angle, XZ plane angle)
Returns
Nothing
iplot_locs3d(obj; <keyword arguments>)
3D interactive preview of channel locations.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}=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 gray palettecart::Bool=false
: if true, use Cartesian coordinates, otherwise use spherical coordinatescamera::Tuple{Real, Real}=(20, 45)
: camera position – (XY plane angle, XZ plane angle)
Returns
Nothing
NeuroAnalyzer.ipsd
— Functionipsd(obj; <keyword arguments>)
Interactive PSD of continuous signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::String
: channel namezoom::Real=10
: how many seconds are displayed in one segment
Returns
Nothing
NeuroAnalyzer.ipsd_ep
— Functionipsd_ep(obj, ch)
Interactive PSD of epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::String
: channel name
Returns
Nothing
NeuroAnalyzer.iselect_seg
— Functioniselect_seg(m; <keyword arguments>)
Interactive selection of matrix area.
Arguments
m::AbstractMatrix
shape::Symbol=:r
: selection shape::r
: rectangular:c
: circular:p
: point
extract::Bool=false
: if true, return values of the matrixv::Bool=false
: if true, return as vector (matrix m by rows over columns)
Returns
r1::Int64
: upper-left cornerr2::Int64
: bottom-right cornerc1::Int64
: upper-left cornerc2::Int64
: bottom-right corner
or
seg::Union{AbstractMatrix, AbstractVector, Tuple{AbstractVector, AbstractVector}}
: extracted segment
NeuroAnalyzer.ispectrogram
— Functionispectrogram(obj; <keyword arguments>)
Interactive spectrogram of continuous signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::String
: channel namezoom::Real=10
: how many seconds are displayed in one segment
Returns
Nothing
NeuroAnalyzer.ispectrogram_ep
— Functionispectrogram_ep(obj; <keyword arguments>)
Interactive spectrogram of epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::String
: channel name
Returns
Nothing
NeuroAnalyzer.itopo
— Functionitopo(obj; <keyword arguments>)
Interactive topographical map of continuous signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{String, Vector{String}}
: channels to plot
Returns
Nothing
NeuroAnalyzer.itopo_ep
— Functionitopo_ep(obj; <keyword arguments>)
Interactive topographical map of epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{String, Vector{String}}
: channels to plot
Returns
Nothing
NeuroAnalyzer.iview
— Functioniview(obj; <keyword arguments>)
Interactive view of continuous signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectmch::Bool=true
: draw multichannel signal (up to 20 channels in one plot)zoom::Real=10
: how many seconds are displayed in one segmentbad::Bool=true
: list of bad channels; if not false – plot bad channels using this listsnap::Bool=true
: snap region markers to grid at 0.0, 0.25, 0.5 and 0.75 time points
Returns
seg::Union{Nothing, Tuple{Float64, Float64}}
iview(obj1, obj2; <keyword arguments>)
Interactive view of two continuous signals.
Arguments
obj1::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectobj2::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectzoom::Real=10
: how many seconds are displayed in one segment
Returns
Nothing
iview(obj, c; <keyword arguments>)
Interactive view of embedded or external component of continuous signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectc::Union{Symbol, AbstractArray}
: component to plotzoom::Real=10
: how many seconds are displayed in one segment
Returns
Nothing
iview(p)
View plot object.
Arguments
p::Plots.Plot{Plots.GRBackend}
Returns
Nothing
iview(file_name)
View PNG image.
Arguments
file_name::String
Returns
Nothing
iview(c)
View Cairo surface object.
Arguments
c::Cairo.CairoSurfaceBase{UInt32}
Returns
Nothing
NeuroAnalyzer.iview_ep
— Functioniview_ep(obj; <keyword arguments>)
Interactive view of epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectmch::Bool=true
: draw multichannel signal (up to 20 channels in one plot)ep::Int64=1
: initial epoch to displaybad::Bool=true
: list of bad channels; if not false – plot bad channels using this listsnap::Bool=true
: snap region markers to grid at 0.0, 0.25, 0.5 and 0.75 time points
Returns
seg::Union{Nothing, Tuple{Float64, Float64}}
iview_ep(obj1, obj2; <keyword arguments>)
Interactive view of two epoched signals.
Arguments
obj1::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectobj2::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectep::Int64=1
: initial epoch to display
Returns
Nothing
iview_ep(obj, c; <keyword arguments>)
Interactive view of embedded or external component of epoched signal.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectc::Union{Symbol, AbstractArray}
: component to plotep::Int64=1
: initial epoch to display
Returns
Nothing
NeuroAnalyzer.iview_ica
— Functioniview_ica(obj; <keyword arguments>)
Interactive view of embedded ("ic" and "ic_mw") ICA components.
Arguments
obj::NeuroAnalyzer.NEURO
: NeuroAnalyzer NEURO objectch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Nothing
iview_ica(obj, ic, ic_mw; <keyword arguments>)
Interactive view 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)ch::Union{String, Vector{String}}
: channel name or list of channel names
Returns
Nothing
Statistics
Statistics.std
— Functionstd(itr; corrected::Bool=true, mean=nothing[, dims])
Compute the sample standard deviation of collection itr
.
The algorithm returns an estimator of the generative distribution's standard deviation under the assumption that each entry of itr
is a sample drawn from the same unknown distribution, with the samples uncorrelated. For arrays, this computation is equivalent to calculating sqrt(sum((itr .- mean(itr)).^2) / (length(itr) - 1))
. If corrected
is true
, then the sum is scaled with n-1
, whereas the sum is scaled with n
if corrected
is false
with n
the number of elements in itr
.
If itr
is an AbstractArray
, dims
can be provided to compute the standard deviation over dimensions.
A pre-computed mean
may be provided. When dims
is specified, mean
must be an array with the same shape as mean(itr, dims=dims)
(additional trailing singleton dimensions are allowed).
If array contains NaN
or missing
values, the result is also NaN
or missing
(missing
takes precedence if array contains both). Use the skipmissing
function to omit missing
entries and compute the standard deviation of non-missing values.
std(x::AbstractArray, w::AbstractWeights, [dim]; mean=nothing, corrected=false)
Compute the standard deviation of a real-valued array x
, optionally over a dimension dim
. Observations in x
are weighted using weight vector w
. The uncorrected (when corrected=false
) sample standard deviation is defined as:
\[\sqrt{\frac{1}{\sum{w}} \sum_{i=1}^n {w_i\left({x_i - μ}\right)^2 }}\]
where $n$ is the length of the input and $μ$ is the mean. The unbiased estimate (when corrected=true
) of the population standard deviation is computed by replacing $\frac{1}{\sum{w}}$ with a factor dependent on the type of weights used:
AnalyticWeights
: $\frac{1}{\sum w - \sum {w^2} / \sum w}$FrequencyWeights
: $\frac{1}{\sum{w} - 1}$ProbabilityWeights
: $\frac{n}{(n - 1) \sum w}$ where $n$ equalscount(!iszero, w)
Weights
:ArgumentError
(bias correction not supported)
std(ce::CovarianceEstimator, x::AbstractVector; mean=nothing)
Compute the standard deviation of the vector x
using the estimator ce
.
std(d::UnivariateDistribution)
Return the standard deviation of distribution d
, i.e. sqrt(var(d))
.
std(m::MixedModel)
Return the estimated standard deviations of the random effects as a Vector{Vector{T}}
.
FIXME: This uses an old convention of isfinite(sdest(m)). Probably drop in favor of m.σs
std(obj)
Calculate standard deviation of the signal data (along epochs).
Arguments
obj::NeuroAnalyzer.NEURO
Returns
s::Matrix{Float64}
NeuroAnalyzer.binom_prob
— Functionbinom_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
bp::Float64
: probability
NeuroAnalyzer.binom_stat
— Functionbinom_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.bootstrap_ci
— Functionbootstrap_ci(s; <keyword arguments>)
Calculate Confidence Interval using bootstrapping.
Arguments
s::AbstractMatrix
: signal (time points × epochs)n1::Int64=3000
: number of stage 1 resamplings – number of samples in the resampled signaln2::Int64=1000
: number of stage 2 resamplings – number of samples sampled from the signalci::Float64=0.95
: confidence interval
Returns
Named tuple containing:
s_avg::Vector{Float64}
: averaged signals_ci_l::Vector{Float64}
: lower bound of the confidence intervals_ci_h::Vector{Float64}
: upper bound of the confidence interval
NeuroAnalyzer.bootstrap_stat
— Functionbootstrap_stat(s; <keyword arguments>)
Calculate signal statistic using bootstrapping.
Arguments
s::AbstractMatrix
: signal (time points × epochs)n1::Int64=3000
: number of stage 1 resamplings – number of samples in the resampled signaln2::Int64=1000
: number of stage 2 resamplings – number of samples sampled from the signalf::String
: statistic function to be applied, e.g.f="abs(maximum(OBJ))"; signal is given using variable
OBJ` here.
Returns
out::AbstractVector
NeuroAnalyzer.channel_stats
— Functionchannel_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.ci2z
— Functionci2z(ci)
Calculate critical z score.
Arguments
ci::Float64
: confidence level
Returns
z::Float64
NeuroAnalyzer.ci_median
— Functionci_median(x; <keyword arguments>)
Calculate confidence interval for a median.
Arguments
x::AbstractVector
ci::Float64=0.95
: confidence level
Returns
ci_median::Tuple{Float64, Float64}
ci_median(x; <keyword arguments>)
Calculate confidence interval for a median.
Arguments
x::AbstractArray
ci::Float64=0.95
: confidence level
Returns
ci_median::Tuple{Float64, Float64}
NeuroAnalyzer.ci_prop
— Functionci_prop(p, n; <keyword arguments>)
Calculate confidence interval for a proportion.
Arguments
p::Float64
: proportionn::Int64
: sample sizeci::Float64=0.95
: confidence level
Returns
ci_prop::Tuple{Float64, Float64}
NeuroAnalyzer.ci_r
— Functionci_r(x, y; <keyword arguments>)
Calculate confidence interval for a correlation coefficient.
Arguments
x::AbstractVector
y::AbstractVector
ci::Float64=0.95
: confidence level
Returns
ci_r::Tuple{Float64, Float64}
ci_r(; <keyword arguments>)
Calculate confidence interval for a correlation coefficient.
Arguments
r::Float64
: correlation coefficientn::Int64
: number of observationsci::Float64=0.95
: confidence level
Returns
ci_r::Tuple{Float64, Float64}
NeuroAnalyzer.cmp_stat
— Functioncmp_stat(stat_dist, v)
Calculate proportion of elements below or above a given statistic value.
Arguments
stat_dist::AbstractVector
: statistic values distributionv::Real
: statistic valuetype::Symbol=:g
: calculation proportion of elements greater (:g
) or lesser (:l
) thanv
Returns
p::Float64
NeuroAnalyzer.cmp_test
— Functioncmp_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::Float64
: 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
— Functioncor_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 intervalts::Tuple{Float64, String}
: t-statisticsdf::Int64
: degrees of freedomp::Float64
: p-value
NeuroAnalyzer.cosine_similarity
— Functioncosine_similarity(s1, s2)
Calculate cosine similarity.
Arguments
s1::AbstractVector
s2::AbstractVector
Returns
cs::Float64
NeuroAnalyzer.count_thresh
— Functioncount_thresh(x; <keyword arguments>)
Collect thresholded elements, e.g. in a topographical map.
Arguments
x::AbstractMatrix
t::Real
: threshold valuet_type::Symbol=:g
: rule for thresholding::eq
: =:geq
: ≥:leq
: ≤:g
: >:l
: <
Returns
Named tuple containing:
x_t::Matrix{Bool}
: thresholded matrixn::Int64
: number of elements
NeuroAnalyzer.crit_t
— Functioncrit_t(df, alpha; <keyword arguments>)
Calculate critical t value.
Arguments
df::Real
: degrees of freedom (usually df = n - 1)alpha::Float64=0.05
: alpha valuetwosided::Bool=false
: one or two tailed probability
Returns
t::Float64
Notes
Critical region for one tailed probability:
- left:
(-∞ , -t]
- right:
[t , ∞)
Critical region for two tailed probability: (-∞ , -t] ∪ [t, ∞)
NeuroAnalyzer.cvar_mean
— Functioncvar_mean(x)
Calculate coefficient of variation for a mean.
Arguments
x::AbstractVector
Returns
cvar_mean::Float64
NeuroAnalyzer.cvar_median
— Functioncvar_median(x)
Calculate coefficient of variation for a median.
Arguments
x::AbstractVector
Returns
cvar_median::Float64
NeuroAnalyzer.distance
— Functionslope(p1, p2)
Calculate distance between two points.
Arguments
p1::Tuple{Real, Real}
p2::Tuple{Real, Real}
Returns
d::Float64
: distance
NeuroAnalyzer.dprime
— Functiondprime(p1::Real, p2::Real)
Calculate d' and response bias for two proportions.
Arguments
p1::Real
p2::Real
Returns
Named tuple containing:
dp::Float64
rb::Float64
: response bias
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{Int64}
NeuroAnalyzer.effsize
— Functioneffsize(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, uses maximum likelihood estimator by Hedges and OlkinΔ::Float64
: Glass' Δ
NeuroAnalyzer.effsize_p2g
— Functioneffsize_p2g(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.epoch_stats
— Functionepoch_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.f1
— Functionf1(; <keyword arguments>)
Assess performance of the classification model using F1-score. F1-score value ranges from 0 to 1.
Arguments
tp::Int64
: number of true positivestn::Int64
: number of true negativesfp::Int64
: number of false positivesfn::Int64
: number of false negatives
Returns
Named tuple containing:
f1::Float64
: F1-scorep::Float64
: precisionr::Float64
: recall
Source
https://www.statology.org/what-is-a-good-f1-score/
NeuroAnalyzer.flim
— Functionflim(p, f; <keyword arguments>)
Trim power spectrum or spectrogram array to a range of frequencies.
Arguments
p::AbstractArray
: powersf::AbstractVector
: frequenciesfrq_lim::Tuple{Real, Real}
: frequency bounds
Returns
Named tuple containing:
p::Union{Array{Float64, 3}, Array{Float64, 4}}
: powersf::Vector{Float64}
: frequencies
NeuroAnalyzer.friedman
— Functionfriedman(m)
Estimate Friedman's nonparametric two-way analysis of variance (and Kendall's coefficient of concordance).
Arguments
m::AbstractArray
: values × groups
Returns
Named tuple containing:
f::Float64
: Friedmank::Float64
: Kendallp::Float64
: P-value
Notes
- H0 (Friedman) is that the treatments are equal
- H0 (Kendall) is that there is agreement between rankings or test results
- Kendall's coefficient of concordance ranges from 0 to 1, with 0 meaning no agreement across raters (judges)
NeuroAnalyzer.fwhm
— Functionfwhm(s)
Calculate indices of full-width half-maximum points of a Gaussian-like distribution.
Arguments
s::AbstractVector
Returns
p1_idx::Int64
: pre-peak half-maximum pointp_idx::Int64
: peakp2_idx::Int64
: post-peak half-maximum point
NeuroAnalyzer.grubbs
— Functiongrubbs(x; <keyword arguments>)
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.hildebrand_rule
— Functionhildebrand_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.infcrit
— Functioninfcrit(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.jaccard_similarity
— Functionjaccard_similarity(x, y)
Calculate Jaccard similarity between two vectors.
Arguments
x::AbstractVector
y::AbstractVector
Returns
j::Float64
NeuroAnalyzer.k_categories
— Functionk_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.linreg
— Functionlinreg(x, y)
Linear regression between two vectors.
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::Float64
: 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.mcc
— Functionmcc(; <keyword arguments>)
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.mdiff
— Functionmdiff(s1, s2; <keyword arguments>)
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
mdiff(s1, s2; <keyword arguments>)
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}
mdiff(obj1, obj2; <keyword arguments>)
Calculate mean difference and 95% confidence interval for two channels.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2:NeuroAnalyzer.NEURO
ch1::Union{String, Vector{String}}
: list of channelsch2::Union{String, Vector{String}}
: list of channelsep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(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.meanc
— Functionmeanc(x; <keyword arguments>)
Calculate circular mean.
Arguments
x::AbstractVector
: anglesrad::Bool=false
: angles in radians (rad=true
) or degrees (rad=false
)
Returns
m::Float64
NeuroAnalyzer.meang
— Functionmeang(x)
Calculate geometric mean.
Arguments
x::AbstractVector
Returns
m::Float64
NeuroAnalyzer.meanh
— Functionmeanh(x)
Calculate harmonic mean.
Arguments
x::AbstractVector
Returns
m::Float64
NeuroAnalyzer.meanw
— Functionmeanw(x, w)
Calculate weighted mean.
Arguments
x::AbstractVector
w::AbstractVector
: weights
Returns
m::Float64
NeuroAnalyzer.moe
— Functionmoe(n)
Calculate margin of error for given sample size n
.
Arguments
n::Int64
Returns
m::Float64
moe(x)
Calculate margin of error.
Arguments
x::AbstractArray
Returns
m::Float64
NeuroAnalyzer.msci95
— Functionmsci95(s; <keyword arguments>)
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
msci95(s; <keyword arguments>)
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
msci95(s; <keyword arguments>)
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::Matrix{Float64}
: meanss::Matrix{Float64}
: standard deviationsu::Matrix{Float64}
: upper 95% CIsl::Matrix{Float64}
: lower 95% CI
msci95(obj; <keyword arguments>)
Calculate mean, standard deviation and 95% confidence interval.
Arguments
obj::NeuroAnalyzer.NEURO
ch::Union{String, Vector{String}}
: channel name or list of channel namesn::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
msci95(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
msci95(s1, s2)
Calculate mean difference, standard deviation and 95% confidence interval.
Arguments
s1::AbstractArray
s2::AbstractArray
Returns
Named tuple containing:
sm::Matrix{Float64}
: meanss::Matrix{Float64}
: standard deviationsu::Matrix{Float64}
: upper 95% CIsl::Matrix{Float64}
: lower 95% CI
msci95(obj1, obj2; <keyword arguments>)
Calculate mean difference, standard deviation and 95% confidence interval.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2:NeuroAnalyzer.NEURO
ch1::Union{String, Vector{String}}
: list of channelsch2::Union{String, Vector{String}}
: list of channelsep1::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, <:AbstractRange}=_c(nepochs(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.mscr
— Functionmscr(; <keyword arguments>)
Assess performance of the classification model using misclassification rate.
Arguments
tp::Int64
: number of true positivestn::Int64
: number of true negativesfp::Int64
: number of false positivesfn::Int64
: number of false negatives
Returns
Named tuple containing:
mr::Float64
: misclassification rateacc::Float64
: accuracy
Source
https://www.statology.org/misclassification-rate/
NeuroAnalyzer.norminv
— Functionnorminv(x::Real)
Convert probability to a normal distribution with a peak at 0.5.
Arguments
x::Real
Returns
n::Float64
NeuroAnalyzer.outlier_detect
— Functionoutlier_detect(x; <keyword arguments>)
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.p2z
— Functionp2z(p; <keyword arguments>)
Calculate z score for p value.
Arguments
p::Float64=0.05
: confidence leveltwosided::Bool=false
: one or two tailed probability
Returns
z::Float64
NeuroAnalyzer.permute
— Functionpermute(s, n)
Permute signal data.
Arguments
s::AbstractVector
n::Int64
: number of permutations
Returns
s_new::Matrix{Float64}
permute(s, n)
Permute signal data.
Arguments
s::AbstractArray
n::Int64
: number of permutations
Returns
s_new::Union{Array{Float64, 3}, Array{Float64, 4}}
NeuroAnalyzer.pooledstd
— Functionpooledstd(x1, x2; <keyword arguments>)
Calculate pooled standard deviation
Arguments
x1::AbstractVector
x2::AbstractVector
type::Symbol=:cohen
: use Cohen's equation (:cohen
) or maximum likelihood estimator by Hedges and Olkin (:hedges
)
Returns
ps::Float64
NeuroAnalyzer.power_c1g
— Functionpower_c1g(; <keyword arguments>)
Calculate study power for a continuous variable (group 1 vs population).
Arguments
m::Real
: population means::Real
: population standard deviationxbar::Real
: group meann::Int64
: group sample sizealpha::Float64=0.05
: the probability of type I error
Returns
p::Float64
: study power
NeuroAnalyzer.power_c2g
— Functionpower_c2g(; <keyword arguments>)
Calculate study power for a continuous variable (group 1 vs group 2).
Arguments
m1::Real
: group 1 means1::Real
: group 1 standard deviationn1::Int64
: group 1 sample sizem2::Real
: group 2 means2::Real
: group 2 standard deviationn2::Int64
: group 2 sample sizealpha::Float64=0.05
: the probability of type I error
Returns
p::Float64
: study power
NeuroAnalyzer.power_p1g
— Functionpower_p1g(; <keyword arguments>)
Calculate required sample size for a proportion (group 1 vs population).
Arguments
p1::Float64
: population incidencep2::Float64
: group 1 anticipated incidencen1::Int64
: group 1 sample sizealpha::Float64=0.05
: the probability of type I error
Returns
p::Float64
: study power
NeuroAnalyzer.power_p2g
— Functionpower_p2g(; <keyword arguments>)
Calculate required sample size for a proportion (group 1 vs group 2).
Arguments
p1::Float64
: group 1 incidencep2::Float64
: group 2 incidencen1::Int64
: group 1 sample sizen2::Int64
: group 2 sample sizealpha::Float64=0.05
: the probability of type I error
Returns
p::Float64
: study power
NeuroAnalyzer.prank
— Functionprank(x)
Calculate percentile rank.
Arguments
x::AbstractVector
: the vector to analyze
Returns
p::Vector{Float64}
: percentile ranks
NeuroAnalyzer.pred_int
— Functionpred_int(n)
Calculate the prediction interval (95% CI adjusted for sample size)
Arguments
n::Int64
: sample size
Returns
pi::Float64
NeuroAnalyzer.r1r2_test
— Functionr1r2_test(; <keyword arguments>)
Test if two correlation coefficients are significantly different.
Arguments
r1::Float64
: correlation coefficient, group 1r2::Float64
: correlation coefficient, group 2n1::Int64
: number of observations, group 1n2::Int64
: number of observations, group 2
Returns
z::Float64
: z score
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.rng
— Functionrng(x)
Calculate range.
Arguments
x::AbstractArray
Returns
r::Float64
NeuroAnalyzer.seg_extract
— Functionseg_extract(m, rc; <keyword arguments>)
Extract segment from a matrix.
Arguments
m::AbstractMatrix
rc::NTuple{4, Int64}
: upper-left corner row and column, bottom-right corner row and columnc::Bool=false
: if true, use circular segment; for circular segment the segment is always returned as vectorv::Bool=false
: if true, return as vector (matrix m by rows over columns)
Returns
seg::Union{AbstractMatrix, AbstractVector}
NeuroAnalyzer.seg_mean
— Functionseg_mean(seg)
Calculate mean of a segment (e.g. spectrogram).
Arguments
seg::AbstractArray
Returns
sm::Vector{Float64}
: averaged segment
seg2_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
— Functionsem(x)
Calculate standard error of the mean.
Arguments
x::AbstractVector
Returns
s::Float64
NeuroAnalyzer.sem_diff
— Functionsem_diff(x, y)
Calculate SEM (standard error of the mean) for the difference of two means.
Arguments
x::AbstractVector
y::AbstractVector
Returns
sem_diff::Float64
NeuroAnalyzer.size_c1diff
— Functionsize_c1diff(; <keyword arguments>)
Calculate required sample size for detecting a difference in a continuous variable (group 1 vs population).
Arguments
s1::Real
: population standard deviations2::Real
: study standard deviation that we want to detecttwosided::Bool=true
: if true, the estimation is for two-sided differencepower::Float64=0.8
: the ability to detect a difference between groups (power = 1 - beta, where beta is the probability of type II error)
Returns
n::Int64
: study sample size
NeuroAnalyzer.size_c1g
— Functionsize_c1g(; <keyword arguments>)
Calculate required sample size for a continuous variable (group 1 vs population).
Arguments
m::Real
: population means::Real
: population standard deviationxbar::Real
: expected group meanalpha::Float64=0.05
: the probability of type I errorpower::Float64=0.8
: the ability to detect a difference between groups (power = 1 - beta, where beta is the probability of type II error)iter::Bool=false
: use iterative method
Returns
n::Int64
: group sample size
NeuroAnalyzer.size_c2g
— Functionsize_c2g(; <keyword arguments>)
Calculate required sample size for a continuous variable (group 1 vs group 2).
Arguments
m1::Real
: group 1 means1::Real
: group 1 standard deviationm2::Real
: group 2 mean (expected)r::Int64=1
: enrollment ratio – the ratio of group 2 to group 1 enrollmentalpha::Float64=0.05
: the probability of type I errorpower::Float64=0.8
: the ability to detect a difference between groups (power = 1 - beta, where beta is the probability of type II error)
Returns
Named tuple containing:
n1::Int64
: group 1 sample sizen2::Int64
: group 2 sample size
NeuroAnalyzer.size_p1diff
— Functionsize_p1diff(; <keyword arguments>)
Calculate required sample size for detecting a difference in a proportion (group 1 vs population).
Arguments
p1::Real
: population proportionp2::Real
: study proportion that we want to detectpower::Float64=0.8
: the ability to detect a difference between groups (power = 1 - beta, where beta is the probability of type II error)
Returns
n::Int64
: study sample size (for both study groups)
NeuroAnalyzer.size_p1g
— Functionsize_p1g(; <keyword arguments>)
Calculate required sample size for a proportion (group 1 vs population).
Arguments
p1::Float64
: population incidencep2::Float64
: group anticipated incidencealpha::Float64=0.05
: the probability of type I errorpower::Float64=0.8
: the ability to detect a difference between groups (power = 1 - beta, where beta is the probability of type II error)
Returns
n::Int64
: group 1 sample size
NeuroAnalyzer.size_p2g
— Functionsize_p2g(; <keyword arguments>)
Calculate required sample size for a proportion (group 1 vs group 2).
Arguments
p1::Float64
: group 1 anticipated incidencep2::Float64
: group 2 anticipated incidencer::Int64=1
: enrollment ratio – the ratio of group 2 to group 1 enrollmentalpha::Float64=0.05
: the probability of type I errorpower::Float64=0.8
: the ability to detect a difference between groups (power = 1 - beta, where beta is the probability of type II error)
Returns
Named tuple containing:
n1::Int64
: group 1 sample sizen2::Int64
: group 2 sample size
NeuroAnalyzer.slope
— Functionslope(p1, p2)
Calculate slope of the line crossing two points.
Arguments
p1::Tuple{Real, Real}
p2::Tuple{Real, Real}
Returns
s::Float64
: slope
NeuroAnalyzer.spec_seg
— Functionspec_seg(sp, st, sf; <keyword arguments>)
Return spectrogram segment.
Arguments
sp::Matrix{Float64}
: spectrogram powerssf::Vector{Float64}
: spectrogram frequenciesst::Vector{Float64}
: spectrogram timet::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
spec_seg(sp, sf, st; <keyword arguments>)
Return spectrogram segment.
Arguments
sp::AbstractArray
: spectrogram powerssf::AbstractVector
: spectrogram frequenciesst::AbstractVector
: spectrogram timech::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.summary
— Functionsummary(x)
Return summary statistics.
Arguments
x::AbstractVector
Returns
Named tuple containing:
mm::Float64
: means::Float64
: standard deviationv::Float64
: varianceme::Float64
: medianmo::Float64
: mode
summary(x, y)
Return summary statistics.
Arguments
x::AbstractVector
y::AbstractVector
g1::String="1"
: group 1 nameg2::String="2"
: group 2 name
Returns
Named tuple containing:
mm1::Float64
: meanmm2::Float64
: means1::Float64
: standard deviations2::Float64
: standard deviationv1::Float64
: variancev2::Float64
: varianceme1::Float64
: medianme2::Float64
: medianmo1::Float64
: modemo2::Float64
: mode
NeuroAnalyzer.tlim
— Functiontlim(p, f; <keyword arguments>)
Trim spectrogram array to a range of time points.
Arguments
p::AbstractArray
: powerst::AbstractVector
: time pointsseg::Tuple{Real, Real}
: time segment
Returns
Named tuple containing:
p::Array{Float64, 4}
: powerst::Vector{Float64}
: time points
NeuroAnalyzer.vartest
— Functionvartest(obj; <keyword arguments>)
Calculate variance F-test.
Arguments
obj::NeuroAnalyzer.NEURO
- `ch::Union{String, Vector{String}}: list of channels
Returns
Named tuple containing:
f::Array{Float64, 3}
p::Array{Float64, 3}
vartest(obj1, obj2; <keyword arguments>)
Calculate variance F-test.
Arguments
obj1::NeuroAnalyzer.NEURO
obj2::NeuroAnalyzer.NEURO
ch1::Union{String, Vector{String}}
: list of channelsch2::Union{String, Vector{String}}
: list of channelsep1::Union{Int64, Vector{Int64}, AbstractRange}=_c(nepochs(obj1))
: default use all epochsep2::Union{Int64, Vector{Int64}, AbstractRange}=_c(nepochs(obj2))
: default use all epochs
Returns
Named tuple containing:
f::Array{Float64, 3}
p::Array{Float64, 3}
NeuroAnalyzer.z2p
— Functionz2p(z; <keyword arguments>)
Calculate probability for a given z value.
Arguments
z::Real
: z valuetwosided::Bool=false
: one or two tailed probability
Returns
p::Float64
NeuroAnalyzer.z_score
— Functionz_score(x)
Calculate Z-scores for each value of the vector x
.
Arguments
x::AbstractVector
Returns
z::Vector{Float64}
Study
NeuroAnalyzer.create_study
— Functionstudy(obj, group)
Create NeuroAnalyzer STUDY object.
Arguments
obj::Vector{NeuroAnalyzer.NEURO}
group::Vector{Symbol}
Returns
study::NeuroAnalyzer.STUDY
Missing docstring for NeuroAnalyzer.epoch_len
. Check Documenter's build log for details.
Missing docstring for NeuroAnalyzer.nchannels
. Check Documenter's build log for details.
Missing docstring for NeuroAnalyzer.nepochs
. Check Documenter's build log for details.
NeuroAnalyzer.obj_n
— Functionobj_n(study)
Return number of NeuroAnalyzer NEURO objects in the study.
Arguments
study::NeuroAnalyzer.STUDY
Returns
n::Int64
Missing docstring for NeuroAnalyzer.sr
. Check Documenter's build log for details.
NeuroRecorder
NeuroAnalyzer.eda
— Functioneda(; <keyword arguments>)
Record electrodermal activity (EDA), also called Galvanic Skin Response (GSR) or skin conductance, in CLI mode. EDA is recorded using Groove GSR sensor via Arduino attached to the PC via USB cable (virtual serial port).
Arguments
duration::Int64=20
: recording duration in secondsport_name::String="/dev/ttyUSB0"
: serial port to which the Arduino is connected
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.ftt
— Functionftt(; <keyword arguments>)
Perform Finger Tapping Test (FTT) in CLI mode. Use computer keyboard (SPACEBAR key) or switch panel attached to Raspberry Pi via a GPIO pin. Number of taps, time points and durations of taps are recorded. Also, taps during intervals (when the study subject should suppress tapping) are recorded. When using computer keyboard, only the number of taps and their time points are recorded; tap durations are set to 100 ms.
Arguments
duration::Int64=5
: single trial duration in secondstrials::Int64=2
: number of trialsinterval::Int64=2
: interval between trials in secondsgpio::Int64=-1
: Raspberry Pi GPIO to which the switch is connected (e.g.gpio=23
is Pi board pin 16); set to -1 to disable using GPIOport_name::String=""
: serial port to which the switch is connected (e.g./dev/ttyACM0
); set to "" to disable using serial port
Returns
Named tuple containing:
taps::Vector{Int64}
: number of taps per trialtap_t::Vector{Vector{Float64}}
: taps time point [ms]tap_d::Vector{Vector{Float64}}
: taps duration [ms]taps_int::Vector{Int64}
: number of taps per trial during intervalstap_t_int::Vector{Vector{Float64}}
: taps time point [ms] during intervalstap_d_int::Vector{Vector{Float64}}
: taps duration [ms] during intervals
NeuroAnalyzer.ieda
— Functionieda(; <keyword arguments>)
Record electrodermal activity (EDA), also called Galvanic Skin Response (GSR) or skin conductance, in GUI mode. EDA is recorded using Groove GSR sensor via Arduino attached to the PC via USB cable (virtual serial port). Sampling rate is 50 Hz.
Arguments
duration::Int64=20
: recording duration in secondsport_name::String="/dev/ttyUSB0"
: serial port to which the Arduino is connected
Returns
obj_new::NeuroAnalyzer.NEURO
NeuroAnalyzer.iftt
— Functioniftt(; <keyword arguments>)
Perform Finger Tapping Test (FTT) in GUI mode. Use computer keyboard (SPACEBAR key) or switch panel attached to Raspberry Pi via a GPIO pin and to the PC via USB (virtual serial port). Number of taps, time points and durations of taps are recorded. Also, taps during intervals (when the study subject should suppress tapping) are recorded.
Arguments
duration::Int64=5
: single trial duration in secondstrials::Int64=2
: number of trialsinterval::Int64=2
: interval between trials in secondsgpio::Int64=-1
: Raspberry Pi GPIO to which the switch is connected (e.g.gpio=23
is Pi board pin 16); set to -1 to disable using GPIOport_name::String=""
: serial port to which the switch is connected (e.g./dev/ttyACM0
); set to "" to disable using serial port
Returns
Named tuple containing:
taps::Vector{Int64}
: number of taps per trialtap_t::Vector{Vector{Float64}}
: taps time point [ms]tap_d::Vector{Vector{Float64}}
: taps duration [ms]taps_int::Vector{Int64}
: number of taps per trial during intervalstap_t_int::Vector{Vector{Float64}}
: taps time point [ms] during intervalstap_d_int::Vector{Vector{Float64}}
: taps duration [ms] during intervals
NeuroStim
NeuroAnalyzer.ect_charge
— Functionect_charge(; <keyword arguments>)
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.tacs_dose
— Functiontacs_dose(; <keyword arguments>)
Calculate charge
, current_density
and charge_ density
for tACS stimulation.
Arguments
current::Real
: stimulation current (peak to peak) [mA]pad_area::Real
: electrode pad area [cm²]duration::Real
: stimulation duration [s]offset::Real
: current offset [μA]frequency::Real
: sinus frequency [Hz]phase::Real
: phase shift [degree]
Returns
Named tuple containing:
charge::Float64
: charge [C]current_density::Float64
: current density [A/m²]charge_density::Float64
: delivered charge density [kC/m²]
NeuroAnalyzer.tdcs_dose
— Functiontdcs_dose(; <keyword arguments>)
Calculate charge
, current_density
and charge_ density
for tDCS stimulation.
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_model
— Functiontes_model(; <keyword arguments>)
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
NeuroAnalyzer.tes_protocol
— Functiontes_protocol(; <keyword arguments>)
Create TES (tDCS/tACS/tRNS/tPCS) protocol.
Arguments
type::Symbol
: stimulation type (:tDCS
,:tACS
,:tRNS
,:tPCS
)hd::Bool
: high-density 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.tpcs_dose
— Functiontpcs_dose(; <keyword arguments>)
Calculate charge
, current_density
and charge_ density
for tPCS stimulation.
Arguments
current::Real
: stimulation current (peak to peak) [mA]pad_area::Real
: electrode pad area [cm²]duration::Real
: stimulation duration [s]pw::Real
: pulse width [ms]isi::Real
: interstimulus interval [ms]
Returns
Named tuple containing:
charge::Float64
: charge [C]current_density::Float64
: current density [A/m²]charge_density::Float64
: delivered charge density [kC/m²]