Skip to content

Commit

Permalink
Tests/UTF_ReachTargetVoltage.ipf: Rework them
Browse files Browse the repository at this point in the history
We know have 6 sweeps in the stimset, which triggers the finish condition
as we need one sweep more than the targetVoltages wave. Also added is a
test with multiple headstages.
  • Loading branch information
t-b committed Jan 14, 2025
1 parent fe090a4 commit 10f81b5
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 18 deletions.
87 changes: 69 additions & 18 deletions Packages/tests/HardwareAnalysisFunctions/UTF_ReachTargetVoltage.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
#pragma rtFunctionErrors=1
#pragma ModuleName=ReachTargetVoltageTesting

static Constant HEADSTAGE = 1

static Function [STRUCT DAQSettings s] PS_GetDAQSettings(string device)

InitDAQSettingsFromString(s, "MD1_RA1_I0_L0_BKG1_DB0" + \
"__HS" + num2str(HEADSTAGE) + "_DA1_AD1_CM:IC:_ST:ReachTargetVoltage_DA_0:")
InitDAQSettingsFromString(s, "MD1_RA1_I0_L0_BKG1_DB0" + \
"__HS1_DA1_AD1_CM:IC:_ST:ReachTargetVoltage_DA_0:")

return [s]
End

static Function GlobalPreAcq(string device)

PGC_SetAndActivateControl(device, "slider_DataAcq_ActiveHeadstage", val = HEADSTAGE)
PGC_SetAndActivateControl(device, "slider_DataAcq_ActiveHeadstage", val = 1)

PGC_SetAndActivateControl(device, "check_DataAcq_AutoBias", val = 1)
PGC_SetAndActivateControl(device, "setvar_DataAcq_AutoBiasV", val = -70)
Expand All @@ -26,15 +24,15 @@ static Function GlobalPreInit(string device)
PASS()
End

static Function [WAVE/Z deltaI, WAVE/Z deltaV, WAVE/Z resistance, WAVE/Z resistanceErr, WAVE/Z autobiasFromDialog] GetLBNEntries_IGNORE(string device, variable sweepNo)
static Function [WAVE/Z deltaI, WAVE/Z deltaV, WAVE/Z resistance, WAVE/Z resistanceErr, WAVE/Z autobiasFromDialog] GetLBNEntries_IGNORE(string device, variable sweepNo, variable headstage)

WAVE numericalValues = GetLBNumericalValues(device)

WAVE/Z deltaI = GetLastSettingEachSCI(numericalValues, sweepNo, LABNOTEBOOK_USER_PREFIX + LBN_DELTA_I, HEADSTAGE, UNKNOWN_MODE)
WAVE/Z deltaV = GetLastSettingEachSCI(numericalValues, sweepNo, LABNOTEBOOK_USER_PREFIX + LBN_DELTA_V, HEADSTAGE, UNKNOWN_MODE)
WAVE/Z resistance = GetLastSettingEachSCI(numericalValues, sweepNo, LABNOTEBOOK_USER_PREFIX + LBN_RESISTANCE_FIT, HEADSTAGE, UNKNOWN_MODE)
WAVE/Z resistanceErr = GetLastSettingEachSCI(numericalValues, sweepNo, LABNOTEBOOK_USER_PREFIX + LBN_RESISTANCE_FIT_ERR, HEADSTAGE, UNKNOWN_MODE)
WAVE/Z autobiasFromDialog = GetLastSettingEachSCI(numericalValues, sweepNo, LABNOTEBOOK_USER_PREFIX + LBN_AUTOBIAS_TARGET_DIAG, HEADSTAGE, UNKNOWN_MODE)
WAVE/Z deltaI = GetLastSettingEachSCI(numericalValues, sweepNo, LABNOTEBOOK_USER_PREFIX + LBN_DELTA_I, headstage, UNKNOWN_MODE)
WAVE/Z deltaV = GetLastSettingEachSCI(numericalValues, sweepNo, LABNOTEBOOK_USER_PREFIX + LBN_DELTA_V, headstage, UNKNOWN_MODE)
WAVE/Z resistance = GetLastSettingEachSCI(numericalValues, sweepNo, LABNOTEBOOK_USER_PREFIX + LBN_RESISTANCE_FIT, headstage, UNKNOWN_MODE)
WAVE/Z resistanceErr = GetLastSettingEachSCI(numericalValues, sweepNo, LABNOTEBOOK_USER_PREFIX + LBN_RESISTANCE_FIT_ERR, headstage, UNKNOWN_MODE)
WAVE/Z autobiasFromDialog = GetLastSettingEachSCI(numericalValues, sweepNo, LABNOTEBOOK_USER_PREFIX + LBN_AUTOBIAS_TARGET_DIAG, headstage, UNKNOWN_MODE)
End

static Function RTV_Works_preAcq(string device)
Expand All @@ -53,12 +51,12 @@ static Function RTV_Works_REENTRY([string str])

variable sweepNo

CHECK_EQUAL_VAR(GetSetVariable(str, "SetVar_Sweep"), 5)
CHECK_EQUAL_VAR(GetSetVariable(str, "SetVar_Sweep"), 6)

sweepNo = AFH_GetLastSweepAcquired(str)
CHECK_EQUAL_VAR(sweepNo, 4)
CHECK_EQUAL_VAR(sweepNo, 5)

