From f7458471a2cf33b8afeaab8c6173522a6d2f9cf4 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 5 Aug 2024 22:04:31 +0200 Subject: [PATCH] changes --- Packages/MIES/MIES_AnalysisFunctions.ipf | 6 +- .../MIES_AnalysisFunctions_MultiPatchSeq.ipf | 9 +-- ...isFunctions_MultiPatchSeq_SpikeControl.ipf | 14 ++-- .../MIES/MIES_AnalysisFunctions_PatchSeq.ipf | 69 +++++++++++++------ Packages/MIES/MIES_Constants.ipf | 2 +- 5 files changed, 68 insertions(+), 32 deletions(-) diff --git a/Packages/MIES/MIES_AnalysisFunctions.ipf b/Packages/MIES/MIES_AnalysisFunctions.ipf index 32baaf10f3..0b669bdf7d 100644 --- a/Packages/MIES/MIES_AnalysisFunctions.ipf +++ b/Packages/MIES/MIES_AnalysisFunctions.ipf @@ -1310,6 +1310,9 @@ Function ComplainOutOfRangeDAScale(string device, variable sweepNo, variable ana switch(anaFuncType) case PSQ_CHIRP: case PSQ_RAMP: + case PSQ_DA_SCALE: + case PSQ_SQUARE_PULSE: + case PSQ_RHEOBASE: WAVE result = LBN_GetNumericWave() result[0, NUM_HEADSTAGES - 1] = (statusHS[p] == 1) key = CreateAnaFuncLBNKey(anaFuncType, PSQ_FMT_LBN_DASCALE_OOR) @@ -1317,12 +1320,13 @@ Function ComplainOutOfRangeDAScale(string device, variable sweepNo, variable ana break case MSQ_FAST_RHEO_EST: case MSQ_DA_SCALE: + case SC_SPIKE_CONTROL: WAVE result = LBN_GetNumericWave() result[0, NUM_HEADSTAGES - 1] = (statusHS[p] == 1) key = CreateAnaFuncLBNKey(anaFuncType, MSQ_FMT_LBN_DASCALE_OOR) ED_AddEntryToLabnotebook(device, key, result, overrideSweepNo = sweepNo, unit = LABNOTEBOOK_BINARY_UNIT) break - case INVALID_ANALYSIS_FUNCTION: + case INVALID_ANALYSIS_FUNCTION: // ReachTargetVoltage // do nothing break default: diff --git a/Packages/MIES/MIES_AnalysisFunctions_MultiPatchSeq.ipf b/Packages/MIES/MIES_AnalysisFunctions_MultiPatchSeq.ipf index 63915f499d..d51189f25e 100644 --- a/Packages/MIES/MIES_AnalysisFunctions_MultiPatchSeq.ipf +++ b/Packages/MIES/MIES_AnalysisFunctions_MultiPatchSeq.ipf @@ -443,7 +443,7 @@ End /// Searches in the complete SCI and assumes that the entries are either 0/1/NaN. /// /// @todo merge with LBN functions once these are reworked. -static Function MSQ_GetLBNEntryForHSSCIBool(numericalValues, sweepNo, type, str, headstage) +Function MSQ_GetLBNEntryForHSSCIBool(numericalValues, sweepNo, type, str, headstage) WAVE numericalValues variable sweepNo, type string str @@ -1216,7 +1216,8 @@ Function MSQ_DAScale(device, s) endif key = CreateAnaFuncLBNKey(MSQ_DA_SCALE, MSQ_FMT_LBN_DASCALE_OOR, query = 1) - Make/N=(NUM_HEADSTAGES)/FREE DAScaleOOR = MSQ_GetLBNEntryForHSSCIBool(numericalValues, s.sweepNo, MSQ_FAST_RHEO_EST, MSQ_FMT_LBN_DASCALE_OOR, p) + Make/N=(NUM_HEADSTAGES)/FREE DAScaleOOR = MSQ_GetLBNEntryForHSSCIBool(numericalValues, s.sweepNo, \ + MSQ_FAST_RHEO_EST, MSQ_FMT_LBN_DASCALE_OOR, p) WAVE values = LBN_GetNumericWave() values[INDEP_HEADSTAGE] = Sum(DAScaleOOR) == 0 @@ -1269,11 +1270,11 @@ Function MSQ_DAScale(device, s) index = mod(DAScalesIndex[i], DimSize(DAScales, ROWS)) - limitsCheck = (s.eventType == POST_SWEEP_EVENT) + limitsCheck = (s.eventType == POST_SWEEP_EVENT) retCheckDAScale = 0 ASSERT(isFinite(daScaleOffset[i]), "DAScale offset is non-finite") - retCheckDAScale = SetDAScale(device, i, s.sweepNo, absolute = (DAScales[index] + daScaleOffset[i]) * PICO_TO_ONE, limitsCheck = limitsCheck) + retCheckDAScale = SetDAScale(device, i, s.sweepNo, absolute = (DAScales[index] + daScaleOffset[i]) * PICO_TO_ONE, limitsCheck = limitsCheck) DAScalesIndex[i] += 1 if(limitsCheck && retCheckDAScale) diff --git a/Packages/MIES/MIES_AnalysisFunctions_MultiPatchSeq_SpikeControl.ipf b/Packages/MIES/MIES_AnalysisFunctions_MultiPatchSeq_SpikeControl.ipf index 6c0ab19830..b60348e78a 100644 --- a/Packages/MIES/MIES_AnalysisFunctions_MultiPatchSeq_SpikeControl.ipf +++ b/Packages/MIES/MIES_AnalysisFunctions_MultiPatchSeq_SpikeControl.ipf @@ -151,10 +151,11 @@ End /// @brief Return pass/fail state of the sweep /// -/// This is true iff we have for the current stimulus set sweep count a passing headstage +/// This is true iff we have for the current stimulus set sweep count a passing +/// headstage and did not have a SetDAScale/SetDAScaleModOp out-of-range condition. static Function SC_GetSweepPassed(string device, variable sweepNo) - variable setSweepCount + variable setSweepCount, setSweepQC WAVE headstageQCTotalPerSweepCount = SC_GetHeadstageQCForSetCount(device, sweepNo) @@ -162,11 +163,12 @@ static Function SC_GetSweepPassed(string device, variable sweepNo) setSweepCount = SC_GetSetSweepCount(numericalValues, sweepNo) FindValue/RMD=[][setSweepCount]/V=(0.0) headstageQCTotalPerSweepCount + setSweepQC = (V_Value == -1) - // TODO - key = CreateAnaFuncLBNKey(SC_SPIKE_CONTROL, PSQ_FMT_LBN_DASCALE_OOR, query = 1) + Make/N=(NUM_HEADSTAGES)/FREE DAScaleOOR = MSQ_GetLBNEntryForHSSCIBool(numericalValues, s.sweepNo, \ + MSQ_FAST_RHEO_EST, MSQ_FMT_LBN_DASCALE_OOR, p) - return V_Value == -1 + return setSweepQC && Sum(DAScaleOOR) == 0 End /// @brief Return 1 if we are currently acquiring the last sweep in the stimulus set, 0 otherwise @@ -789,7 +791,7 @@ static Function SC_ReactToQCFailures(string device, variable sweepNo, string par endif if(retCheckDAScale) - ComplainOutOfRangeDAScale(device, s.sweepNo, PSQ_RAMP) + ComplainOutOfRangeDAScale(device, s.sweepNo, SC_SPIKE_CONTROL) endif End diff --git a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf index 7a106abc32..f1c2f9c112 100644 --- a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf +++ b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf @@ -2911,6 +2911,13 @@ static Function PSQ_DS_AdaptiveIsFinished(string device, variable sweepNo, varia endif endif + key = CreateAnaFuncLBNKey(PSQ_DA_SCALE, PSQ_FMT_LBN_DASCALE_OOR, query = 1) + WAVE/Z DAScaleOOR = GetLastSetting(numericalValues, sweepNo, key, UNKNOWN_MODE) + + if(WaveExists(DAScaleOOR) && DAScaleOOR[headstage]) + return 1 + endif + [WAVE sweepPassed, emptySCI] = PSQ_DS_GetLabnotebookData(device, sweepNo, headstage, PSQ_DS_SWEEP_PASS, fromRhSuAd = fromRhSuAd) if(DimSize(sweepPassed, ROWS) < numSweepsWithSaturation) @@ -3677,7 +3684,7 @@ Function PSQ_DAScale(device, s) variable sweepPassed, setPassed, length, minLength, reachedFinalSlope, fitOffset, fitSlope, apfreq, enoughFIPointsPassedQC variable minimumSpikeCount, maximumSpikeCount, daScaleModifierParam, measuredAllFutureDAScales, fallbackDAScaleRangeFac variable sweepsInSet, passesInSet, acquiredSweepsInSet, multiplier, asyncAlarmPassed, supraStimsetCycle - variable daScaleStepMinNorm, daScaleStepMaxNorm, maxSlope, validFit + variable daScaleStepMinNorm, daScaleStepMaxNorm string msg, stimset, key, opMode, offsetOp, textboxString, str, errMsg variable daScaleOffset variable finalSlopePercent = NaN @@ -4183,9 +4190,13 @@ Function PSQ_DAScale(device, s) enoughSweepsPassed = PSQ_NumPassesInSet(numericalValues, PSQ_DA_SCALE, s.sweepNo, s.headstage) >= numSweepsPass + key = CreateAnaFuncLBNKey(PSQ_DA_SCALE, PSQ_FMT_LBN_DASCALE_OOR, query = 1) + WAVE/Z DAScaleOOR = GetLastSetting(numericalValues, s.sweepNo, key, UNKNOWN_MODE) + DAScaleOORQC = !WaveExists(DAScaleOOR) + strswitch(opMode) case PSQ_DS_SUB: - setPassed = enoughSweepsPassed + setPassed = enoughSweepsPassed && DAScaleOORQC break case PSQ_DS_SUPRA: if(IsFinite(finalSlopePercent)) @@ -4193,12 +4204,12 @@ Function PSQ_DAScale(device, s) WAVE fISlopeReached = GetLastSettingIndepEachSCI(numericalValues, s.sweepNo, key, s.headstage, UNKNOWN_MODE) ASSERT(WaveExists(fISlopeReached), "Missing fiSlopeReached LBN entry") - setPassed = enoughSweepsPassed && Sum(fISlopeReached) > 0 + setPassed = enoughSweepsPassed && Sum(fISlopeReached) > 0 && DAScaleOORQC else sprintf msg, "Final slope percentage not present\r" DEBUGPRINT(msg) - setPassed = enoughSweepsPassed + setPassed = enoughSweepsPassed && DAScaleOORQC endif break case PSQ_DS_ADAPT: @@ -4265,7 +4276,16 @@ Function PSQ_DAScale(device, s) ASSERT(0, "Invalid case") break endswitch - SetDAScale(device, i, s.sweepNo, absolute = DAScale * PICO_TO_ONE) + + limitCheck = (s.eventType == POST_SWEEP_EVENT) + retCheckDAScale = 0 + + retCheckDAScale = SetDAScale(device, i, s.sweepNo, absolute = DAScale * PICO_TO_ONE, limitCheck = limitCheck) + + if(limitCheck && retCheckDAScale) + ComplainOutOfRangeDAScale(device, s.sweepNo, MSQ_DA_SCALE) + break + endif endif endfor endif @@ -4363,7 +4383,7 @@ Function PSQ_SquarePulse(device, s) STRUCT AnalysisFunction_V3 &s variable stepsize, DAScale, totalOnsetDelay, setPassed, sweepPassed, multiplier - variable val, samplingFrequencyPassed, asyncAlarmPassed, ret + variable val, samplingFrequencyPassed, asyncAlarmPassed, ret, retCheckDAScale string key, msg multiplier = AFH_GetAnalysisParamNumerical("SamplingMultiplier", s.params) @@ -4407,7 +4427,7 @@ Function PSQ_SquarePulse(device, s) PGC_SetAndActivateControl(device, "check_Settings_ITITP", val = 0) PSQ_StoreStepSizeInLBN(device, PSQ_SQUARE_PULSE, s.sweepNo, PSQ_SP_INIT_AMP_p100) - SetDAScale(device, s.headstage, s.sweepNo, absolute = PSQ_SP_INIT_AMP_p100) + SetDAScale(device, s.headstage, s.sweepNo, absolute = PSQ_SP_INIT_AMP_p100, limitCheck = 0) return 0 @@ -4460,7 +4480,7 @@ Function PSQ_SquarePulse(device, s) RA_SkipSweeps(device, Inf, SWEEP_SKIP_AUTO, limitToSetBorder = 1) endif elseif(CheckIfClose(stepSize, PSQ_SP_INIT_AMP_m50)) - SetDAScale(device, s.headstage, s.sweepNo, absolute = DAScale + stepsize) + retCheckDAScale = SetDAScale(device, s.headstage, s.sweepNo, absolute = DAScale + stepsize) elseif(CheckIfClose(stepSize, PSQ_SP_INIT_AMP_p10)) WAVE value = LBN_GetNumericWave() value[INDEP_HEADSTAGE] = DAScale @@ -4475,8 +4495,8 @@ Function PSQ_SquarePulse(device, s) endif elseif(CheckIfClose(stepSize, PSQ_SP_INIT_AMP_p100)) PSQ_StoreStepSizeInLBN(device, PSQ_SQUARE_PULSE, s.sweepNo, PSQ_SP_INIT_AMP_m50) - stepsize = PSQ_SP_INIT_AMP_m50 - SetDAScale(device, s.headstage, s.sweepNo, absolute = DAScale + stepsize) + stepsize = PSQ_SP_INIT_AMP_m50 + retCheckDAScale = SetDAScale(device, s.headstage, s.sweepNo, absolute = DAScale + stepsize) else ASSERT(0, "Unknown stepsize") endif @@ -4492,7 +4512,12 @@ Function PSQ_SquarePulse(device, s) ASSERT(0, "Unknown stepsize") endif - SetDAScale(device, s.headstage, s.sweepNo, absolute = DAScale + stepsize) + retCheckDAScale = SetDAScale(device, s.headstage, s.sweepNo, absolute = DAScale + stepsize) + endif + + if(retCheckDAScale) + ComplainOutOfRangeDAScale(device, s.sweepNo, PSQ_RAMP) + sweepPassed = 0 endif sprintf msg, "Sweep has %s\r", ToPassFail(sweepPassed) @@ -4626,7 +4651,7 @@ Function PSQ_Rheobase(device, s) variable DAScale, val, numSweeps, currentSweepHasSpike, lastSweepHasSpike, setPassed, diff variable baselineQCPassed, finalDAScale, initialDAScale, stepSize, previousStepSize, samplingFrequencyPassed - variable totalOnsetDelay, asyncAlarmPassed + variable totalOnsetDelay, asyncAlarmPassed, retCheckDAScale variable i, ret, numSweepsWithSpikeDetection, sweepNoFound, length, minLength, multiplier, chunk string key, msg @@ -4702,7 +4727,7 @@ Function PSQ_Rheobase(device, s) endif endif - SetDAScale(device, s.headstage, s.sweepNo, absolute = finalDAScale) + SetDAScale(device, s.headstage, s.sweepNo, absolute = finalDAScale, limitCheck = 0) return 0 @@ -4891,7 +4916,16 @@ Function PSQ_Rheobase(device, s) break endif - SetDAScale(device, s.headstage, s.sweepNo, absolute = DAScale) + retCheckDAScale = SetDAScale(device, s.headstage, s.sweepNo, absolute = DAScale) + + if(retCheckDAScale) + ComplainOutOfRangeDAScale(device, s.sweepNo, PSQ_RHEOBASE) + + WAVE result = LBN_GetNumericWave() + key = CreateAnaFuncLBNKey(PSQ_RHEOBASE, PSQ_FMT_LBN_SET_PASS) + result[INDEP_HEADSTAGE] = 0 + ED_AddEntryToLabnotebook(device, key, result, unit = LABNOTEBOOK_BINARY_UNIT) + endif break case POST_SET_EVENT: WAVE numericalValues = GetLBNumericalValues(device) @@ -5143,12 +5177,7 @@ Function PSQ_Ramp(device, s) PGC_SetAndActivateControl(device, "check_Settings_ITITP", val = 1) PGC_SetAndActivateControl(device, "Check_Settings_InsertTP", val = 1) - retCheckDAScale = SetDAScale(device, s.headstage, s.sweepNo, absolute = PSQ_RA_DASCALE_DEFAULT * PICO_TO_ONE) - - if(retCheckDAScale) - ComplainOutOfRangeDAScale(device, s.sweepNo, PSQ_RAMP) - return 1 - endif + SetDAScale(device, s.headstage, s.sweepNo, absolute = PSQ_RA_DASCALE_DEFAULT * PICO_TO_ONE, limitCheck = 0) return 0 diff --git a/Packages/MIES/MIES_Constants.ipf b/Packages/MIES/MIES_Constants.ipf index 4eccdfada8..57cbbf5b08 100644 --- a/Packages/MIES/MIES_Constants.ipf +++ b/Packages/MIES/MIES_Constants.ipf @@ -1419,7 +1419,7 @@ StrConstant MSQ_FMT_LBN_SPIKE_COUNTS_STATE = "%s Spike counts state" StrConstant MSQ_FMT_LBN_IDEAL_SPIKE_COUNTS = "%s Ideal spike counts" StrConstant MSQ_FMT_LBN_RERUN_TRIAL = "%s Rerun Trials" StrConstant MSQ_FMT_LBN_RERUN_TRIAL_EXC = "%s Rerun Trials exceeded" -StrConstant PSQ_FMT_LBN_DASCALE_OOR = "%s DAScale out of range" +StrConstant MSQ_FMT_LBN_DASCALE_OOR = "%s DAScale out of range" /// @} /// @name Workaround flags for CreateAnaFuncLBNKey()