@@ -702,10 +702,10 @@ static Function [WAVE/D peakX, WAVE/D peakY] PSX_AnalyzePeaks(WAVE sweepDataOffF
702
702
riseTimeParams[ %$ "Differentiate Threshold" ] , \
703
703
p)
704
704
705
- Multithread psxEvent[][ %$ "Rise Time" ] = PSX_CalculateRiseTime ( sweepDataOffFilt, psxEvent, kernelAmp, \
706
- riseTimeParams[ %$ "Lower Threshold" ] , \
707
- riseTimeParams[ %$ "Upper Threshold" ] , \
708
- p)
705
+ Multithread psxEvent[][ %$ "Rise Time" ] = PSX_CalculateRiseTimeWrapper ( sweepDataOffFilt, psxEvent, kernelAmp, \
706
+ riseTimeParams[ %$ "Lower Threshold" ] , \
707
+ riseTimeParams[ %$ "Upper Threshold" ] , \
708
+ p)
709
709
710
710
psxEvent[][ % tau] = PSX_FitEventDecay ( sweepDataOffFilt, psxEvent, maxTauFactor, eventFit, p)
711
711
@@ -1739,25 +1739,40 @@ static Function/WAVE PSX_OperationStatsImpl(string graph, string id, WAVE/WAVE s
1739
1739
return output
1740
1740
End
1741
1741
1742
- threadsafe static Function PSX_CalculateRiseTime ( WAVE sweepDataOffFilt, WAVE psxEvent, variable kernelAmp, variable lowerThreshold, variable upperThreshold, variable index)
1742
+ threadsafe static Function PSX_CalculateRiseTimeWrapper ( WAVE sweepDataOffFilt, WAVE psxEvent, variable kernelAmp, variable lowerThreshold, variable upperThreshold, variable index)
1743
1743
1744
- variable dY, xStart, xEnd, yStart, yEnd, xlt, xupt, lowerLevel, upperLevel, riseTime
1745
- variable printDebug
1746
- string comboKey
1744
+ variable error, xStart, xEnd, yStart, yEnd, riseTime
1745
+ string comboKey
1747
1746
1748
1747
// deconvPeak is defined in the deconvoluted wave,
1749
1748
// so we can't use %deconvPeak as y-value
1750
1749
xStart = psxEvent[ index][ %$ "Onset Time" ]
1751
-
1752
- if ( IsNaN ( xStart))
1753
- return NaN
1754
- endif
1755
-
1756
1750
yStart = sweepDataOffFilt ( xStart)
1757
1751
1758
1752
xEnd = psxEvent[ index][ % peak_t]
1759
1753
yEnd = psxEvent[ index][ % peak]
1760
1754
1755
+ [ riseTime, error] = PSX_CalculateRiseTime ( sweepDataOffFilt, xStart, xEnd, yStart, yEnd, lowerThreshold, upperThreshold, kernelAmp)
1756
+
1757
+ #ifdef DEBUGGING_ENABLED
1758
+ if ( error)
1759
+ comboKey = JWN_GetStringFromWaveNote ( psxEvent, PSX_EVENTS_COMBO_KEY_WAVE_NOTE)
1760
+
1761
+ printf "comboKey: %s, x: [%g, %g], y: [%g, %g], index: %d, dY: %g, thresholds: [%g, %g], levels: [%g, %g], risetime: %g, xlt: %g, xupt: %g\r " , comboKey, xStart, xEnd, yStart, yEnd, index, dY, lowerThreshold, upperThreshold, lowerLevel, upperLevel, risetime, xlt, xupt
1762
+ endif
1763
+ #endif // DEBUGGING_ENABLED
1764
+
1765
+ return riseTime
1766
+ End
1767
+
1768
+ threadsafe static Function [variable riseTime, variable error] PSX_CalculateRiseTime ( WAVE data, variable xStart, variable xEnd, variable yStart, variable yEnd, variable lowerThreshold, variable upperThreshold, variable kernelAmp)
1769
+
1770
+ variable dY, xlt, xupt, lowerLevel, upperLevel
1771
+
1772
+ if ( IsNaN ( xStart))
1773
+ return [ NaN , 0 ]
1774
+ endif
1775
+
1761
1776
dY = abs ( yStart - yEnd)
1762
1777
1763
1778
lowerLevel = min ( yStart, yEnd) + lowerThreshold * dY
@@ -1767,34 +1782,26 @@ threadsafe static Function PSX_CalculateRiseTime(WAVE sweepDataOffFilt, WAVE psx
1767
1782
xlt = NaN
1768
1783
xupt = NaN
1769
1784
1770
- FindLevel / R= ( xStart, xEnd) / Q sweepDataOffFilt , lowerLevel
1785
+ FindLevel / R= ( xStart, xEnd) / Q data , lowerLevel
1771
1786
1772
1787
if ( ! V_flag)
1773
1788
xlt = V_levelX
1774
1789
else
1775
- printDebug = 1
1790
+ error = 1
1776
1791
endif
1777
1792
1778
- FindLevel / R= ( xStart, xEnd) / Q sweepDataOffFilt , upperLevel
1793
+ FindLevel / R= ( xStart, xEnd) / Q data , upperLevel
1779
1794
1780
1795
if ( ! V_flag)
1781
1796
xupt = V_levelX
1782
1797
else
1783
- printDebug = 1
1798
+ error = 1
1784
1799
endif
1785
1800
1786
1801
ASSERT_TS ( kernelAmp != 0 && IsFinite ( kernelAmp) , "kernelAmp must be finite and not zero" )
1787
1802
riseTime = ( xlt - xupt) * sign ( kernelAmp) * ( -1 )
1788
1803
1789
- #ifdef DEBUGGING_ENABLED
1790
- if ( printDebug)
1791
- comboKey = JWN_GetStringFromWaveNote ( psxEvent, PSX_EVENTS_COMBO_KEY_WAVE_NOTE)
1792
-
1793
- printf "comboKey: %s, x: [%g, %g], y: [%g, %g], index: %d, dY: %g, thresholds: [%g, %g], levels: [%g, %g], risetime: %g, xlt: %g, xupt: %g\r " , comboKey, xStart, xEnd, yStart, yEnd, index, dY, lowerThreshold, upperThreshold, lowerLevel, upperLevel, risetime, xlt, xupt
1794
- endif
1795
- #endif // DEBUGGING_ENABLED
1796
-
1797
- return riseTime
1804
+ return [ riseTime, error]
1798
1805
End
1799
1806
1800
1807
threadsafe static Function PSX_CalculateOnsetTime ( WAVE sweepDataDiff, WAVE psxEvent, variable kernelAmp, variable diffThreshPerc, variable index)
0 commit comments