NeuroAnalyzer tutorials: General remarks

NeuroAnalyzer functions operate on NeuroAnalyzer objects. The major object is NeuroAnalyzer.NEURO, which is an equivalent of single recording of any type (e.g. EEG or MEG).

mutable struct NEURO
    header::NeuroAnalyzer.HEADER
    time_pts::Vector{Float64}                         # time points for the whole signal
    epoch_time::Vector{Float64}                       # time points for single epoch
    data::Array{<:Number, 3}                          # data must have at least one channel and one epoch
    components::Dict{Any}                             # additional data, e.g. ICs
    markers::DataFrame                                # event markers
    locs::DataFrame                                   # channel locations
    history::Vector{String}                           # list of operations
end

The NeuroAnalyzer.NEURO object contains a header with the following meta-data:

mutable struct HEADER
    subject::Dict
    recording::Dict
    experiment::Dict
end

The subject dictionary contains the following keys:

  • :id::String
  • :first_name::String
  • :middle_name::String
  • :last_name::String
  • :handedness::String
  • :head_circumference::Real
  • :weight::Real
  • :height::Real

For EEG/sEEG/ECOG objects, the recording dictionary contains the following keys:

  • :data_type::String: “eeg”
  • :file_name::String
  • :file_size_mb::Float64
  • :file_type::String: e.g. “EDF”, “EDF+”, “BDF”, “BDF+”, “Digitrack”, “BrainVision”, “CSV”, SET”, “GDF”
  • :recording::String: e.g. equipment name
  • :recording_date::String
  • :recording_time::String
  • :recording_notes::String
  • :channel_type::Vector{String}: e.g. [“eeg”, “eog”, “emg”]
  • :reference::String: e.g. “AVG”
  • :label::Vector{String}: e.g. [“Fp1”, “Fp2”]
  • :transducers
  • :unit::Vector{String}: e.g. [“uV”]
  • :prefiltering::Vector{String}
  • :line_frequency::Int64: power line frequency (50 or 60 Hz), default is 50 Hz
  • :sampling_rate::Int64
  • :gain::Vector{Float64}
  • :bad_channel::Matrix{Bool}
  • :channel_order::Vector{Int64}: logical order of channels, i.e. sorted by types
  • :epoch_id::String

For MEG objects, the recording dictionary contains the following keys:

  • :data_type::String: “meg”
  • :file_name::String
  • :file_size_mb::Float64
  • :file_type::String: “FIFF”
  • :recording::String
  • :recording_date::String
  • :recording_time::String
  • :recording_notes::String
  • :channel_type::Vector{String}: e.g. [“mag”, “grad”]
  • :reference::String
  • :label::Vector{String}: e.g. [“MEG1”, “MEG2”]
  • :unit::Vector{String}: e.g. [“fT”]
  • :prefiltering::Vector{String}
  • :line_frequency::Int64: power line frequency (50 or 60 Hz), default is 50 Hz
  • :sampling_rate::Int64
  • :magnetometers::Vector{Int64}: list of channel of particular type
  • :gradiometers::Vector{Int64}: list of channel of particular type
  • :gradiometers_planar::Vector{Int64}: list of channel of particular type
  • :gradiometers_axial::Vector{Int64}: list of channel of particular type
  • :coils::Vector{Int64}
  • :bad_channel::Matrix{Bool}
  • :channel_order::Vector{Int64}: logical order of channels, i.e. sorted by types
  • :ssp_labels::Vector{String}: name of SSP projections
  • :ssp_channels::Vector{Bool}: channels for which SSP projections are calculated
  • :ssp_data::Matrix{Float64}: SSP data
  • :epoch_id::String

For NIRS objects, the recording dictionary contains the following keys:

  • :data_type::String: “nirs”
  • :file_name::String
  • :file_size_mb::Float64
  • :file_type::String: “NIRS”, NIRX” or “SNIRF”
  • :recording::String: e.g. equipment name
  • :recording_date::String
  • :recording_time::String
  • :recording_notes::String
  • :wavelengths::Vector{Float64}
  • :wavelength_index::Vector{Int64}: wavelength indices for nirs_int and nirs_od channels
  • :channel_pairs::Matrix{Int64}: matrix of source-detector pairs
  • :channel_type::Vector{String}
  • :label::Vector{String}: channel labels (sensor_detector wavelength), e.g. [“S1_D1 780”]
  • :unit::Vector{String}
  • :optode_labels::Vector{String}: sensors and detector labels, e.g. [“nirs_int”, “nirs_od”, “nirs_hbo”]
  • :sampling_rate::Int64
  • :bad_channel::Matrix{Bool}
  • :channel_order::Vector{Int64}: logical order of channels, i.e. sorted by types
  • :epoch_id::String

