@@ -116,8 +116,12 @@ static Function/S AD_GetResultMessage(variable anaFuncType, variable passed, WAV
116
116
117
117
// PSQ_DA
118
118
// - baseline QC
119
- // - needs at least $NUM_DA_SCALES passing sweeps
120
- // and for supra mode if the FinalSlopePercent parameter is present this has to be reached as well
119
+ // - SUB/SUPRA: needs at least $NUM_DA_SCALES passing sweeps
120
+ // - SUPRA: if the FinalSlopePercent parameter is present this has to be reached as well
121
+ // - ADAPT: - fewer than $NumInvalidSlopeSweepsAllowed invalid f-I slopes
122
+ // - fISlopeReached QC or initial f-I slope QC was invalid
123
+ // - measured all future DAScale values
124
+ // - enough points for Fit QC
121
125
122
126
// PSQ_PB
123
127
// - baseline QC
@@ -477,8 +481,9 @@ static Function/S AD_GetDAScaleFailMsg(numericalValues, textualValues, sweepNo,
477
481
DFREF sweepDFR
478
482
variable headstage
479
483
480
- string msg, key, fISlopeStr
481
- variable numPasses, numRequiredPasses, finalSlopePercent
484
+ string msg, key, fISlopeStr, opMode
485
+ variable numPasses, numRequiredPasses, finalSlopePercent, slopePercentage, measuredAllFutureDAScales
486
+ variable numInvalidSlopeSweepsAllowed, numFailedSweeps
482
487
483
488
numPasses = PSQ_NumPassesInSet ( numericalValues, PSQ_DA_SCALE, sweepNo, headstage)
484
489
@@ -489,11 +494,50 @@ static Function/S AD_GetDAScaleFailMsg(numericalValues, textualValues, sweepNo,
489
494
WAVE /T params = GetLastSettingTextSCI ( numericalValues, textualValues, sweepNo, "Function params" , headstage, DATA_ACQUISITION_MODE)
490
495
endif
491
496
492
- WAVE /Z DAScales = AFH_GetAnalysisParamWave ( "DAScales" , params[ headstage])
493
- ASSERT ( WaveExists ( DASCales) , "analysis function parameters don't have a DAScales entry" )
494
- numRequiredPasses = DimSize ( DAScales, ROWS)
497
+ opMode = AFH_GetAnalysisParamTextual ( "OperationMode" , params[ headstage])
498
+
499
+ strswitch ( opMode)
500
+ case PSQ_DS_SUB:
501
+ case PSQ_DS_SUPRA:
502
+
503
+ WAVE /Z DAScales = AFH_GetAnalysisParamWave ( "DAScales" , params[ headstage])
504
+ ASSERT ( WaveExists ( DASCales) , "analysis function parameters don't have a DAScales entry" )
505
+ numRequiredPasses = DimSize ( DAScales, ROWS)
506
+
507
+ msg = AD_GetPerSweepFailMessage ( PSQ_DA_SCALE, numericalValues, textualValues, sweepNo, sweepDFR, headstage, numRequiredPasses = numRequiredPasses)
508
+ break
509
+ case PSQ_DS_ADAPT:
510
+ msg = AD_GetPerSweepFailMessage ( PSQ_DA_SCALE, numericalValues, textualValues, sweepNo, sweepDFR, headstage)
511
+
512
+ if ( ! IsEmpty ( msg))
513
+ return msg
514
+ endif
515
+
516
+ key = CreateAnaFuncLBNKey ( PSQ_DA_SCALE, PSQ_FMT_LBN_DA_AT_FUTURE_DASCALES_PASS, query = 1 )
517
+ measuredAllFutureDAScales = GetLastSettingIndep ( numericalValues, sweepNo, key, UNKNOWN_MODE)
518
+
519
+ if ( ! measuredAllFutureDAScales)
520
+ sprintf msg, "Could not acquire all requested future DAScale values"
521
+ endif
522
+
523
+ if ( ! IsEmpty ( msg))
524
+ return msg
525
+ endif
526
+
527
+ key = CreateAnaFuncLBNKey ( PSQ_DA_SCALE, PSQ_FMT_LBN_DA_AT_VALID_SLOPE_PASS, query = 1 )
528
+ WAVE slopePasses = GetLastSettingEachSCI ( numericalValues, sweepNo, key, headstage, UNKNOWN_MODE)
529
+ numFailedSweeps = DimSize ( slopePasses, ROWS) - Sum ( slopePasses)
530
+
531
+ numInvalidSlopeSweepsAllowed = AFH_GetAnalysisParamNumerical ( "NumInvalidSlopeSweepsAllowed" , params[ headstage])
532
+
533
+ if ( numFailedSweeps >= numInvalidSlopeSweepsAllowed)
534
+ sprintf msg, "Encountered %g sweeps with invalid slopes, but only %g are allowed." , numFailedSweeps, numInvalidSlopeSweepsAllowed
535
+ endif
536
+ break
537
+ default :
538
+ ASSERT ( 0, "Invalid opMode" )
539
+ endswitch
495
540
496
- msg = AD_GetPerSweepFailMessage ( PSQ_DA_SCALE, numericalValues, textualValues, sweepNo, sweepDFR, headstage, numRequiredPasses = numRequiredPasses)
497
541
if ( ! IsEmpty ( msg))
498
542
return msg
499
543
endif
@@ -509,7 +553,25 @@ static Function/S AD_GetDAScaleFailMsg(numericalValues, textualValues, sweepNo,
509
553
510
554
finalSlopePercent = AFH_GetAnalysisParamNumerical ( "FinalSlopePercent" , params[ headstage])
511
555
512
- sprintf msg, "Failure as we did not reach the required fI slope (target: %g%% reached: %s%%)" , finalSlopePercent, fISlopeStr
556
+ if ( IsFinite ( finalSlopePercent))
557
+ // Supra
558
+ sprintf msg, "Failure as we did not reach the required fI slope (target: %g%% reached: %s%%)" , finalSlopePercent, fISlopeStr
559
+ else
560
+ // Adaptive Suprathreshold
561
+ key = CreateAnaFuncLBNKey ( PSQ_DA_SCALE, PSQ_FMT_LBN_DA_AT_INIT_VALID_SLOPE_PASS, query = 1 )
562
+ WAVE initialFISlopeValid = GetLastSettingSCI ( numericalValues, sweepNo, key, headstage, UNKNOWN_MODE)
563
+
564
+ if ( initialFISlopeValid[ headstage])
565
+ key = CreateAnaFuncLBNKey ( PSQ_DA_SCALE, PSQ_FMT_LBN_DA_AT_MAX_SLOPE, query = 1 )
566
+ WAVE maxSlopeLBN = GetLastSetting ( numericalValues, sweepNo, key, UNKNOWN_MODE)
567
+
568
+ slopePercentage = AFH_GetAnalysisParamNumerical ( "SlopePercentage" , params[ headstage])
569
+ fISlope[ p] = maxSlopeLBN[ headstage] * ( 1 - ( slopePercentage * PERCENT_TO_ONE))
570
+ fISlopeStr = RemoveEnding ( NumericWaveToList ( fISlope, "%, " , format = "%.15g" ) , "%, " )
571
+ sprintf msg, "The fit slope was not small enough for the given slope percentage (target: %g%% reached: %s%%)" , slopePercentage, fISlopeStr
572
+ endif
573
+ endif
574
+
513
575
return msg
514
576
endif
515
577
@@ -726,7 +788,7 @@ static Function/S AD_GetPerSweepFailMessage(variable anaFuncType, WAVE numerical
726
788
string key, msg, str
727
789
string text = ""
728
790
variable numPasses, i , numSweeps, sweepNo, boundsAction, spikeCheck, resistancePass, accessRestPass, resistanceRatio
729
- variable avgCheckPass, stopReason, stimsetQC, baselineQC
791
+ variable avgCheckPass, stopReason, stimsetQC, baselineQC, enoughFIPointsQC
730
792
string perSweepFailedMessage = ""
731
793
732
794
if ( ! ParamIsDefault ( numRequiredPasses))
@@ -854,6 +916,23 @@ static Function/S AD_GetPerSweepFailMessage(variable anaFuncType, WAVE numerical
854
916
sprintf text, "Sweep %d failed: Limited resolution" , sweepNo
855
917
break
856
918
endif
919
+
920
+ key = CreateAnaFuncLBNKey ( anaFuncType, PSQ_FMT_LBN_DA_AT_ENOUGH_FI_POINTS_PASS, query = 1 )
921
+ enoughFIPointsQC = GetLastSettingIndep ( numericalValues, sweepNo, key, UNKNOWN_MODE)
922
+
923
+ if ( IsFinite ( enoughFIPointsQC) && ! enoughFIPointsQC)
924
+ sprintf text, "Sweep %d failed: Not enough points for fit" , sweepNo
925
+ break
926
+ endif
927
+
928
+ key = CreateAnaFuncLBNKey ( anaFuncType, PSQ_FMT_LBN_DA_AT_VALID_SLOPE_PASS, query = 1 )
929
+ WAVE /Z validFitSlope = GetLastSetting ( numericalValues, sweepNo, key, UNKNOWN_MODE)
930
+
931
+ if ( WaveExists ( validFitSlope) && ! validFitSlope[ headstage])
932
+ sprintf text, "Sweep %d failed: Invalid fit slope" , sweepNo
933
+ break
934
+ endif
935
+
857
936
break
858
937
case PSQ_PIPETTE_BATH:
859
938
[ baselineQC, msg] = AD_GetBaselineFailMsg ( anaFuncType, numericalValues, sweepNo, headstage)
0 commit comments