Skip to content

Commit

Permalink
Merge juce8 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiegle committed Nov 2, 2024
2 parents bf9a090 + da57a50 commit 38304a6
Show file tree
Hide file tree
Showing 16 changed files with 574 additions and 264 deletions.
1 change: 0 additions & 1 deletion Source/Basestations/OneBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ float OneBox::getFillPercentage()

for (int i = 0; i < getProbeCount(); i++)
{
LOGDD ("Percentage for probe ", i, ": ", probes[i]->fifoFillPercentage);

if (probes[i]->fifoFillPercentage > perc)
perc = probes[i]->fifoFillPercentage;
Expand Down
4 changes: 2 additions & 2 deletions Source/Basestations/SimulatedBasestation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ bool SimulatedBasestation::open()
headstages.add (new SimulatedHeadstage (this, i + 1, "NP1110", 48948211 + i));
break;
case ProbeType::NP2_1:
headstages.add (new SimulatedHeadstage (this, i + 1, "NP2000", 58948291 + i));
headstages.add (new SimulatedHeadstage (this, i + 1, "NP2003", 58948291 + i));
break;
case ProbeType::NP2_4:
headstages.add (new SimulatedHeadstage (this, i + 1, "NP2010", 68948291 + i));
headstages.add (new SimulatedHeadstage (this, i + 1, "NP2013", 68948291 + i));
break;
case ProbeType::OPTO:
headstages.add (new SimulatedHeadstage (this, i + 1, "NP1300", 78948291 + i));
Expand Down
127 changes: 106 additions & 21 deletions Source/Formats/IMRO.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,59 @@ class IMRO
LOGC ("Could not create file: ", file.getFullPathName());
}

if (settings.probeType == ProbeType::NP1 || settings.probeType == ProbeType::NHP10 || settings.probeType == ProbeType::NHP25 || settings.probeType == ProbeType::NHP45 || settings.probeType == ProbeType::UHD1)
String imroPartId;
String partNumber = settings.probe->info.part_number;

if (partNumber.startsWith ("NP"))
{
file.appendText ("(0,384)");
imroPartId = partNumber.substring (2);
}
else if (settings.probeType == ProbeType::NP2_1)
else
{
file.appendText ("(21,384)");
if (partNumber.equalsIgnoreCase ("PRB2_1_2_0640_0"))
imroPartId = "21";
else if (partNumber.equalsIgnoreCase ("PRB2_4_2_0640_0"))
imroPartId = "24";
else if (partNumber.equalsIgnoreCase ("PRB_1_4_0480_1") || partNumber.equalsIgnoreCase ("PRB_1_4_0480_1_C") || partNumber.equalsIgnoreCase ("PRB_1_2_0480_2"))
{
imroPartId = "0";
}
else
{
LOGC ("Unknown part number: ", partNumber);
return false;
}
}
else if (settings.probeType == ProbeType::NP2_4)

String imroChannelCount;

if (settings.probeType == ProbeType::NHP1)
{
file.appendText ("(24,384)");
imroChannelCount = "128";
}
else if (settings.probeType == ProbeType::NHP1)
else if (settings.probeType == ProbeType::QUAD_BASE)
{
file.appendText ("(0,128)");
imroChannelCount = "1536";
}

else
{
return false;
imroChannelCount = "384";
}

if (settings.probeType == ProbeType::UHD2)
{
// not yet implemented
writeUHDFile (file, settings);
return true;
}
else
file.appendText ("(" + imroPartId + "," + imroChannelCount + ")");

