File tree Expand file tree Collapse file tree 6 files changed +40
-10
lines changed Expand file tree Collapse file tree 6 files changed +40
-10
lines changed Original file line number Diff line number Diff line change @@ -234,7 +234,12 @@ void AnalogIO::processFrame (uint64_t eventWord)
234234
235235 currentAverageFrame = 0 ;
236236
237- timestamps[currentFrame] = deviceContext->convertTimestampToSeconds (frame->time );
237+ // NB: In ONI v1.0 frame clock is when the frame is created, not necessarily when the data is received.
238+ // For local and passthrough devices, we will instead use the hub clock for the timestamp; in
239+ // ONI v2.0 this behavior may change, and frame->time can be used instead for consistency across devices.
240+ auto hubClock = (uint64_t *) frame->data ;
241+
242+ timestamps[currentFrame] = deviceContext->convertTimestampToSeconds (*hubClock);
238243 sampleNumbers[currentFrame] = sampleNumber++;
239244 eventCodes[currentFrame] = eventWord;
240245
Original file line number Diff line number Diff line change @@ -133,14 +133,19 @@ void DigitalIO::processFrames()
133133 {
134134 size_t offset = 0 ;
135135
136- uint16_t * dataPtr = (uint16_t *) frame->data ;
136+ // NB: In ONI v1.0 frame clock is when the frame is created, not necessarily when the data is received.
137+ // For local and passthrough devices, we will instead use the hub clock for the timestamp; in
138+ // ONI v2.0 this behavior may change, and frame->time can be used instead for consistency across devices.
139+ auto hubClock = (uint64_t *) frame->data ;
137140
138- timestamps[currentFrame] = deviceContext->convertTimestampToSeconds (frame-> time );
141+ timestamps[currentFrame] = deviceContext->convertTimestampToSeconds (*hubClock );
139142 sampleNumbers[currentFrame] = sampleNumber++;
140143
141144 constexpr int inputDataOffset = 4 ;
142145 constexpr int buttonDataOffset = inputDataOffset + 1 ;
143146
147+ uint16_t * dataPtr = (uint16_t *) frame->data ;
148+
144149 uint64_t inputState = *(dataPtr + inputDataOffset);
145150 uint64_t buttonState = *(dataPtr + buttonDataOffset);
146151
Original file line number Diff line number Diff line change @@ -82,9 +82,14 @@ void HarpSyncInput::processFrames()
8282 oni_frame_t * frame;
8383 while (frameQueue.try_dequeue (frame))
8484 {
85- uint32_t * dataPtr = (uint32_t *) frame->data ;
85+ // NB: In ONI v1.0 frame clock is when the frame is created, not necessarily when the data is received.
86+ // For local and passthrough devices, we will instead use the hub clock for the timestamp; in
87+ // ONI v2.0 this behavior may change, and frame->time can be used instead for consistency across devices.
88+ auto hubClock = (uint64_t *) frame->data ;
89+
90+ timestamps[currentFrame] = deviceContext->convertTimestampToSeconds (*hubClock);
8691
87- timestamps[currentFrame] = deviceContext-> convertTimestampToSeconds ( frame->time ) ;
92+ uint32_t * dataPtr = ( uint32_t *) frame->data ;
8893
8994 harpTimeSamples[currentFrame] = *(dataPtr + 2 ) + 1 ;
9095
Original file line number Diff line number Diff line change @@ -152,8 +152,12 @@ void MemoryMonitor::processFrames()
152152
153153 while (frameQueue.try_dequeue (frame))
154154 {
155+ // NB: In ONI v1.0 frame clock is when the frame is created, not necessarily when the data is received.
156+ // For local and passthrough devices, we will instead use the hub clock for the timestamp; in
157+ // ONI v2.0 this behavior may change, and frame->time can be used instead for consistency across devices.
158+ auto hubClock = (uint64_t *) frame->data ;
159+ auto t = deviceContext->convertTimestampToSeconds (*hubClock);
155160 uint32_t * dataPtr = (uint32_t *) frame->data ;
156- auto t = deviceContext->convertTimestampToSeconds (frame->time );
157161 auto p = 100 .0f * float (*(dataPtr + 2 )) / totalMemory;
158162 lastPercentUsedValue = p;
159163 oni_destroy_frame (frame);
Original file line number Diff line number Diff line change @@ -287,12 +287,17 @@ void Neuropixels1e::processFrames()
287287 oni_frame_t * frame;
288288 while (frameQueue.try_dequeue (frame))
289289 {
290- uint16_t * dataPtr = (uint16_t *) frame->data ;
291- dataPtr += dataOffset;
290+ // NB: In ONI v1.0 frame clock is when the frame is created, not necessarily when the data is received.
291+ // For local and passthrough devices, we will instead use the hub clock for the timestamp; in
292+ // ONI v2.0 this behavior may change, and frame->time can be used instead for consistency across devices.
293+ auto hubClock = (uint64_t *) frame->data ;
292294
293- apTimestamps[superFrameCount] = deviceContext->convertTimestampToSeconds (frame-> time );
295+ apTimestamps[superFrameCount] = deviceContext->convertTimestampToSeconds (*hubClock );
294296 apSampleNumbers[superFrameCount] = apSampleNumber++;
295297
298+ uint16_t * dataPtr = (uint16_t *) frame->data ;
299+ dataPtr += dataOffset;
300+
296301 for (size_t i = 0 ; i < framesPerSuperFrame; i++)
297302 {
298303 if (i == 0 ) // LFP data
Original file line number Diff line number Diff line change @@ -535,7 +535,13 @@ void Neuropixels2e::processFrames()
535535 uint16_t * amplifierData = dataPtr + 9 ;
536536
537537 sampleNumbers[probeIndex][frameCount[probeIndex]] = sampleNumber[probeIndex]++;
538- timestamps[probeIndex][frameCount[probeIndex]] = deviceContext->convertTimestampToSeconds (frame->time );
538+
539+ // NB: In ONI v1.0 frame clock is when the frame is created, not necessarily when the data is received.
540+ // For local and passthrough devices, we will instead use the hub clock for the timestamp; in
541+ // ONI v2.0 this behavior may change, and frame->time can be used instead for consistency across devices.
542+ auto hubClock = (uint64_t *) frame->data ;
543+
544+ timestamps[probeIndex][frameCount[probeIndex]] = deviceContext->convertTimestampToSeconds (*hubClock);
539545
540546 for (int i = 0 ; i < FramesPerSuperFrame; i++)
541547 {
You can’t perform that action at this time.
0 commit comments