How do I find and plot the average of action potentials from a trace?
Hi,
I need to find the average wave from several in a trace.
I would like to produce a figure where the action potentials are stacked, with their average incorporated into the figure.
I only managed to find peaks in the waveform and plot them but I don’t know how to proceed.
%What I have so far:
clear
close all
D = load(‘C:UsersrsanaDesktopAPAnalysisS2C1_17082020_WM4peaks.mat’);
F = fieldnames(D);
C = struct2cell(D);
vm = C{1}.values; % Signal Vector
L1 = numel(vm); % Length
% Set Time Vector for ms Interval
t = linspace(0, L1, L1).’*C{1}.interval;
% Determine peaks, time interval, and cutoff for APs
[peaks, int, W] = findpeaks(vm, ‘WidthReference’, ‘halfprom’);
figure
plot(t, vm)
hold on
plot(t(int), peaks, ‘+r’)
hold off
xlabel(‘Time (s)’)
ylabel(‘Voltage (mV)’)
%%%
The above generates labelled peaks. So I am wondering how to extract, stack, and average them.
Thank you,
RoksanaHi,
I need to find the average wave from several in a trace.
I would like to produce a figure where the action potentials are stacked, with their average incorporated into the figure.
I only managed to find peaks in the waveform and plot them but I don’t know how to proceed.
%What I have so far:
clear
close all
D = load(‘C:UsersrsanaDesktopAPAnalysisS2C1_17082020_WM4peaks.mat’);
F = fieldnames(D);
C = struct2cell(D);
vm = C{1}.values; % Signal Vector
L1 = numel(vm); % Length
% Set Time Vector for ms Interval
t = linspace(0, L1, L1).’*C{1}.interval;
% Determine peaks, time interval, and cutoff for APs
[peaks, int, W] = findpeaks(vm, ‘WidthReference’, ‘halfprom’);
figure
plot(t, vm)
hold on
plot(t(int), peaks, ‘+r’)
hold off
xlabel(‘Time (s)’)
ylabel(‘Voltage (mV)’)
%%%
The above generates labelled peaks. So I am wondering how to extract, stack, and average them.
Thank you,
Roksana Hi,
I need to find the average wave from several in a trace.
I would like to produce a figure where the action potentials are stacked, with their average incorporated into the figure.
I only managed to find peaks in the waveform and plot them but I don’t know how to proceed.
%What I have so far:
clear
close all
D = load(‘C:UsersrsanaDesktopAPAnalysisS2C1_17082020_WM4peaks.mat’);
F = fieldnames(D);
C = struct2cell(D);
vm = C{1}.values; % Signal Vector
L1 = numel(vm); % Length
% Set Time Vector for ms Interval
t = linspace(0, L1, L1).’*C{1}.interval;
% Determine peaks, time interval, and cutoff for APs
[peaks, int, W] = findpeaks(vm, ‘WidthReference’, ‘halfprom’);
figure
plot(t, vm)
hold on
plot(t(int), peaks, ‘+r’)
hold off
xlabel(‘Time (s)’)
ylabel(‘Voltage (mV)’)
%%%
The above generates labelled peaks. So I am wondering how to extract, stack, and average them.
Thank you,
Roksana waveform analysis, average action potential MATLAB Answers — New Questions