Skip to content

Commit 1d08c7d

Browse files
committed
Use hub clock instead of frame clock for passthrough devices
- Add note describing the current behavior and the plans in ONI 2.0 to change the behavior
1 parent ebe43dd commit 1d08c7d

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed

Source/Devices/AnalogIO.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ void AnalogIO::processFrame(uint64_t eventWord)
231231

232232
currentAverageFrame = 0;
233233

234+
// NB: In ONI v1.0 frame clock is when the frame is created, not necessarily when the data is received.
235+
// For local and passthrough devices, we will instead use the hub clock for the timestamp; in
236+
// ONI v2.0 this behavior may change, and frame->time can be used instead for consistency across devices.
234237
auto hubClock = (uint64_t*)frame->data;
235238

236239
timestamps[currentFrame] = deviceContext->convertTimestampToSeconds(*hubClock);

Source/Devices/DigitalIO.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ void DigitalIO::processFrames()
133133
{
134134
size_t offset = 0;
135135

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.
136139
auto hubClock = (uint64_t*)frame->data;
137140

138141
timestamps[currentFrame] = deviceContext->convertTimestampToSeconds(*hubClock);

Source/Devices/HarpSyncInput.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ void HarpSyncInput::processFrames()
8383
oni_frame_t* frame;
8484
while (frameQueue.try_dequeue(frame))
8585
{
86+
// NB: In ONI v1.0 frame clock is when the frame is created, not necessarily when the data is received.
87+
// For local and passthrough devices, we will instead use the hub clock for the timestamp; in
88+
// ONI v2.0 this behavior may change, and frame->time can be used instead for consistency across devices.
8689
auto hubClock = (uint64_t*)frame->data;
8790

8891
timestamps[currentFrame] = deviceContext->convertTimestampToSeconds(*hubClock);

Source/Devices/MemoryMonitor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ void MemoryMonitor::processFrames()
153153

154154
while (frameQueue.try_dequeue(frame))
155155
{
156+
// NB: In ONI v1.0 frame clock is when the frame is created, not necessarily when the data is received.
157+
// For local and passthrough devices, we will instead use the hub clock for the timestamp; in
158+
// ONI v2.0 this behavior may change, and frame->time can be used instead for consistency across devices.
156159
auto hubClock = (uint64_t*)frame->data;
157160
auto t = deviceContext->convertTimestampToSeconds(*hubClock);
158161
uint32_t* dataPtr = (uint32_t*)frame->data;

Source/Devices/Neuropixels1e.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,17 @@ void Neuropixels1e::processFrames()
290290
oni_frame_t* frame;
291291
while (frameQueue.try_dequeue(frame))
292292
{
293-
uint16_t* dataPtr = (uint16_t*)frame->data;
294-
dataPtr += dataOffset;
293+
// NB: In ONI v1.0 frame clock is when the frame is created, not necessarily when the data is received.
294+
// For local and passthrough devices, we will instead use the hub clock for the timestamp; in
295+
// ONI v2.0 this behavior may change, and frame->time can be used instead for consistency across devices.
296+
auto hubClock = (uint64_t*)frame->data;
295297

296-
apTimestamps[superFrameCount] = deviceContext->convertTimestampToSeconds(frame->time);
298+
apTimestamps[superFrameCount] = deviceContext->convertTimestampToSeconds(*hubClock);
297299
apSampleNumbers[superFrameCount] = apSampleNumber++;
298300

301+
uint16_t* dataPtr = (uint16_t*)frame->data;
302+
dataPtr += dataOffset;
303+
299304
for (size_t i = 0; i < framesPerSuperFrame; i++)
300305
{
301306
if (i == 0) // LFP data

Source/Devices/Neuropixels2e.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Neuropixels2e::Neuropixels2e(std::string name, std::string hubName, const oni_de
3030
INeuropixel(NeuropixelsV2eValues::numberOfSettings, NeuropixelsV2eValues::numberOfShanks)
3131
{
3232
probeSN.fill(0);
33-
frameCount.fill(0);
34-
sampleNumber.fill(0);
33+
frameCount.fill(0);
34+
sampleNumber.fill(0);
3535

3636
for (int i = 0; i < NeuropixelsV2eValues::numberOfSettings; i++)
3737
{
@@ -493,8 +493,8 @@ uint64_t Neuropixels2e::getProbeSN(uint8_t probeSelect)
493493

494494
void Neuropixels2e::startAcquisition()
495495
{
496-
frameCount.fill(0);
497-
sampleNumber.fill(0);
496+
frameCount.fill(0);
497+
sampleNumber.fill(0);
498498
}
499499

500500
void Neuropixels2e::stopAcquisition()
@@ -534,7 +534,13 @@ void Neuropixels2e::processFrames()
534534
uint16_t* amplifierData = dataPtr + 9;
535535

536536
sampleNumbers[probeIndex][frameCount[probeIndex]] = sampleNumber[probeIndex]++;
537-
timestamps[probeIndex][frameCount[probeIndex]] = deviceContext->convertTimestampToSeconds(frame->time);
537+
538+
// NB: In ONI v1.0 frame clock is when the frame is created, not necessarily when the data is received.
539+
// For local and passthrough devices, we will instead use the hub clock for the timestamp; in
540+
// ONI v2.0 this behavior may change, and frame->time can be used instead for consistency across devices.
541+
auto hubClock = (uint64_t*)frame->data;
542+
543+
timestamps[probeIndex][frameCount[probeIndex]] = deviceContext->convertTimestampToSeconds(*hubClock);
538544

539545
for (int i = 0; i < FramesPerSuperFrame; i++)
540546
{

0 commit comments

Comments
 (0)