Counting spikes for each trial given spike times
6 views (last 30 days)
Show older comments
I have a vector that is 3x144, that contains the angle of stimulus in row 1, the start time of that stimulus in row 2, and the end time of that stimulus in row 3. Each column makes up one "trial." I have another vector of size 1x12197 that contains the times of neuron spikes. Each column contains the time stamp of one spike. I am trying to write a nested for loop which goes through the spike times vector, called spiketimes10, and the vector with the directions and start times and end times called direction_intervals, and count how many spikes occurred in each trial. My for loops seem to only iterate through once, as they only add "1" one time to each column representing the spike count. I cannot figure out what is wrong. Any help would be greatly appreciated!
direction_intervals=[];
direction_intervals(1)=240;
for i=1:length(stimulus)-1;
if stimulus(i,2)~=stimulus(i+1,2);
direction_intervals(i+1)=stimulus(i+1,2);
elseif stimulus(i,2)==stimulus(i+1,2);
direction_intervals(i+1)=10;
end
end
% This creates a direction intervals vector
% Row 1 is the directions
% Row 2 is the start times of each direction
% Row 3 is the end times of each direction
direction_intervals=direction_intervals(direction_intervals~=10);
direction_intervals(2,:)=0;
direction_intervals(2,:)=[0:4E6:575995000];
direction_intervals(3,:)=0;
for i=1:length(direction_intervals)-1;
direction_intervals(3,i)=direction_intervals(2,i+1)-5000;
end
direction_intervals(3,144)=575995000;
NumSpikes=zeros(1,144);
for i=1:length(spiketimes10)
for j=1:length(direction_intervals)
if direction_intervals(2,j)<spiketimes10(i)<direction_intervals(3,j);
NumSpikes(j)=NumSpikes(j)+1;
end
end
end
0 Comments
Answers (0)
See Also
Categories
Find more on Electrophysiology in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!