Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4ba734f
PSX_RestoreGuiState: Prefer GUI control setter over PGC
t-b Apr 1, 2025
694e4de
PSX_GetEventIndexAndComboIndex: Handle vs in keyboard navigation
t-b Apr 4, 2025
31968f4
PSX: Tweak detection algorithm
timjarsky Mar 18, 2025
b5174c5
PSX: Calculate the starting point for the average fit better
t-b Mar 19, 2025
36190c7
PSX_GetEventFitRange: Change starting position
t-b Mar 19, 2025
facdd0c
PSX_CalculateEventProperties: Tweak baseline calculation
t-b Mar 19, 2025
0f87b96
UTF_SweepFormula_PSX.ipf: Fix tests
t-b Mar 19, 2025
bd31c79
PSX_GetGoodTau: Handle edge case
t-b Mar 25, 2025
065f9d2
MIES_SweepFormula_PSX.ipf: Tweak PSX_TAU_CALC_FACTOR
timjarsky Mar 19, 2025
46e53a4
MIES_SweepFormula_PSX.ipf: Tweak peak and baseline calculation
t-b Apr 7, 2025
f7c42c0
PSX_CalculateRiseTime: Factor it out
t-b Mar 25, 2025
8049b5d
PSX_CalculateRiseTime: Return error when xStart is NaN
t-b Mar 26, 2025
bd2d5cb
PSX_UpdateDisplayedFit: Remove yOffset
t-b Apr 7, 2025
12785da
PSX_FitAcceptAverage: Use different method for calculating start posi…
t-b Mar 25, 2025
a2464de
MIES_SweepFormula_PSX.ipf: Revise event peak and baseline calculation
t-b Apr 7, 2025
96d3216
PSX_GetEventFitRange/PSX_FitEventDecay: Revise them
t-b Apr 7, 2025
4ebc2f6
PSX_FitEventDecay: Switch from single exponential to double exponenti…
timjarsky Apr 2, 2025
31c79e2
PSX_FitAcceptAverage: Multiple simultaneous fits to the accepted all …
timjarsky Apr 2, 2025
85f48ee
PSX_FilterEventsKernelAmpSign: Ignore events with non-finite deconv v…
t-b Apr 7, 2025
6c0764e
PSX: Add more vertical lines for peak_t and baseline_t
t-b Apr 7, 2025
6cbecb5
PSX_FitEventDecay: Support three tau instead of one
t-b Apr 2, 2025
8bbc1ec
stopping the collapse of the universe by filtering out negative time …
timjarsky Apr 10, 2025
89c809c
another tau filter
timjarsky Apr 10, 2025
13022bc
BandPassWithRingingDetection: Add it
timjarsky Apr 23, 2025
aa05ae8
psxDeconvFilter: Rework it
t-b May 9, 2025
9151a43
MIES_SweepFormula_PSX.ipf: Document SweepFormula operation signatures
t-b May 9, 2025
c229ad1
psxSweepBPFilter: Add it
t-b May 9, 2025
7301f5b
PSX_FilterSweepData/PSX_DeconvoluteSweepData: Always make order even
t-b May 12, 2025
fdd0d1b
BandPassWithRingingDetection: Minor cleanup
t-b May 12, 2025
9d35eca
BandPassWithRingingDetection: Remove the offset for every iteration
t-b May 12, 2025
d4633f3
BandPassWithRingingDetection: Reorganize the code
t-b May 12, 2025
47ffc83
PSX_Operation: Fix data gathering after failure
t-b May 13, 2025
5e0966a
Packages/doc/SweepFormula.rst: Update it
t-b May 28, 2025
80cfee5
PSX: Use 2^x padding for FFT input
t-b May 30, 2025
4a59144
PSX: Prefer odd number of historgram bins
timjarsky May 30, 2025
d850612
Revert "PSX: Use 2^x padding for FFT input"
timjarsky May 30, 2025
078ed82
PSX_FitAcceptAverage: Calculate maximum of it as well
t-b Jun 4, 2025
fa55e69
PSX: Add average fit for all states
t-b Jun 4, 2025
2387ca4
MIES_Utilities_Algorithm.ipf: Add helper routines for DoFFT
t-b Jun 5, 2025
bebaa38
PSX: Implement sweep data shortening for faster FFT
t-b Jun 6, 2025
1d03076
PSX: Supply default values for filtering derived from the kernel
t-b Jun 10, 2025
282b111
PSX: Add Onset and Rise y values to psxEvent
t-b Jun 10, 2025
5e04066
PSX_FitAverage: Store fit results in datafolder hierarchy
t-b Jun 10, 2025
db96e98
Packages/doc/SweepFormula.rst: Add units for rise and decay tau
t-b Jun 10, 2025
5a6bdcf
PSX_Operation: Add peakThreshold to parameter JSON
t-b Jun 25, 2025
a651366
PSX_OperationStatsImpl: Output more entries for stats postprocessing
t-b Jul 9, 2025
79445d3
Tim's questionable changes :)
timjarsky Jul 28, 2025
4cbb3a8
PSX_UpdateAverageTraces: Fix indexing confusion
t-b Jul 29, 2025
53d99a0
new function to determine the fit end time for the decay to the avera…
timjarsky Aug 5, 2025
d9ddd44
Update Packages/MIES/MIES_SweepFormula_PSX.ipf
timjarsky Aug 6, 2025
ba0dc32
Update Packages/MIES/MIES_SweepFormula_PSX.ipf
timjarsky Aug 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Packages/MIES/MIES_Cache.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ End
/// @param psxParameters JSON dump of the psx/psxKernel operation parameters
Function/S CA_PSXEventsKey(string comboKey, string psxParameters)