[WAVE deltaI, WAVE deltaV, WAVE resistance, WAVE resistanceErr, WAVE autobiasFromDialog] = GetLBNEntries_IGNORE(str, sweepNo)
[WAVE deltaI, WAVE deltaV, WAVE resistance, WAVE resistanceErr, WAVE autobiasFromDialog] = GetLBNEntries_IGNORE(str, sweepNo, 1)

CHECK_WAVE(deltaI, NUMERIC_WAVE)
CHECK_WAVE(deltaV, NUMERIC_WAVE)
Expand All @@ -84,19 +82,72 @@ static Function RTV_WorksWithIndexing_REENTRY([string str])

variable sweepNo

CHECK_EQUAL_VAR(GetSetVariable(str, "SetVar_Sweep"), 6)
CHECK_EQUAL_VAR(GetSetVariable(str, "SetVar_Sweep"), 7)

sweepNo = AFH_GetLastSweepAcquired(str)
CHECK_EQUAL_VAR(sweepNo, 5)
CHECK_EQUAL_VAR(sweepNo, 6)

[WAVE deltaI, WAVE deltaV, WAVE resistance, WAVE resistanceErr, WAVE autobiasFromDialog] = GetLBNEntries_IGNORE(str, 0)
[WAVE deltaI, WAVE deltaV, WAVE resistance, WAVE resistanceErr, WAVE autobiasFromDialog] = GetLBNEntries_IGNORE(str, 0, 1)

CHECK_WAVE(deltaI, NUMERIC_WAVE)
CHECK_WAVE(deltaV, NUMERIC_WAVE)
CHECK_WAVE(resistance, NUMERIC_WAVE)
CHECK_WAVE(resistanceErr, NUMERIC_WAVE)
CHECK_WAVE(autobiasFromDialog, NUMERIC_WAVE)

CHECK_EQUAL_WAVES(autobiasFromDialog, {-69, NaN, NaN, NaN, NaN}, mode = WAVE_DATA)
CHECK_EQUAL_WAVES(autobiasFromDialog, {-69, NaN, NaN, NaN, NaN, NaN}, mode = WAVE_DATA)
CHECK_EQUAL_VAR(GetSetVariable(str, "setvar_DataAcq_AutoBiasV"), -69)
End

static Function RTV_WorksWithMultipleHeadstages_preAcq(string device)

AFH_AddAnalysisParameter("ReachTargetVoltage_DA_0", "EnableIndexing", var = 0)

PGC_SetAndActivateControl(device, "slider_DataAcq_ActiveHeadstage", val = 1)

PGC_SetAndActivateControl(device, "check_DataAcq_AutoBias", val = 1)
PGC_SetAndActivateControl(device, "setvar_DataAcq_AutoBiasV", val = -70)

PGC_SetAndActivateControl(device, "slider_DataAcq_ActiveHeadstage", val = 2)

PGC_SetAndActivateControl(device, "check_DataAcq_AutoBias", val = 1)
PGC_SetAndActivateControl(device, "setvar_DataAcq_AutoBiasV", val = -70)
End

// UTF_TD_GENERATOR DeviceNameGeneratorMD1
static Function RTV_WorksWithMultipleHeadstages([string str])

STRUCT DAQSettings s

InitDAQSettingsFromString(s, "MD1_RA1_I0_L0_BKG1_DB0" + \
"__HS2_DA0_AD0_CM:IC:_ST:ReachTargetVoltage_DA_0:" + \
"__HS1_DA1_AD1_CM:IC:_ST:ReachTargetVoltage_DA_0:")

AcquireData_NG(s, str)
End

static Function RTV_WorksWithMultipleHeadstages_REENTRY([string str])

variable sweepNo

CHECK_EQUAL_VAR(GetSetVariable(str, "SetVar_Sweep"), 6)

sweepNo = AFH_GetLastSweepAcquired(str)
CHECK_EQUAL_VAR(sweepNo, 5)

[WAVE deltaI, WAVE deltaV, WAVE resistance, WAVE resistanceErr, WAVE autobiasFromDialog] = GetLBNEntries_IGNORE(str, sweepNo, 1)

CHECK_WAVE(deltaI, NUMERIC_WAVE)
CHECK_WAVE(deltaV, NUMERIC_WAVE)
CHECK_WAVE(resistance, NUMERIC_WAVE)
CHECK_WAVE(resistanceErr, NUMERIC_WAVE)
CHECK_WAVE(autobiasFromDialog, NULL_WAVE)

[WAVE deltaI, WAVE deltaV, WAVE resistance, WAVE resistanceErr, WAVE autobiasFromDialog] = GetLBNEntries_IGNORE(str, sweepNo, 2)

CHECK_WAVE(deltaI, NUMERIC_WAVE)
CHECK_WAVE(deltaV, NUMERIC_WAVE)
CHECK_WAVE(resistance, NUMERIC_WAVE)
CHECK_WAVE(resistanceErr, NUMERIC_WAVE)
CHECK_WAVE(autobiasFromDialog, NULL_WAVE)
End
Binary file modified Packages/tests/_2017_09_01_192934-compressed.nwb
Binary file not shown.

0 comments on commit 10f81b5

Please sign in to comment.