Skip to content

Commit 792283d

Browse files
committed
Add depth and shank information to Neuropixels channels
- The format is based on the Neuropixels-PXI plugin, in Source/NeuropixThread.cpp::updateSettings(*)
1 parent cbe6494 commit 792283d

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

Source/NeuropixelsComponents.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,4 +562,64 @@ static class NeuropixelsV1
562562
return baseConfigs;
563563
}
564564
};
565+
566+
static class NeuropixelsHelpers
567+
{
568+
public:
569+
/** Set all channel metadata, starting with the last (most recently added) channel and working backwards over all selected electrodes */
570+
static void setChannelMetadata (OwnedArray<ContinuousChannel>* continuousChannels, const std::vector<std::unique_ptr<ProbeSettings>>& probeSettings)
571+
{
572+
ContinuousChannel** channels = continuousChannels->end();
573+
channels--;
574+
575+
for (auto it = probeSettings.rbegin(); it != probeSettings.rend(); it++)
576+
{
577+
ProbeSettings* probeSetting = it->get();
578+
579+
for (int i = probeSetting->numberOfChannels - 1; i >= 0; i--)
580+
{
581+
auto channel = *channels--;
582+
583+
int globalIndex = probeSetting->selectedElectrode[i];
584+
int shankIndex = probeSetting->electrodeMetadata[globalIndex].shank;
585+
586+
float xpos = probeSetting->electrodeMetadata[globalIndex].xpos;
587+
float ypos = probeSetting->electrodeMetadata[globalIndex].ypos;
588+
589+
// NB: Depth must be a unique value for compatibility with legacy LFP viewer channel sorting algorithm
590+
float depth = ypos + (float)shankIndex * 10000.0f + xpos * 0.001f;
591+
592+
channel->position.x = xpos;
593+
channel->position.y = depth;
594+
595+
channel->group.name = "Shank " + String (shankIndex + 1);
596+
channel->group.number = shankIndex;
597+
598+
// NB: Add real Y position as a metadata descriptor
599+
MetadataDescriptor yposDescriptor (MetadataDescriptor::MetadataType::FLOAT,
600+
1,
601+
"ypos",
602+
"Channel y-position (relative to shank tip)",
603+
"channel.ypos");
604+
605+
MetadataValue yposValue (MetadataDescriptor::MetadataType::FLOAT, 1);
606+
yposValue.setValue (ypos);
607+
608+
channel->addMetadata (yposDescriptor, yposValue);
609+
610+
// NB: Add electrode index as metadata
611+
MetadataDescriptor selectedElectrodeDescriptor (MetadataDescriptor::MetadataType::UINT16,
612+
1,
613+
"electrode_index",
614+
"Electrode index for this channel",
615+
"neuropixels.electrode_index");
616+
617+
MetadataValue selectedElectrodeValue (MetadataDescriptor::MetadataType::UINT16, 1);
618+
selectedElectrodeValue.setValue ((uint16) globalIndex);
619+
620+
channel->addMetadata (selectedElectrodeDescriptor, selectedElectrodeValue);
621+
}
622+
}
623+
}
624+
};
565625
} // namespace OnixSourcePlugin

Source/OnixSource.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,8 @@ void OnixSource::updateSettings (OwnedArray<ContinuousChannel>* continuousChanne
836836
deviceInfos->add (device);
837837

838838
addIndividualStreams (source->streamInfos, dataStreams, deviceInfos, continuousChannels);
839+
840+
NeuropixelsHelpers::setChannelMetadata (continuousChannels, std::static_pointer_cast<Neuropixels1f> (source)->settings);
839841
}
840842
else if (type == OnixDeviceType::BNO || type == OnixDeviceType::POLLEDBNO)
841843
{
@@ -885,6 +887,8 @@ void OnixSource::updateSettings (OwnedArray<ContinuousChannel>* continuousChanne
885887
deviceInfos->add (device);
886888

887889
addIndividualStreams (source->streamInfos, dataStreams, deviceInfos, continuousChannels);
890+
891+
NeuropixelsHelpers::setChannelMetadata (continuousChannels, std::static_pointer_cast<Neuropixels2e> (source)->settings);
888892
}
889893
else if (type == OnixDeviceType::MEMORYMONITOR)
890894
{
@@ -979,6 +983,8 @@ void OnixSource::updateSettings (OwnedArray<ContinuousChannel>* continuousChanne
979983
deviceInfos->add (device);
980984

981985
addIndividualStreams (source->streamInfos, dataStreams, deviceInfos, continuousChannels);
986+
987+
NeuropixelsHelpers::setChannelMetadata (continuousChannels, std::static_pointer_cast<Neuropixels1e> (source)->settings);
982988
}
983989
else if (type == OnixDeviceType::OUTPUTCLOCK)
984990
{

Source/UI/NeuropixelsV1Interface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,8 @@ void NeuropixelsV1Interface::selectElectrodes (std::vector<int> electrodes)
925925
{
926926
std::static_pointer_cast<Neuropixels1> (device)->settings[0]->selectElectrodes (electrodes);
927927

928+
CoreServices::updateSignalChain (editor);
929+
928930
repaint();
929931
}
930932

Source/UI/NeuropixelsV2eProbeInterface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,8 @@ void NeuropixelsV2eProbeInterface::selectElectrodes (std::vector<int> electrodes
682682
{
683683
std::static_pointer_cast<Neuropixels2e> (device)->settings[probeIndex]->selectElectrodes (electrodes);
684684

685+
CoreServices::updateSignalChain (editor);
686+
685687
repaint();
686688
}
687689

0 commit comments

Comments
 (0)