Skip to content

Commit 87ab3e0

Browse files
committed
Before acquisition, check if the probe type and probe part number match
- Confirms if the selected probe type is the same as the connected hardware. Used to confirm if a probe is connected that is not implemented (such as the 1.0 UHD probe), or to confirm that the correct probe is selected (2.0 single- or quad-shank probes)
1 parent dc08b3b commit 87ab3e0

File tree

8 files changed

+91
-14
lines changed

8 files changed

+91
-14
lines changed

Source/Devices/Neuropixels1.cpp

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,20 @@ void Neuropixels1::defineMetadata (ProbeSettings* settings, ProbeType probeType)
175175
settings->probeMetadata.name = "Neuropixels 1.0";
176176

177177
std::vector<std::array<float, 2>> shankOutline {
178-
{ 27, 31 },
179-
{ 27, 514 },
180-
{ 27 + 5, 522 },
181-
{ 27 + 10, 514 },
182-
{ 27 + 10, 31 }
178+
{ 27, 31},
179+
{ 27, 514},
180+
{ 27 + 5, 522},
181+
{27 + 10, 514},
182+
{27 + 10, 31}
183183
};
184184

185185
std::vector<std::array<float, 2>> probeContour {
186-
{ 0, 155 },
187-
{ 35, 0 },
188-
{ 70, 155 },
189-
{ 70, 9770 },
190-
{ 0, 9770 },
191-
{ 0, 155 }
186+
{ 0, 155},
187+
{35, 0},
188+
{70, 155},
189+
{70, 9770},
190+
{ 0, 9770},
191+
{ 0, 155}
192192
};
193193

194194
settings->probeMetadata.shank_count = 1;
@@ -520,3 +520,15 @@ void Neuropixels1::setGainCalibrationFilePath (std::string filepath)
520520
{
521521
gainCalibrationFilePath = filepath;
522522
}
523+
524+
bool Neuropixels1::validateProbeTypeAndPartNumber ()
525+
{
526+
if (! NeuropixelsProbeMetadata::validateProbeTypeAndPartNumber (settings[0]->probeType, probeMetadata.getProbePartNumber()))
527+
{
528+
Onix1::showWarningMessageBoxAsync ("Probe Type / Number Mismatch", "The selected probe type is " + ProbeTypeString.at (settings[0]->probeType) + ", but the probe part number is " + probeMetadata.getProbePartNumber() + ".");
529+
return false;
530+
}
531+
532+
return true;
533+
}
534+

Source/Devices/Neuropixels1.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ class Neuropixels1 : public INeuropixel<NeuropixelsV1Values::numberOfChannels, N
133133
void updateLfpOffsets (std::array<float, numLfpSamples>&, int64);
134134
void updateApOffsets (std::array<float, numApSamples>&, int64);
135135

