Skip to content

Commit

Permalink
Merge pull request #2208 from AllenInstitute/feature/2208-allow-to-se…
Browse files Browse the repository at this point in the history
…t-cell-electrode-name

FFI_SetCellElectrodeName: Add it
  • Loading branch information
t-b authored Sep 1, 2024
2 parents 31e4327 + 80bfc75 commit 009ea53
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_AmplifierInteraction.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ Function AI_SendToAmp(device, headStage, mode, func, value, [checkBeforeWrite, u
string str

ASSERT(func > MCC_BEGIN_INVALID_FUNC && func < MCC_END_INVALID_FUNC, "MCC function constant is out for range")
ASSERT(headStage >= 0 && headStage < NUM_HEADSTAGES, "invalid headStage index")
ASSERT(IsValidHeadstage(headstage), "invalid headStage index")
AI_AssertOnInvalidClampMode(mode)

if(ParamIsDefault(checkBeforeWrite))
Expand Down
12 changes: 12 additions & 0 deletions Packages/MIES/MIES_ForeignFunctionInterface.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,15 @@ Function/WAVE FFI_GetAvailableMessageFilters()

return wv
End

/// @brief Set the headstage/cell electrode name
Function FFI_SetCellElectrodeName(string device, variable headstage, string name)

DAP_AbortIfUnlocked(device)
ASSERT(IsValidHeadstage(headstage), "Invalid headstage index")
ASSERT(H5_IsValidIdentifier(name), "Name of the electrode/headstage needs to be a valid HDF5 identifier")

WAVE/T cellElectrodeNames = GetCellElectrodeNames(device)

cellElectrodeNames[headstage] = name
End
8 changes: 8 additions & 0 deletions Packages/MIES/MIES_MiesUtilities_Checks.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@ Function IsValidSamplingMultiplier(multiplier)

return IsFinite(multiplier) && WhichListItem(num2str(multiplier), DAP_GetSamplingMultiplier()) != -1
End

/// @brief Check if the given headstage index is valid
///
/// UTF_NOINSTRUMENTATION
threadsafe Function IsValidHeadstage(variable headstage)

return IsInteger(headstage) && headstage >= 0 && headstage < NUM_HEADSTAGES
End
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_MiesUtilities_Config.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ End
threadsafe Function/S GetDefaultElectrodeName(headstage)
variable headstage

ASSERT_TS(headstage >= 0 && headstage < NUM_HEADSTAGES, "Invalid headstage")
ASSERT_TS(IsValidHeadstage(headstage), "Invalid headstage")

return num2str(headstage)
End
Expand Down
8 changes: 4 additions & 4 deletions Packages/MIES/MIES_MiesUtilities_Logbook.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ threadsafe Function/WAVE GetLastSettingEachRAC(numericalValues, sweepNo, setting

variable i, numSweeps

ASSERT_TS(headstage >= 0 && headstage < NUM_HEADSTAGES, "Invalid headstage")
ASSERT_TS(IsValidHeadstage(headstage), "Invalid headstage")

WAVE/Z sweeps = AFH_GetSweepsFromSameRACycle(numericalValues, sweepNo)
if(!WaveExists(sweeps) || DimSize(sweeps, ROWS) == 0)
Expand Down Expand Up @@ -1083,7 +1083,7 @@ threadsafe Function/WAVE GetLastSettingTextEachRAC(numericalValues, textualValue

variable i, numSweeps

ASSERT_TS(headstage >= 0 && headstage < NUM_HEADSTAGES, "Invalid headstage")
ASSERT_TS(IsValidHeadstage(headstage), "Invalid headstage")

WAVE/Z sweeps = AFH_GetSweepsFromSameRACycle(numericalValues, sweepNo)
if(!WaveExists(sweeps) || DimSize(sweeps, ROWS) == 0)
Expand Down Expand Up @@ -1258,7 +1258,7 @@ threadsafe Function/WAVE GetLastSettingEachSCI(numericalValues, sweepNo, setting

variable i, numSweeps

ASSERT_TS(headstage >= 0 && headstage < NUM_HEADSTAGES, "Invalid headstage")
ASSERT_TS(IsValidHeadstage(headstage), "Invalid headstage")

WAVE/Z sweeps = AFH_GetSweepsFromSameSCI(numericalValues, sweepNo, headstage)
if(!WaveExists(sweeps) || DimSize(sweeps, ROWS) == 0)
Expand Down Expand Up @@ -1300,7 +1300,7 @@ threadsafe Function/WAVE GetLastSettingTextEachSCI(numericalValues, textualValue

variable i, numSweeps

ASSERT_TS(headstage >= 0 && headstage < NUM_HEADSTAGES, "Invalid headstage")
ASSERT_TS(IsValidHeadstage(headstage), "Invalid headstage")

WAVE/Z sweeps = AFH_GetSweepsFromSameSCI(numericalValues, sweepNo, headstage)
if(!WaveExists(sweeps) || DimSize(sweeps, ROWS) == 0)
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_PressureControl.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2207,7 +2207,7 @@ Function P_SetPressureMode(device, headStage, pressureMode, [pressure])
variable pressureMode
variable pressure

ASSERT(headstage < NUM_HEADSTAGES && headStage >= 0, "Select headstage number between 0 and 7")
ASSERT(IsValidHeadstage(headStage), "Select headstage number between 0 and 7")
ASSERT(pressureMode >= PRESSURE_METHOD_ATM && pressureMode <= PRESSURE_METHOD_MANUAL, "Select a pressure mode between -1 and 4")

WAVE PressureDataWv = P_GetPressureDataWaveRef(device)
Expand Down
9 changes: 9 additions & 0 deletions Packages/tests/Basic/UTF_Utils_Checks.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,12 @@ static Function CheckMatchAgainstWildCardPatterns()
End

/// @}

static Function TestIsValidHeadstageWorking()

CHECK_EQUAL_VAR(IsValidHeadstage(0), 1)
CHECK_EQUAL_VAR(IsValidHeadstage(1), 1)
CHECK_EQUAL_VAR(IsValidHeadstage(NUM_HEADSTAGES - 1), 1)
CHECK_EQUAL_VAR(IsValidHeadstage(NaN), 0)
CHECK_EQUAL_VAR(IsValidHeadstage(1.5), 0)
End
6 changes: 2 additions & 4 deletions Packages/tests/HardwareBasic/UTF_BasicHardwareTests.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2471,10 +2471,8 @@ End

static Function TestCustomElectrodeNamesInNWB_preAcq(string device)

WAVE/T cellElectrodeNames = GetCellElectrodeNames(device)
// must be valid HDF5 identifiers
cellElectrodeNames[0] = "Electric Dreams of Voltage"
cellElectrodeNames[1] = "Electric Dreams of Current"
FFI_SetCellElectrodeName(device, 0, "Electric Dreams of Voltage")
FFI_SetCellElectrodeName(device, 1, "Electric Dreams of Current")
End

// UTF_TD_GENERATOR DeviceNameGeneratorMD1
Expand Down

0 comments on commit 009ea53

Please sign in to comment.