Excel Tables from EEG Data - Nearest peak value after event, global average values, local average values
Afficher commentaires plus anciens
I am trying to get the nearest peak value after an event, global average values, and local average values. Below I have examples of the tables I am trying to get. I want each table in a different excel file and I can provide the subject numbers.

I have attached a zip folder with the files you should need.
%% Importing_and_Plotting_EEG_Example
close all; clear all; clc;
% look to 300 ms for peak after stimulation
% add folder with csv file to path
addpath 'C:\Users\chris\Documents\College\Sixth Year\DAGSI\Data\EMOTIV Recordings\Event Marker Try 4'
% change current directory to where this Matlab file is
cd 'C:\Users\chris\Documents\College\Sixth Year\DAGSI\Data\EMOTIV Recordings'
% stops Matlab from rounding numbers
format long;
% Importing csv data
T=readtable('Try 4.csv'); %This reads the csv data into a table named T
timestampOrig=T.Timestamp; %this makes timestampOrig equal to the original Timestamp
T.Timestamp=T.Timestamp-T.Timestamp(1); %This changes the official Timestamp column so it is 0 at the start of the recording
% Changes the sensor names from EEG_<sensor> to <sensor>
T.Properties.VariableNames(2:end)=extractAfter(T.Properties.VariableNames(2:end),'_');
%T5=head(T, 5) %shows first 5 rows of table T
Int=readtable('Event Marker Try 4_EPOCX_126368_2021.06.04T15.42.31.04.00_intervalMarker.csv');
EvtMar=Int.latency;
EvtMarLab=Int.type;
EvtLab=readtable('Try 4 Event Labels.xlsx');
table(EvtLab)
I think I can use findpeaks, but I'm having trouble getting the peaks narrowed down and getting the data organized correctly.
%% Time Between Peaks
%Assigns the peak values and indices of peak values to variables
%<sensor>pk and <sensor>index, respectively
[AF3pk, AF3index]=findpeaks(T.AF3, T.Timestamp,'MinPeakProminence',100); [F7pk, F7index]=findpeaks(T.F7, T.Timestamp,'MinPeakProminence',100);
[F3pk, F3index]=findpeaks(T.F3, T.Timestamp,'MinPeakProminence',100); [FC5pk, FC5index]=findpeaks(T.FC5, T.Timestamp,'MinPeakProminence',100);
[T7pk, T7index]=findpeaks(T.T7, T.Timestamp,'MinPeakProminence',100); [P7pk, P7index]=findpeaks(T.P7, T.Timestamp,'MinPeakProminence',100);
[O1pk, O1index]=findpeaks(T.O1, T.Timestamp,'MinPeakProminence',100); [O2pk, O2index]=findpeaks(T.O2, T.Timestamp,'MinPeakProminence',100);
[P8pk, P8index]=findpeaks(T.P8, T.Timestamp,'MinPeakProminence',100); [T8pk, T8index]=findpeaks(T.T8, T.Timestamp,'MinPeakProminence',100);
[FC6pk, FC6index]=findpeaks(T.FC6, T.Timestamp,'MinPeakProminence',100); [F4pk, F4index]=findpeaks(T.F4, T.Timestamp,'MinPeakProminence',100);
[F8pk, F8index]=findpeaks(T.F8, T.Timestamp,'MinPeakProminence',100); [AF4pk, AF4index]=findpeaks(T.AF4, T.Timestamp,'MinPeakProminence',100);
I also want it to say either N/A or 0 if there is no peak in that section. I am trying to automate this prcocess since I have 15 subjects and about 20 minutes of data each (So, over 137,200 data points each).
Any help would be appreciated!
Note: I posted one of these as a different question (https://www.mathworks.com/matlabcentral/answers/1574933-finding-peaks-after-event-in-a-time-frame) but I didn't describe what I was trying to get well enough.
Réponses (1)
Christina Diersing
le 10 Nov 2021
Catégories
En savoir plus sur EEG/MEG/ECoG dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!