Browse Source

Spike detection fix

master
Apostolos Fanakis 6 years ago
parent
commit
1e7e2e19a6
  1. 7
      spike_sorting.m

7
spike_sorting.m

@ -11,8 +11,6 @@
%% %%
%% ================================================================================================= %% =================================================================================================
%% S.1 %% S.1
clear all
datasetMedians = zeros(8); datasetMedians = zeros(8);
datasetFactors = zeros(8); datasetFactors = zeros(8);
@ -133,6 +131,7 @@ for fileIndex=1:4
if data(sample) >= threshold if data(sample) >= threshold
% spike found % spike found
numberOfSpikes = numberOfSpikes + 1; numberOfSpikes = numberOfSpikes + 1;
spikeStartIndex = sample;
% skips cheking until values are below threshold again % skips cheking until values are below threshold again
while sample <= length(data) while sample <= length(data)
@ -145,7 +144,7 @@ for fileIndex=1:4
% Q.2.1 % Q.2.1
spikesTimesEst(numberOfSpikes) = firstIndex; spikesTimesEst(numberOfSpikes) = firstIndex;
% Q.2.2 % Q.2.2
spikesEst(numberOfSpikes, :) = data(firstIndex-34:firstIndex+29); spikesEst(numberOfSpikes, :) = data(spikeStartIndex-1+firstIndex-34:spikeStartIndex-1+firstIndex+29);
break; break;
end end
end end
@ -154,7 +153,7 @@ for fileIndex=1:4
end end
fprintf('%d spikes found for dataset #%d\n', numberOfSpikes, fileIndex); fprintf('%d spikes found for dataset #%d\n', numberOfSpikes, fileIndex);
fprintf('actial number of spikes = %d\n', length(Dataset.spikeTimes)); fprintf('actual number of spikes = %d\n', length(Dataset.spikeTimes));
fprintf('diff = %d\n\n', abs(length(Dataset.spikeTimes) - numberOfSpikes)); fprintf('diff = %d\n\n', abs(length(Dataset.spikeTimes) - numberOfSpikes));
figure(); figure();

Loading…
Cancel
Save