From 1e7e2e19a6e215ad68701ed860acbe0ee1e6d641 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Fri, 28 Dec 2018 21:02:41 +0200 Subject: [PATCH] Spike detection fix --- spike_sorting.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spike_sorting.m b/spike_sorting.m index dea9d0a..4cb1468 100644 --- a/spike_sorting.m +++ b/spike_sorting.m @@ -11,8 +11,6 @@ %% %% ================================================================================================= %% S.1 -clear all - datasetMedians = zeros(8); datasetFactors = zeros(8); @@ -133,6 +131,7 @@ for fileIndex=1:4 if data(sample) >= threshold % spike found numberOfSpikes = numberOfSpikes + 1; + spikeStartIndex = sample; % skips cheking until values are below threshold again while sample <= length(data) @@ -145,7 +144,7 @@ for fileIndex=1:4 % Q.2.1 spikesTimesEst(numberOfSpikes) = firstIndex; % Q.2.2 - spikesEst(numberOfSpikes, :) = data(firstIndex-34:firstIndex+29); + spikesEst(numberOfSpikes, :) = data(spikeStartIndex-1+firstIndex-34:spikeStartIndex-1+firstIndex+29); break; end end @@ -154,7 +153,7 @@ for fileIndex=1:4 end 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)); figure();