for (int i = 0; i < settings.selectedChannel.size(); i++)
{
String channelInfo = "(" + String (settings.selectedChannel[i]); // channel

if (settings.probeType == ProbeType::NP2_4)
if (settings.probeType == ProbeType::NP2_4 || settings.probeType == ProbeType::QUAD_BASE)
channelInfo += " " + String (settings.selectedShank[i]); // shank

if (settings.probeType == ProbeType::NP2_1)
Expand All @@ -79,7 +105,12 @@ class IMRO

channelInfo += " " + String (settings.referenceIndex); // reference

if (settings.probeType == ProbeType::NP2_1 || settings.probeType == ProbeType::NP2_4)
if (settings.probeType == ProbeType::QUAD_BASE
|| settings.probeType == ProbeType::NP2_4)
{
channelInfo += " " + String (settings.selectedElectrode[i] - 1280 * settings.selectedShank[i]); // electrode
}
else if (settings.probeType == ProbeType::NP2_1)
{
channelInfo += " " + String (settings.selectedElectrode[i]); // electrode
}
Expand Down Expand Up @@ -128,26 +159,58 @@ class IMRO

if (value == 0)
{
if (! (settings.probeType == ProbeType::NP1) && ! (settings.probeType == ProbeType::NHP10))
settings.probeType == ProbeType::NP1;

LOGC ("Neuropixels 1.0 probe detected.");
settings.probeType = ProbeType::NP1;
}
else if (value >= 1010 && value <= 1016)
{
LOGC ("Neuropixels NHP probe 10 mm probe detected.");
settings.probeType = ProbeType::NHP10;
}
else if (value >= 1020 && value <= 1022)
{
LOGC ("Neuropixels NHP probe 25 mm probe detected.");
settings.probeType = ProbeType::NHP25;
}
else if (value >= 1030 && value <= 1032)
{
LOGC ("Neuropixels NHP probe 45 mm probe detected.");
settings.probeType = ProbeType::NHP45;
}
else if (value == 1200 || value == 1210)
{
LOGC ("Neuropixels NHP passive probe detected.");
settings.probeType = ProbeType::NHP1;
}
else if (value == 21 || value == 2003 || value == 2004)
{
LOGC ("Neuropixels 2.0 single shank probe detected.");
settings.probeType = ProbeType::NP2_1;
}

else if (value == 24 || value == 2013 || value == 2014)
{
LOGC ("Neuropixels 2.0 multi-shank probe detected.");
settings.probeType = ProbeType::NP2_4;
}
else if (value == 2020 || value == 2021)
{
LOGC ("Neuropixels 2.0 quad base probe detected.");
settings.probeType = ProbeType::QUAD_BASE;
}
else if (value == 1100 || value == 1120 || value == 1121 || value == 1122 || value == 1123)
{
LOGC ("Neuropixels UHD passive probe detected.");
settings.probeType = ProbeType::UHD1;
}
else if (value == 1110)
{
LOGC ("Neuropixels UHD active probe detected.");
settings.probeType = ProbeType::UHD2;
}
else
{
LOGC ("Unknown probe type: ", value)
return false;
LOGC ("Could not load IMRO, unknown probe part number: ", value);
return false;
}

foundHeader = true;
Expand Down Expand Up @@ -176,7 +239,10 @@ class IMRO

static void parseValues (Array<int> values, ProbeType probeType, ProbeSettings& settings)
{
if (probeType == ProbeType::NP1 || probeType == ProbeType::NHP10 || probeType == ProbeType::NHP45)
if (probeType == ProbeType::NP1
|| probeType == ProbeType::NHP10
|| probeType == ProbeType::NHP25
|| probeType == ProbeType::NHP45)
{
// 0 = 1.0 probe
// channel ID
Expand Down Expand Up @@ -277,9 +343,9 @@ class IMRO
settings.referenceIndex = values[2];
settings.selectedElectrode.add (values[3]);
}
else if (probeType == ProbeType::NP2_4)
else if (probeType == ProbeType::NP2_4 || probeType == ProbeType::QUAD_BASE)
{
// 24 = 4-shank 2.0
// 4-shank 2.0
// channel ID
// shank ID
// bank ID
Expand Down Expand Up @@ -346,6 +412,25 @@ class IMRO
return 3;
}
}

static void writeUHDFile (File file, ProbeSettings settings)
{
String configuration = settings.availableElectrodeConfigurations[settings.electrodeConfigurationIndex];

int columnMode = 2; // ALL

if (configuration.startsWith ("1 x 384"))
columnMode = 1; // OUTER

file.appendText ("(1110,"
+ String (columnMode) + ","
+ String (settings.referenceIndex) + ","
+ String ((int) settings.availableApGains[settings.apGainIndex]) + ","
+ String ((int) settings.availableLfpGains[settings.lfpGainIndex]) + ","
+ String ((int) settings.apFilterState) + ")");

// TODO -- write the rest of the file
}
};

#endif
3 changes: 2 additions & 1 deletion Source/Headstages/SimulatedHeadstage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ SimulatedHeadstage::SimulatedHeadstage (Basestation* bs, int port, String PN, in
probes.add (new SimulatedProbe (basestation, this, flexCables[0], 1, PN, SN));
probes[0]->setStatus (SourceStatus::CONNECTING);

if (PN == "NP2000" || PN == "NP2010")
if (PN == "NP2003" || PN == "NP2004" || PN == "NP2013" || PN == "NP2014")
{
// 2.0 headstage, add a placeholder for second dock
probes.add (nullptr);
}
}
37 changes: 33 additions & 4 deletions Source/NeuropixComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,37 @@ enum class ProbeType
QUAD_BASE
};

static std::string probeTypeToString(const ProbeType type)
{
switch (type)
{
case ProbeType::NP1:
return "Neuropixels 1.0";
case ProbeType::NHP10:
return "Neuropixels NHP 10 mm";
case ProbeType::NHP25:
return "Neuropixels NHP 25 mm";
case ProbeType::NHP45:
return "Neuropixels NHP 45 mm";
case ProbeType::NHP1:
return "Neuropixels NHP Passive";
case ProbeType::UHD1:
return "Neuropixels UHD (Fixed)";
case ProbeType::UHD2:
return "Neuropixels UHD (Switchable)";
case ProbeType::NP2_1:
return "Neuropixels 2.0 Single Shank";
case ProbeType::NP2_4:
return "Neuropixels 2.0 Multi Shank";
case ProbeType::OPTO:
return "Neuropixels Opto";
case ProbeType::QUAD_BASE:
return "Neuropixels 2.0 Quad Base";
default:
return "Unknown";
}
}

enum class SourceStatus
{
DISCONNECTED, //There is no communication between probe and computer
Expand Down Expand Up @@ -271,7 +302,6 @@ struct ProbeSettings
class NeuropixComponent
{
public:

/** Constructor */
NeuropixComponent() {}

Expand All @@ -287,14 +317,13 @@ class NeuropixComponent
if (error != Neuropixels::SUCCESS)
{
LOGE (function, ": ", Neuropixels::getErrorMessage (error));
}
}

return error;
}
}

/** Holds error codes*/
Neuropixels::NP_ErrorCode errorCode;

};

/** Holds info about APIv3, as well as a boolean value to indicate whether or not it is being used*/
Expand Down
Loading

0 comments on commit 38304a6

Please sign in to comment.