-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
850 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
%initializing | ||
|
||
d_area = 0; | ||
|
||
% d = your data | ||
% enter your values here: | ||
d_start = 150; | ||
d_end = 600; | ||
|
||
%num_intervals = 50; | ||
|
||
%interval = ceil( (d_end-d_start)/num_intervals ); | ||
|
||
interval = 1; | ||
|
||
d_b = d - d(d_start); %subtracting baseline | ||
|
||
x = (d_start : interval : d_end)'; | ||
y = d_b (x); | ||
|
||
%plotting | ||
figure; hold on | ||
plot (d); | ||
|
||
%AF trapezoid integration | ||
for i = 1 : size(x)-1 | ||
d_area (i) = (x(i+1) - x(i)) * ((y(i) + y(i+1))/2); | ||
|
||
%plotting trapezoid | ||
t_x = [x(i), x(i), x(i+1), x(i+1)]; | ||
t_y = [0, y(i), y(i+1), 0]; | ||
|
||
fill (t_x, t_y, 'r'); | ||
end | ||
|
||
AF_area = sum(d_area) | ||
|
||
%trapz integration | ||
trapz_area = trapz(x,y) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
classdef IclTrace | ||
%ICLTRACE Summary of this class goes here | ||
% Detailed explanation goes here | ||
|
||
properties | ||
end | ||
|
||
methods | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
%% Averages traces on a selected figure | ||
|
||
data_b = {}; | ||
|
||
|
||
h = findobj(gca,'Type','line'); | ||
fig_x=get(h,'Xdata'); | ||
fig_y=get(h,'Ydata'); | ||
|
||
data_start = 1900; | ||
stim_start = 2000; | ||
data_finish = 2600; | ||
|
||
|
||
%subtract baseline | ||
figure; hold on; | ||
grey=[.8,.8,.8]; | ||
|
||
for i = 1 : size (fig_y) | ||
base = mean (fig_y{i}(data_start:stim_start)); | ||
data_b{i} = fig_y{i} - base; | ||
|
||
plot (data_b{i}(data_start:data_finish), 'Color', grey); | ||
end | ||
|
||
dim = ndims(data_b{2}); %# Get the number of dimensions for your arrays | ||
M = cat(dim+1,data_b{:}); %# Convert to a (dim+1)-dimensional matrix | ||
y_mean = mean(M,dim+1); %# Get the mean across arrays | ||
|
||
plot (y_mean (data_start:data_finish), 'r'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
function avgCurve = avgcurves( inputX, inputY ) | ||
%avgcurves Takes (x,y) curve, averages y for any repeating | ||
% x values. | ||
|
||
|
||
|
||
%% sort inputX and inputY into a cell% | ||
tempCell = sortvectors( inputX, inputY ); | ||
|
||
srtCurve.x = tempCell{1}; | ||
srtCurve.y = tempCell{2}; | ||
|
||
|
||
%% initializing newCurve and temp | ||
% pre-allocating empty values for newCurve | ||
newCurve.x = zeros(length(inputX),1); | ||
newCurve.y = zeros(length(inputY),1); | ||
newCurve.std = zeros(length(inputY),1); | ||
newCurve.stdErr = zeros(length(inputY),1); | ||
|
||
% initializing the first new X and Y | ||
newCurve.x(1) = srtCurve.x(1); | ||
newCurve.y(1) = srtCurve.y(1); | ||
|
||
%temp is a buffer vector holding all y-val's that have the same x-val | ||
temp = newCurve.y(1); | ||
|
||
uniqI = 1; %the index of the current unique x,y | ||
|
||
%% create averaged curve | ||
for i = 2 : length( srtCurve.x ) %from the second value : last | ||
|
||
if srtCurve.x(i) == srtCurve.x(i-1) %if two pts in a row are the same | ||
|
||
% if temp ~= inf | ||
temp = [temp; srtCurve.y(i)]; %add new point to temp | ||
% else | ||
% temp = srtCurve.y(i); | ||
% end | ||
|
||
%calculating y (avg), std and stdErr for the current x | ||
newCurve.y(uniqI) = mean(temp(~isnan(temp))); %new y-value is mean(temp) | ||
% newCurve.calcStd (uniqI, temp); | ||
|
||
newCurve.std(uniqI) = std(temp(~isnan(temp))); | ||
newCurve.stdErr(uniqI) = std(temp(~isnan(temp))) / sqrt( length(temp(~isnan(temp))) ); | ||
|
||
else | ||
uniqI = uniqI + 1; %update uniqI | ||
|
||
%update newCurve | ||
newCurve.x(uniqI) = srtCurve.x(i); | ||
newCurve.y(uniqI) = srtCurve.y(i); | ||
% newCurve = newCurve.calcStd (uniqI, temp); | ||
|
||
newCurve.std(uniqI) = std(temp(~isnan(temp))); | ||
newCurve.stdErr(uniqI) = std(temp(~isnan(temp))) / sqrt( length(temp(~isnan(temp))) ); | ||
|
||
temp = newCurve.y(uniqI); %update temp to the next value | ||
|
||
end %if | ||
|
||
end %for | ||
|
||
%delete zero values by making newCurve.x and .y go only until uniqI | ||
|
||
% curve = {newCurve.x newCurve.y newCurve.std newCurve.stdErr}; | ||
% | ||
% curve = curve(1:uniqI,1); | ||
% | ||
% [newCurve.x newCurve.y newCurve.std newCurve.stdErr] = curve{1,:}; | ||
% | ||
|
||
% a little cell magic | ||
|
||
% structure names | ||
curveHeadings = {'x' 'y' 'std' 'stdErr'}; | ||
|
||
%conversting to a matrix | ||
curve_mat = cell2mat( struct2cell(newCurve)' ); | ||
|
||
%assigining non-zero values to a cell | ||
shortCurve_cell = num2cell( curve_mat(1:uniqI,:), 1)'; | ||
|
||
%converting back to a structure | ||
newCurve = cell2struct (shortCurve_cell, curveHeadings, 1); | ||
|
||
|
||
|
||
|
||
|
||
% newCurve.x = newCurve.x(1:uniqI,1); | ||
% newCurve.y = newCurve.y(1:uniqI,1); | ||
% newCurve.std = newCurve.std(1:uniqI,1); | ||
% newCurve.stdErr = newCurve.stdErr(1:uniqI,1); | ||
%% plotting results | ||
|
||
% Create axes | ||
% axes('Position',[0.13 0.1126 0.775 0.815]); | ||
% box('on'); | ||
% hold('all'); | ||
|
||
|
||
%plot raw data and averaged data% | ||
%plot (srtCurve.x, srtCurve.y, 'k.', newCurve.x,newCurve.y, '-ko'); | ||
|
||
plot (newCurve.x,newCurve.y, '-ko'); hold on; | ||
%plot error bars% | ||
% | ||
% stdErr( length(srtCurve) ) = []; | ||
% | ||
% for i=1: length(strCurve.x) | ||
% stdErr = | ||
% | ||
% end | ||
|
||
|
||
% stdErr = 10 * rand (1, length(newCurve.x) ); %generate random stdErr | ||
|
||
|
||
errorbar(newCurve.x, newCurve.y, newCurve.stdErr,'LineStyle','none','Color',[0 0 1]); | ||
|
||
|
||
%% output | ||
|
||
avgCurve = newCurve; | ||
|
||
|
||
end | ||
|
||
% function newCurve = calcStd(uniqI, temp) | ||
% | ||
% end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function output = compare_v_th (current_cell) | ||
|
||
% current_cell = cell_05; | ||
|
||
for i = 1:min (size(current_cell)) | ||
|
||
sample = current_cell(:,i); | ||
|
||
findAPs(sample); | ||
APdata = find_dv_peaks (sample); | ||
AP_th = find_v_th (APdata.APs); | ||
|
||
total_th = []; | ||
for j = 1:length (AP_th) | ||
total_th = [total_th; AP_th(j).v]; | ||
end | ||
|
||
mean_th(i,1) = mean (total_th); | ||
f = find_v_th ({APdata.mean_AP}); | ||
mean_th_mAP(i,1) = f.v; | ||
end | ||
|
||
output.mean_th = mean_th; | ||
output.mean_th_mAP = mean_th_mAP; | ||
|
||
figure; hold on; | ||
|
||
plot (output.mean_th, '.'); plot (output.mean_th_mAP, 'r.'); | ||
end |
Oops, something went wrong.