From 0873c5ee10bd1c3e11338498d32e1510890a5268 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Tue, 16 Jul 2024 18:07:58 +0200 Subject: [PATCH] PSQ_DS_AdaptiveIsFinished: Fix requirement for multiple f-I slope QC matches We actually want to ignore failing baseline QC in between. Broken since b2fe42f4 (PSQ_DAScale: Revise adaptive suprathreshold mode, 2024-04-01). --- .../MIES/MIES_AnalysisFunctions_PatchSeq.ipf | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf index 0cb644bcdb..312676b289 100644 --- a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf +++ b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf @@ -2669,8 +2669,8 @@ End static Function PSQ_DS_AdaptiveIsFinished(string device, variable sweepNo, variable headstage, variable numSweepsWithSaturation) - string key - variable measuredAllFutureDAScales + string key + variable measuredAllFutureDAScales, numFound, i, numSweeps WAVE numericalValues = GetLBNumericalValues(device) @@ -2702,12 +2702,28 @@ static Function PSQ_DS_AdaptiveIsFinished(string device, variable sweepNo, varia return 0 endif - MatrixOP/FREE passedAndSlopeReached = sweepPassed && fISlopeReached + // we want numSweepsWithSaturation sweeps with passing f-I slope QC and sweep QC + // and there should not be sweeps with failing f-I slope QC in between + numSweeps = DimSize(sweepPassed, ROWS) + for(i = 0; i < numSweeps; i += 1) + + if(!sweepPassed[i]) + continue + endif + + // sweeps have QC passing below + + if(!fiSlopeReached[i]) + numFound = 0 + continue + endif + + numFound += 1 + endfor - Make/FREE/N=(numSweepsWithSaturation)/I/B match = 1 - FindSequence/I=match passedAndSlopeReached + ASSERT(!(numFound > numSweepsWithSaturation), "Done too many sweeps") - return V_Value >= 0 + return numFound == numSweepsWithSaturation End static Function [WAVE apfreqRhSuAd, WAVE DAScalesRhSuAd, WAVE/Z apfreqCurrentSCI, WAVE/Z DAScaleCurrentSCI] PSQ_DS_GetAPFreqAndDaScales(WAVE numericalValues, WAVE textualValues, variable sweepNo, variable headstage)