Skip to content
Draft
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
2 changes: 1 addition & 1 deletion Source/Devices/AnalogIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ AnalogIO::AnalogIO (std::string name, std::string hubName, const oni_dev_idx_t d
: OnixDevice (name, hubName, AnalogIO::getDeviceType(), deviceIdx_, oni_ctx)
{
StreamInfo analogInputStream = StreamInfo (
OnixDevice::createStreamName ({ getHubName(), name, "AnalogInput" }),
createStreamName ("AnalogInput", false),
"Analog Input data",
getStreamIdentifier(),
numChannels,
Expand Down
12 changes: 6 additions & 6 deletions Source/Devices/Bno055.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic

std::string port = getPortName (deviceIdx);
StreamInfo eulerAngleStream = StreamInfo (
OnixDevice::createStreamName ({ port, getHubName(), getName(), "Euler" }),
createStreamName ("Euler"),
"Bosch Bno055 9-axis inertial measurement unit (IMU) Euler angle",
streamIdentifier,
3,
Expand All @@ -46,7 +46,7 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic
streamInfos.add (eulerAngleStream);

StreamInfo quaternionStream = StreamInfo (
OnixDevice::createStreamName ({ port, getHubName(), getName(), "Quaternion" }),
createStreamName ("Quaternion"),
"Bosch Bno055 9-axis inertial measurement unit (IMU) Quaternion",
streamIdentifier,
4,
Expand All @@ -61,7 +61,7 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic
streamInfos.add (quaternionStream);

StreamInfo accelerationStream = StreamInfo (
OnixDevice::createStreamName ({ port, getHubName(), getName(), "Acceleration" }),
createStreamName ("Acceleration"),
"Bosch Bno055 9-axis inertial measurement unit (IMU) Acceleration",
streamIdentifier,
3,
Expand All @@ -76,7 +76,7 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic
streamInfos.add (accelerationStream);

StreamInfo gravityStream = StreamInfo (
OnixDevice::createStreamName ({ port, getHubName(), getName(), "Gravity" }),
createStreamName ("Gravity"),
"Bosch Bno055 9-axis inertial measurement unit (IMU) Gravity",
streamIdentifier,
3,
Expand All @@ -91,7 +91,7 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic
streamInfos.add (gravityStream);

StreamInfo temperatureStream = StreamInfo (
OnixDevice::createStreamName ({ port, getHubName(), getName(), "Temperature" }),
createStreamName ("Temperature"),
"Bosch Bno055 9-axis inertial measurement unit (IMU) Temperature",
streamIdentifier,
1,
Expand All @@ -105,7 +105,7 @@ Bno055::Bno055 (std::string name, std::string hubName, const oni_dev_idx_t devic
streamInfos.add (temperatureStream);

StreamInfo calibrationStatusStream = StreamInfo (
OnixDevice::createStreamName ({ port, getHubName(), getName(), "Calibration" }),
createStreamName ("Calibration"),
"Bosch Bno055 9-axis inertial measurement unit (IMU) Calibration status",
streamIdentifier,
4,
Expand Down
6 changes: 3 additions & 3 deletions Source/Devices/DigitalIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ DigitalIO::DigitalIO (std::string name, std::string hubName, const oni_dev_idx_t
: OnixDevice (name, hubName, DigitalIO::getDeviceType(), deviceIdx_, oni_ctx)
{
StreamInfo digitalInputStream = StreamInfo (
OnixDevice::createStreamName ({ getHubName(), name, "DigitalInputs" }),
createStreamName ({ getHubName(), name, "DigitalInputs" }),
"Digital Inputs data",
getStreamIdentifier(),
NumDigitalInputs,
Expand All @@ -43,7 +43,7 @@ DigitalIO::DigitalIO (std::string name, std::string hubName, const oni_dev_idx_t
streamInfos.add (digitalInputStream);

StreamInfo digitalButtonStream = StreamInfo (
OnixDevice::createStreamName ({ getHubName(), name, "DigitalButtons" }),
createStreamName ({ getHubName(), name, "DigitalButtons" }),
"Digital Buttons data",
getStreamIdentifier(),
NumButtons,
Expand Down Expand Up @@ -111,7 +111,7 @@ EventChannel::Settings DigitalIO::getEventChannelSettings (DataStream* stream)
{
EventChannel::Settings settings {
EventChannel::Type::TTL,
OnixDevice::createStreamName ({ getHubName(), getName(), "Events" }),
createStreamName ("Events", false),
"Digital inputs and breakout button states coming from a DigitalIO device",
getStreamIdentifier() + ".event.digital",
stream,
Expand Down
2 changes: 1 addition & 1 deletion Source/Devices/HarpSyncInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ HarpSyncInput::HarpSyncInput (std::string name, std::string hubName, const oni_d
setEnabled (false);

StreamInfo harpTimeStream = StreamInfo (
OnixDevice::createStreamName ({ getHubName(), getName(), "HarpTime" }),
createStreamName ("HarpTime", false),
"Harp clock time corresponding to the local acquisition ONIX clock count",
getStreamIdentifier(),
1,
Expand Down
2 changes: 1 addition & 1 deletion Source/Devices/MemoryMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ MemoryMonitor::MemoryMonitor (std::string name, std::string hubName, const oni_d
: OnixDevice (name, hubName, MemoryMonitor::getDeviceType(), deviceIdx_, oni_ctx)
{
StreamInfo percentUsedStream = StreamInfo (
OnixDevice::createStreamName ({ getHubName(), getName(), "PercentUsed" }),
createStreamName ("PercentUsed", false),
"Percent of available memory that is currently used",
getStreamIdentifier(),
1,
Expand Down
33 changes: 24 additions & 9 deletions Source/Devices/Neuropixels1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,22 +302,37 @@ void Neuropixels1::defineMetadata (ProbeSettings<numberOfChannels, numberOfElect

uint64_t Neuropixels1::getProbeSerialNumber (int index)
{
return probeNumber;
return probeMetadata.getProbeSerialNumber();
}

std::string Neuropixels1::getProbePartNumber (int index)
{
return probeMetadata.getProbePartNumber();
}

std::string Neuropixels1::getFlexPartNumber (int index)
{
return probeMetadata.getFlexPartNumber();
}

std::string Neuropixels1::getFlexVersion (int index)
{
return probeMetadata.getFlexVersion();
}

bool Neuropixels1::parseGainCalibrationFile()
{
if (gainCalibrationFilePath == "None" || gainCalibrationFilePath == "")
{
Onix1::showWarningMessageBoxAsync ("Missing File", "Missing gain calibration file for probe " + std::to_string (probeNumber));
Onix1::showWarningMessageBoxAsync ("Missing File", "Missing gain calibration file for probe " + std::to_string (probeMetadata.getProbeSerialNumber()));
return false;
}

File gainFile = File (gainCalibrationFilePath);

if (! gainFile.existsAsFile())
{
Onix1::showWarningMessageBoxAsync ("Invalid File", "Invalid gain calibration file for probe " + std::to_string (probeNumber));
Onix1::showWarningMessageBoxAsync ("Invalid File", "Invalid gain calibration file for probe " + std::to_string (probeMetadata.getProbeSerialNumber()));
return false;
}

Expand All @@ -328,9 +343,9 @@ bool Neuropixels1::parseGainCalibrationFile()

LOGD ("Gain calibration file SN = ", gainSN);

if (gainSN != probeNumber)
if (gainSN != probeMetadata.getProbeSerialNumber())
{
Onix1::showWarningMessageBoxAsync ("Serial Number Mismatch", "Gain calibration file serial number (" + std::to_string (gainSN) + ") does not match probe serial number (" + std::to_string (probeNumber) + ").");
Onix1::showWarningMessageBoxAsync ("Serial Number Mismatch", "Gain calibration file serial number (" + std::to_string (gainSN) + ") does not match probe serial number (" + std::to_string (probeMetadata.getProbeSerialNumber()) + ").");
return false;
}

Expand Down Expand Up @@ -366,15 +381,15 @@ bool Neuropixels1::parseAdcCalibrationFile()
{
if (adcCalibrationFilePath == "None" || adcCalibrationFilePath == "")
{
Onix1::showWarningMessageBoxAsync ("Missing File", "Missing ADC calibration file for probe " + std::to_string (probeNumber));
Onix1::showWarningMessageBoxAsync ("Missing File", "Missing ADC calibration file for probe " + std::to_string (probeMetadata.getProbeSerialNumber()));
return false;
}

File adcFile = File (adcCalibrationFilePath);

if (! adcFile.existsAsFile())
{
Onix1::showWarningMessageBoxAsync ("Invalid File", "Invalid ADC calibration file for probe " + std::to_string (probeNumber));
Onix1::showWarningMessageBoxAsync ("Invalid File", "Invalid ADC calibration file for probe " + std::to_string (probeMetadata.getProbeSerialNumber()));
return false;
}

Expand All @@ -385,9 +400,9 @@ bool Neuropixels1::parseAdcCalibrationFile()

LOGD ("ADC calibration file SN = ", adcSN);

if (adcSN != probeNumber)
if (adcSN != probeMetadata.getProbeSerialNumber())
{
Onix1::showWarningMessageBoxAsync ("Serial Number Mismatch", "ADC calibration serial number (" + std::to_string (adcSN) + ") does not match probe serial number (" + std::to_string (probeNumber) + ").");
Onix1::showWarningMessageBoxAsync ("Serial Number Mismatch", "ADC calibration serial number (" + std::to_string (adcSN) + ") does not match probe serial number (" + std::to_string (probeMetadata.getProbeSerialNumber()) + ").");
return false;
}

Expand Down
14 changes: 10 additions & 4 deletions Source/Devices/Neuropixels1.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "../I2CRegisterContext.h"
#include "../NeuropixelsComponents.h"
#include "../OnixDevice.h"
#include "NeuropixelsProbeMetadata.h"

namespace OnixSourcePlugin
{
Expand Down Expand Up @@ -52,10 +52,13 @@ class Neuropixels1 : public INeuropixel<NeuropixelsV1Values::numberOfChannels, N
/** Select a preset electrode configuration, based on the index of the given enum */
std::vector<int> selectElectrodeConfiguration (int electrodeConfigurationIndex) override;

uint64_t getProbeSerialNumber (int index = 0) override;

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

uint64_t getProbeSerialNumber (int index = 0) override;
std::string getProbePartNumber (int index = 0) override;
std::string getFlexPartNumber (int index = 0) override;
std::string getFlexVersion (int index = 0) override;

bool parseGainCalibrationFile();
bool parseAdcCalibrationFile();

Expand All @@ -73,7 +76,7 @@ class Neuropixels1 : public INeuropixel<NeuropixelsV1Values::numberOfChannels, N

const uint32_t ENABLE = 0x8000;

static constexpr int ProbeI2CAddress = 0x70;
NeuropixelsProbeMetadata probeMetadata;

static constexpr int superFramesPerUltraFrame = 12;
static constexpr int framesPerSuperFrame = 13;
Expand All @@ -84,6 +87,9 @@ class Neuropixels1 : public INeuropixel<NeuropixelsV1Values::numberOfChannels, N
static constexpr uint16_t NumberOfAdcBins = 1024;
static constexpr float DataMidpoint = NumberOfAdcBins / 2;

static constexpr int ProbeI2CAddress = 0x70;
static constexpr int FlexEepromI2CAddress = 0x50;

static constexpr int secondsToSettle = 5;
static constexpr int samplesToAverage = 100;

Expand Down
27 changes: 5 additions & 22 deletions Source/Devices/Neuropixels1e.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Neuropixels1e::Neuropixels1e (std::string name, std::string hubName, const oni_d
{
std::string port = getPortName (getDeviceIdx());
StreamInfo apStream = StreamInfo (
OnixDevice::createStreamName ({ port, getHubName(), getName(), STREAM_NAME_AP }),
createStreamName (STREAM_NAME_AP),
"Neuropixels 1.0 AP band data stream",
getStreamIdentifier(),
numberOfChannels,
Expand All @@ -94,7 +94,7 @@ Neuropixels1e::Neuropixels1e (std::string name, std::string hubName, const oni_d
streamInfos.add (apStream);

StreamInfo lfpStream = StreamInfo (
OnixDevice::createStreamName ({ port, getHubName(), getName(), STREAM_NAME_LFP }),
createStreamName (STREAM_NAME_LFP),
"Neuropixels 1.0 LFP band data stream",
getStreamIdentifier(),
numberOfChannels,
Expand All @@ -117,8 +117,6 @@ Neuropixels1e::Neuropixels1e (std::string name, std::string hubName, const oni_d
apEventCodes[i] = 0;
lfpEventCodes[i] = 0;
}

probeNumber = 0;
}

int Neuropixels1e::configureDevice()
Expand All @@ -132,25 +130,10 @@ int Neuropixels1e::configureDevice()
if (rc != ONI_ESUCCESS)
throw error_str ("Unable to set I2C rate for " + getName());

// Get Probe SN

int errorCode = 0;

for (int i = 0; i < 8; i++)
{
oni_reg_val_t reg_val;
rc = flex->ReadByte (OFFSET_ID + i, &reg_val);

if (rc != ONI_ESUCCESS)
throw error_str ("Unable to read the probe serial number for device at address " + getDeviceIdx());

if (reg_val <= 0xFF)
{
probeNumber |= (((uint64_t) reg_val) << (i * 8));
}
}
// Get Probe Metadata
probeMetadata = NeuropixelsProbeMetadata (flex.get(), OnixDeviceType::NEUROPIXELSV1E);

LOGD ("Probe SN: ", probeNumber);
LOGD ("Probe SN: ", probeMetadata.getProbeSerialNumber());

return ONI_ESUCCESS;
}
Expand Down
12 changes: 3 additions & 9 deletions Source/Devices/Neuropixels1e.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,15 @@ class Neuropixels1e : public Neuropixels1

static constexpr int FlexEepromI2CAddress = 0x50;

static constexpr uint32_t OFFSET_ID = 0;
static constexpr uint32_t OFFSET_VERSION = 10;
static constexpr uint32_t OFFSET_REVISION = 11;
static constexpr uint32_t OFFSET_FLEXPN = 20;
static constexpr uint32_t OFFSET_PROBEPN = 40;
std::unique_ptr<I2CRegisterContext> deserializer;
std::unique_ptr<I2CRegisterContext> serializer;
std::unique_ptr<I2CRegisterContext> flex;

static constexpr uint8_t DefaultGPO10Config = 0b00010001; // GPIO0 Low, NP in MUX reset
static constexpr uint8_t DefaultGPO32Config = 0b10010001; // LED off, GPIO1 Low
static constexpr uint32_t Gpo10ResetMask = 1 << 3; // Used to issue mux reset command to probe
static constexpr uint32_t Gpo32LedMask = 1 << 7; // Used to turn on and off LED

std::unique_ptr<I2CRegisterContext> deserializer;
std::unique_ptr<I2CRegisterContext> serializer;
std::unique_ptr<I2CRegisterContext> flex;

void resetProbe();
void writeShiftRegisters();

Expand Down
35 changes: 6 additions & 29 deletions Source/Devices/Neuropixels1f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Neuropixels1f::Neuropixels1f (std::string name, std::string hubName, const oni_d
{
std::string port = getPortName (deviceIdx);
StreamInfo apStream = StreamInfo (
OnixDevice::createStreamName ({ port, getHubName(), getName(), STREAM_NAME_AP }),
createStreamName (STREAM_NAME_AP),
"Neuropixels 1.0 AP band data stream",
getStreamIdentifier(),
numberOfChannels,
Expand All @@ -82,7 +82,7 @@ Neuropixels1f::Neuropixels1f (std::string name, std::string hubName, const oni_d
streamInfos.add (apStream);

StreamInfo lfpStream = StreamInfo (
OnixDevice::createStreamName ({ port, getHubName(), getName(), STREAM_NAME_LFP }),
createStreamName (STREAM_NAME_LFP),
"Neuropixels 1.0 LFP band data stream",
getStreamIdentifier(),
numberOfChannels,
Expand All @@ -105,8 +105,6 @@ Neuropixels1f::Neuropixels1f (std::string name, std::string hubName, const oni_d
apEventCodes[i] = 0;
lfpEventCodes[i] = 0;
}

probeNumber = 0;
}

int Neuropixels1f::configureDevice()
Expand All @@ -123,32 +121,11 @@ int Neuropixels1f::configureDevice()
return ONI_ESUCCESS;
}

// Get Probe SN
uint32_t eepromOffset = 0;
uint32_t i2cAddr = 0x50;
int errorCode = 0;

for (int i = 0; i < 8; i++)
{
oni_reg_addr_t reg_addr = ((eepromOffset + i) << 7) | i2cAddr;

oni_reg_val_t reg_val;
rc = deviceContext->readRegister (deviceIdx, reg_addr, &reg_val);

if (rc != ONI_ESUCCESS)
{
LOGE (oni_error_str (rc));
throw error_str ("Could not communicate with " + getName() + " on " + getHubName()
+ ". Ensure that the flex connection is properly seated, or disable the device if it is not connected.");
}

if (reg_val <= 0xFF)
{
probeNumber |= (((uint64_t) reg_val) << (i * 8));
}
}
// Get Probe Metadata
auto flex = std::make_unique<I2CRegisterContext> (FlexEepromI2CAddress, deviceIdx, deviceContext);
probeMetadata = NeuropixelsProbeMetadata (flex.get(), OnixDeviceType::NEUROPIXELSV1F);

LOGD ("Probe SN: ", probeNumber);
LOGD ("Probe SN: ", probeMetadata.getProbeSerialNumber());

// Enable device streaming
rc = deviceContext->writeRegister (deviceIdx, 0x8000, 1);
Expand Down
Loading