Skip to content

Commit

Permalink
Display full UHD channel layout
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiegle committed May 16, 2024
1 parent 7ddf547 commit 7de77da
Show file tree
Hide file tree
Showing 7 changed files with 1,958 additions and 113 deletions.
223 changes: 193 additions & 30 deletions Source/Probes/Geometry.cpp

Large diffs are not rendered by default.

18 changes: 13 additions & 5 deletions Source/Probes/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,26 @@ class Geometry
static void NP2(int shank_count, Array<ElectrodeMetadata>& em,
ProbeMetadata& pm);

/** Neuropixels UHD
/** Neuropixels UHD Passive
*
Available switchable or unswitchable
Fixed site layout
Site spacing: 6 um,
Site spacing: 6 um, 4.5 um or 3 um
*/
static void UHD(bool switchable,
int numColumns,
static void UHDPassive(int numColumns,
float siteSpacing,
Array<ElectrodeMetadata>& em,
ProbeMetadata& pm);

/** Neuropixels UHD Active
*
Switchable site layout
Site spacing: 6 um
*/
static void UHDActive(Array<ElectrodeMetadata>& em,
ProbeMetadata& pm);

/** Neuropixels Opto
*/
static void OPTO(Array<ElectrodeMetadata>& em,
Expand Down
812 changes: 790 additions & 22 deletions Source/Probes/Neuropixels_UHD.cpp

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Source/Probes/Neuropixels_UHD.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class Neuropixels_UHD : public Probe

private:

/** Creates arrays of selected electrodes for each available config */
void createElectrodeConfigurations();

Neuropixels::electrodePacket packet[MAXPACKETS];
Neuropixels::NP_ErrorCode errorCode;

Expand All @@ -116,6 +119,10 @@ class Neuropixels_UHD : public Probe
int64 lfp_timestamps[MAXPACKETS];
uint64 lfp_event_codes[MAXPACKETS];

Array<String> availableElectrodeConfigurations;

OwnedArray<Array<int>> electrodeConfigurations;

};


Expand Down
877 changes: 869 additions & 8 deletions Source/Probes/SimulatedProbe.cpp

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Source/Probes/SimulatedProbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ class SimulatedProbe : public Probe
/** Acquires data from the probe */
void run() override;

/** Creates arrays of selected electrodes for each available config */
void createElectrodeConfigurationsUHD();

bool apFilterSwitch;

SimulatedData simulatedData;
Expand All @@ -126,6 +129,10 @@ class SimulatedProbe : public Probe
int64 lfp_timestamps[MAXPACKETS];
uint64 lfp_event_codes[MAXPACKETS];

Array<String> availableElectrodeConfigurationsUHD;

OwnedArray<Array<int>> electrodeConfigurationsUHD;

};


