NeuroAnalyzer tutorials: Analyze EEG (1)

Load data:

using NeuroAnalyzer
eeg = load("files/eeg.hdf");
[ Info: Loaded: EEG (24 × 282991 × 1; 1105.43 s)

Any analysis data (e.g. ICA, PCA) can be stored within the NeuroAnalyzer object as a component.

For more details, see add_component(), list_component(), delete_component(), rename_component(), component_type(), extract_component().

(!) Since components are derived from the signal, all embedded components are removed from the object when the signal data is altered in any way (e.g. channel removal, filtering).

(!) All embedded components are saved together with the signal data when using save() in the native NeuroAnalyzer format (HDF5).

Add component:

e = epoch_stats(eeg)
add_component!(eeg, c=:epoch_mean, v=e[1])

Show components:

list_component(eeg)
1-element Vector{Symbol}:
 :epoch_mean

Get component type:

component_type(eeg, c=:epoch_mean)
Vector{Float64} (alias for Array{Float64, 1})

Get data of the embedded component:

extract_component(eeg, c=:epoch_mean)
1-element Vector{Float64}:
 0.025165531627866868

Delete component:

delete_component(eeg, c=:epoch_mean)
NeuroAnalyzer.NEURO(NeuroAnalyzer.HEADER(Dict{Symbol, Any}(:weight => -1, :id => "", :middle_name => "", :height => -1, :head_circumference => -1, :handedness => "", :last_name => "528004  SIT 52, 20220831-122227-{d589f756-53fc-4f1b-915d-6e3b8c1560ad}", :first_name => ""), Dict{Symbol, Any}(:epoch_id => "", :channel_type => ["eeg", "eeg", "eeg", "eeg", "eeg", "eeg", "eeg", "eeg", "eeg", "eeg"  …  "eeg", "eeg", "ref", "ref", "eeg", "eeg", "eeg", "eog", "eog", "ecg"], :label => ["Fp1", "Fp2", "F3", "F4", "C3", "C4", "P3", "P4", "O1", "O2"  …  "T5", "T6", "A1", "A2", "Fz", "Cz", "Pz", "EOG1", "EOG2", "ECG"], :prefiltering => ["HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz"  …  "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz"], :gain => [0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218  …  0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218], :data_type => "eeg", :recording_notes => "", :recording_date => "31.08.22", :sampling_rate => 256, :file_type => "EDF"…), Dict(:name => "", :design => "", :notes => "")), [0.0, 0.004, 0.008, 0.012, 0.016, 0.02, 0.023, 0.027, 0.031, 0.035  …  1105.395, 1105.398, 1105.402, 1105.406, 1105.41, 1105.414, 1105.418, 1105.422, 1105.426, 1105.43], [0.0, 0.004, 0.008, 0.012, 0.016, 0.02, 0.023, 0.027, 0.031, 0.035  …  1105.395, 1105.398, 1105.402, 1105.406, 1105.41, 1105.414, 1105.418, 1105.422, 1105.426, 1105.43], [4.992164730175867 5.664430996112374 … -3.1830986460670267 0.0006574697346035663; 10.545994968978613 8.645145968055244 … 2.690060794085174 0.0004150149321296981; … ; -8.292293128262147 -5.490081181977235 … -0.6385598239986807 0.0008236881401195717; -10.297767714759269 4.464504630941899 … -8.80813398237423 0.0018241535887852933;;;], Dict{Any, Any}(), 0×5 DataFrame
 Row  id      start    length   description  channel  String  Float64  Float64  String       Int64   
─────┴────────────────────────────────────────────────, 23×9 DataFrame
 Row  label   loc_radius  loc_theta  loc_x    loc_y    loc_z    loc_radius_sp ⋯
     │ String  Float64     Float64    Float64  Float64  Float64  Float64       ⋯
─────┼──────────────────────────────────────────────────────────────────────────
   1 │ Fp1           1.0       108.0    -0.31     0.95    -0.03            1.0 ⋯
   2 │ Fp2           1.0        72.0     0.31     0.95    -0.03            1.0
   3 │ F7            1.0       144.0    -0.81     0.59    -0.03            1.0
   4 │ F3            0.65      129.0    -0.55     0.67     0.5             1.0
   5 │ Fz            0.51       90.0     0.0      0.72     0.7             1.0 ⋯
   6 │ F4            0.65       51.0     0.55     0.67     0.5             1.0
   7 │ F8            1.0        36.0     0.81     0.59    -0.03            1.0
   8 │ T3            1.0       180.0    -1.0      0.0     -0.03            1.0
   9 │ C3            0.51      180.0    -0.72     0.0      0.7             1.0 ⋯
  10 │ Cz            0.0         0.0     0.0      0.0      1.0             1.0
  11 │ C4            0.51        0.0     0.72     0.0      0.7             1.0
  ⋮  │   ⋮         ⋮           ⋮         ⋮        ⋮        ⋮           ⋮       ⋱
  14 │ P3            0.65      231.0    -0.55    -0.67     0.5             1.0
  15 │ Pz            0.51      270.0     0.0     -0.72     0.7             1.0 ⋯
  16 │ P4            0.65      309.0     0.55    -0.67     0.5             1.0
  17 │ T6            1.0       324.0     0.81    -0.59    -0.03            1.0
  18 │ O1            1.0       252.0    -0.31    -0.95    -0.03            1.0
  19 │ O2            1.0       288.0     0.31    -0.95    -0.03            1.0 ⋯
  20 │ A1            1.0       192.0    -0.92    -0.23    -0.55            1.1
  21 │ A2            1.0       -12.0     0.92    -0.23    -0.55            1.1
  22 │ EOG1          1.01      149.0    -0.87     0.51    -0.37            1.0
  23 │ EOG2          1.01       31.0     0.87     0.51    -0.37            1.0 ⋯
                                                    3 columns and 2 rows omitted, ["reset_components(OBJ)", "filter(OBJ, ch=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], fprototype=iirnotch, ftype=nothing, cutoff=50, order=8, rp=-1, rs=-1, dir=twopass, w=nothing)", "reset_components(OBJ)", "filter(OBJ, ch=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], fprototype=fir, ftype=hp, cutoff=0.1, order=8, rp=-1, rs=-1, dir=twopass, w=nothing)", "reset_components(OBJ)", "trim(OBJ, seg=(1, 257), remove_epochs=false)", "reset_components(OBJ)", "trim(OBJ, seg=(1793, 2561), remove_epochs=false)", "reset_components(OBJ)", "trim(OBJ, seg=(1537, 2049), remove_epochs=false)"  …  "reset_components(OBJ)", "trim(OBJ, seg=(20929, 23553), remove_epochs=false)", "reset_components(OBJ)", "trim(OBJ, seg=(19137, 21313), remove_epochs=false)", "reset_components(OBJ)", "trim(OBJ, seg=(17409, 19585), remove_epochs=false)", "reset_components(OBJ)", "trim(OBJ, seg=(49537, 51265), remove_epochs=false)", "add_component(OBJ, c=epoch_mean, v", "delete_component(OBJ, c=epoch_mean)"])

Delete all components:

reset_components(eeg)
NeuroAnalyzer.NEURO(NeuroAnalyzer.HEADER(Dict{Symbol, Any}(:weight => -1, :id => "", :middle_name => "", :height => -1, :head_circumference => -1, :handedness => "", :last_name => "528004  SIT 52, 20220831-122227-{d589f756-53fc-4f1b-915d-6e3b8c1560ad}", :first_name => ""), Dict{Symbol, Any}(:epoch_id => "", :channel_type => ["eeg", "eeg", "eeg", "eeg", "eeg", "eeg", "eeg", "eeg", "eeg", "eeg"  …  "eeg", "eeg", "ref", "ref", "eeg", "eeg", "eeg", "eog", "eog", "ecg"], :label => ["Fp1", "Fp2", "F3", "F4", "C3", "C4", "P3", "P4", "O1", "O2"  …  "T5", "T6", "A1", "A2", "Fz", "Cz", "Pz", "EOG1", "EOG2", "ECG"], :prefiltering => ["HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz"  …  "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz", "HP:0,18Hz LP:104,0Hz"], :gain => [0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218  …  0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218, 0.17935713740749218], :data_type => "eeg", :recording_notes => "", :recording_date => "31.08.22", :sampling_rate => 256, :file_type => "EDF"…), Dict(:name => "", :design => "", :notes => "")), [0.0, 0.004, 0.008, 0.012, 0.016, 0.02, 0.023, 0.027, 0.031, 0.035  …  1105.395, 1105.398, 1105.402, 1105.406, 1105.41, 1105.414, 1105.418, 1105.422, 1105.426, 1105.43], [0.0, 0.004, 0.008, 0.012, 0.016, 0.02, 0.023, 0.027, 0.031, 0.035  …  1105.395, 1105.398, 1105.402, 1105.406, 1105.41, 1105.414, 1105.418, 1105.422, 1105.426, 1105.43], [4.992164730175867 5.664430996112374 … -3.1830986460670267 0.0006574697346035663; 10.545994968978613 8.645145968055244 … 2.690060794085174 0.0004150149321296981; … ; -8.292293128262147 -5.490081181977235 … -0.6385598239986807 0.0008236881401195717; -10.297767714759269 4.464504630941899 … -8.80813398237423 0.0018241535887852933;;;], Dict{Any, Any}(), 0×5 DataFrame
 Row  id      start    length   description  channel  String  Float64  Float64  String       Int64   
─────┴────────────────────────────────────────────────, 23×9 DataFrame
 Row  label   loc_radius  loc_theta  loc_x    loc_y    loc_z    loc_radius_sp ⋯
     │ String  Float64     Float64    Float64  Float64  Float64  Float64       ⋯
─────┼──────────────────────────────────────────────────────────────────────────
   1 │ Fp1           1.0       108.0    -0.31     0.95    -0.03            1.0 ⋯
   2 │ Fp2           1.0        72.0     0.31     0.95    -0.03            1.0
   3 │ F7            1.0       144.0    -0.81     0.59    -0.03            1.0
   4 │ F3            0.65      129.0    -0.55     0.67     0.5             1.0
   5 │ Fz            0.51       90.0     0.0      0.72     0.7             1.0 ⋯
   6 │ F4            0.65       51.0     0.55     0.67     0.5             1.0
   7 │ F8            1.0        36.0     0.81     0.59    -0.03            1.0
   8 │ T3            1.0       180.0    -1.0      0.0     -0.03            1.0
   9 │ C3            0.51      180.0    -0.72     0.0      0.7             1.0 ⋯
  10 │ Cz            0.0         0.0     0.0      0.0      1.0             1.0
  11 │ C4            0.51        0.0     0.72     0.0      0.7             1.0
  ⋮  │   ⋮         ⋮           ⋮         ⋮        ⋮        ⋮           ⋮       ⋱
  14 │ P3            0.65      231.0    -0.55    -0.67     0.5             1.0
  15 │ Pz            0.51      270.0     0.0     -0.72     0.7             1.0 ⋯
  16 │ P4            0.65      309.0     0.55    -0.67     0.5             1.0
  17 │ T6            1.0       324.0     0.81    -0.59    -0.03            1.0
  18 │ O1            1.0       252.0    -0.31    -0.95    -0.03            1.0
  19 │ O2            1.0       288.0     0.31    -0.95    -0.03            1.0 ⋯
  20 │ A1            1.0       192.0    -0.92    -0.23    -0.55            1.1
  21 │ A2            1.0       -12.0     0.92    -0.23    -0.55            1.1
  22 │ EOG1          1.01      149.0    -0.87     0.51    -0.37            1.0
  23 │ EOG2          1.01       31.0     0.87     0.51    -0.37            1.0 ⋯
                                                    3 columns and 2 rows omitted, ["reset_components(OBJ)", "filter(OBJ, ch=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], fprototype=iirnotch, ftype=nothing, cutoff=50, order=8, rp=-1, rs=-1, dir=twopass, w=nothing)", "reset_components(OBJ)", "filter(OBJ, ch=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], fprototype=fir, ftype=hp, cutoff=0.1, order=8, rp=-1, rs=-1, dir=twopass, w=nothing)", "reset_components(OBJ)", "trim(OBJ, seg=(1, 257), remove_epochs=false)", "reset_components(OBJ)", "trim(OBJ, seg=(1793, 2561), remove_epochs=false)", "reset_components(OBJ)", "trim(OBJ, seg=(1537, 2049), remove_epochs=false)"  …  "reset_components(OBJ)", "trim(OBJ, seg=(20929, 23553), remove_epochs=false)", "reset_components(OBJ)", "trim(OBJ, seg=(19137, 21313), remove_epochs=false)", "reset_components(OBJ)", "trim(OBJ, seg=(17409, 19585), remove_epochs=false)", "reset_components(OBJ)", "trim(OBJ, seg=(49537, 51265), remove_epochs=false)", "add_component(OBJ, c=epoch_mean, v", "reset_components(OBJ)"])