From bb9375a2bc12d152dc09388f4bfa0c39efa0dafb Mon Sep 17 00:00:00 2001 From: Josh Siegle <jsiegle@mit.edu> Date: Tue, 20 Jan 2015 18:52:17 -0800 Subject: [PATCH] Fix bug in spike timestamp alignment --- Source/Processors/RecordNode/OriginalRecording.cpp | 12 ------------ Source/Processors/SpikeDetector/SpikeDetector.cpp | 5 ++--- Source/Processors/SpikeSorter/SpikeSorter.cpp | 4 ++-- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Source/Processors/RecordNode/OriginalRecording.cpp b/Source/Processors/RecordNode/OriginalRecording.cpp index f6c95fd54..4ea3446e5 100644 --- a/Source/Processors/RecordNode/OriginalRecording.cpp +++ b/Source/Processors/RecordNode/OriginalRecording.cpp @@ -639,18 +639,6 @@ void OriginalRecording::writeSpike(const SpikeObject& spike, int electrodeIndex) SPIKE_METADATA_SIZE; // 42, from SpikeObject.h - // format: - // 1 byte of event type (always = 4 for spikes) - // 8 bytes for 64-bit timestamp - // 2 bytes for 16-bit electrode ID - // 2 bytes for 16-bit number of channels (n) - // 2 bytes for 16-bit number of samples (m) - // 2*n*m bytes for 16-bit samples - // 2*n bytes for 16-bit gains - // 2*n bytes for 16-bit thresholds - - // const MessageManagerLock mmLock; - diskWriteLock.enter(); fwrite(spikeBuffer, 1, totalBytes, spikeFileArray[electrodeIndex]); diff --git a/Source/Processors/SpikeDetector/SpikeDetector.cpp b/Source/Processors/SpikeDetector/SpikeDetector.cpp index c17173d18..bc53a8b64 100755 --- a/Source/Processors/SpikeDetector/SpikeDetector.cpp +++ b/Source/Processors/SpikeDetector/SpikeDetector.cpp @@ -379,8 +379,7 @@ void SpikeDetector::addWaveformToSpikeObject(SpikeObject* s, // float gain[MAX_NUMBER_OF_SPIKE_CHANNELS]; // uint16_t threshold[MAX_NUMBER_OF_SPIKE_CHANNELS]; - s->timestamp = timestamp + peakIndex; - + s->timestamp = getTimestamp(currentChannel) + peakIndex; s->nSamples = spikeLength; @@ -512,7 +511,7 @@ void SpikeDetector::process(AudioSampleBuffer& buffer, // uint16_t threshold[MAX_NUMBER_OF_SPIKE_CHANNELS]; SpikeObject newSpike; - newSpike.timestamp = peakIndex; + newSpike.timestamp = 0; //getTimestamp(currentChannel) + peakIndex; newSpike.timestamp_software = -1; newSpike.source = i; newSpike.nChannels = electrode->numChannels; diff --git a/Source/Processors/SpikeSorter/SpikeSorter.cpp b/Source/Processors/SpikeSorter/SpikeSorter.cpp index 096d4c6ec..813bdc28c 100644 --- a/Source/Processors/SpikeSorter/SpikeSorter.cpp +++ b/Source/Processors/SpikeSorter/SpikeSorter.cpp @@ -712,7 +712,7 @@ void SpikeSorter::addWaveformToSpikeObject(SpikeObject* s, int spikeLength = electrodes[electrodeNumber]->prePeakSamples + + electrodes[electrodeNumber]->postPeakSamples; - s->timestamp = hardware_timestamp + peakIndex; + s->timestamp = getTimestamp(currentChannel) + peakIndex; // convert sample offset to software ticks float samplesPerSec = getSampleRate(); @@ -944,7 +944,7 @@ void SpikeSorter::process(AudioSampleBuffer& buffer, SpikeObject newSpike; newSpike.sortedId = 0; // unsorted. - newSpike.timestamp = peakIndex; + newSpike.timestamp = getTimestamp(currentChannel) + peakIndex; newSpike.electrodeID = electrode->electrodeID; newSpike.channel = chan; newSpike.source = i; -- GitLab