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 faed32f commit 7384114
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 22 deletions.
67 changes: 46 additions & 21 deletions Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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")
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_Constants.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7384114

Please sign in to comment.