From 5d4bc9751c3a5d538099d0566bb9a15bf029effe Mon Sep 17 00:00:00 2001 From: Josh Siegle Date: Fri, 26 Apr 2024 14:36:10 -0700 Subject: [PATCH] Add preset configs for quad base --- Source/Probes/Neuropixels_QuadBase.cpp | 385 ++++--------------------- Source/UI/NeuropixInterface.cpp | 8 +- 2 files changed, 66 insertions(+), 327 deletions(-) diff --git a/Source/Probes/Neuropixels_QuadBase.cpp b/Source/Probes/Neuropixels_QuadBase.cpp index 4eb9ff6..c313162 100644 --- a/Source/Probes/Neuropixels_QuadBase.cpp +++ b/Source/Probes/Neuropixels_QuadBase.cpp @@ -67,60 +67,32 @@ Neuropixels_QuadBase::Neuropixels_QuadBase(Basestation* bs, Headstage* hs, Flex* settings.referenceIndex = 0; settings.apFilterState = false; - channel_count = 384 * 4; + channel_count = 384; lfp_sample_rate = 2500.0f; // not used ap_sample_rate = 30000.0f; - for (int i = 0; i < channel_count; i++) + for (int shank = 0; shank < 4; shank++) { - settings.selectedBank.add(Bank::A); - settings.selectedChannel.add(electrodeMetadata[i].channel); - settings.selectedShank.add(0); - settings.selectedElectrode.add(electrodeMetadata[i].global_index); + for (int i = 0; i < channel_count; i++) + { + settings.selectedBank.add(Bank::A); + settings.selectedChannel.add(electrodeMetadata[i].channel); + settings.selectedShank.add(shank); + settings.selectedElectrode.add(electrodeMetadata[i].global_index); + } } + + settings.availableReferences.add("Ext"); + settings.availableReferences.add("Tip"); + settings.availableReferences.add("Ground"); - if (probeMetadata.shank_count == 1) - { - settings.availableReferences.add("Ext"); - settings.availableReferences.add("Tip"); - - settings.availableElectrodeConfigurations.add("Bank A"); - settings.availableElectrodeConfigurations.add("Bank B"); - settings.availableElectrodeConfigurations.add("Bank C"); - settings.availableElectrodeConfigurations.add("Bank D"); - } - else { - settings.availableReferences.add("Ext"); - settings.availableReferences.add("Tip"); - settings.availableReferences.add("Ground"); - - settings.availableElectrodeConfigurations.add("Shank 1 Bank A"); - settings.availableElectrodeConfigurations.add("Shank 1 Bank B"); - settings.availableElectrodeConfigurations.add("Shank 1 Bank C"); - settings.availableElectrodeConfigurations.add("Shank 2 Bank A"); - settings.availableElectrodeConfigurations.add("Shank 2 Bank B"); - settings.availableElectrodeConfigurations.add("Shank 2 Bank C"); - settings.availableElectrodeConfigurations.add("Shank 3 Bank A"); - settings.availableElectrodeConfigurations.add("Shank 3 Bank B"); - settings.availableElectrodeConfigurations.add("Shank 3 Bank C"); - settings.availableElectrodeConfigurations.add("Shank 4 Bank A"); - settings.availableElectrodeConfigurations.add("Shank 4 Bank B"); - settings.availableElectrodeConfigurations.add("Shank 4 Bank C"); - settings.availableElectrodeConfigurations.add("All Shanks 1-96"); - settings.availableElectrodeConfigurations.add("All Shanks 97-192"); - settings.availableElectrodeConfigurations.add("All Shanks 193-288"); - settings.availableElectrodeConfigurations.add("All Shanks 289-384"); - settings.availableElectrodeConfigurations.add("All Shanks 385-480"); - settings.availableElectrodeConfigurations.add("All Shanks 481-576"); - settings.availableElectrodeConfigurations.add("All Shanks 577-672"); - settings.availableElectrodeConfigurations.add("All Shanks 673-768"); - settings.availableElectrodeConfigurations.add("All Shanks 769-864"); - settings.availableElectrodeConfigurations.add("All Shanks 865-960"); - settings.availableElectrodeConfigurations.add("All Shanks 961-1056"); - settings.availableElectrodeConfigurations.add("All Shanks 1057-1152"); - settings.availableElectrodeConfigurations.add("All Shanks 1153-1248"); - } + settings.availableElectrodeConfigurations.add("Bank A"); + settings.availableElectrodeConfigurations.add("Bank B"); + settings.availableElectrodeConfigurations.add("Bank C"); + settings.availableElectrodeConfigurations.add("Bank D"); + settings.availableElectrodeConfigurations.add("Single column"); + settings.availableElectrodeConfigurations.add("Tetrodes"); open(); } @@ -242,303 +214,74 @@ void Neuropixels_QuadBase::selectElectrodes() Array Neuropixels_QuadBase::selectElectrodeConfiguration(String config) { + Array selection; if (config.equalsIgnoreCase("Bank A")) { - for (int i = 0; i < 384; i++) - selection.add(i); - } - else if (config.equalsIgnoreCase("Bank B")) - { - for (int i = 384; i < 768; i++) - selection.add(i); - } - else if (config.equalsIgnoreCase("Bank C")) - { - - for (int i = 768; i < 1152; i++) - selection.add(i); - - } - else if (config.equalsIgnoreCase("Bank D")) - { - - for (int i = 896; i < 1280; i++) - selection.add(i); - - } - else if (config.equalsIgnoreCase("Shank 1 Bank A")) - { - for (int i = 0; i < 384; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("Shank 1 Bank B")) - { - for (int i = 384; i < 768; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("Shank 1 Bank C")) - { - for (int i = 768; i < 1152; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("Shank 2 Bank A")) - { - int startElectrode = 1280; - - for (int i = startElectrode; i < startElectrode + 384; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("Shank 2 Bank B")) - { - int startElectrode = 1280 + 384; - - for (int i = startElectrode; i < startElectrode + 384; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("Shank 2 Bank C")) - { - int startElectrode = 1280 + 384 * 2; - - for (int i = startElectrode; i < startElectrode + 384; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("Shank 3 Bank A")) - { - int startElectrode = 1280 * 2; - - for (int i = startElectrode; i < startElectrode + 384; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("Shank 3 Bank B")) - { - int startElectrode = 1280 * 2 + 384; - - for (int i = startElectrode; i < startElectrode + 384; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("Shank 3 Bank C")) - { - int startElectrode = 1280 * 2 + 384 * 2; - - for (int i = startElectrode; i < startElectrode + 384; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("Shank 4 Bank A")) - { - int startElectrode = 1280 * 3; - - for (int i = startElectrode; i < startElectrode + 384; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("Shank 4 Bank B")) - { - int startElectrode = 1280 * 3 + 384; - - for (int i = startElectrode; i < startElectrode + 384; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("Shank 4 Bank C")) - { - int startElectrode = 1280 * 3 + 384 * 2; - - for (int i = startElectrode; i < startElectrode + 384; i++) - { - selection.add(i); - } - } - else if (config.equalsIgnoreCase("All Shanks 1-96")) - { - - int startElectrode = 0; - - for (int shank = 0; shank < 4; shank++) - { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) - { - selection.add(i); - } - } - } - else if (config.equalsIgnoreCase("All Shanks 97-192")) - { - - int startElectrode = 96; - for (int shank = 0; shank < 4; shank++) { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) - { - selection.add(i); - } + for (int i = 0; i < 384; i++) + selection.add(i + 1280 * shank); } } - else if (config.equalsIgnoreCase("All Shanks 193-288")) + else if (config.equalsIgnoreCase("Bank B")) { - - int startElectrode = 192; - for (int shank = 0; shank < 4; shank++) { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) - { - selection.add(i); - } + for (int i = 384; i < 768; i++) + selection.add(i + 1280 * shank); } } - else if (config.equalsIgnoreCase("All Shanks 289-384")) + else if (config.equalsIgnoreCase("Bank C")) { - - int startElectrode = 288; - for (int shank = 0; shank < 4; shank++) { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) - { - selection.add(i); - } + for (int i = 768; i < 1152; i++) + selection.add(i + 1280 * shank); } } - else if (config.equalsIgnoreCase("All Shanks 385-480")) - { - int startElectrode = 384; - - for (int shank = 0; shank < 4; shank++) - { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) - { - selection.add(i); - } - } - } - else if (config.equalsIgnoreCase("All Shanks 481-576")) + else if (config.equalsIgnoreCase("Bank D")) { - - int startElectrode = 480; - for (int shank = 0; shank < 4; shank++) { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) - { - selection.add(i); - } + for (int i = 896; i < 1280; i++) + selection.add(i + 1280 * shank); } } - else if (config.equalsIgnoreCase("All Shanks 577-672")) - { - - int startElectrode = 576; - for (int shank = 0; shank < 4; shank++) - { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) - { - selection.add(i); - } - } - } - else if (config.equalsIgnoreCase("All Shanks 673-768")) + else if (config.equalsIgnoreCase("Single Column")) { - - int startElectrode = 672; - for (int shank = 0; shank < 4; shank++) { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) - { - selection.add(i); - } - } - } - else if (config.equalsIgnoreCase("All Shanks 769-864")) - { + for (int i = 0; i < 384; i += 2) + selection.add(i + 1280 * shank); - int startElectrode = 768; - - for (int shank = 0; shank < 4; shank++) - { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) - { - selection.add(i); - } - } - } - else if (config.equalsIgnoreCase("All Shanks 865-960")) - { - - int startElectrode = 864; - - for (int shank = 0; shank < 4; shank++) - { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) - { - selection.add(i); - } + for (int i = 385; i < 768; i += 2) + selection.add(i + 1280 * shank); } + } - else if (config.equalsIgnoreCase("All Shanks 961-1056")) + else if (config.equalsIgnoreCase("Tetrodes")) { - - int startElectrode = 960; - for (int shank = 0; shank < 4; shank++) { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) + for (int i = 0; i < 384; i += 8) { - selection.add(i); + for (int j = 0; j < 4; j++) + selection.add(i + j + 1280 * shank); } - } - } - else if (config.equalsIgnoreCase("All Shanks 1057-1152")) - { - - int startElectrode = 1056; - for (int shank = 0; shank < 4; shank++) - { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) + for (int i = 388; i < 768; i += 8) { - selection.add(i); + for (int j = 0; j < 4; j++) + selection.add(i + j + 1280 * shank); } } + } - else if (config.equalsIgnoreCase("All Shanks 1153-1248")) - { - int startElectrode = 1152; - - for (int shank = 0; shank < 4; shank++) - { - for (int i = startElectrode + 1280 * shank; i < startElectrode + 96 + 1280 * shank; i++) - { - selection.add(i); - } - } - } return selection; } @@ -560,7 +303,6 @@ void Neuropixels_QuadBase::setAllReferences() Neuropixels::channelreference_t refId; int refElectrodeBank = 0; - int shank = 0; switch (settings.referenceIndex) { @@ -569,36 +311,27 @@ void Neuropixels_QuadBase::setAllReferences() break; case 1: refId = Neuropixels::TIP_REF; - shank = 0; break; case 2: - refId = Neuropixels::TIP_REF; - shank = 1; + refId = Neuropixels::GND_REF; break; - case 3: - refId = Neuropixels::TIP_REF; - shank = 2; - break; - case 4: - refId = Neuropixels::TIP_REF; - shank = 3; - break; - case 5: - refId = Neuropixels::INT_REF; - break; - + default: refId = Neuropixels::EXT_REF; } - for (int channel = 0; channel < channel_count; channel++) - Neuropixels::setReference(basestation->slot, - headstage->port, - dock, - channel, - shank, - refId, - refElectrodeBank); + for (int shank = 0; shank < 4; shank++) + { + for (int channel = 0; channel < channel_count; channel++) + Neuropixels::setReference(basestation->slot, + headstage->port, + dock, + channel, + shank, + refId, + refElectrodeBank); + } + LOGD("Updated reference for slot: ", basestation->slot, " port: ", headstage->port, " dock: ", dock, " to ", refId); diff --git a/Source/UI/NeuropixInterface.cpp b/Source/UI/NeuropixInterface.cpp index 60eb83e..4e34e5b 100644 --- a/Source/UI/NeuropixInterface.cpp +++ b/Source/UI/NeuropixInterface.cpp @@ -1153,6 +1153,7 @@ void NeuropixInterface::selectElectrodes(Array electrodes) } } else { + if (electrodeMetadata[j].channel == channel && electrodeMetadata[j].shank == shank) { if (electrodeMetadata[j].bank == bank) @@ -1583,6 +1584,9 @@ ProbeSettings NeuropixInterface::getProbeSettings() else p.referenceIndex = -1; + LOGD("Getting probe settings"); + int numElectrodes = 0; + for (auto electrode : electrodeMetadata) { if (electrode.status == ElectrodeStatus::CONNECTED) @@ -1591,10 +1595,12 @@ ProbeSettings NeuropixInterface::getProbeSettings() p.selectedBank.add(electrode.bank); p.selectedShank.add(electrode.shank); p.selectedElectrode.add(electrode.global_index); + numElectrodes++; // std::cout << electrode.channel << " : " << electrode.global_index << std::endl; } } + LOGD("Found ", numElectrodes, " connected electrodes."); p.probe = probe; p.probeType = probe->type; @@ -1702,7 +1708,7 @@ void NeuropixInterface::saveParameters(XmlElement* xml) String chString = String(bank); - if (probe->type == ProbeType::NP2_4) + if (probe->type == ProbeType::NP2_4 || probe->type == ProbeType::QUAD_BASE) chString += ":" + String(shank); channelNode->setAttribute("CH" + String(channel), chString);