Skip to content

Commit

Permalink
Show the calibration warning only once after applying probe settings …
Browse files Browse the repository at this point in the history
…for all probes
  • Loading branch information
anjaldoshi committed Jul 1, 2024
1 parent 0f1304c commit f6260fe
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 105 deletions.
2 changes: 1 addition & 1 deletion Source/NeuropixCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ NeuropixCanvas::NeuropixCanvas (GenericProcessor* processor_, NeuropixEditor* ed
{
CustomTabComponent* basestationTab = new CustomTabComponent (editor, false);
topLevelTabComponent->addTab (String (" Slot " + String (basestation->slot) + " "),
findColour (ThemeColours::componentBackground),
findColour (ThemeColours::componentBackground).darker (0.2f),
basestationTab,
true);

Expand Down
30 changes: 30 additions & 0 deletions Source/NeuropixThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ NeuropixThread::NeuropixThread (SourceNode* sn, DeviceType type_) : DataThread (
type (type_),
baseStationAvailable (false),
probesInitialized (false),
calibrationWarningShown (false),
initializationComplete (false),
configurationComplete (false)
{
Expand Down Expand Up @@ -415,6 +416,9 @@ void NeuropixThread::applyProbeSettingsQueue()
settings.probe->setStatus (SourceStatus::UPDATING);
}

Array<Probe*> uncalibratedProbes;

// Apply settings to probes
for (auto settings : probeSettingsUpdateQueue)
{
if (settings.probe->basestation->isBusy())
Expand All @@ -435,12 +439,38 @@ void NeuropixThread::applyProbeSettingsQueue()

settings.probe->setStatus (SourceStatus::CONNECTED);

if (! settings.probe->isCalibrated)
uncalibratedProbes.add (settings.probe);

LOGC ("Wrote configuration");
}
}

probeSettingsUpdateQueue.clear();

// Show warning if any probes are uncalibrated
if (uncalibratedProbes.size() > 0 && ! calibrationWarningShown)
{
String message = "Missing calibration files for the following probe(s):\n\n";

for (auto probe : uncalibratedProbes)
{
message += String::fromUTF8 (" \xe2\x80\xa2 ") + probe->name + " (serial number: " + String (probe->info.serial_number) + ")\n";
}

message += "\nADC and Gain calibration files must be located in \"CalibrationInfo\\<serial_number>\" folder in the directory where the Open Ephys GUI was launched. ";
message += "The GUI will proceed without calibration. The plugin must be deleted and re-inserted once calibration files have been added";

// Show alert window on the message thread asynchronously
MessageManager::callAsync ([this, message]
{ auto* alertWindow = new AlertWindow ("Calibration files not found", message, MessageBoxIconType::WarningIcon, sn->getEditor()->getTopLevelComponent());
alertWindow->addButton ("OK", 1, KeyPress (KeyPress::returnKey), KeyPress (KeyPress::escapeKey));
alertWindow->enterModalState (true, nullptr, true); });

uncalibratedProbes.clear();
calibrationWarningShown = true;
}

configurationComplete = true;
}

Expand Down
2 changes: 2 additions & 0 deletions Source/NeuropixThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ class NeuropixThread : public DataThread, public Timer
bool internalTrigger;
bool autoRestart;

bool calibrationWarningShown;

bool initializationComplete;
bool configurationComplete;

Expand Down
14 changes: 1 addition & 13 deletions Source/Probes/CustomPassiveProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,7 @@ void CustomPassiveProbe::calibrate()

if (! probeDirectory.exists())
{
if (! calibrationWarningShown)
{
// show popup notification window
String message = "Missing calibration files for probe serial number " + String (info.serial_number);
message += ". ADC and Gain calibration files must be located in 'CalibrationInfo\\<serial_number>' folder in the directory where the Open Ephys GUI was launched.";
message += "The GUI will proceed without calibration.";
message += "The plugin must be deleted and re-inserted once calibration files have been added";

AlertWindow::showMessageBox (AlertWindow::AlertIconType::WarningIcon, "Calibration files missing", message, "OK");

calibrationWarningShown = true;
}

LOGD ("!!! Calibration files not found for probe serial number: ", info.serial_number);
return;
}

Expand Down
14 changes: 1 addition & 13 deletions Source/Probes/Neuropixels1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,7 @@ void Neuropixels1::calibrate()

if (! probeDirectory.exists())
{
if (! calibrationWarningShown)
{
// show popup notification window
String message = "Missing calibration files for probe serial number " + String (info.serial_number);
message += ". ADC and Gain calibration files must be located in 'CalibrationInfo\\<serial_number>' folder in the directory where the Open Ephys GUI was launched.";
message += "The GUI will proceed without calibration.";
message += "The plugin must be deleted and re-inserted once calibration files have been added";

AlertWindow::showMessageBox (AlertWindow::AlertIconType::WarningIcon, "Calibration files missing", message, "OK");

calibrationWarningShown = true;
}

LOGD ("!!! Calibration files not found for probe serial number: ", info.serial_number);
return;
}

Expand Down
16 changes: 3 additions & 13 deletions Source/Probes/Neuropixels2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,7 @@ void Neuropixels2::calibrate()

if (! probeDirectory.exists())
{
if (! calibrationWarningShown)
{
// show popup notification window
String message = "Missing calibration files for probe serial number " + String (info.serial_number);
message += ". ADC and Gain calibration files must be located in 'CalibrationInfo\\<serial_number>' folder in the directory where the Open Ephys GUI was launched.";
message += "The GUI will proceed without calibration.";
message += "The plugin must be deleted and re-inserted once calibration files have been added";

AlertWindow::showMessageBox (AlertWindow::AlertIconType::WarningIcon, "Calibration files missing", message, "OK");

calibrationWarningShown = true;
}

LOGD ("!!! Calibration files not found for probe serial number: ", info.serial_number);
return;
}

Expand Down Expand Up @@ -224,6 +212,8 @@ void Neuropixels2::calibrate()
}

