Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
639bfd6
PSX_RestoreGuiState: Prefer GUI control setter over PGC
t-b Apr 1, 2025
92c02c0
PSX_GetEventIndexAndComboIndex: Handle vs in keyboard navigation
t-b Apr 4, 2025
f2fdced
PSX: Tweak detection algorithm
timjarsky Mar 18, 2025
1691e34
PSX: Calculate the starting point for the average fit better
t-b Mar 19, 2025
e53a923
PSX_GetEventFitRange: Change starting position
t-b Mar 19, 2025
d8727e5
PSX_CalculateEventProperties: Tweak baseline calculation
t-b Mar 19, 2025
ad50bca
UTF_SweepFormula_PSX.ipf: Fix tests
t-b Mar 19, 2025
d5d8d9f
PSX_GetGoodTau: Handle edge case
t-b Mar 25, 2025
f61bab0
MIES_SweepFormula_PSX.ipf: Tweak PSX_TAU_CALC_FACTOR
timjarsky Mar 19, 2025
ce40b0f
MIES_SweepFormula_PSX.ipf: Tweak peak and baseline calculation
t-b Apr 7, 2025
58b8dc8
PSX_CalculateRiseTime: Factor it out
t-b Mar 25, 2025
2ec4962
PSX_CalculateRiseTime: Return error when xStart is NaN
t-b Mar 26, 2025
96085d1
PSX_UpdateDisplayedFit: Remove yOffset
t-b Apr 7, 2025
6f46e5b
PSX_FitAcceptAverage: Use different method for calculating start posi…
t-b Mar 25, 2025
1484439
MIES_SweepFormula_PSX.ipf: Revise event peak and baseline calculation
t-b Apr 7, 2025
5ecaa09
PSX_GetEventFitRange/PSX_FitEventDecay: Revise them
t-b Apr 7, 2025
9e11faf
PSX_FitEventDecay: Switch from single exponential to double exponenti…
timjarsky Apr 2, 2025
c5daab8
PSX_FitAcceptAverage: Multiple simultaneous fits to the accepted all …
timjarsky Apr 2, 2025
be9d057
PSX_FilterEventsKernelAmpSign: Ignore events with non-finite deconv v…
t-b Apr 7, 2025
5739a7e
PSX: Add more vertical lines for peak_t and baseline_t
t-b Apr 7, 2025
14341d2
PSX_FitEventDecay: Support three tau instead of one
t-b Apr 2, 2025
3e6dda9
BandPassWithRingingDetection: Add it
timjarsky Apr 23, 2025
9cc0fed
psxDeconvFilter: Rework it
t-b May 9, 2025
bd91bdd
psxSweepBPFilter: Add it
t-b May 9, 2025
e97641f
PSX_FilterSweepData/PSX_DeconvoluteSweepData: Always make order even
t-b May 12, 2025
ea82d03
BandPassWithRingingDetection: Minor cleanup
t-b May 12, 2025
90e5578
BandPassWithRingingDetection: Remove the offset for every iteration
t-b May 12, 2025
7b6998a
BandPassWithRingingDetection: Reorganize the code
t-b May 12, 2025
d04391a
PSX_Operation: Fix data gathering after failure
t-b May 13, 2025
a789371
PSX: Use 2^x padding for FFT input
t-b May 30, 2025
8adb123
PSX: Prefer odd number of historgram bins
timjarsky May 30, 2025
80a8106
Revert "PSX: Use 2^x padding for FFT input"
timjarsky May 30, 2025
cb7d8e6
PSX_FitAcceptAverage: Calculate maximum of it as well
t-b Jun 4, 2025
c113d32
PSX: Add average fit for all states
t-b Jun 4, 2025
71c1cc5
MIES_Utilities_Algorithm.ipf: Add helper routines for DoFFT
t-b Jun 5, 2025
7555815
PSX: Implement sweep data shortening for faster FFT
t-b Jun 6, 2025
cbf5e67
PSX: Supply default values for filtering derived from the kernel
t-b Jun 10, 2025
8a71928
PSX: Add Onset and Rise y values to psxEvent
t-b Jun 10, 2025
7041da8
PSX_FitAverage: Store fit results in datafolder hierarchy
t-b Jun 10, 2025
cdde11a
Packages/doc/SweepFormula.rst: Add units for rise and decay tau
t-b Jun 10, 2025
20a2564
PSX_Operation: Add peakThreshold to parameter JSON
t-b Jun 25, 2025
1f4bbe3
PSX_OperationStatsImpl: Output more entries for stats postprocessing
t-b Jul 9, 2025
8f97842
PSX_FitAverage: Enhance onset calculation
timjarsky Jul 28, 2025
431ff0f
PSX_UpdateAverageTraces: Fix indexing confusion
t-b Jul 29, 2025
14be857
new function to determine the fit end time for the decay to the avera…
timjarsky Aug 5, 2025
e7d1d4f
Packages/MIES/MIES_SweepFormula_PSX.ipf: Fix variable casing and enha…
timjarsky Aug 6, 2025
9a33ce4
PSX_FitAverage: Don't clutter the current datafolder
t-b Jan 23, 2026
1223c97
GetTestCode: Remove setting code twice
t-b Jan 23, 2026
6980b33
PSX_CalculateOnsetTimeFromAvg: Make it more robust
t-b Jan 23, 2026
3b2585b
Packages/doc/SweepFormula.rst: Update it
t-b May 28, 2025
977970b
PSX_GetFindPeakBoxSize: Remove pointless special casing for the tests
t-b Jan 23, 2026
b1a2b69
PSX_FitAverage: Don't assert out on onsetX being NaN
t-b Jan 23, 2026
da16efa
MIES_SweepFormula_PSX.ipf: Remove commented out code
t-b Jan 23, 2026
31c3574
UTF_SweepFormula_PSX.ipf: Fix tests again
t-b Jan 23, 2026
f57c291
GetAllFilesRecursivelyFromPath: Kill path before returning
t-b Jan 26, 2026
759770e
UTF_SweepFormula_PSX.ipf: Add some more tests
t-b Jan 23, 2026
8d71c75
Packages/MIES/SweepFormulaHelp.ifn: Update it
t-b Jan 26, 2026
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 @@ -2375,12 +2375,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 @@ -2409,10 +2410,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 @@ -2425,9 +2428,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 @@ -92,7 +92,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