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)