using NeuroAnalyzer
eeg = import_edf("files/eeg/eeg.edf")NeuroAnalyzer Glossary
The glossary defines terms and conventions specific to NeuroAnalyzer. Examples use the EEG recording from the tutorial files:
Bad channel
A channel marked as unusable (e.g. flat, noisy or disconnected). Bad channels are stored as a Boolean vector, one value per channel, in obj.header.recording[:bad_channel], and can be selected with ch = "bad". With the exclude_bads preference set, bad channels are excluded from analyses that support it. See Mark bad channels.
Channel
A single signal recorded over time. Each channel has a label (e.g. "Fp1"), a channel type (e.g. "eeg" or "eog") and a unit (e.g. "μV"). Channel properties are stored in the header:
rec = eeg.header.recording
println("labels: ", rec[:label][1:5])
println("types: ", rec[:channel_type][[1, 17, 22, 24]])
println("units: ", rec[:unit][1:3])labels: ["Fp1", "Fp2", "F3", "F4", "C3"]
types: ["eeg", "ref", "eog", "ecg"]
units: ["μV", "μV", "μV"]
Channel selection
Functions select channels with the ch keyword argument, which accepts:
- a label:
ch = "Fp1" - a vector of labels:
ch = ["Fp1", "Fp2"] - a channel type:
ch = "eeg",ch = "eog"; group types are also accepted:"meg"(magnetometers and gradiometers),"nirs"(all NIRS signal types),"sensors"(all motion sensor types) "all"- all channels"bad"- channels marked as bad- a regular expression, matched anywhere in the label:
ch = r"^F"(all labels starting with F)
Labels, types and keywords may be mixed in a vector, e.g. ch = ["eeg", "eog"]. get_channel() returns the channel numbers of a selection:
println(get_channel(eeg; ch = r"^F"))
println(get_channel(eeg; ch = ["eog", "ecg"]))[1, 2, 3, 4, 11, 12, 19]
[22, 23, 24]
Channel type
The kind of signal a channel contains, e.g. "eeg", "ref" (reference electrode), "eog", "ecg", "emg", "mag" and "grad" (MEG magnetometers and gradiometers), "nirs_od" (NIRS optical density), "accel" (accelerometer), "mrk" (marker channel) or "other". All available channel types are listed in the NeuroAnalyzer.channel_types variable.
Data
The recorded signal values, stored in obj.data as a 3-dimensional array of 64-bit floats: channels × samples × epochs. A continuous recording has one epoch:
println("channels × samples × epochs: ", size(eeg.data))channels × samples × epochs: (24, 308480, 1)
Analysis results are returned as vectors (e.g. one value per channel), matrices (e.g. channels × epochs) or arrays of higher dimension (e.g. channels × frequencies × epochs).
Data type
The kind of recording a NEURO object holds, stored in obj.header.recording[:data_type] and returned by datatype():
eeg- electroencephalography (EEG)ecog- electrocorticography (ECoG)seeg- stereoelectroencephalography (SEEG)ieeg- intracranial electroencephalography (iEEG)csd- current source density (CSD)meg- magnetoencephalography (MEG)nirs- near-infrared spectroscopy (NIRS)sensors- various body sensorseda- electrodermal activity (EDA)mep- motor evoked potentials (MEP)erp- event-related potential (ERP)erf- event-related field (ERF)tpt- two-point pinch test (TPT)
All available data types are listed in the NeuroAnalyzer.data_types variable. Many functions accept only some data types, e.g. average_epochs() requires EEG or MEG.
Epoch
A segment of recorded data, defined either by markers (e.g. stimulus onsets) or by fixed time intervals. Every NEURO object contains at least one epoch; a continuous recording is a single epoch. All epochs have the same length:
ep = epoch(eeg; ep_len = 2)
println("epochs: ", nepochs(ep), ", length: ", epoch_len(ep), " samples")epochs: 602, length: 512 samples
Epoching is done after filtering, which should be applied to the continuous signal.
Epoch time
The time axis of a single epoch, in seconds, stored in obj.epoch_time. For epochs created with an offset (e.g. a pre-stimulus baseline), the epoch time starts at a negative value, so that 0 is the event onset:
ep = epoch(eeg; ep_len = 2, offset = 0.5)
println("epoch time: ", ep.epoch_time[1], " … ", ep.epoch_time[end], " s")epoch time: -0.5 … 1.49609375 s
See also time points.
ERP / ERF object
The result of average_epochs(): an object of data type erp (EEG) or erf (MEG) containing only the signal channels. Epoch 1 is the average of all epochs; the following epochs are the individual epochs:
erp = average_epochs(ep)
println("data type: ", datatype(erp), ", epochs: ", nepochs(erp),
" (average + ", nepochs(ep), ")")data type: erp, epochs: 603 (average + 602)
Fiducials
Anatomical landmarks used to align channel locations with the head: the nasion (between the eyes), the inion (at the back of the head) and the left and right preauricular points (LPA, RPA, in front of the ears). Their default positions in NeuroAnalyzer’s head coordinates are stored in NeuroAnalyzer.fiducial_points.
Header
Metadata of a NEURO object, stored in obj.header, with three dictionaries:
subject- subject information (ID, name, handedness, weight, height, head circumference)recording- recording information (data type, file name, sampling rate, channel labels, types and units, bad channels, reference, gain, recording date and time, line frequency, pre-filtering, notes)experiment- experiment name, design and notes
println(sort(collect(keys(eeg.header.recording))))[:bad_channel, :channel_order, :channel_type, :data_type, :epoch_id, :file_name, :file_size_mb, :file_type, :gain, :label, :line_frequency, :prefiltering, :recording, :recording_date, :recording_notes, :recording_time, :reference, :sampling_rate, :transducers, :unit]
header() prints a summary.
History
The list of processing steps applied to a NEURO object, with their parameters, stored in obj.history; each processing function appends an entry. history() prints it:
println(ep.history)["epoch(obj; marker=, offset=0.5, ep_len=512)"]
Label
The name of a channel, e.g. "Fp1" for EEG or "S1_D1 OD" for NIRS. Labels are returned by labels() and must be unique. On import, EEG labels are cleaned by default (e.g. "EEG Fp1" → "Fp1"), see the clean_labels keyword of the importers.
Locs
The positions of electrodes or sensors (e.g. EEG electrodes or NIRS optodes), stored in obj.locs, a data frame with one row per channel. Positions are stored in three coordinate systems:
- Cartesian (
loc_x,loc_y,loc_z) - Planar (
loc_radius,loc_theta), for 2-D head plots - Spherical (
loc_radius_sph,loc_theta_sph,loc_phi_sph)
Angles are in degrees; theta is measured counter-clockwise from the X axis (right) and phi is the elevation above the XY plane. Coordinates are normalized so that the head fits a unit sphere.
NeuroAnalyzer uses the RAS (Right-Anterior-Superior) coordinate system:
| Axis | Positive direction | Negative direction |
|---|---|---|
| X | Right | Left |
| Y | Anterior (front) | Posterior (rear) |
| Z | Superior (top) | Inferior (bottom) |
load_locs!(eeg; file_name = "files/locs/standard-10-20-cap19-elmiko.locs")
eeg.locs[1:3, :]| Row | label | loc_radius | loc_theta | loc_x | loc_y | loc_z | loc_radius_sph | loc_theta_sph | loc_phi_sph |
|---|---|---|---|---|---|---|---|---|---|
| String | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | |
| 1 | Fp1 | 1.0 | 108.0 | -0.308829 | 0.950477 | -0.034896 | 1.0 | 108.0 | -1.9998 |
| 2 | Fp2 | 1.0 | 72.0 | 0.308829 | 0.950477 | -0.034896 | 1.0 | 72.0 | -1.9998 |
| 3 | F3 | 0.652169 | 129.0 | -0.545004 | 0.673024 | 0.500009 | 1.0 | 129.0 | 30.0006 |
See Channel locations.
Marker
An event recorded with the signal, such as a stimulus onset or a button press. Markers are stored in obj.markers, a data frame with one row per event and five columns:
id- event identifier (e.g."stim")start- time of the event in secondslength- duration of the event in seconds (0for instantaneous events)value- event value or description (e.g."S01")channel- channel number the event refers to;0means all channels
Markers are added with add_marker!() and used to create event-related epochs with epoch(obj; marker = ...).
Montage
A set of channels derived from the recorded ones, e.g. a bipolar montage in which each channel is the difference of two electrodes ("Fp1-F7"). Montages are applied with reference_custom(); montage files can be imported with import_montage() and edited with edit_montage(). See also reference.
Mutator
A function that modifies its input object in place instead of returning a modified copy. Mutators have the ! suffix, e.g. delete_channel!() or load_locs!(); the version without ! returns a new object and leaves the input unchanged. Mutators save memory for large recordings.
NEURO object
The fundamental data structure in NeuroAnalyzer. Each object contains:
header- header with subject, recording and experiment metadatahistory- processing historymarkers- event markerslocs- channel locationstime_pts- time pointsepoch_time- epoch timedata- recorded data
A NEURO object is created by importing a recording (e.g. import_edf(), import_fiff(), import_nirs()), by loading a saved object (load_neuro()) or by creating an empty one (create_object()). See NEURO objects.
Pick
A named group of EEG channel locations: :left, :right, :central (midline), :frontal, :temporal, :parietal and :occipital (or their abbreviations :l, :r, :c, :f, :t, :p, :o). Picks are combined with AND, e.g. [:left, :frontal]:
println(channel_pick(eeg; pick = [:left, :frontal]))["F3", "F7", "Fp1"]
Region picks are based on the letters of the 10–20 labels (F, T, P, O, z) and laterality on odd (left) and even (right) electrode numbers.
Plugin
An external Julia file that adds functions to NeuroAnalyzer; plugins are installed with plugins_install() and loaded at startup. See Plugins.
Preferences
Persistent settings of NeuroAnalyzer: progress bars, verbose messages, colors and exclusion of bad channels. They are changed with set_progress_bar(), set_verbose(), set_colors(), set_exclude_bads() or set_prefs() and stored between sessions. See Preferences.
Private function
A function whose name starts with _ (e.g. NeuroAnalyzer._band_power()). Private functions work on plain vectors and arrays and are used internally by the public functions that take NEURO objects; they are not exported, may change without notice, and are not intended for regular use.
Reference
The electrode (or combination of electrodes) against which potentials are measured. The current reference is stored in obj.header.recording[:reference]. A recording can be re-referenced, e.g. to the common average (reference_avg()), the auricular (reference_a()) or mastoid electrodes (reference_m()), a single electrode (reference_ce()), the surface Laplacian (reference_slap(), reference_plap()) or a custom montage (reference_custom()).
Sampling rate
The number of samples recorded per second (Hz), returned by sr(). The Nyquist frequency, the highest frequency that can be represented, is half of the sampling rate.
println("sampling rate: ", sr(eeg), " Hz")sampling rate: 256 Hz
Segment
A part of the signal given by its start and end time in seconds, e.g. seg = (10, 20), used by plotting functions and some editing functions.
Signal channel
A channel whose type matches the data type of the object, i.e. a channel carrying the measured brain signal:
- EEG:
"eeg"channels (e.g."Fp1","C3") - MEG: magnetometers (
"mag") and gradiometers ("grad") - NIRS: NIRS channels (e.g. optical density,
"nirs_od", or hemoglobin concentrations,"nirs_hbo","nirs_hbr")
Reference ("ref"), EOG, ECG, EMG and marker channels are recorded with the signal but are not signal channels; some functions (e.g. average_epochs(), reference_avg()) use only signal channels.
Time points
The time of every sample of the recording, in seconds from the start, stored in obj.time_pts. After epoching, time points continue across epochs (they give the time of each sample in the original recording); see also epoch time.
Unit
The physical unit of a channel, stored in obj.header.recording[:unit], e.g. "μV" (EEG), "fT" (MEG magnetometers), "fT/cm" (MEG gradiometers), "μV/m²" (current source density), "μM/mm" (NIRS hemoglobin concentration), "m/s²" (accelerometer), "μS" (EDA). All available units are listed in the NeuroAnalyzer.channel_units variable.