From 73841149e921f5fecf7636c38151270c4b1e2d11 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Tue, 26 Nov 2024 20:59:25 +0100 Subject: [PATCH] changes --- .../MIES/MIES_AnalysisFunctions_PatchSeq.ipf | 67 +++++++++++++------ Packages/MIES/MIES_Constants.ipf | 2 +- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf index 5d429afc15..5edb884f35 100644 --- a/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf +++ b/Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf @@ -1601,24 +1601,11 @@ static Function PSQ_GetLastPassingLongRHSweep(string device, variable headstage, return INVALID_SWEEP_NUMBER End -/// @brief Return the previously acquired sweep number -/// -/// But only when it fullfills all of the following conditions: -/// - 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 string key, opMode - sweepNo = AFH_GetLastSweepAcquired(device) - - if(!IsValidSweepNumber(sweepNo)) - return INVALID_SWEEP_NUMBER - endif - WAVE numericalValues = GetLBNumericalValues(device) WAVE textualValues = GetLBTextualValues(device) @@ -1653,6 +1640,44 @@ static Function PSQ_GetPreviousSetQCFailingAdaptive(string device, variable head return sweepNo End +/// @brief Return the previously acquired sweep numbers +/// +/// Return one sweep number for each SCI which fullfills all of the following conditions: +/// - DAScale supra adaptive analysis function was run +/// - failing set QC +/// - all analysis parameters are the same +/// - used same targetV autobias value +/// - within the reach of FailingAdaptiveSCIRange analysis parameter +static Function/WAVE PSQ_GetPreviousSetQCFailingAdaptive(string device, variable headstage, string params) + + variable sweepNo, failingAdaptiveSCIRange + + sweepNo = AFH_GetLastSweepAcquired(device) + + if(!IsValidSweepNumber(sweepNo)) + return {INVALID_SWEEP_NUMBER} + endif + + failingAdaptiveSCIRange = AFH_GetAnalysisParamNumerical("FailingAdaptiveSCIRange", params, defValue = FAILING_ADAPTIVE_SCI_RANGE_DEFAULT) + + if(failingAdaptiveSCIRange == 0) + // feature turned off + return {INVALID_SWEEP_NUMBER} + endif + + WAVE numericalValues = GetLBNumericalValues(device) + + // i == 0: previous SCI + // i == x: x SCIs before + for(i = 0; i < failingAdaptiveSCIRange; i++) + WAVE/Z sweepsSCI = AFH_GetSweepsFromSameSCI(numericalValues, sweepNo, headstage) + endfor + + // TODO + + PSQ_IsSuitableFailingAdaptiveSweep(device, sweepNo, headstage, params) +End + /// @brief Return the truth that str is a valid PSQ_DAScale operation mode Function PSQ_DS_IsValidMode(string str) @@ -3078,12 +3103,12 @@ static Function/WAVE PSQ_DS_GetPassingRhSuAdSweepsAndStoreInLBN(string device, v return $"" endif - failingAdaptiveSweep = PSQ_GetPreviousSetQCFailingAdaptive(device, headstage, params) + WAVE/ZZ failingAdaptiveSweeps = PSQ_GetPreviousSetQCFailingAdaptive(device, headstage, params) if(TestOverrideActive()) WAVE overrideResults = GetOverrideResults() WAVE sweeps = JWN_GetNumericWaveFromWaveNote(overrideResults, "/PassingRhSuAdSweeps") - JWN_SetNumberInWaveNote(overrideResults, "/FailingAdaptiveSweep", failingAdaptiveSweep) + JWN_SetWaveInWaveNote(overrideResults, "/FailingAdaptiveSweep", failingAdaptiveSweep) // consistency checks WAVE DAScalesRhSuAd = JWN_GetNumericWaveFromWaveNote(overrideResults, "/DAScalesRhSuAd") @@ -3095,13 +3120,13 @@ static Function/WAVE PSQ_DS_GetPassingRhSuAdSweepsAndStoreInLBN(string device, v 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 + Concatenate/NP=(ROWS)/FREE {passingRheobaseSweeps, passingSupraSweeps}, sweeps + + if() + WAVE/Z passingAdaptiveSweeps = PSQ_DS_GetPassingDAScaleSweeps(numericalValues, failingAdaptiveSweep, headstage) - Concatenate/NP=(ROWS)/FREE {passingRheobaseSweeps, passingSupraSweeps, passingAdaptiveSweeps}, sweeps + endif endif WAVE/T RhSuAdSweepsLBN = LBN_GetTextWave() 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