return CA_PSXBaseKey(comboKey, psxParameters) + " Events " + ":Version 2"
return CA_PSXBaseKey(comboKey, psxParameters) + " Events " + ":Version 3"
End

Function/S CA_PSXOperationKey(string comboKey, string psxParameters)
Expand All @@ -509,7 +509,7 @@ End

Function/S CA_PSXAnalyzePeaks(string comboKey, string psxParameters)

return CA_PSXBaseKey(comboKey, psxParameters) + " Analyze Peaks " + ":Version 2"
return CA_PSXBaseKey(comboKey, psxParameters) + " Analyze Peaks " + ":Version 3"
End

/// @brief Return the key for the igor info entries
Expand Down Expand Up @@ -582,6 +582,12 @@ threadsafe Function/S CA_CalculateFetchEpochsKey(WAVE numericalvalues, WAVE text

return "Version 1:" + Hash(key + num2istr(crc), HASH_SHA2_256)
End

Function/S CA_GetGoodFFTSizesKeys()

return "GetGoodFFTSizes Version 1"
End

///@}

/// @brief Make space for one new entry in the cache waves
Expand Down
24 changes: 13 additions & 11 deletions Packages/MIES/MIES_Constants.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2358,12 +2358,13 @@ Constant SECONDS_PER_DAY = 86400
StrConstant DB_AXIS_PART_EPOCHS = "_EP"
///@}

StrConstant SF_OP_PSX = "psx"
StrConstant SF_OP_PSX_KERNEL = "psxKernel"
StrConstant SF_OP_PSX_STATS = "psxStats"
StrConstant SF_OP_PSX_RISETIME = "psxRiseTime"
StrConstant SF_OP_PSX_PREP = "psxPrep"
StrConstant SF_OP_PSX_DECONV_FILTER = "psxDeconvFilter"
StrConstant SF_OP_PSX = "psx"
StrConstant SF_OP_PSX_KERNEL = "psxKernel"
StrConstant SF_OP_PSX_STATS = "psxStats"
StrConstant SF_OP_PSX_RISETIME = "psxRiseTime"
StrConstant SF_OP_PSX_PREP = "psxPrep"
StrConstant SF_OP_PSX_DECONV_BP_FILTER = "psxDeconvBPFilter"
StrConstant SF_OP_PSX_SWEEP_BP_FILTER = "psxSweepBPFilter"

/// @name Available PSX states
/// @anchor PSXStates
Expand Down Expand Up @@ -2392,10 +2393,12 @@ Constant PSX_MARKER_UNDET = 18
/// @name Custom error codes for PSX_FitEventDecay()
/// @anchor FitEventDecayCustomErrors
///@{
Constant PSX_DECAY_FIT_ERROR = -10000
Constant PSX_DECAY_FIT_ERROR = -10000
Constant PSX_DECAY_FIT_INVALID_RANGE_ERROR = -10001

///@}

StrConstant PSX_STATS_LABELS = "Average;Median;Average Deviation;Standard deviation;Skewness;Kurtosis"
StrConstant PSX_STATS_LABELS = "Average;Median;Average Deviation;Standard deviation;Skewness;Kurtosis;Lower quartile;Upper quartile;Inter-quartile range;Median absolute deviation;Most frequent value"

/// @name Horizontal offset modes in all event graph
///
Expand All @@ -2408,9 +2411,8 @@ Constant PSX_HORIZ_OFFSET_PEAK = 1
Constant PSX_HORIZ_OFFSET_SLEW = 2
///@}

Constant PSX_DECONV_FILTER_DEF_LOW = 500
Constant PSX_DECONV_FILTER_DEF_HIGH = 50
Constant PSX_DECONV_FILTER_DEF_ORDER = 7
Constant PSX_SWEEP_FILTER_DEF_ORDER = 4
Constant PSX_DECONV_FILTER_DEF_ORDER = 4

StrConstant PSX_JWN_COMBO_KEYS_NAME = "ComboKeys"

Expand Down
77 changes: 77 additions & 0 deletions Packages/MIES/MIES_MiesUtilities_Algorithm.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -641,3 +641,80 @@ threadsafe Function/WAVE FindIndizes(WAVE numericOrTextWave, [variable col, stri

return result
End

/// @brief Band‑pass filters a wave while automatically reducing IIR filter
/// order until the output contains no NaNs/Infs and its SEM is not larger than
/// the original (simple ringing detection).
///
/// @param src – input wave
/// @param fHigh – pass‑band edge frequencies in Hz (Igor’s band‑pass requires fLow > fHigh; the routine swaps them if needed)
/// @param fLow – low part
/// @param maxOrder – starting (maximum) IIR filter order to try (>0)
///
/// Logic: iteratively lowers the filter order until three conditions are met:
/// 1. FilterIIR executes without error.
/// 2. WaveStats reports V_numNaNs = 0 and V_numInfs = 0.
/// 3. SEM(filtered) ≤ SEM(original).
///
/// @retval realOrder filter order that finally succeeded (NaN if every order failed)
/// @retval filtered filtered data
Function [variable realOrder, WAVE filtered] BandPassWithRingingDetection(WAVE src, variable fHigh, variable fLow, variable maxOrder)

variable err, samp, semOrig, offset, i
string msg

ASSERT(IsInteger(maxOrder) && maxOrder > 0 && isEven(maxOrder), "maxOrder must be a positive and even integer")

// Igor band-pass expects fLow > fHigh
[fHigh, fLow] = MinMax(fLow, fHigh)

// Sampling rate (Hz) – assumes X scaling is in milliseconds
samp = 1 / (DeltaX(src) * MILLI_TO_ONE)

// Pre-compute SEM(original) once
WaveStats/Q src
semOrig = V_sem
offset = v_avg
ASSERT(V_numNaNs == 0 && V_numInfs == 0, "Expected only finite value in input data")

// Prepare destination wave
Duplicate/FREE src, filtered

for(i = maxOrder; i > 0; i -= 2)
Multithread filtered = src - offset

FilterIIR/LO=(fLow / samp)/HI=(fHigh / samp)/DIM=(ROWS)/ORD=(i) filtered; err = GetRTError(1)
if(err)
continue
endif

WaveStats/Q filtered
if(V_numNaNs > 0 || V_numInfs > 0)
sprintf msg, "V_numNaNs: %g, V_numInfs: %g", V_numNaNs, V_numInfs
DEBUGPRINT(msg)

// bad numerical output → lower order
continue
endif

if(V_sem > semOrig)
sprintf msg, "V_sem: %g,semOrig: %g", V_sem, semOrig
DEBUGPRINT(msg)

// noisier than original → ringing
continue
endif

Multithread filtered += offset

sprintf msg, "maxOrder: %g, realOrder: %g", maxOrder, i
DEBUGPRINT(msg)

return [i, filtered]
endfor

sprintf msg, "maxOrder: %g, realOrder: NaN", maxOrder
DEBUGPRINT(msg)

return [NaN, $""]
End
3 changes: 2 additions & 1 deletion Packages/MIES/MIES_SweepFormula.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ Function/WAVE SF_GetNamedOperations()
SF_OP_LOG10, SF_OP_APFREQUENCY, SF_OP_CURSORS, SF_OP_SELECTSWEEPS, SF_OP_AREA, SF_OP_SETSCALE, SF_OP_BUTTERWORTH, \
SF_OP_SELECTCHANNELS, SF_OP_DATA, SF_OP_LABNOTEBOOK, SF_OP_WAVE, SF_OP_FINDLEVEL, SF_OP_EPOCHS, SF_OP_TP, \
SF_OP_STORE, SF_OP_SELECT, SF_OP_POWERSPECTRUM, SF_OP_TPSS, SF_OP_TPBASE, SF_OP_TPINST, SF_OP_TPFIT, \
SF_OP_PSX, SF_OP_PSX_KERNEL, SF_OP_PSX_STATS, SF_OP_PSX_RISETIME, SF_OP_PSX_PREP, SF_OP_PSX_DECONV_FILTER, \
SF_OP_PSX, SF_OP_PSX_KERNEL, SF_OP_PSX_STATS, SF_OP_PSX_RISETIME, SF_OP_PSX_PREP, SF_OP_PSX_DECONV_BP_FILTER, \
SF_OP_PSX_SWEEP_BP_FILTER, \
SF_OP_MERGE, SF_OP_FIT, SF_OP_FITLINE, SF_OP_DATASET, SF_OP_SELECTVIS, SF_OP_SELECTCM, SF_OP_SELECTSTIMSET, \
SF_OP_SELECTIVSCCSWEEPQC, SF_OP_SELECTIVSCCSETQC, SF_OP_SELECTRANGE, SF_OP_SELECTEXP, SF_OP_SELECTDEV, \
SF_OP_SELECTEXPANDSCI, SF_OP_SELECTEXPANDRAC, SF_OP_SELECTSETCYCLECOUNT, SF_OP_SELECTSETSWEEPCOUNT, \
Expand Down
7 changes: 5 additions & 2 deletions Packages/MIES/MIES_SweepFormula_Executor.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,11 @@ Function/WAVE SFE_FormulaExecutor(STRUCT SF_ExecutionData &exd, [variable srcLoc
case SF_OP_PSX_PREP:
WAVE out = PSX_OperationPrep(exdop)
break
case SF_OP_PSX_DECONV_FILTER:
WAVE out = PSX_OperationDeconvFilter(exdop)
case SF_OP_PSX_DECONV_BP_FILTER:
WAVE out = PSX_OperationDeconvBPFilter(exdop)
break
case SF_OP_PSX_SWEEP_BP_FILTER:
WAVE out = PSX_OperationSweepBPFilter(exdop)
break
case SF_OP_MERGE:
WAVE out = SFO_OperationMerge(exdop)
Expand Down
Loading
Loading