Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 65 additions & 54 deletions Source/Devices/Neuropixels1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Neuropixels1::Neuropixels1 (std::string name, std::string hubName, OnixDeviceTyp
{
}

void Neuropixels1::setSettings (ProbeSettings<NeuropixelsV1Values::numberOfChannels, NeuropixelsV1Values::numberOfElectrodes>* settings_, int index)
void Neuropixels1::setSettings (ProbeSettings* settings_, int index)
{
if (index >= settings.size())
{
Expand All @@ -58,47 +58,55 @@ void Neuropixels1::setSettings (ProbeSettings<NeuropixelsV1Values::numberOfChann
settings[index]->updateProbeSettings (settings_);
}

std::vector<int> Neuropixels1::selectElectrodeConfiguration (int electrodeConfigurationIndex)
std::vector<int> Neuropixels1::selectElectrodeConfiguration (int electrodeConfigurationIndex, ProbeType probeType)
{
std::vector<int> selection;

if (electrodeConfigurationIndex == (int32_t) ElectrodeConfiguration::BankA)
if (probeType == ProbeType::NPX_V1)
{
for (int i = 0; i < 384; i++)
selection.emplace_back (i);
}
else if (electrodeConfigurationIndex == (int32_t) ElectrodeConfiguration::BankB)
{
for (int i = 384; i < 768; i++)
selection.emplace_back (i);
}
else if (electrodeConfigurationIndex == (int32_t) ElectrodeConfiguration::BankC)
{
for (int i = 576; i < 960; i++)
selection.emplace_back (i);
}
else if (electrodeConfigurationIndex == (int32_t) ElectrodeConfiguration::SingleColumn)
{
for (int i = 0; i < 384; i += 2)
selection.emplace_back (i);

for (int i = 385; i < 768; i += 2)
selection.emplace_back (i);
}
else if (electrodeConfigurationIndex == (int32_t) ElectrodeConfiguration::Tetrodes)
{
for (int i = 0; i < 384; i += 8)
if (electrodeConfigurationIndex == (int32_t) ElectrodeConfiguration::BankA)
{
for (int j = 0; j < 4; j++)
selection.emplace_back (i + j);
for (int i = 0; i < 384; i++)
selection.emplace_back (i);
}
else if (electrodeConfigurationIndex == (int32_t) ElectrodeConfiguration::BankB)
{
for (int i = 384; i < 768; i++)
selection.emplace_back (i);
}
else if (electrodeConfigurationIndex == (int32_t) ElectrodeConfiguration::BankC)
{
for (int i = 576; i < 960; i++)
selection.emplace_back (i);
}
else if (electrodeConfigurationIndex == (int32_t) ElectrodeConfiguration::SingleColumn)
{
for (int i = 0; i < 384; i += 2)
selection.emplace_back (i);

for (int i = 388; i < 768; i += 8)
for (int i = 385; i < 768; i += 2)
selection.emplace_back (i);
}
else if (electrodeConfigurationIndex == (int32_t) ElectrodeConfiguration::Tetrodes)
{
for (int j = 0; j < 4; j++)
selection.emplace_back (i + j);
for (int i = 0; i < 384; i += 8)
{
for (int j = 0; j < 4; j++)
selection.emplace_back (i + j);
}

for (int i = 388; i < 768; i += 8)
{
for (int j = 0; j < 4; j++)
selection.emplace_back (i + j);
}
}
}
else
{
LOGE ("Invalid probe type given for a Neuropixels 2.0 device: ", ProbeTypeString.at (probeType));
return selection;
}

assert (selection.size() == numberOfChannels && "Invalid number of selected channels.");

Expand Down Expand Up @@ -169,26 +177,26 @@ void Neuropixels1::updateLfpOffsets (std::array<float, numLfpSamples>& samples,
}
}

void Neuropixels1::defineMetadata (ProbeSettings<numberOfChannels, numberOfElectrodes>* settings)
void Neuropixels1::defineMetadata (ProbeSettings* settings, ProbeType probeType)
{
settings->probeType = ProbeType::NPX_V1;
settings->probeType = probeType;
settings->probeMetadata.name = "Neuropixels 1.0";

std::vector<std::array<float, 2>> shankOutline {
{ 27, 31 },
{ 27, 514 },
{ 27 + 5, 522 },
{ 27 + 10, 514 },
{ 27 + 10, 31 }
{ 27, 31},
{ 27, 514},
{ 27 + 5, 522},
{27 + 10, 514},
{27 + 10, 31}
};

std::vector<std::array<float, 2>> probeContour {
{ 0, 155 },
{ 35, 0 },
{ 70, 155 },
{ 70, 9770 },
{ 0, 9770 },
{ 0, 155 }
{ 0, 155},
{35, 0},
{70, 155},
{70, 9770},
{ 0, 9770},
{ 0, 155}
};

settings->probeMetadata.shank_count = 1;
Expand All @@ -200,13 +208,6 @@ void Neuropixels1::defineMetadata (ProbeSettings<numberOfChannels, numberOfElect
settings->probeMetadata.num_adcs = 32; // NB: Is this right for 1.0e?
settings->probeMetadata.adc_bits = 10; // NB: Is this right for 1.0e?

settings->availableBanks = {
Bank::A,
Bank::B,
Bank::C,
Bank::NONE // disconnected
};

Array<float> xpositions = { 27.0f, 59.0f, 11.0f, 43.0f };

for (int i = 0; i < numberOfElectrodes; i++)
Expand Down Expand Up @@ -296,8 +297,6 @@ void Neuropixels1::defineMetadata (ProbeSettings<numberOfChannels, numberOfElect
settings->electrodeConfigurationIndex = (int32_t) ElectrodeConfiguration::BankA;
auto selection = selectElectrodeConfiguration (settings->electrodeConfigurationIndex);
settings->selectElectrodes (selection);

settings->isValid = true;
}

uint64_t Neuropixels1::getProbeSerialNumber (int index)
Expand Down Expand Up @@ -529,3 +528,15 @@ void Neuropixels1::setGainCalibrationFilePath (std::string filepath)
{
gainCalibrationFilePath = filepath;
}

bool Neuropixels1::validateProbeTypeAndPartNumber()
{
if (! NeuropixelsProbeMetadata::validateProbeTypeAndPartNumber (settings[0]->probeType, probeMetadata.getProbePartNumber()))
{
Onix1::showWarningMessageBoxAsync ("Probe Type / Number Mismatch", "The selected probe type is " + ProbeTypeString.at (settings[0]->probeType) + ", but the probe part number is " + probeMetadata.getProbePartNumber() + ".");
return false;
}

return true;
}

8 changes: 5 additions & 3 deletions Source/Devices/Neuropixels1.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ class Neuropixels1 : public INeuropixel<NeuropixelsV1Values::numberOfChannels, N
void setGainCalibrationFilePath (std::string filepath);

// INeuropixels methods
void defineMetadata (ProbeSettings<numberOfChannels, numberOfElectrodes>* settings) override;
void defineMetadata (ProbeSettings* settings, ProbeType probeType) override;

/** Select a preset electrode configuration, based on the index of the given enum */
std::vector<int> selectElectrodeConfiguration (int electrodeConfigurationIndex) override;
std::vector<int> selectElectrodeConfiguration (int electrodeConfigurationIndex, ProbeType probeType = ProbeType::NPX_V1) override;

void setSettings (ProbeSettings<numberOfChannels, numberOfElectrodes>* settings_, int index = 0) override;
void setSettings (ProbeSettings* settings_, int index = 0) override;

uint64_t getProbeSerialNumber (int index = 0) override;
std::string getProbePartNumber (int index = 0) override;
Expand Down Expand Up @@ -133,6 +133,8 @@ class Neuropixels1 : public INeuropixel<NeuropixelsV1Values::numberOfChannels, N
void updateLfpOffsets (std::array<float, numLfpSamples>&, int64);
void updateApOffsets (std::array<float, numApSamples>&, int64);

bool validateProbeTypeAndPartNumber ();

enum class ElectrodeConfiguration : int32_t
{
BankA = 0,
Expand Down
5 changes: 4 additions & 1 deletion Source/Devices/Neuropixels1e.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Neuropixels1e::Neuropixels1e (std::string name, std::string hubName, const oni_d
"lfp");
streamInfos.add (lfpStream);

defineMetadata (settings[0].get());
defineMetadata (settings[0].get(), ProbeType::NPX_V1);

adcCalibrationFilePath = "None";
gainCalibrationFilePath = "None";
Expand Down Expand Up @@ -197,6 +197,9 @@ void Neuropixels1e::resetProbe()

bool Neuropixels1e::updateSettings()
{
if (! validateProbeTypeAndPartNumber())
return false;

auto updater = NeuropixelsV1eBackgroundUpdater (this);

return updater.updateSettings() && adcValues.size() == NeuropixelsV1Values::AdcCount;
Expand Down
5 changes: 4 additions & 1 deletion Source/Devices/Neuropixels1f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Neuropixels1f::Neuropixels1f (std::string name, std::string hubName, const oni_d
"lfp");
streamInfos.add (lfpStream);

defineMetadata (settings[0].get());
defineMetadata (settings[0].get(), ProbeType::NPX_V1);

adcCalibrationFilePath = "None";
gainCalibrationFilePath = "None";
Expand Down Expand Up @@ -153,6 +153,9 @@ int Neuropixels1f::configureDevice()

bool Neuropixels1f::updateSettings()
{
if (! validateProbeTypeAndPartNumber())
return false;

auto updater = NeuropixelsV1fBackgroundUpdater (this);

return updater.updateSettings() && adcValues.size() == NeuropixelsV1Values::AdcCount;
Expand Down
Loading