errorCode = Neuropixels::np_setHSLed (basestation->slot, headstage->port, false);

isCalibrated = true;
}

void Neuropixels2::selectElectrodes()
Expand Down
14 changes: 1 addition & 13 deletions Source/Probes/NeuropixelsOpto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,7 @@ void NeuropixelsOpto::calibrate()

if (! probeDirectory.exists())
{
if (! calibrationWarningShown)
{
// show popup notification window
String message = "Missing calibration files for probe serial number " + String (info.serial_number);
message += ". ADC and Gain calibration files must be located in 'CalibrationInfo\\<serial_number>' folder in the directory where the Open Ephys GUI was launched.";
message += "The GUI will proceed without calibration.";
message += "The plugin must be deleted and re-inserted once calibration files have been added";

AlertWindow::showMessageBox (AlertWindow::AlertIconType::WarningIcon, "Calibration files missing", message, "OK");

calibrationWarningShown = true;
}

LOGD ("!!! Calibration files not found for probe serial number: ", info.serial_number);
return;
}

Expand Down
14 changes: 1 addition & 13 deletions Source/Probes/Neuropixels_NHP_Active.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,7 @@ void Neuropixels_NHP_Active::calibrate()

if (! probeDirectory.exists())
{
if (! calibrationWarningShown)
{
// show popup notification window
String message = "Missing calibration files for probe serial number " + String (info.serial_number);
message += ". ADC and Gain calibration files must be located in 'CalibrationInfo\\<serial_number>' folder in the directory where the Open Ephys GUI was launched.";
message += "The GUI will proceed without calibration.";
message += "The plugin must be deleted and re-inserted once calibration files have been added";

AlertWindow::showMessageBox (AlertWindow::AlertIconType::WarningIcon, "Calibration files missing", message, "OK");

calibrationWarningShown = true;
}

LOGD ("!!! Calibration files not found for probe serial number: ", info.serial_number);
return;
}

Expand Down
16 changes: 3 additions & 13 deletions Source/Probes/Neuropixels_NHP_Passive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,7 @@ void Neuropixels_NHP_Passive::calibrate()

if (! probeDirectory.exists())
{
if (! calibrationWarningShown)
{
// show popup notification window
String message = "Missing calibration files for probe serial number " + String (info.serial_number);
message += ". ADC and Gain calibration files must be located in 'CalibrationInfo\\<serial_number>' folder in the directory where the Open Ephys GUI was launched.";
message += "The GUI will proceed without calibration.";
message += "The plugin must be deleted and re-inserted once calibration files have been added";

AlertWindow::showMessageBox (AlertWindow::AlertIconType::WarningIcon, "Calibration files missing", message, "OK");

calibrationWarningShown = true;
}

LOGD ("!!! Calibration files not found for probe serial number: ", info.serial_number);
return;
}

Expand Down Expand Up @@ -199,6 +187,8 @@ void Neuropixels_NHP_Passive::calibrate()
{
LOGD ("Successfully wrote probe config ");
}

isCalibrated = true;
}

void Neuropixels_NHP_Passive::selectElectrodes()
Expand Down
16 changes: 3 additions & 13 deletions Source/Probes/Neuropixels_QuadBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,7 @@ void Neuropixels_QuadBase::calibrate()

if (! probeDirectory.exists())
{
if (! calibrationWarningShown)
{
// show popup notification window
String message = "Missing calibration files for probe serial number " + String (info.serial_number);
message += ". ADC and Gain calibration files must be located in 'CalibrationInfo\\<serial_number>' folder in the directory where the Open Ephys GUI was launched.";
message += "The GUI will proceed without calibration.";
message += "The plugin must be deleted and re-inserted once calibration files have been added";

AlertWindow::showMessageBox (AlertWindow::AlertIconType::WarningIcon, "Calibration files missing", message, "OK");

calibrationWarningShown = true;
}

LOGD ("!!! Calibration files not found for probe serial number: ", info.serial_number);
return;
}

Expand Down Expand Up @@ -189,6 +177,8 @@ void Neuropixels_QuadBase::calibrate()
}

errorCode = Neuropixels::np_setHSLed (basestation->slot, headstage->port, false);

isCalibrated = true;
}

void Neuropixels_QuadBase::selectElectrodes()
Expand Down
14 changes: 1 addition & 13 deletions Source/Probes/Neuropixels_UHD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,7 @@ void Neuropixels_UHD::calibrate()

if (! probeDirectory.exists())
{
if (! calibrationWarningShown)
{
// show popup notification window
String message = "Missing calibration files for probe serial number " + String (info.serial_number);
message += ". ADC and Gain calibration files must be located in 'CalibrationInfo\\<serial_number>' folder in the directory where the Open Ephys GUI was launched.";
message += "The GUI will proceed without calibration.";
message += "The plugin must be deleted and re-inserted once calibration files have been added";

AlertWindow::showMessageBox (AlertWindow::AlertIconType::WarningIcon, "Calibration files missing", message, "OK");

calibrationWarningShown = true;
}

LOGD ("!!! Calibration files not found for probe serial number: ", info.serial_number);
return;
}

Expand Down

0 comments on commit f6260fe

Please sign in to comment.