Expand Down
127 changes: 79 additions & 48 deletions Source/UI/NeuropixInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,17 +672,11 @@ void NeuropixInterface::comboBoxChanged(ComboBox* comboBox)
{
if (comboBox == electrodeConfigurationComboBox)
{

String preset = electrodeConfigurationComboBox->getText();

if (probe->type == ProbeType::UHD2) // switchable probe
updateProbeSettingsInBackground();
else
{
Array<int> selection = probe->selectElectrodeConfiguration(preset);
Array<int> selection = probe->selectElectrodeConfiguration(preset);

selectElectrodes(selection);
}
selectElectrodes(selection);
}
else if ((comboBox == apGainComboBox) || (comboBox == lfpGainComboBox))
{
Expand Down Expand Up @@ -1130,48 +1124,66 @@ void NeuropixInterface::selectElectrodes(Array<int> electrodes)
{
// update selection state

for (int i = 0; i <electrodes.size(); i++)
if (probe->type == ProbeType::UHD2)
{

Bank bank = electrodeMetadata[electrodes[i]].bank;
int channel = electrodeMetadata[electrodes[i]].channel;
int shank = electrodeMetadata[electrodes[i]].shank;
for (int i = 0; i < electrodeMetadata.size(); i++)
{
electrodeMetadata.getReference(i).status = ElectrodeStatus::DISCONNECTED;
}

for (int j = 0; j < electrodeMetadata.size(); j++)
for (int i = 0; i < electrodes.size(); i++)
{
if (probe->type != ProbeType::QUAD_BASE)
electrodeMetadata.getReference(electrodes[i]).status = ElectrodeStatus::CONNECTED;
}
}
else {
for (int i = 0; i < electrodes.size(); i++)
{

Bank bank = electrodeMetadata[electrodes[i]].bank;
int channel = electrodeMetadata[electrodes[i]].channel;
int shank = electrodeMetadata[electrodes[i]].shank;
int global_index = electrodeMetadata[electrodes[i]].global_index;

for (int j = 0; j < electrodeMetadata.size(); j++)
{
if (electrodeMetadata[j].channel == channel)
{
if (electrodeMetadata[j].bank == bank && electrodeMetadata[j].shank == shank)

if (probe->type == ProbeType::QUAD_BASE) {

if (electrodeMetadata[j].channel == channel && electrodeMetadata[j].shank == shank)
{
electrodeMetadata.getReference(j).status = ElectrodeStatus::CONNECTED;
if (electrodeMetadata[j].bank == bank)
{
electrodeMetadata.getReference(j).status = ElectrodeStatus::CONNECTED;
}
else
{
electrodeMetadata.getReference(j).status = ElectrodeStatus::DISCONNECTED;
}
}
}
else {

else
if (electrodeMetadata[j].channel == channel)
{
electrodeMetadata.getReference(j).status = ElectrodeStatus::DISCONNECTED;
if (electrodeMetadata[j].bank == bank && electrodeMetadata[j].shank == shank)
{
electrodeMetadata.getReference(j).status = ElectrodeStatus::CONNECTED;
}

else
{
electrodeMetadata.getReference(j).status = ElectrodeStatus::DISCONNECTED;
}
}
}
}
else {

if (electrodeMetadata[j].channel == channel && electrodeMetadata[j].shank == shank)
{
if (electrodeMetadata[j].bank == bank)
{
electrodeMetadata.getReference(j).status = ElectrodeStatus::CONNECTED;
}
else
{
electrodeMetadata.getReference(j).status = ElectrodeStatus::DISCONNECTED;
}
}
}

}
}


repaint();

updateProbeSettingsInBackground();
Expand Down Expand Up @@ -1480,7 +1492,7 @@ void NeuropixInterface::drawLegend(Graphics& g)

bool NeuropixInterface::applyProbeSettings(ProbeSettings p, bool shouldUpdateProbe)
{
LOGC("Apply probe settings for ", p.probe->name, " shouldUpdate: ", shouldUpdateProbe);
LOGC("NeuropixInterface applying probe settings for ", p.probe->name, " shouldUpdate: ", shouldUpdateProbe);

if (p.probeType != probe->type)
{
Expand Down Expand Up @@ -1515,24 +1527,34 @@ bool NeuropixInterface::applyProbeSettings(ProbeSettings p, bool shouldUpdatePro
electrodeMetadata.getReference(i).status = ElectrodeStatus::DISCONNECTED;
}

// update selection state
for (int i = 0; i < p.selectedChannel.size(); i++)
if (probe->type == ProbeType::UHD2)
{
Bank bank = p.selectedBank[i];
int channel = p.selectedChannel[i];
int shank = p.selectedShank[i];
Array<int> selection = probe->selectElectrodeConfiguration(electrodeConfigurationComboBox->getText());

for (int j = 0; j < electrodeMetadata.size(); j++)
selectElectrodes(selection);
}
else {
// update selection state
for (int i = 0; i < p.selectedChannel.size(); i++)
{
if (electrodeMetadata[j].channel == channel &&
electrodeMetadata[j].bank == bank &&
electrodeMetadata[j].shank == shank)
Bank bank = p.selectedBank[i];
int channel = p.selectedChannel[i];
int shank = p.selectedShank[i];

for (int j = 0; j < electrodeMetadata.size(); j++)
{
electrodeMetadata.getReference(j).status = ElectrodeStatus::CONNECTED;
if (electrodeMetadata[j].channel == channel &&
electrodeMetadata[j].bank == bank &&
electrodeMetadata[j].shank == shank)
{
electrodeMetadata.getReference(j).status = ElectrodeStatus::CONNECTED;
}
}
}
}



// apply settings in background thread
if (shouldUpdateProbe)
{
Expand Down Expand Up @@ -1932,15 +1954,24 @@ void NeuropixInterface::loadParameters(XmlElement* xml)

String configurationName = matchingNode->getStringAttribute("electrodeConfigurationPreset", "NONE");

//std::cout << "configurationName: " << configurationName << std::endl;
settings.electrodeConfigurationIndex = settings.availableElectrodeConfigurations.indexOf(configurationName);
//std::cout << "electrodeConfigurationIndex: " << settings.electrodeConfigurationIndex << std::endl;
std::cout << "configurationName: " << configurationName << std::endl;

for (int i = 0; i < electrodeConfigurationComboBox->getNumItems(); i++)
{
if (electrodeConfigurationComboBox->getItemText(i).equalsIgnoreCase(configurationName))
{
std::cout << "Found matching configuration at index: " << i << std::endl;
electrodeConfigurationComboBox->setSelectedItemIndex(i, dontSendNotification);
std::cout << "Setting electrodeConfigurationIndex: " << i -1 << std::endl;
settings.electrodeConfigurationIndex = i - 1;

//if (probe->type == ProbeType::UHD2)
//{
// Array<int> selection = probe->selectElectrodeConfiguration(electrodeConfigurationComboBox->getText());
//
// selectElectrodes(selection);
// }

break;
}

Expand Down

0 comments on commit 7de77da

Please sign in to comment.