Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
t-b committed Nov 26, 2024
1 parent 7384114 commit daec7e1
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1613,31 +1613,31 @@ 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")

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
Expand All @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit daec7e1

Please sign in to comment.