136+
bool validateProbeTypeAndPartNumber ();
137+
136138
enum class ElectrodeConfiguration : int32_t
137139
{
138140
BankA = 0,

Source/Devices/Neuropixels1e.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ void Neuropixels1e::resetProbe()
197197

198198
bool Neuropixels1e::updateSettings()
199199
{
200+
if (! validateProbeTypeAndPartNumber())
201+
return false;
202+
200203
auto updater = NeuropixelsV1eBackgroundUpdater (this);
201204

202205
return updater.updateSettings() && adcValues.size() == NeuropixelsV1Values::AdcCount;

Source/Devices/Neuropixels1f.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ int Neuropixels1f::configureDevice()
153153

154154
bool Neuropixels1f::updateSettings()
155155
{
156+
if (! validateProbeTypeAndPartNumber())
157+
return false;
158+
156159
auto updater = NeuropixelsV1fBackgroundUpdater (this);
157160

158161
return updater.updateSettings() && adcValues.size() == NeuropixelsV1Values::AdcCount;

Source/Devices/Neuropixels2e.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@ bool Neuropixels2e::updateSettings()
342342
{
343343
if (probeMetadata[i].getProbeSerialNumber() != 0)
344344
{
345+
if (! NeuropixelsProbeMetadata::validateProbeTypeAndPartNumber (settings[i]->probeType, probeMetadata[i].getProbePartNumber()))
346+
{
347+
Onix1::showWarningMessageBoxAsync ("Probe Type / Number Mismatch", "The selected probe type is " + ProbeTypeString.at (settings[i]->probeType) + ", but the probe part number is " + probeMetadata[i].getProbePartNumber() + ".");
348+
return false;
349+
}
350+
345351
if (gainCorrectionFilePath[i] == "None" || gainCorrectionFilePath[i] == "")
346352
{
347353
Onix1::showWarningMessageBoxAsync ("Missing File", "Missing gain correction file for probe " + std::to_string (probeMetadata[i].getProbeSerialNumber()));

Source/Devices/NeuropixelsProbeMetadata.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,39 @@ NeuropixelsProbeMetadata::NeuropixelsProbeMetadata(I2CRegisterContext* flex, Oni
8686
}
8787
}
8888

89+
bool NeuropixelsProbeMetadata::validateProbeTypeAndPartNumber (ProbeType probeType, std::string partNumber)
90+
{
91+
if (probeType == ProbeType::NONE)
92+
return false;
93+
94+
else if (probeType == ProbeType::NPX_V1)
95+
{
96+
if (partNumber == "PRB_1_4_0480_1" || partNumber == "PRB_1_4_0480_1_C" || partNumber == "PRB_1_2_0480_2")
97+
return true;
98+
99+
else
100+
return false;
101+
}
102+
else if (probeType == ProbeType::NPX_V2_SINGLE_SHANK)
103+
{
104+
if (partNumber == "NP2003" || partNumber == "NP2004")
105+
return true;
106+
107+
else
108+
return false;
109+
}
110+
else if (probeType == ProbeType::NPX_V2_QUAD_SHANK)
111+
{
112+
if (partNumber == "NP2013" || partNumber == "NP2014")
113+
return true;
114+
115+
else
116+
return false;
117+
}
118+
else
119+
return false;
120+
}
121+
89122
const uint64_t NeuropixelsProbeMetadata::getProbeSerialNumber() const
90123
{
91124
return probeSerialNumber;

Source/Devices/NeuropixelsProbeMetadata.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#pragma once
2424

2525
#include "../I2CRegisterContext.h"
26+
#include "../NeuropixelsComponents.h"
2627
#include "../OnixDevice.h"
2728

2829
namespace OnixSourcePlugin
@@ -38,6 +39,8 @@ namespace OnixSourcePlugin
3839
const std::string getFlexPartNumber() const;
3940
const std::string getFlexVersion() const;
4041

42+
static bool validateProbeTypeAndPartNumber (ProbeType probeType, std::string partNumber);
43+
4144
private:
4245
OnixDeviceType deviceType = OnixDeviceType::UNKNOWN;
4346

Source/NeuropixelsComponents.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ enum class ProbeType
3939
NPX_V2_QUAD_SHANK,
4040
};
4141

42+
const std::map<ProbeType, std::string> ProbeTypeString = {
43+
{ ProbeType::NONE, "None"},
44+
{ ProbeType::NPX_V1, "Neuropixels 1.0"},
45+
{ProbeType::NPX_V2_SINGLE_SHANK, "Neuropixels 2.0 - single shank"},
46+
{ ProbeType::NPX_V2_QUAD_SHANK, "Neuropixels 2.0 - multishank"},
47+
};
48+
4249
enum class Bank
4350
{
4451
NONE = -1,
@@ -212,7 +219,14 @@ struct NeuropixelsV1Adc
212219
const int threshold;
213220

214221
NeuropixelsV1Adc (int compP_ = 16, int compN_ = 16, int slope_ = 0, int coarse_ = 0, int fine_ = 0, int cfix_ = 0, int offset_ = 0, int threshold_ = 512)
215-
: compP (compP_), compN (compN_), slope (slope_), coarse (coarse_), fine (fine_), cfix (cfix_), offset (offset_), threshold (threshold_)
222+
: compP (compP_),
223+
compN (compN_),
224+
slope (slope_),
225+
coarse (coarse_),
226+
fine (fine_),
227+
cfix (cfix_),
228+
offset (offset_),
229+
threshold (threshold_)
216230
{
217231
}
218232
};
@@ -241,9 +255,10 @@ struct NeuropixelsV2eValues
241255

242256
struct ProbeSettings
243257
{
244-
ProbeSettings (int numChannels, int numElectrodes, ProbeType type) : numberOfChannels (numChannels), numberOfElectrodes (numElectrodes)
258+
ProbeSettings (int numChannels, int numElectrodes, ProbeType type) : numberOfChannels (numChannels),
259+
numberOfElectrodes (numElectrodes)
245260
{
246-
selectedBank = std::vector<Bank>(numChannels, Bank::A);
261+
selectedBank = std::vector<Bank> (numChannels, Bank::A);
247262
selectedShank = std::vector<int> (numChannels, 0);
248263
selectedElectrode = std::vector<int> (numChannels);
249264

0 commit comments

Comments
 (0)