From daec7e13ed0910ef8735139c28108783fab8f8e4 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Tue, 26 Nov 2024 22:22:20 +0100 Subject: [PATCH] changes --- .../MIES/MIES_AnalysisFunctions_PatchSeq.ipf | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf index 5edb884f35..9e2cccc229 100644 --- a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf +++ b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf @@ -1613,20 +1613,20 @@ static Function PSQ_IsSuitableFailingAdaptiveSweep(string device, variable sweep opMode = GetLastSettingTextIndep(textualValues, sweepNo, key, UNKNOWN_MODE) if(cmpstr(opMode, PSQ_DS_ADAPT)) - return INVALID_SWEEP_NUMBER + return 0 endif key = CreateAnaFuncLBNKey(PSQ_DA_SCALE, PSQ_FMT_LBN_SET_PASS, query = 1) setQC = GetLastSettingIndep(numericalValues, sweepNo, key, UNKNOWN_MODE, defValue = 0) if(setQC) - return INVALID_SWEEP_NUMBER + return 0 endif WAVE/T previousAnalysisParams = GetLastSetting(textualValues, sweepNo, ANALYSIS_FUNCTION_PARAMS_LBN, DATA_ACQUISITION_MODE) if(cmpstr(previousAnalysisParams[headstage], params)) - return INVALID_SWEEP_NUMBER + return 0 endif currentAutoBiasV = DAG_GetNumericalValue(device, "setvar_DataAcq_AutoBiasV") @@ -1634,10 +1634,10 @@ static Function PSQ_IsSuitableFailingAdaptiveSweep(string device, variable sweep WAVE autoBiasV = GetLastSetting(numericalValues, sweepNo, "Autobias Vcom", DATA_ACQUISITION_MODE) if(!CheckIfClose(autoBiasV[headstage], currentAutoBiasV, tol = 1e-2)) - return INVALID_SWEEP_NUMBER + return 0 endif - return sweepNo + return 1 End /// @brief Return the previously acquired sweep numbers @@ -1650,7 +1650,7 @@ End /// - within the reach of FailingAdaptiveSCIRange analysis parameter static Function/WAVE PSQ_GetPreviousSetQCFailingAdaptive(string device, variable headstage, string params) - variable sweepNo, failingAdaptiveSCIRange + variable sweepNo, failingAdaptiveSCIRange, i sweepNo = AFH_GetLastSweepAcquired(device) @@ -1661,21 +1661,40 @@ static Function/WAVE PSQ_GetPreviousSetQCFailingAdaptive(string device, variable failingAdaptiveSCIRange = AFH_GetAnalysisParamNumerical("FailingAdaptiveSCIRange", params, defValue = FAILING_ADAPTIVE_SCI_RANGE_DEFAULT) if(failingAdaptiveSCIRange == 0) - // feature turned off + // turned off return {INVALID_SWEEP_NUMBER} endif WAVE numericalValues = GetLBNumericalValues(device) + // at most as many matches as the last acquired sweep number + Make/FREE/N=(sweepNo) sweeps = NaN + // i == 0: previous SCI // i == x: x SCIs before + sciSweepNo = sweepNo for(i = 0; i < failingAdaptiveSCIRange; i++) - WAVE/Z sweepsSCI = AFH_GetSweepsFromSameSCI(numericalValues, sweepNo, headstage) + WAVE/Z sweepsSCI = AFH_GetSweepsFromSameSCI(numericalValues, sciSweepNo, headstage) + + if(!WaveExists(sweepsSCI)) + break + endif + + sciSweepNo = WaveMin(sweepsSCI) + if(!PSQ_IsSuitableFailingAdaptiveSweep(device, sciSweepNo, headstage, params)) + break + endif + + sweeps[idx] = sciSweepNo + idx++ + + // step one SCI before + sciSweepNo -= 1 endfor - // TODO + WAVE/Z sweepsClean = ZapNaNs(sweeps) - PSQ_IsSuitableFailingAdaptiveSweep(device, sweepNo, headstage, params) + return sweepsClean End /// @brief Return the truth that str is a valid PSQ_DAScale operation mode