Skip to content

Commit 390d13f

Browse files
committed
Save both Neuropixels 2.0 probes when recording starts
- Standardize how stream names are created across the code base for 2.0 probes - Standardized the stream name itself for 2.0 probes to include the device name, similar to other devices
1 parent 76093dd commit 390d13f

File tree

7 files changed

+26
-16
lines changed

7 files changed

+26
-16
lines changed

Source/Devices/Neuropixels2e.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,15 @@ Neuropixels2e::~Neuropixels2e()
5353
deviceContext->setOption (ONIX_OPT_PASSTHROUGH, 0);
5454
}
5555

56+
std::string Neuropixels2e::createStreamName (int n)
57+
{
58+
return OnixDevice::createStreamName (ProbeString + std::to_string (n));
59+
}
60+
5661
void Neuropixels2e::createDataStream (int n)
5762
{
5863
StreamInfo apStream = StreamInfo (
59-
createStreamName ("Probe" + std::to_string (n)),
64+
createStreamName (n),
6065
"Neuropixels 2.0 data stream",
6166
getStreamIdentifier(),
6267
numberOfChannels,

Source/Devices/Neuropixels2e.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class Neuropixels2e : public INeuropixel<NeuropixelsV2eValues::numberOfChannels,
6161
void stopAcquisition() override;
6262
void processFrames() override;
6363
void addSourceBuffers (OwnedArray<DataBuffer>& sourceBuffers) override;
64+
std::string createStreamName (int);
6465

6566
int getNumProbes() const;
6667

Source/NeuropixelsComponents.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ std::vector<unsigned char> toBitReversedBytes (std::bitset<N> bits)
346346
return bytes;
347347
}
348348

349+
static const std::string ProbeString = "Probe";
350+
349351
template <int ch, int e>
350352
class INeuropixel
351353
{

Source/OnixDevice.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ enum class OnixDeviceType
5757
UNKNOWN
5858
};
5959

60-
static const std::string ProbeString = "Probe";
61-
6260
struct StreamInfo
6361
{
6462
public:

Source/OnixSource.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ void OnixSource::startRecording()
12621262
if (device->getDeviceType() == OnixDeviceType::NEUROPIXELSV1E || device->getDeviceType() == OnixDeviceType::NEUROPIXELSV1F)
12631263
{
12641264
auto npx = std::static_pointer_cast<Neuropixels1>(device);
1265-
auto streamName = npx->createStreamName(); // NB: Create the automatic stream name, without any suffixes and including the port name
1265+
auto streamName = npx->createStreamName();
12661266

12671267
auto streamExists = dataStreamExists(streamName, sn->getDataStreams());
12681268

@@ -1275,15 +1275,19 @@ void OnixSource::startRecording()
12751275
else if (device->getDeviceType() == OnixDeviceType::NEUROPIXELSV2E)
12761276
{
12771277
auto npx = std::static_pointer_cast<Neuropixels2e>(device);
1278-
auto streamName = npx->createStreamName(); // NB: Create the automatic stream name, without any suffixes and including the port name
12791278

1280-
auto streamExists = dataStreamExists(streamName, sn->getDataStreams());
1279+
for (int i = 0; i < npx->getNumProbes(); i++)
1280+
{
1281+
auto streamName = npx->createStreamName(i);
12811282

1282-
if (!streamExists)
1283-
return;
1283+
auto streamExists = dataStreamExists(streamName, sn->getDataStreams());
12841284

1285-
if (!npx->saveProbeInterfaceFile(dir, streamName))
1286-
return;
1285+
if (!streamExists)
1286+
return;
1287+
1288+
if (!npx->saveProbeInterfaceFile(dir, streamName))
1289+
return;
1290+
}
12871291
}
12881292
}
12891293
}

Source/OnixSourceCanvas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void OnixSourceCanvas::addHub (std::string hubName, int offset)
100100

101101
tab = addTopLevelTab (getTopLevelTabName (port, hubName), (int) port);
102102

103-
devices.emplace_back (std::make_shared<Neuropixels2e> (ProbeString, hubName, passthroughIndex, context));
103+
devices.emplace_back (std::make_shared<Neuropixels2e> (OnixDevice::TypeString.at (OnixDeviceType::NEUROPIXELSV2E), hubName, passthroughIndex, context));
104104
devices.emplace_back (std::make_shared<PolledBno055> (OnixDevice::TypeString.at (OnixDeviceType::POLLEDBNO), hubName, passthroughIndex, context));
105105
}
106106

Source/UI/NeuropixelsV2eInterface.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ NeuropixelsV2eInterface::NeuropixelsV2eInterface (std::shared_ptr<Neuropixels2e>
3333
topLevelTabComponent = std::make_unique<CustomTabComponent> (true);
3434
addAndMakeVisible (topLevelTabComponent.get());
3535

36-
probeInterfaces[0] = std::make_unique<NeuropixelsV2eProbeInterface> (d, 0, e, c);
37-
topLevelTabComponent->addTab ("Probe0", Colours::grey, CustomViewport::createCustomViewport (probeInterfaces[0].get()), true, 0);
38-
39-
probeInterfaces[1] = std::make_unique<NeuropixelsV2eProbeInterface> (d, 1, e, c);
40-
topLevelTabComponent->addTab ("Probe1", Colours::grey, CustomViewport::createCustomViewport (probeInterfaces[1].get()), true, 1);
36+
for (int i = 0; i < numProbes; i++)
37+
{
38+
probeInterfaces[i] = std::make_unique<NeuropixelsV2eProbeInterface> (d, i, e, c);
39+
topLevelTabComponent->addTab (ProbeString + std::to_string (i), Colours::grey, CustomViewport::createCustomViewport (probeInterfaces[i].get()), true, i);
40+
}
4141

4242
deviceComponent = std::make_unique<Component>();
4343
deviceComponent->setBounds (0, 0, 600, 40);

0 commit comments

Comments
 (0)