NeuroAnalyzer tutorials: Process EEG (1)

Reference to channel(s) - if more than one channel is used as reference, the average of these channels is used:

reference_ch!(eeg, ch=[1, 2])
reference_ch!(eeg, ch=2:4)
reference_ch!(eeg, ch=18)

Reference to common average:

reference_car!(eeg)
# do not include current electrode and Fp1, Fp2, O1 and O2 when calculating common average
reference_car!(eeg, exclude_fpo=true, exclude_current=true)

Reference to ipsilateral auricular electrodes:

reference_a!(eeg, type=:i)

Reference to contralateral mastoid electrodes:

reference_m!(eeg, type=:c)

Reference using planar Laplacian, 4 or 2 adjacent electrodes:

eeg_car = reference_car(eeg)
p1 = plot_topo(eeg_car, seg=(0, 10), title="CAR",)
eeg_lap = reference_plap(eeg, nn=4, weights=false)
p2 = plot_topo(eeg_lap, seg=(0, 10), title="unweighted Laplacian (4)")
eeg_lap = reference_plap(eeg, nn=2, weights=true)
p3 = plot_topo(eeg_lap, seg=(0, 10), title="weighted Laplacian (2)")
p = plot(p1, p2, p3, plot_empty(), layout=(2,2))
plot_save(p, file_name="images/lap4.png")

(!) Planar Laplacian referencing required electrode locations.

Custom referencing, e.g. bipolar longitudinal:

eeg_bipl = reference_custom(eeg, ref_list=["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"], ref_name="BIP ||")
info(eeg_bipl)

Output:

              Data type: EEG
            File format: EDF
            Source file: ~/.julia/artifacts/25cbd5d6479ab71d126b918e5b7eefa495dface0/test-files/eeg-test-edf.edf
         File size [MB]: 14.19
       Memory size [MB]: 59.09
                Subject: 
              Recording: EEGDigiTrack EEG-1042 (42-channel EEG Amplifier) V0.5 Rev. 41
        Recording notes: 
         Recording date: 25.04.22
         Recording time: 09.31.41
     Sampling rate (Hz): 256
Signal length [samples]: 309760
Signal length [seconds]: 1210.0
     Number of channels: 23
       Number of epochs: 1
 Epoch length [samples]: 309760
 Epoch length [seconds]: 1210.0
         Reference type: BIP ||
                 Labels: yes
                Markers: no
      Channel locations: no
             Components: no
Channels:
 ch     label           type        unit    
 1      Fz-Cz           EEG         μV      
 2      Cz-Pz           EEG         μV      
 3      Fp1-F7          EEG         μV      
 4      Fp1-F3          EEG         μV      
 5      F7-T3           EEG         μV      
 6      T3-T5           EEG         μV      
 7      T5-O1           EEG         μV      
 8      F3-C3           EEG         μV      
 9      C3-P3           EEG         μV      
 10     P3-O1           EEG         μV      
 11     Fp2-F8          EEG         μV      
 12     Fp2-F4          EEG         μV      
 13     F8-T4           EEG         μV      
 14     T4-T6           EEG         μV      
 15     T6-O2           EEG         μV      
 16     F4-C4           EEG         μV      
 17     C4-P4           EEG         μV      
 18     P4-O2           EEG         μV      
 19     A1              REF         μV      
 20     A2              REF         μV      
 21     EOG1            EOG         μV      
 22     EOG2            EOG         μV      
 23     ECG             ECG         mV

Examples of other montages:

Custom montages may be loaded from a file:

ref_l, ref_n = import_montage(joinpath(NeuroAnalyzer.PATH, "montages", "bip_long.txt"))
reference_custom(eeg, ref_listref_l, ref_name=ref_n)