For MEP objects, the recording dictionary contains the following keys:

  • :data_type::String: “mep”
  • :file_name::String
  • :file_size_mb::Float64
  • :file_type::String: “DuoMag”
  • :recording::String: e.g. equipment name
  • :recording_date::String
  • :recording_time::String
  • :recording_notes::String
  • :channel_type::Vector{String}
  • :label::Vector{String}: signal labels, e.g. [“MEP1”]
  • :unit::Vector{String}
  • :sampling_rate::Int64
  • :stimulation_intensity: TMS stimulation intensity [%]
  • :stimulation_sample: location of stimulation [in samples]
  • :markers_pos: location of positive marker [in samples]
  • :markers_neg: location of negative marker [in samples]
  • :bad_channel::Matrix{Bool}
  • :channel_order::Vector{Int64}: logical order of channels, i.e. sorted by types
  • :epoch_id::String

For EDA objects, the recording dictionary contains the following keys:

  • :data_type::String: “mep”
  • :file_name::String
  • :file_size_mb::Float64
  • :file_type::String: “DuoMag”
  • :recording::String: e.g. equipment name
  • :recording_date::String
  • :recording_time::String
  • :recording_notes::String
  • :channel_type::Vector{String}
  • :label::Vector{String}: signal labels, e.g. [“MEP1”]
  • :unit::Vector{String}
  • :sampling_rate::Int64
  • :stimulation_intensity: TMS stimulation intensity [%]
  • :stimulation_sample: location of stimulation [in samples]
  • :markers_pos: location of positive marker [in samples]
  • :markers_neg: location of negative marker [in samples]
  • :bad_channel::Matrix{Bool}
  • :channel_order::Vector{Int64}: logical order of channels, i.e. sorted by types
  • :epoch_id::String

For SENSORS objects, the recording dictionary contains the following keys:

  • :data_type::String: “mep”
  • :file_name::String
  • :file_size_mb::Float64
  • :file_type::String: “DuoMag”
  • :recording::String: e.g. equipment name
  • :recording_date::String
  • :recording_time::String
  • :recording_notes::String
  • :channel_type::Vector{String}
  • :label::Vector{String}: signal labels, e.g. [“MEP1”]
  • :unit::Vector{String}
  • :prefiltering::Vector{String}
  • :sampling_rate::Int64
  • :bad_channel::Matrix{Bool}
  • :channel_order::Vector{Int64}: logical order of channels, i.e. sorted by types
  • :epoch_id::String

The experiment dictionary contains the following keys:

  • :name
  • :notes
  • :design

Event markers is a DataFrame with the following columns: - :id: id of the event, type String - :start: event start point in seconds, type Float64 - :length: event length in seconds, type Float64 - :value: event value, type String - :channel: event channel, default is 0 (all channels)

For multichannel recordings, signal is stored in data as Array{Float64, 3} (channels × signals × epochs). If epochs are not defined, the whole signal is an epoch, i.e. there is always at least one epoch.

Higher NeuroAnalyzer functions (operating on NeuroAnalyzer.NEURO object) use named arguments for all arguments other than input object(s), e.g. delete_epoch!(my_eeg, ep=12).

Study object is stored in the NeuroAnalyzer.STUDY structure:

```{julia}
mutable struct STUDY
    header::Dict{Symbol, Any}
    objects::Vector{NeuroAnalyzer.NEURO}
    groups::Vector{Symbol}
end
```

Multiple dispatch mechanism is used wherever possible.

Most edit/process functions have a mutator variant (e.g. delete_epoch() and delete_epoch!()). Mutators modify the input NEURO object in-place, e.g. you may use delete_channel!(my_eeg, ch="Fp1") instead of my_eeg = delete_channel(my_eeg, ch="Fp1").

Functions operating on individual channels accept channels by their names (labels), e.g. ch="C4". Multiple channels may be given, e.g. ch=["Fp1", "Fp2"]; ch="all" returns all channels in the object. Additionally, channels may be provided by their type, e.g. ch="eeg" or ch=["eeg", "eog"].

In the NeuroAnalyzer.NEURO channels are stored in the original sequence (physical order); for plotting channels are grouped by their types (logical order); the logical order is stored in :channel_order field of the object header.