From 1e67599693ef241a7ca39f3f639b217b4072c2ef Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Wed, 27 Nov 2024 15:49:28 +0100 Subject: [PATCH 1/5] JWN_SetWaveInWaveNote: Enhance assertion messages This makes the error clearer. --- Packages/MIES/MIES_JSONWaveNotes.ipf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/MIES/MIES_JSONWaveNotes.ipf b/Packages/MIES/MIES_JSONWaveNotes.ipf index 56dba54cda..d07adaf021 100644 --- a/Packages/MIES/MIES_JSONWaveNotes.ipf +++ b/Packages/MIES/MIES_JSONWaveNotes.ipf @@ -257,8 +257,8 @@ threadsafe Function JWN_SetWaveInWaveNote(WAVE wv, string jsonPath, WAVE noteWav variable jsonID, idx string jsonPathArray - ASSERT_TS(WaveExists(wv), "Missing wave") - ASSERT_TS(WaveExists(noteWave), "Missing noteWave") + ASSERT_TS(WaveExists(wv), "Missing wave to attach JSON wave note") + ASSERT_TS(WaveExists(noteWave), "Missing wave to add into the JSON wave note") ASSERT_TS(!IsEmpty(jsonPath), "Empty jsonPath") From 70a72187b4c86eabfcb7fb6e64a92fd0d9ac1be9 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Tue, 26 Nov 2024 20:59:25 +0100 Subject: [PATCH 2/5] PSQ_DAScale (Adapt): Allow to look further back for passing adaptive sweeps The new FailingAdaptiveSCIRange analysis parameter allows to tune the formerly hardcoded (1) number of SCIs we look back for failing adaptive sets. It defaults to 1, can be turned off with 0 and allows inf for always taking all SCIs into account. --- .../MIES/MIES_AnalysisFunctions_PatchSeq.ipf | 128 +++++++--- Packages/MIES/MIES_Constants.ipf | 2 +- .../UTF_PatchSeqDAScale_Adapt.ipf | 219 +++++++++++++++--- 3 files changed, 286 insertions(+), 63 deletions(-) diff --git a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf index 5d429afc15..40db3dddef 100644 --- a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf +++ b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf @@ -1117,7 +1117,7 @@ End /// - "PassingSupraSweep": Sweep with passing supra set QC /// - "PassingRheobaseSweep": Sweep with passing rheobase set QC /// - "PassingRhSuAdSweeps": List of passing rheobase/supra/adaptive SCI sweeps -/// - "FailingAdaptiveSweep": Failing adaptive sweep, the very last one, of the previous SCI (*written* by PSQ_DaScale) +/// - "PassingAdaptiveSweepFromFailingSet": Passing adaptive sweeps from failing sets from previous SCIs (*written* by PSQ_DaScale) /// /// #PSQ_CHIRP: /// @@ -1601,45 +1601,39 @@ static Function PSQ_GetLastPassingLongRHSweep(string device, variable headstage, return INVALID_SWEEP_NUMBER End -/// @brief Return the previously acquired sweep number +/// @brief Return the truth that sweepNo/headstage is from an adaptive SCI with special properties /// -/// But only when it fullfills all of the following conditions: +/// Special properties: /// - DAScale supra adaptive analysis function was run /// - failing set QC /// - all analysis parameters are the same /// - used same targetV autobias value -static Function PSQ_GetPreviousSetQCFailingAdaptive(string device, variable headstage, string params) +static Function PSQ_IsSuitableFailingAdaptiveSweep(string device, variable sweepNo, variable headstage, string params) - variable sweepNo, setQC, currentAutoBiasV + variable setQC, currentAutoBiasV string key, opMode - sweepNo = AFH_GetLastSweepAcquired(device) - - if(!IsValidSweepNumber(sweepNo)) - return INVALID_SWEEP_NUMBER - endif - WAVE numericalValues = GetLBNumericalValues(device) WAVE textualValues = GetLBTextualValues(device) key = CreateAnaFuncLBNKey(PSQ_DA_SCALE, PSQ_FMT_LBN_DA_OPMODE, query = 1) - opMode = GetLastSettingTextIndep(textualValues, sweepNo, key, UNKNOWN_MODE) + opMode = GetLastSettingTextIndepSCI(numericalValues, textualValues, sweepNo, key, headstage, 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) + setQC = GetLastSettingIndepSCI(numericalValues, sweepNo, key, headstage, 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) + WAVE/T previousAnalysisParams = GetLastSettingTextSCI(numericalValues, textualValues, sweepNo, ANALYSIS_FUNCTION_PARAMS_LBN, headstage, DATA_ACQUISITION_MODE) if(cmpstr(previousAnalysisParams[headstage], params)) - return INVALID_SWEEP_NUMBER + return 0 endif currentAutoBiasV = DAG_GetNumericalValue(device, "setvar_DataAcq_AutoBiasV") @@ -1647,10 +1641,66 @@ static Function PSQ_GetPreviousSetQCFailingAdaptive(string device, variable head 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 1 +End + +/// @brief Return passing sweeps from failing adaptive sets +/// +/// Look into as many previous SCIs as given in the FailingAdaptiveSCIRange analysis parameter to return the +/// passing sweeps where the SCI fullfills the properties listed at @ref PSQ_IsSuitableFailingAdaptiveSweep() +static Function/WAVE PSQ_GetPreviousSetQCFailingAdaptive(string device, variable headstage, string params) + + variable sweepNo, failingAdaptiveSCIRange, i, sciSweepNo + + sweepNo = AFH_GetLastSweepAcquired(device) + + if(!IsValidSweepNumber(sweepNo)) + return $"" + endif + + failingAdaptiveSCIRange = AFH_GetAnalysisParamNumerical("FailingAdaptiveSCIRange", params, defValue = FAILING_ADAPTIVE_SCI_RANGE_DEFAULT) + + if(failingAdaptiveSCIRange == 0) + // turned off + return $"" endif - return sweepNo + WAVE numericalValues = GetLBNumericalValues(device) + + // i == x: x SCIs earlier + sciSweepNo = sweepNo + for(i = 0; i < failingAdaptiveSCIRange; i++) + WAVE/Z sweepsSCI = AFH_GetSweepsFromSameSCI(numericalValues, sciSweepNo, headstage) + + if(!WaveExists(sweepsSCI)) + break + endif + + sciSweepNo = WaveMin(sweepsSCI) + if(!PSQ_IsSuitableFailingAdaptiveSweep(device, sciSweepNo, headstage, params)) + continue + endif + + WAVE/ZZ passingAdaptiveSweeps = PSQ_DS_GetPassingDAScaleSweeps(numericalValues, sciSweepNo, headstage) + + if(WaveExists(passingAdaptiveSweeps)) + Concatenate/FREE/NP=(ROWS) {passingAdaptiveSweeps}, sweeps + endif + + sciSweepNo -= 1 + endfor + + if(!WaveExists(sweeps)) + return $"" + endif + + // ensure that the sweeps are ordered ascending + Sort sweeps, sweeps + + return sweeps End /// @brief Return the truth that str is a valid PSQ_DAScale operation mode @@ -3014,19 +3064,20 @@ static Function/WAVE PSQ_DS_FilterPassingData(WAVE/Z data, WAVE/Z booleanQC, [va return passingData End -static Function/WAVE PSQ_DS_GetPassingDAScaleSweeps(WAVE numericalValues, variable passingSweep, variable headstage) +/// @brief Return a wave with all passing sweeps from the SCI containing sweepNo/headstage +static Function/WAVE PSQ_DS_GetPassingDAScaleSweeps(WAVE numericalValues, variable sweepNo, variable headstage) string key - if(!IsValidSweepNumber(passingSweep)) + if(!IsValidSweepNumber(sweepNo)) return $"" endif - WAVE/Z sweeps = AFH_GetSweepsFromSameSCI(numericalValues, passingSweep, headstage) + WAVE/Z sweeps = AFH_GetSweepsFromSameSCI(numericalValues, sweepNo, headstage) ASSERT(WaveExists(sweeps), "Missing sweeps from passing DAScale SCI") key = CreateAnaFuncLBNKey(PSQ_DA_SCALE, PSQ_FMT_LBN_SWEEP_PASS, query = 1) - WAVE sweepsQC = GetLastSettingIndepEachSCI(numericalValues, passingSweep, key, headstage, UNKNOWN_MODE) + WAVE sweepsQC = GetLastSettingIndepEachSCI(numericalValues, sweepNo, key, headstage, UNKNOWN_MODE) WAVE/Z passingSweeps = PSQ_DS_FilterPassingData(sweeps, sweepsQC) @@ -3059,7 +3110,7 @@ End static Function/WAVE PSQ_DS_GetPassingRhSuAdSweepsAndStoreInLBN(string device, variable sweepNo, variable headstage, string params) - variable passingSupraSweep, passingRheobaseSweep, failingAdaptiveSweep + variable passingSupraSweep, passingRheobaseSweep string key passingSupraSweep = PSQ_GetLastPassingDAScale(device, headstage, PSQ_DS_SUPRA) @@ -3078,12 +3129,16 @@ static Function/WAVE PSQ_DS_GetPassingRhSuAdSweepsAndStoreInLBN(string device, v return $"" endif - failingAdaptiveSweep = PSQ_GetPreviousSetQCFailingAdaptive(device, headstage, params) + WAVE/ZZ passingAdSweepsFailSet = PSQ_GetPreviousSetQCFailingAdaptive(device, headstage, params) + + if(!WaveExists(passingAdSweepsFailSet)) + Make/FREE/N=0 passingAdSweepsFailSet + endif if(TestOverrideActive()) WAVE overrideResults = GetOverrideResults() WAVE sweeps = JWN_GetNumericWaveFromWaveNote(overrideResults, "/PassingRhSuAdSweeps") - JWN_SetNumberInWaveNote(overrideResults, "/FailingAdaptiveSweep", failingAdaptiveSweep) + JWN_SetWaveInWaveNote(overrideResults, "/PassingAdaptiveSweepFromFailingSet", passingAdSweepsFailSet) // consistency checks WAVE DAScalesRhSuAd = JWN_GetNumericWaveFromWaveNote(overrideResults, "/DAScalesRhSuAd") @@ -3093,15 +3148,10 @@ static Function/WAVE PSQ_DS_GetPassingRhSuAdSweepsAndStoreInLBN(string device, v else WAVE numericalValues = GetLBNumericalValues(device) - WAVE passingRheobaseSweeps = PSQ_DS_GetPassingRheobaseSweeps(numericalValues, passingRheobaseSweep, headstage) - WAVE passingSupraSweeps = PSQ_DS_GetPassingDAScaleSweeps(numericalValues, passingSupraSweep, headstage) - WAVE/Z passingAdaptiveSweeps = PSQ_DS_GetPassingDAScaleSweeps(numericalValues, failingAdaptiveSweep, headstage) - - if(!WaveExists(passingAdaptiveSweeps)) - Make/N=0/FREE passingAdaptiveSweeps - endif + WAVE passingRheobaseSweeps = PSQ_DS_GetPassingRheobaseSweeps(numericalValues, passingRheobaseSweep, headstage) + WAVE passingSupraSweeps = PSQ_DS_GetPassingDAScaleSweeps(numericalValues, passingSupraSweep, headstage) - Concatenate/NP=(ROWS)/FREE {passingRheobaseSweeps, passingSupraSweeps, passingAdaptiveSweeps}, sweeps + Concatenate/NP=(ROWS)/FREE {passingRheobaseSweeps, passingSupraSweeps, passingAdSweepsFailSet}, sweeps endif WAVE/T RhSuAdSweepsLBN = LBN_GetTextWave() @@ -3401,6 +3451,7 @@ Function/S PSQ_DAScale_GetParams() "[DAScaleModifier:variable]," + \ "[DaScaleStepWidthMinMaxRatio:variable]," + \ "DAScales:wave," + \ + "[FailingAdaptiveSCIRange]," + \ "[FinalSlopePercent:variable]," + \ "[MaximumSpikeCount:variable]," + \ "[MinimumSpikeCount:variable]," + \ @@ -3439,6 +3490,9 @@ Function/S PSQ_DAScale_GetHelp(string name) return "DA Scale Factors in pA" case "AbsFrequencyMinDistance": return "Minimum absolute frequency distance for DAScale estimation. Only for \"AdaptiveSupra\"." + case "FailingAdaptiveSCIRange": + return "Number of stimset cycles (SCIs) we search backwards in time for failing Adaptive sets, defaults to 1. " \ + + "Set to 0 to turn it off and inf to look into all available SCIs. Only for \"AdaptiveSupra\"." case "MaxFrequencyChangePercent": return "The maximum allowed difference for the frequency for two consecutive measurements. " \ + "In case this value is overshot, we redo the measurement with a fitting DAScale in-between. " \ @@ -3513,6 +3567,12 @@ Function/S PSQ_DAScale_CheckParam(string name, STRUCT CheckParametersStruct &s) return "Invalid value" endif break + case "FailingAdaptiveSCIRange": + val = AFH_GetAnalysisParamNumerical(name, s.params) + if(!(IsNullOrPositiveAndFinite(val) || val == Inf)) + return "Invalid value" + endif + break case "NumInvalidSlopeSweepsAllowed": val = AFH_GetAnalysisParamNumerical(name, s.params) if(!(val >= 0 && val <= IDX_NumberOfSweepsInSet(s.setName))) diff --git a/Packages/MIES/MIES_Constants.ipf b/Packages/MIES/MIES_Constants.ipf index 74eb6a2f9a..8216a78403 100644 --- a/Packages/MIES/MIES_Constants.ipf +++ b/Packages/MIES/MIES_Constants.ipf @@ -1299,7 +1299,7 @@ Constant PSQ_DA_NUM_SWEEPS_SATURATION = 2 Constant PSQ_DA_NUM_INVALID_SLOPE_SWEEPS_ALLOWED = 3 Constant PSQ_DA_MAX_FREQUENCY_CHANGE_PERCENT = 20 Constant PSQ_DA_DASCALE_STEP_WITH_MIN_MAX_FACTOR = 3 - +Constant FAILING_ADAPTIVE_SCI_RANGE_DEFAULT = 1 ///@} /// @name PatchSeq Ramp diff --git a/Packages/tests/HardwareAnalysisFunctions/UTF_PatchSeqDAScale_Adapt.ipf b/Packages/tests/HardwareAnalysisFunctions/UTF_PatchSeqDAScale_Adapt.ipf index b9449dfd3a..7e18dd40ff 100644 --- a/Packages/tests/HardwareAnalysisFunctions/UTF_PatchSeqDAScale_Adapt.ipf +++ b/Packages/tests/HardwareAnalysisFunctions/UTF_PatchSeqDAScale_Adapt.ipf @@ -8,31 +8,32 @@ /// /// .. Column order: test overrides, labnotebook entries, analysis parameters /// -///============= ==================== ============================ ============================== ========================= ====================== ============================ ======================= ================================== ============ ==================== ================== ====================== ============================== ========== ============= ================= ========================= ============================== ============================== =========================== ============================= ========================= =================== -/// Test case Baseline chunk0 QC Baseline chunk [1, inf] QC Enough rheobase/supra sweeps Passing rheobase sweeps Passing supra sweeps Valid initial f-I slope QC Valid initial f-I fit Initial f-I data is dense enough Failed f-I Valid f-I slope QC Fit f-I slope QC Enough f-I points QC Measured all future DAScales Async QC Sampling QC SlopePercentage NumSweepsWithSaturation DAScaleRangeFactor NumInvalidSlopeSweepsAllowed MaxFrequencyChangePercent DaScaleStepWidthMinMaxRatio AbsFrequencyMinDistance SamplingFrequency -///============= ==================== ============================ ============================== ========================= ====================== ============================ ======================= ================================== ============ ==================== ================== ====================== ============================== ========== ============= ================= ========================= ============================== ============================== =========================== ============================= ========================= =================== -/// PS_DS_AD1 - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓ ✓ - ✓ def 2 def def 5 3 2 def -/// PS_DS_AD2 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 1 def def 25 3 2 def -/// PS_DS_AD2a ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 2 def def 25 3 2 def -/// PS_DS_AD2b ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 2 def def 25 1.5 2 def -/// PS_DS_AD3 [-,✓,✓] ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,✓,✓] [-,✓,✓] ✓ [✓,-,✓] ✓ ✓ def 2 def def 25 3 2 def -/// PS_DS_AD4 ✓ ✓ ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 2 def def 25 3 2 def -/// PS_DS_AD4a ✓ ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 2 def def 25 3 2 def -/// PS_DS_AD5 ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 2 def def 25 3 2 def -/// PS_DS_AD6 ✓ ✓ ✓ ✓ ✓ - ✓ ✓ ✓ - ✓ ✓ ✓ ✓ ✓ def 1 def def 25 3 2 def -/// PS_DS_AD7 ✓ ✓ ✓ ✓ ✓ - ✓ - ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 1 def def 10 1.1 2 def -/// PS_DS_AD8 ✓ ✓ ✓ ✓ ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 1 def def 25 3 2 def -/// PS_DS_AD9 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,-] [-,-] ✓ ✓ ✓ ✓ def 3 2 2 45 3 2 def -/// PS_DS_AD10 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓ - ✓ ✓ def 2 def def 25 1.2 2 def -/// PS_DS_AD11 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,-,✓] ✓ [-,-,✓] ✓ ✓ 60 1 1 1 45 1.2 2 def -/// PS_DS_AD12 [✓,-,✓,✓] ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,-,✓,✓] ✓ [-,✓-,,✓] ✓ ✓ def 2 def def 25 3 1.1 def -/// PS_DS_AD13 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - def 2 def def 25 3 0.5 def -/// PS_DS_AD14 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,✓ ] [-,✓ ] ✓ ✓ ✓ ✓ ✓ def 1 def def 25 3 2 def -/// PS_DS_AD15 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,✓ ] [-,✓ ] ✓ ✓ [-,-,✓] ✓ ✓ def 1 def def 25 3 2 def -/// PS_DS_AD16 ✓ [-,-,✓,-,✓] ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,-,✓,✓,✓] ✓ [✓,✓,-,✓,✓] ✓ ✓ def 2 def def 25 3 1.1 def -/// PS_DS_AD17 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓ ✓ ✓ ✓ def 2 def def 25 3 1.1 def -/// PS_DS_AD18 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓ ✓ ✓ ✓ def 3 def def 25 3 1.1 def -///============= ==================== ============================ ============================== ========================= ====================== ============================ ======================= ================================== ============ ==================== ================== ====================== ============================== ========== ============= ================= ========================= ============================== ============================== =========================== ============================= ========================= =================== +///============= ==================== ============================ ============================== ========================= ====================== ============================ ======================= ================================== ============ ==================== ================== ====================== ============================== ========== ============= ================= ========================= ============================== ============================== =========================== ============================= ========================= =================== ========================= +/// Test case Baseline chunk0 QC Baseline chunk [1, inf] QC Enough rheobase/supra sweeps Passing rheobase sweeps Passing supra sweeps Valid initial f-I slope QC Valid initial f-I fit Initial f-I data is dense enough Failed f-I Valid f-I slope QC Fit f-I slope QC Enough f-I points QC Measured all future DAScales Async QC Sampling QC SlopePercentage NumSweepsWithSaturation DAScaleRangeFactor NumInvalidSlopeSweepsAllowed MaxFrequencyChangePercent DaScaleStepWidthMinMaxRatio AbsFrequencyMinDistance SamplingFrequency FailingAdaptiveSCIRange +///============= ==================== ============================ ============================== ========================= ====================== ============================ ======================= ================================== ============ ==================== ================== ====================== ============================== ========== ============= ================= ========================= ============================== ============================== =========================== ============================= ========================= =================== ========================= +/// PS_DS_AD1 - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓ ✓ - ✓ def 2 def def 5 3 2 def def +/// PS_DS_AD1a ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓ ✓ [✓,-,✓] ✓ def 3 def def 5 3 2 def def +/// PS_DS_AD2 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 1 def def 25 3 2 def def +/// PS_DS_AD2a ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 2 def def 25 3 2 def def +/// PS_DS_AD2b ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 2 def def 25 1.5 2 def def +/// PS_DS_AD3 [-,✓,✓] ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,✓,✓] [-,✓,✓] ✓ [✓,-,✓] ✓ ✓ def 2 def def 25 3 2 def def +/// PS_DS_AD4 ✓ ✓ ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 2 def def 25 3 2 def def +/// PS_DS_AD4a ✓ ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 2 def def 25 3 2 def def +/// PS_DS_AD5 ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 2 def def 25 3 2 def def +/// PS_DS_AD6 ✓ ✓ ✓ ✓ ✓ - ✓ ✓ ✓ - ✓ ✓ ✓ ✓ ✓ def 1 def def 25 3 2 def def +/// PS_DS_AD7 ✓ ✓ ✓ ✓ ✓ - ✓ - ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 1 def def 10 1.1 2 def def +/// PS_DS_AD8 ✓ ✓ ✓ ✓ ✓ ✓ - ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ def 1 def def 25 3 2 def def +/// PS_DS_AD9 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,-] [-,-] ✓ ✓ ✓ ✓ def 3 2 2 45 3 2 def def +/// PS_DS_AD10 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓ - ✓ ✓ def 2 def def 25 1.2 2 def def +/// PS_DS_AD11 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,-,✓] ✓ [-,-,✓] ✓ ✓ 60 1 1 1 45 1.2 2 def def +/// PS_DS_AD12 [✓,-,✓,✓] ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,-,✓,✓] ✓ [-,✓-,,✓] ✓ ✓ def 2 def def 25 3 1.1 def def +/// PS_DS_AD13 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - def 2 def def 25 3 0.5 def def +/// PS_DS_AD14 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,✓ ] [-,✓ ] ✓ ✓ ✓ ✓ ✓ def 1 def def 25 3 2 def def +/// PS_DS_AD15 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,✓ ] [-,✓ ] ✓ ✓ [-,-,✓] ✓ ✓ def 1 def def 25 3 2 def def +/// PS_DS_AD16 ✓ [-,-,✓,-,✓] ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ [-,-,✓,✓,✓] ✓ [✓,✓,-,✓,✓] ✓ ✓ def 2 def def 25 3 1.1 def def +/// PS_DS_AD17 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓ ✓ ✓ ✓ def 2 def def 25 3 1.1 def def +/// PS_DS_AD18 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ - ✓ ✓ ✓ ✓ def 3 def def 25 3 1.1 def def +///============= ==================== ============================ ============================== ========================= ====================== ============================ ======================= ================================== ============ ==================== ================== ====================== ============================== ========== ============= ================= ========================= ============================== ============================== =========================== ============================= ========================= =================== ========================= /// /// @endrst @@ -360,6 +361,8 @@ static Function PS_DS_AD1_preAcq(string device) AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "NumSweepsWithSaturation", var = 2) AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "DaScaleStepWidthMinMaxRatio", var = 3) + AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "FailingAdaptiveSCIRange", var = Inf) + // SamplingMultiplier, SamplingFrequency use defaults AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "MaxFrequencyChangePercent", var = 5) @@ -466,7 +469,7 @@ End static Function PS_DS_AD1_REENTRY_REENTRY([string str]) - variable sweepNo, failingAdaptiveSweep + variable sweepNo sweepNo = 5 WAVE/WAVE entries = GetEntries_IGNORE(str, sweepNo) @@ -478,8 +481,168 @@ static Function PS_DS_AD1_REENTRY_REENTRY([string str]) WAVE/Z overrideResults = GetOverrideResults() CHECK_WAVE(overrideResults, NUMERIC_WAVE) - failingAdaptiveSweep = JWN_GetNumberFromWaveNote(overrideResults, "FailingAdaptiveSweep") - CHECK_EQUAL_VAR(failingAdaptiveSweep, 2) + WAVE/Z passingAdSweepsFailSet = JWN_GetNumericWaveFromWaveNote(overrideResults, "PassingAdaptiveSweepFromFailingSet") + + Make/FREE/D/N=0 empty + CHECK_EQUAL_WAVES(passingAdSweepsFailSet, empty) +End + +static Function PS_DS_AD1a_preAcq(string device) + + AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "BaselineRMSLongThreshold", var = 0.5) + AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "BaselineRMSShortThreshold", var = 0.07) + + AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "AbsFrequencyMinDistance", var = 2) + + AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "NumSweepsWithSaturation", var = 3) + AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "DaScaleStepWidthMinMaxRatio", var = 3) + + AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "FailingAdaptiveSCIRange", var = 2) + + // SamplingMultiplier, SamplingFrequency use defaults + + AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "MaxFrequencyChangePercent", var = 5) + + // use defaults for the rest + + Make/FREE asyncChannels = {2, 4} + AFH_AddAnalysisParameter("PSQ_DaScale_Adapt_DA_0", "AsyncQCChannels", wv = asyncChannels) + + SetAsyncChannelProperties(device, asyncChannels, -1e6, +1e6) + + WAVE/Z overrideResults = GetOverrideResults() + CHECK_WAVE(overrideResults, NUMERIC_WAVE) + JWN_SetWaveInWaveNote(overrideResults, "PassingRheobaseSweep", {5}) + JWN_SetWaveInWaveNote(overrideResults, "PassingSupraSweep", {7}) + JWN_SetWaveInWaveNote(overrideResults, "PassingRhSuAdSweeps", {4, 5, 6, 7}) + + Make/FREE/D DAScalesFromRhSuAd = {1, 2, 3, 4} + JWN_SetWaveInWaveNote(overrideResults, "DAScalesRhSuAd", DAScalesFromRhSuAd) + + Make/FREE/D apFrequenciesFromRhSuAd = {10, 11, 13, 16} + JWN_SetWaveInWaveNote(overrideResults, "APFrequenciesRhSuAd", apFrequenciesFromRhSuAd) +End + +// UTF_TD_GENERATOR DeviceNameGeneratorMD1 +static Function PS_DS_AD1a([string str]) + + [STRUCT DAQSettings s] = PS_GetDAQSettings(str) + AcquireData_NG(s, str) + + WAVE wv = PSQ_CreateOverrideResults(str, PSQ_TEST_HEADSTAGE, PSQ_DA_SCALE, opMode = PSQ_DS_ADAPT) + + // async QC passes for first sweep and third sweep only + wv = 0 + wv[][][%APFrequency] = 15 - 0.1 * q + wv[][0, 2; 2][%AsyncQC] = 1 + wv[][][%BaselineQC] = 1 +End + +static Function PS_DS_AD1a_REENTRY([string str]) + + variable sweepNo + + sweepNo = 2 + + WAVE/WAVE entries = GetEntries_IGNORE(str, sweepNo) + + CHECK_EQUAL_TEXTWAVES(entries[%opMode], {PSQ_DS_ADAPT}, mode = WAVE_DATA) + + CHECK_EQUAL_WAVES(entries[%setPass], {0}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%sweepPass], {1, 0, 1}, mode = WAVE_DATA) + + CHECK_EQUAL_WAVES(entries[%rmsShortPass], {1, 1, 1}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%rmsLongPass], {1, 1, 1}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%baselinePass], {1, 1, 1}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%asyncPass], {1, 0, 1}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%samplingPass], {1, 1, 1}, mode = WAVE_DATA) + + CHECK_EQUAL_WAVES(entries[%futureDAScalesPass], {0, 1, 0}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%fiSlopeReachedPass], {1, 1, 1}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%enoughFIPointsPass], {1, 1, 1}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%validSlopePass], {1, 1, 1}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%initialValidSlopePass], {1, NaN, NaN}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%fiSlopeReachedPassFromRhSuAd], {0, 0, 0}, mode = WAVE_DATA) + + CommonAnalysisFunctionChecks(str, sweepNo, entries[%setPass]) + CheckSurveyPlot(str, entries) + + WAVE/Z overrideResults = GetOverrideResults() + CHECK_WAVE(overrideResults, NUMERIC_WAVE) + WAVE/Z passingAdSweepsFailSet = JWN_GetNumericWaveFromWaveNote(overrideResults, "PassingAdaptiveSweepFromFailingSet") + + Make/FREE/D/N=0 empty + CHECK_EQUAL_WAVES(passingAdSweepsFailSet, empty) + + PGC_SetAndActivateControl(str, "DataAcquireButton") + RegisterReentryFunction("PatchSeqTestDAScaleAdapt#" + GetRTStackInfo(1)) +End + +static Function PS_DS_AD1a_REENTRY_REENTRY([string str]) + + variable sweepNo + + sweepNo = 5 + + WAVE/WAVE entries = GetEntries_IGNORE(str, sweepNo) + + CHECK_EQUAL_TEXTWAVES(entries[%opMode], {PSQ_DS_ADAPT}, mode = WAVE_DATA) + + CHECK_EQUAL_WAVES(entries[%setPass], {0}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%sweepPass], {1, 0, 1}, mode = WAVE_DATA) + + WAVE/Z overrideResults = GetOverrideResults() + CHECK_WAVE(overrideResults, NUMERIC_WAVE) + WAVE/Z passingAdSweepsFailSet = JWN_GetNumericWaveFromWaveNote(overrideResults, "PassingAdaptiveSweepFromFailingSet") + + CHECK_EQUAL_WAVES(passingAdSweepsFailSet, {0, 2}, mode = WAVE_DATA) + + PGC_SetAndActivateControl(str, "DataAcquireButton") + RegisterReentryFunction("PatchSeqTestDAScaleAdapt#" + GetRTStackInfo(1)) +End + +static Function PS_DS_AD1a_REENTRY_REENTRY_REENTRY([string str]) + + variable sweepNo + + sweepNo = 8 + + WAVE/WAVE entries = GetEntries_IGNORE(str, sweepNo) + + CHECK_EQUAL_TEXTWAVES(entries[%opMode], {PSQ_DS_ADAPT}, mode = WAVE_DATA) + + CHECK_EQUAL_WAVES(entries[%setPass], {0}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%sweepPass], {1, 0, 1}, mode = WAVE_DATA) + + WAVE/Z overrideResults = GetOverrideResults() + CHECK_WAVE(overrideResults, NUMERIC_WAVE) + WAVE/Z passingAdSweepsFailSet = JWN_GetNumericWaveFromWaveNote(overrideResults, "PassingAdaptiveSweepFromFailingSet") + + CHECK_EQUAL_WAVES(passingAdSweepsFailSet, {0, 2, 3, 5}, mode = WAVE_DATA) + + PGC_SetAndActivateControl(str, "DataAcquireButton") + RegisterReentryFunction("PatchSeqTestDAScaleAdapt#" + GetRTStackInfo(1)) +End + +static Function PS_DS_AD1a_REENTRY_REENTRY_REENTRY_REENTRY([string str]) + + variable sweepNo + + sweepNo = 11 + + WAVE/WAVE entries = GetEntries_IGNORE(str, sweepNo) + + CHECK_EQUAL_TEXTWAVES(entries[%opMode], {PSQ_DS_ADAPT}, mode = WAVE_DATA) + + CHECK_EQUAL_WAVES(entries[%setPass], {0}, mode = WAVE_DATA) + CHECK_EQUAL_WAVES(entries[%sweepPass], {1, 0, 1}, mode = WAVE_DATA) + + WAVE/Z overrideResults = GetOverrideResults() + CHECK_WAVE(overrideResults, NUMERIC_WAVE) + WAVE/Z passingAdSweepsFailSet = JWN_GetNumericWaveFromWaveNote(overrideResults, "PassingAdaptiveSweepFromFailingSet") + + // "FailingAdaptiveSCIRange" equals two so we don't look further back + CHECK_EQUAL_WAVES(passingAdSweepsFailSet, {3, 5, 6, 8}, mode = WAVE_DATA) End static Function PS_DS_AD2_preAcq(string device) From 3834f3832c2475985f9ff06b0370def04a1e3196 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Wed, 27 Nov 2024 23:27:22 +0100 Subject: [PATCH 3/5] ShowTraceInfoTags: Remove BUG messages At least with IP9 BUILD: 56704 these trigger way too often to be usable. --- Packages/MIES/MIES_GuiUtilities.ipf | 2 -- 1 file changed, 2 deletions(-) diff --git a/Packages/MIES/MIES_GuiUtilities.ipf b/Packages/MIES/MIES_GuiUtilities.ipf index a04a77e516..560977872b 100644 --- a/Packages/MIES/MIES_GuiUtilities.ipf +++ b/Packages/MIES/MIES_GuiUtilities.ipf @@ -2140,12 +2140,10 @@ Function ShowTraceInfoTags() // Returns in S_value the state before toggling DoIgorMenu/OVRD "Graph", "Show Trace Info Tags" if(IsNull(S_value)) - BUG("DoIgorMenu returned S_value as null string for \"Show Trace Info Tags\"") KillWindow/Z $S_name return NaN endif if(IsEmpty(S_value)) - BUG("DoIgorMenu returned S_value as empty string for \"Show Trace Info Tags\"") KillWindow/Z $S_name return NaN endif From 1c1b367c92022b899068d321638ff2f85c73bff3 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Wed, 27 Nov 2024 23:37:31 +0100 Subject: [PATCH 4/5] PSQ_DAScale (Adapt): Round calculated DAscale to integer values We don't need the sub pA precision. In PSQ_DS_GatherOvershootCorrection we now also check if the calulated value is the same as the before/after value, as this can now happen with rounding. In PSQ_DS_CalculateDAScale we also use ceil for the too large/small cases so that we always get a different value. --- .../MIES/MIES_AnalysisFunctions_PatchSeq.ipf | 12 +- .../UTF_PatchSeqDAScale_Adapt.ipf | 138 +++++++++--------- 2 files changed, 76 insertions(+), 74 deletions(-) diff --git a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf index 40db3dddef..27755496d6 100644 --- a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf +++ b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf @@ -2443,7 +2443,7 @@ static Function/WAVE PSQ_DS_GatherOvershootCorrection(STRUCT PSQ_DS_DAScaleParam x = DAScales[i] xp = DAScales[i + 1] xs = (xp - x) / 2 - xm = x + xs + xm = round(x + xs) frac = yp / y - 1 DAScaleStepMin = cdp.daScaleStepMinNorm * y @@ -2451,7 +2451,9 @@ static Function/WAVE PSQ_DS_GatherOvershootCorrection(STRUCT PSQ_DS_DAScaleParam maxFreqRelCond = frac > (cdp.maxFrequencyChangePercent * PERCENT_TO_ONE) minFreqDistCond = abs(yp - y) > cdp.absFrequencyMinDistance minDaScaleCond = xs > DAScaleStepMin - alreadyMeasured = WaveExists(futureDAScalesHistoric) && !IsNaN(GetRowIndex(futureDAScalesHistoric, val = xm)) + alreadyMeasured = WaveExists(futureDAScalesHistoric) && !IsNaN(GetRowIndex(futureDAScalesHistoric, val = xm)) \ + && xm != x \ + && xm != xp newDAScaleValue = maxFreqRelCond && minFreqDistCond && minDaScaleCond && !alreadyMeasured @@ -2500,20 +2502,20 @@ static Function PSQ_DS_CalculateDAScale(STRUCT PSQ_DS_DAScaleParams &cdp, variab ASSERT(cdp.maxFrequencyChangePercent > PSQ_DS_MAX_FREQ_OFFSET, "Invalid PSQ_DS_MAX_FREQ_OFFSET") yp = y * (1 + (cdp.maxFrequencyChangePercent - PSQ_DS_MAX_FREQ_OFFSET) * PERCENT_TO_ONE) - xp = (yp - a) / (m) + xp = round((yp - a) / (m)) sprintf msg, "result %g with a=%g, m=%g, [x, xp]=[%g, %g], [y, yp]=[%g, %g], maxFrequencyChangePercent=%g, absDAScaleStepMin=%g, absDAScaleStepMax=%g\r", xp, a, m, x, xp, y, yp, cdp.maxFrequencyChangePercent, absDAScaleStepMin, absDAScaleStepMax DEBUGPRINT(msg) if(CheckIfSmall(m) || abs(x - xp) > absDAScaleStepMax) // avoid excessive too large values - xp = x + absDAScaleStepMax + xp = ceil(x + absDAScaleStepMax) sprintf msg, "corrected result: %g\r", xp DEBUGPRINT(msg) elseif(abs(y - yp) < cdp.absFrequencyMinDistance) // or too small values - xp = x + absDAScaleStepMin + xp = ceil(x + absDAScaleStepMin) sprintf msg, "corrected result: %g\r", xp DEBUGPRINT(msg) diff --git a/Packages/tests/HardwareAnalysisFunctions/UTF_PatchSeqDAScale_Adapt.ipf b/Packages/tests/HardwareAnalysisFunctions/UTF_PatchSeqDAScale_Adapt.ipf index 7e18dd40ff..833a197908 100644 --- a/Packages/tests/HardwareAnalysisFunctions/UTF_PatchSeqDAScale_Adapt.ipf +++ b/Packages/tests/HardwareAnalysisFunctions/UTF_PatchSeqDAScale_Adapt.ipf @@ -442,13 +442,13 @@ static Function PS_DS_AD1_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) Make/FREE/D maxSlopeRef = {2.999999970665357e-10, NaN, NaN} - Make/FREE/T futureDAScalesRef = {"3.5;4.4;", \ - "3.5;4.4;", \ - "3.5;4.4;"} + Make/FREE/T futureDAScalesRef = {"4;5;", \ + "4;5;", \ + "4;5;"} Make/FREE/D fiSlopesFromRhSuAdRef = {1e-10, 2e-10, 3e-10} Make/FREE/D fiOffsetsFromRhSuAdRef = {9, 7, 4} - Make/FREE/D DAScalesRef = {3.5, 3.5, 3.5} + Make/FREE/D DAScalesRef = {4, 4, 4} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_WAVE(entries[%fiSlope], NULL_WAVE) @@ -516,7 +516,7 @@ static Function PS_DS_AD1a_preAcq(string device) JWN_SetWaveInWaveNote(overrideResults, "PassingSupraSweep", {7}) JWN_SetWaveInWaveNote(overrideResults, "PassingRhSuAdSweeps", {4, 5, 6, 7}) - Make/FREE/D DAScalesFromRhSuAd = {1, 2, 3, 4} + Make/FREE/D DAScalesFromRhSuAd = {10, 20, 30, 40} JWN_SetWaveInWaveNote(overrideResults, "DAScalesRhSuAd", DAScalesFromRhSuAd) Make/FREE/D apFrequenciesFromRhSuAd = {10, 11, 13, 16} @@ -733,13 +733,13 @@ static Function PS_DS_AD2_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) Make/FREE/D maxSlopeRef = {3e-10} - Make/FREE/D fiSlopeRef = {8.15217391304348e-12} - Make/FREE/D fiOffsetRef = {15.67391304347826} - Make/FREE/T futureDAScalesRef = {"5.22666666666667;"} + Make/FREE/D fiSlopeRef = {1.000000000000014e-11} + Make/FREE/D fiOffsetRef = {15.59999999999999} + Make/FREE/T futureDAScalesRef = {"5;"} Make/FREE/D fiSlopesFromRhSuAdRef = {1e-10, 2e-10, 3e-10} Make/FREE/D fiOffsetsFromRhSuAdRef = {9, 7, 4} - Make/FREE/D DAScalesRef = {5.226666666666667} + Make/FREE/D DAScalesRef = {5} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_EQUAL_WAVES(entries[%fiSlope], fiSlopeRef, mode = WAVE_DATA, tol = 1e-24) @@ -841,13 +841,13 @@ static Function PS_DS_AD2a_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) Make/FREE/D maxSlopeRef = {3e-10, 3e-10} - Make/FREE/D fiSlopeRef = {8.15217391304348e-12, -1.656314699792955e-11} - Make/FREE/D fiOffsetRef = {15.67391304347826, 16.96570048309179} - Make/FREE/T futureDAScalesRef = {"5.22666666666667;11.2641666666667;", "5.22666666666667;11.2641666666667;"} + Make/FREE/D fiSlopeRef = {1.000000000000014e-11, -1.428571428571428e-11} + Make/FREE/D fiOffsetRef = {15.59999999999999, 16.81428571428572} + Make/FREE/T futureDAScalesRef = {"5;12;", "5;12;"} Make/FREE/D fiSlopesFromRhSuAdRef = {1e-10, 2e-10, 3e-10} Make/FREE/D fiOffsetsFromRhSuAdRef = {9, 7, 4} - Make/FREE/D DAScalesRef = {5.226666666666667, 11.26416666666667} + Make/FREE/D DAScalesRef = {5, 12} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_EQUAL_WAVES(entries[%fiSlope], fiSlopeRef, mode = WAVE_DATA, tol = 1e-24) @@ -950,13 +950,13 @@ static Function PS_DS_AD2b_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) Make/FREE/D maxSlopeRef = {3e-10, 3e-10} - Make/FREE/D fiSlopeRef = {8.15217391304348e-12, -3.312629399585924e-11} - Make/FREE/D fiOffsetRef = {15.67391304347826, 17.83140096618358} - Make/FREE/T futureDAScalesRef = {"5.22666666666667;8.24541666666667;", "5.22666666666667;8.24541666666667;"} + Make/FREE/D fiSlopeRef = {1.000000000000014e-11, -2.5e-11} + Make/FREE/D fiOffsetRef = {15.59999999999999, 17.35} + Make/FREE/T futureDAScalesRef = {"5;9;", "5;9;"} Make/FREE/D fiSlopesFromRhSuAdRef = {1e-10, 2e-10, 3e-10} Make/FREE/D fiOffsetsFromRhSuAdRef = {9, 7, 4} - Make/FREE/D DAScalesRef = {5.226666666666667, 8.245416666666667} + Make/FREE/D DAScalesRef = {5, 9} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_EQUAL_WAVES(entries[%fiSlope], fiSlopeRef, mode = WAVE_DATA, tol = 1e-24) @@ -1063,13 +1063,13 @@ static Function PS_DS_AD3_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) Make/FREE/D maxSlopeRef = {3e-10, 3e-10, 3e-10} - Make/FREE/D fiSlopeRef = {NaN, 8.152173913043478e-12, -1.656314699792955e-11} - Make/FREE/D fiOffsetRef = {NaN, 15.67391304347826, 16.96570048309179} - Make/FREE/T futureDAScalesRef = {"5.22666666666667;", "5.22666666666667;11.2641666666667;", "5.22666666666667;11.2641666666667;"} + Make/FREE/D fiSlopeRef = {NaN, 1.000000000000014e-11, -1.428571428571428e-11} + Make/FREE/D fiOffsetRef = {NaN, 15.59999999999999, 16.81428571428572} + Make/FREE/T futureDAScalesRef = {"5;", "5;12;", "5;12;"} Make/FREE/D fiSlopesFromRhSuAdRef = {1e-10, 2e-10, 3e-10} Make/FREE/D fiOffsetsFromRhSuAdRef = {9, 7, 4} - Make/FREE/D DAScalesRef = {5.226666666666667, 5.226666666666667, 11.26416666666667} + Make/FREE/D DAScalesRef = {5, 5, 12} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_EQUAL_WAVES(entries[%fiSlope], fiSlopeRef, mode = WAVE_DATA, tol = 1e-24) @@ -1376,7 +1376,7 @@ static Function PS_DS_AD7_preAcq(string device) JWN_SetWaveInWaveNote(overrideResults, "PassingSupraSweep", {7}) JWN_SetWaveInWaveNote(overrideResults, "PassingRhSuAdSweeps", {4, 5, 6, 7}) - Make/FREE/D DAScalesFromRhSuAd = {1, 2, 3, 3} + Make/FREE/D DAScalesFromRhSuAd = {10, 20, 30, 30} JWN_SetWaveInWaveNote(overrideResults, "DAScalesRhSuAd", DAScalesFromRhSuAd) // invalid initial valid fit QC but not dense enough @@ -1424,10 +1424,10 @@ static Function PS_DS_AD7_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%initialValidSlopePass], {0, NaN}, mode = WAVE_DATA) CHECK_EQUAL_WAVES(entries[%fiSlopeReachedPassFromRhSuAd], {0, 0, 0}, mode = WAVE_DATA) - Make/FREE/D minDAScaleNormRef = {0.02156862745098039, NaN} + Make/FREE/D minDAScaleNormRef = {0.2156862745098039, NaN} CHECK_EQUAL_WAVES(entries[%minDaScaleNorm], minDAScaleNormRef, mode = WAVE_DATA, tol = 1e-24) - Make/FREE/D maxDAScaleNormRef = {0.02372549019607843, NaN} + Make/FREE/D maxDAScaleNormRef = {0.2372549019607843, NaN} CHECK_EQUAL_WAVES(entries[%maxDaScaleNorm], maxDAScaleNormRef, mode = WAVE_DATA, tol = 1e-24) [WAVE apFreqRef, WAVE apFreqFromRhSuAd, WAVE DAScalesFromRhSuAd, WAVE sweepPassedFRomRhSuAd] = ExtractRefValuesFromOverride(sweepNo) @@ -1437,14 +1437,14 @@ static Function PS_DS_AD7_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%dascaleFromRhSuAd], DAScalesFromRhSuAd, mode = WAVE_DATA) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) - Make/FREE/D maxSlopeRef = {5.666666666666668e-10, 9.999999999999999e-10} - Make/FREE/D fiSlopeRef = {5.666666666666668e-10, 9.999999999999999e-10} + Make/FREE/D maxSlopeRef = {5.666666666666668e-11, 1e-10} + Make/FREE/D fiSlopeRef = {5.666666666666668e-11, 1e-10} Make/FREE/D fiOffsetRef = {-2, -8.5} - Make/FREE/T futureDAScalesRef = {"1.5;2.5;", "1.5;2.5;"} + Make/FREE/T futureDAScalesRef = {"15;25;", "15;25;"} - Make/FREE/D fiSlopesFromRhSuAdRef = {3e-10, 5e-10, NaN} + Make/FREE/D fiSlopesFromRhSuAdRef = {3e-11, 5e-11, NaN} Make/FREE/D fiOffsetsFromRhSuAdRef = {2, -2, NaN} - Make/FREE/D DAScalesRef = {1.5, 2.5} + Make/FREE/D DAScalesRef = {15, 25} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_EQUAL_WAVES(entries[%fiSlope], fiSlopeRef, mode = WAVE_DATA, tol = 1e-24) @@ -1600,11 +1600,11 @@ static Function PS_DS_AD9_REENTRY([string str]) Make/FREE/D maxSlopeRef = {2e-10, NaN} Make/FREE/D fiSlopeRef = {-6.666666666666667e-10, -6.666666666666667e-10} Make/FREE/D fiOffsetRef = {41.66666666666667, 41.66666666666667} - Make/FREE/T futureDAScalesRef = {"5.35;", "5.35;"} + Make/FREE/T futureDAScalesRef = {"5;", "5;"} Make/FREE/D fiSlopesFromRhSuAdRef = {1e-10, 2e-10, 2e-10} Make/FREE/D fiOffsetsFromRhSuAdRef = {9, 7, 7} - Make/FREE/D DAScalesRef = {5.35, 5.35} + Make/FREE/D DAScalesRef = {5, 5} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_WAVE(entries[%fiSlope], NULL_WAVE) @@ -1643,7 +1643,7 @@ static Function PS_DS_AD10_preAcq(string device) JWN_SetWaveInWaveNote(overrideResults, "PassingSupraSweep", {7}) JWN_SetWaveInWaveNote(overrideResults, "PassingRhSuAdSweeps", {4, 5, 6, 7}) - Make/FREE/D DAScalesFromRhSuAd = {1, 2, 3, 4} + Make/FREE/D DAScalesFromRhSuAd = {10, 20, 30, 40} JWN_SetWaveInWaveNote(overrideResults, "DAScalesRhSuAd", DAScalesFromRhSuAd) Make/FREE/D apFrequenciesFromRhSuAd = {10, 11, 13, 16} @@ -1690,10 +1690,10 @@ static Function PS_DS_AD10_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%initialValidSlopePass], {1, NaN, NaN}, mode = WAVE_DATA) CHECK_EQUAL_WAVES(entries[%fiSlopeReachedPassFromRhSuAd], {0, 0, 0}, mode = WAVE_DATA) - Make/FREE/D minDAScaleNormRef = {0.1, NaN, NaN} + Make/FREE/D minDAScaleNormRef = {1, NaN, NaN} CHECK_EQUAL_WAVES(entries[%minDaScaleNorm], minDAScaleNormRef, mode = WAVE_DATA, tol = 1e-24) - Make/FREE/D maxDAScaleNormRef = {0.12, NaN, NaN} + Make/FREE/D maxDAScaleNormRef = {1.2, NaN, NaN} CHECK_EQUAL_WAVES(entries[%maxDaScaleNorm], maxDAScaleNormRef, mode = WAVE_DATA, tol = 1e-24) [WAVE apFreqRef, WAVE apFreqFromRhSuAd, WAVE DAScalesFromRhSuAd, WAVE sweepPassedFRomRhSuAd] = ExtractRefValuesFromOverride(sweepNo) @@ -1703,14 +1703,14 @@ static Function PS_DS_AD10_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%dascaleFromRhSuAd], DAScalesFromRhSuAd, mode = WAVE_DATA) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) - Make/FREE/D maxSlopeRef = {9.374999999999962e-10, 3.125000000000005e-09, 6.510416666666915e-09} - Make/FREE/D fiSlopeRef = {9.374999999999962e-10, 3.125000000000005e-09, 6.510416666666915e-09} - Make/FREE/D fiOffsetRef = {-21.49999999999984, -130.0000000000003, -314.1666666666805} - Make/FREE/T futureDAScalesRef = {"4.96;5.44;", "4.96;5.44;5.6704;", "4.96;5.44;5.6704;5.82246399999999;"} + Make/FREE/D maxSlopeRef = {9e-11, 3e-10, 7.5e-10} + Make/FREE/D fiSlopeRef = {9e-11, 3e-10, 7.5e-10} + Make/FREE/D fiOffsetRef = {-20, -125, -372.5} + Make/FREE/T futureDAScalesRef = {"50;55;", "50;55;57;", "50;55;57;58;"} - Make/FREE/D fiSlopesFromRhSuAdRef = {1e-10, 2e-10, 3e-10} + Make/FREE/D fiSlopesFromRhSuAdRef = {9.999999999999999e-12, 2e-11, 3e-11} Make/FREE/D fiOffsetsFromRhSuAdRef = {9, 7, 4} - Make/FREE/D DAScalesRef = {4.96, 5.440000000000003, 5.6704} + Make/FREE/D DAScalesRef = {50, 55, 57} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_EQUAL_WAVES(entries[%fiSlope], fiSlopeRef, mode = WAVE_DATA, tol = 1e-24) @@ -1755,7 +1755,7 @@ static Function PS_DS_AD11_preAcq(string device) JWN_SetWaveInWaveNote(overrideResults, "PassingSupraSweep", {7}) JWN_SetWaveInWaveNote(overrideResults, "PassingRhSuAdSweeps", {4, 5, 6, 7}) - Make/FREE/D DAScalesFromRhSuAd = {1, 2, 3, 4} + Make/FREE/D DAScalesFromRhSuAd = {10, 20, 30, 40} JWN_SetWaveInWaveNote(overrideResults, "DAScalesRhSuAd", DAScalesFromRhSuAd) Make/FREE/D apFrequenciesFromRhSuAd = {10, 10, 13, 16} @@ -1805,10 +1805,10 @@ static Function PS_DS_AD11_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%initialValidSlopePass], {1, NaN}, mode = WAVE_DATA) CHECK_EQUAL_WAVES(entries[%fiSlopeReachedPassFromRhSuAd], {0, 0, 0}, mode = WAVE_DATA) - Make/FREE/D minDAScaleNormRef = {0.2142857142857143, NaN} + Make/FREE/D minDAScaleNormRef = {2.142857142857143, NaN} CHECK_EQUAL_WAVES(entries[%minDaScaleNorm], minDAScaleNormRef, mode = WAVE_DATA, tol = 1e-24) - Make/FREE/D maxDAScaleNormRef = {0.2571428571428571, NaN} + Make/FREE/D maxDAScaleNormRef = {2.571428571428571, NaN} CHECK_EQUAL_WAVES(entries[%maxDaScaleNorm], maxDAScaleNormRef, mode = WAVE_DATA, tol = 1e-24) [WAVE apFreqRef, WAVE apFreqFromRhSuAd, WAVE DAScalesFromRhSuAd, WAVE sweepPassedFRomRhSuAd] = ExtractRefValuesFromOverride(sweepNo) @@ -1818,17 +1818,17 @@ static Function PS_DS_AD11_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%dascaleFromRhSuAd], DAScalesFromRhSuAd, mode = WAVE_DATA) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) - Make/FREE/D maxSlopeRef = {3e-10, 3e-10} - Make/FREE/D fiSlopeRef = {1.744186046511628e-10, 1.014061654948618e-10} - Make/FREE/D fiOffsetRef = {9.023255813953488, 13.6181719848567} - Make/FREE/T futureDAScalesRef = {"6.29333333333333;11.224;", \ - "6.29333333333333;11.224;"} + Make/FREE/D maxSlopeRef = {3e-11, 3e-11} + Make/FREE/D fiSlopeRef = {1.739130434782609e-11, 1.020408163265306e-11} + Make/FREE/D fiOffsetRef = {9.043478260869566, 13.57142857142857} + Make/FREE/T futureDAScalesRef = {"63;112;", \ + "63;112;"} // we do have three pairs in apFrequenciesFromRhSuAd/DAScalesFromRhSuAd but a neighboring duplicate // so only two valid slopes and offsets - Make/FREE/D fiSlopesFromRhSuAdRef = {PSQ_DS_SKIPPED_FI_SLOPE, 1.5e-10, 3e-10} + Make/FREE/D fiSlopesFromRhSuAdRef = {PSQ_DS_SKIPPED_FI_SLOPE, 1.5e-11, 3e-11} Make/FREE/D fiOffsetsFromRhSuAdRef = {PSQ_DS_SKIPPED_FI_SLOPE, 8.5, 4} - Make/FREE/D DAScalesRef = {6.293333333333333, 11.224} + Make/FREE/D DAScalesRef = {63, 112} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_EQUAL_WAVES(entries[%fiSlope], fiSlopeRef, mode = WAVE_DATA, tol = 1e-24) @@ -1935,13 +1935,13 @@ static Function PS_DS_AD12_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%dascaleFromRhSuAd], DAScalesFromRhSuAd, mode = WAVE_DATA) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) - Make/FREE/D maxSlopeRef = {3.416149068322985e-10, 3.416149068322985e-10, 3.416149068322985e-10, 3.416149068322985e-10} - Make/FREE/D fiSlopeRef = {3.416149068322985e-10, 3.416149068322985e-10, -2.376451525789897e-10, -4.078983962177433e-12} - Make/FREE/D fiOffsetRef = {2.043478260869549, 2.043478260869549, 40.9697542533081, 21.34276443867624} - Make/FREE/T futureDAScalesRef = {"6.72;8.40318181818182;", "6.72;8.40318181818182;", "6.72;8.40318181818182;5.95159090909091;", "6.72;8.40318181818182;5.95159090909091;"} + Make/FREE/D maxSlopeRef = {3.142857142857143e-10, 3.142857142857143e-10, 3.142857142857143e-10, 3.142857142857143e-10} + Make/FREE/D fiSlopeRef = {3.142857142857143e-10, 3.142857142857143e-10, -2e-10, -3.333333333333381e-12} + Make/FREE/D fiOffsetRef = {3, 3, 39, 21.3} + Make/FREE/T futureDAScalesRef = {"7;9;", "7;9;", "7;9;6;", "7;9;6;"} Make/FREE/D fiSlopesFromRhSuAdRef = {2e-10, 2e-10, 1e-10} Make/FREE/D fiOffsetsFromRhSuAdRef = {8, 8, 10.5} - Make/FREE/D DAScalesRef = {6.719999999999999, 8.403181818181814, 8.403181818181814, 5.951590909090905} + Make/FREE/D DAScalesRef = {7, 9, 9, 6} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_EQUAL_WAVES(entries[%fiSlope], fiSlopeRef, mode = WAVE_DATA, tol = 1e-24) @@ -2044,13 +2044,13 @@ static Function PS_DS_AD13_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) Make/FREE/D maxSlopeRef = {4.99999999999999e-09} - Make/FREE/D fiSlopeRef = {-4.999999999999928e-09} - Make/FREE/D fiOffsetRef = {74.99999999999918} - Make/FREE/T futureDAScalesRef = {"1.1;1.269;"} + Make/FREE/D fiSlopeRef = {-2.50000000000002e-09} + Make/FREE/D fiOffsetRef = {45.00000000000023} + Make/FREE/T futureDAScalesRef = {"1;1;1;"} Make/FREE/D fiSlopesFromRhSuAdRef = {4.99999999999999e-09} Make/FREE/D fiOffsetsFromRhSuAdRef = {-44.9999999999999} - Make/FREE/D DAScalesRef = {1.1} + Make/FREE/D DAScalesRef = {1} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_EQUAL_WAVES(entries[%fiSlope], fiSlopeRef, mode = WAVE_DATA, tol = 1e-24) @@ -2154,13 +2154,13 @@ static Function PS_DS_AD14_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) Make/FREE/D maxSlopeRef = {3e-10, 3e-10} - Make/FREE/D fiSlopeRef = {NaN, 8.152173913043478e-12} - Make/FREE/D fiOffsetRef = {NaN, 15.67391304347826} - Make/FREE/T futureDAScalesRef = {"5.22666666666667;", "5.22666666666667;"} + Make/FREE/D fiSlopeRef = {NaN, 1.000000000000014e-11} + Make/FREE/D fiOffsetRef = {NaN, 15.59999999999999} + Make/FREE/T futureDAScalesRef = {"5;", "5;"} Make/FREE/D fiSlopesFromRhSuAdRef = {1e-10, 2e-10, 3e-10} Make/FREE/D fiOffsetsFromRhSuAdRef = {9, 7, 4} - Make/FREE/D DAScalesRef = {5.226666666666667, 5.22666666666667} + Make/FREE/D DAScalesRef = {5, 5} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_EQUAL_WAVES(entries[%fiSlope], fiSlopeRef, mode = WAVE_DATA, tol = 1e-24) @@ -2383,13 +2383,13 @@ static Function PS_DS_AD16_REENTRY([string str]) CHECK_EQUAL_WAVES(entries[%sweepPassFromRhSuAd], sweepPassedFRomRhSuAd, mode = WAVE_DATA) Make/FREE/D maxSlopeRef = {2e-10, NaN, 2e-10, 2e-10, 2e-10} - Make/FREE/D fiSlopeRef = {NaN, NaN, 1.242236024844745e-11, 1.242236024844745e-11, 3.01318267419956e-12} - Make/FREE/D fiOffsetRef = {NaN, NaN, 13.56521739130434, 13.56521739130434, 14.19751412429379} - Make/FREE/T futureDAScalesRef = {"6.72;", "6.72;", "6.72;13.3575;", "6.72;13.3575;", "6.72;13.3575;"} + Make/FREE/D fiSlopeRef = {NaN, NaN, 1.242236024844745e-11, 1.142857142857142e-11, 2.857142857142869e-12} + Make/FREE/D fiOffsetRef = {NaN, NaN, 13.6, 13.6, 14.2} + Make/FREE/T futureDAScalesRef = {"7;", "7;", "7;14;", "7;14;", "7;14;"} Make/FREE/D fiSlopesFromRhSuAdRef = {2e-10, 2e-10, 1e-10} Make/FREE/D fiOffsetsFromRhSuAdRef = {8, 8, 10.5} - Make/FREE/D DAScalesRef = {6.719999999999999, 6.72, 6.72, 13.3575, 13.3575} + Make/FREE/D DAScalesRef = {7, 7, 7, 14, 14} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_EQUAL_WAVES(entries[%fiSlope], fiSlopeRef, mode = WAVE_DATA, tol = 1e-24) @@ -2599,11 +2599,11 @@ static Function PS_DS_AD18_REENTRY([string str]) Make/FREE/D maxSlopeRef = {1e-10} Make/FREE/D fiSlopeRef = {1} Make/FREE/D fiOffsetRef = {1} - Make/FREE/T futureDAScalesRef = {"4.53;"} + Make/FREE/T futureDAScalesRef = {"5;"} Make/FREE/D fiSlopesFromRhSuAdRef = {1e-10} Make/FREE/D fiOffsetsFromRhSuAdRef = {9} - Make/FREE/D DAScalesRef = {4.529999999999999} + Make/FREE/D DAScalesRef = {5} CHECK_EQUAL_WAVES(entries[%maxSlope], maxSlopeRef, mode = WAVE_DATA, tol = 1e-24) CHECK_WAVE(entries[%fiSlope], NULL_WAVE) From 886e9e61a430ca7490baa261c49a0b353f919761 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Wed, 27 Nov 2024 23:40:07 +0100 Subject: [PATCH 5/5] WIP --- Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf index 27755496d6..729abe40d6 100644 --- a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf +++ b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf @@ -3969,6 +3969,10 @@ Function PSQ_DAScale(string device, STRUCT AnalysisFunction_V3 &s) // when the fits from RhSuAd are not valid we are already done endif + // F: fillin + // R: regular + // X: ??? + if(WaveExists(futureDAScales)) PSQ_DS_CalcFutureDAScalesAndStoreInLBN(device, s.sweepNo, s.headstage, futureDAScales) endif