I found a way to get the event-to-peak table (though the setup is different than I originally planned, I like the new setup better). I got a fair amount of the code from the other question I mentioned earlier (https://www.mathworks.com/matlabcentral/answers/1574933-finding-peaks-after-event-in-a-time-frame). Here is the code I used for my table:
%% Event_to_First_Peak_Try_4
close all; clear all; clc;
% 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'
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');
EventTime=Int.latency; %Imports the latency from the file
EventMarkerLabel=Int.type; %Imports the event type/label from the file
% EvtLab=readtable('Try 4 Event Labels.xlsx'); %Import event markers and abbreviations used for plot
% %EvtLab{2,2} = {'Blink Eye'};
% table(EvtLab) %View legend (in table form) of abbreviations used in the plot
% Preallocate variable
Event_Labels = cell(length(EventTime),1);
%Event Labels
Event_Labels=EventMarkerLabel;
%% Plots all together
%creates plot
p=plot(T.Timestamp,T{:,2:width(T)});
xline(EventTime,'--',Event_Labels);%creates vertical lines marking events
% Preallocate variables
Firstpeakafterevent = zeros([width(T)-1, size(EventTime)]);
timeoffirstpeakafterevent = zeros([width(T)-1, size(EventTime)]);
timefromeventtofirstpeak = zeros([width(T)-1, size(EventTime)]);
% Plot
for i=2:width(T) %for the EEG electrode data
%find peaks and locations/times of peaks
[pks,locs] = findpeaks(T{:,i},T.Timestamp, 'MinPeakProminence', 100);
for ii = 1:length(EventTime) %for the experiment length
index = find(locs>EventTime(ii),1); %finds the location(peak) after the event, but closest to the event
if ~isempty(index)
Firstpeakafterevent(i-1,ii,:) = pks(index); %stores peak values in array Firstpeakafterevent
timeoffirstpeakafterevent(i-1,ii,:) = locs(index); %Stores peak times in the array timeoffirstpeakafterevent
timefromeventtofirstpeak(i-1,ii,:) = locs(index)-EventTime(ii);%time from event to first peak
end
end
x = timeoffirstpeakafterevent(i-1,:);
y = Firstpeakafterevent(i-1,:);
x(x==0) = [];
y(y==0) = [];
hold on
scatter(x,y,'v','filled','MarkerFaceColor',p(i-1).Color) %Creates scatterplot for the first peak after each event
end
grid on;
legend(p,T.Properties.VariableNames(2:width(T))) %view legend
%% Data Table
%transposing data so it fits table
timefromeventtofirstpeak = timefromeventtofirstpeak';
timeoffirstpeakafterevent = timeoffirstpeakafterevent';
Firstpeakafterevent = Firstpeakafterevent';
%Filename to print table to
filename='Try 4 Event to Peak Times and Amplitudes.xlsx';
%Create table t with event labels, latency, time of peak, and peak
%amplitudes
t=table(Event_Labels, timefromeventtofirstpeak(:,1), timeoffirstpeakafterevent(:,1), Firstpeakafterevent(:,1),Firstpeakafterevent(:,2),Firstpeakafterevent(:,3),Firstpeakafterevent(:,4),Firstpeakafterevent(:,5),Firstpeakafterevent(:,6),Firstpeakafterevent(:,7),Firstpeakafterevent(:,8),Firstpeakafterevent(:,9),Firstpeakafterevent(:,10),Firstpeakafterevent(:,11),Firstpeakafterevent(:,12),Firstpeakafterevent(:,13),Firstpeakafterevent(:,14));
%Label columns
t.Properties.VariableNames = {'Event','Latency after Event','Time of Peak','AF3 Pk','F7 Pk','F3 Pk','FC5 Pk','T7 Pk','P7 Pk','O1 Pk','O2 Pk','P8 Pk','T8 Pk','FC6 Pk','F4 Pk','F8 Pk','AF4 Pk'};
%Write to excel file
writetable(t,filename,'Sheet',1,'Range','A1');
I am still working on a code for the number of peaks in a section.