Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SweepFormula/psxKernel: Various fixes #2023

Merged
merged 31 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8219a53
SweepFormula/psxKernel: Skip kernel creation for too large decayTau
t-b Feb 23, 2024
2ba79ec
SF_OperationEpochsImpl: Fix giving up too early
t-b Feb 23, 2024
58c8095
PSX_OperationKernel: Avoid assertion with invalid ranges
t-b Feb 23, 2024
5089b3c
SFH_ExtendIncompleteRanges: Ignore null ranges
t-b Feb 23, 2024
9fda580
PSX_OperationSetDimensionLabels: Factor it out
t-b Feb 27, 2024
d359a7a
PSX_Operation: Handle partial results better
t-b Feb 27, 2024
49503f9
PSX_Operation: Output error message when we could not generate data
t-b Feb 27, 2024
667d3f1
PSX_OperationStatsImpl: Rework range handling
t-b Mar 1, 2024
540f83a
Documentation: Update it for psxstats
t-b Mar 1, 2024
0e7c2ab
PSX_OperationImpl: Reorganize code for no event case
t-b Mar 8, 2024
6eed925
PSX_AnalyzePeaks: Factor out calculation of various event properties
t-b Jul 31, 2024
eaaf57d
PSX_AnalyzePeaks: Skip superfluous redimension calls
t-b Jul 31, 2024
c768a0b
PSX_AnalyzePeaks: Throw away events with different sign as the kernel…
t-b Mar 8, 2024
42f8ea0
PSX_CalculateRiseTime: Multithread the calculation
t-b Sep 4, 2024
52076cb
PSX_GetSingleEventRange: Make the offset dependent on tau
t-b Jun 5, 2024
3fcec43
PSX_UpdateSingleEventGraph: Check passed index
t-b Jun 18, 2024
eb98115
SF_PreparePlotter: Remove controls/draw elements on existing panels
t-b Sep 4, 2024
76bb9fb
PSX_ApplyMacroToExistingPanel: Make it static
t-b Sep 4, 2024
450c274
PSX_ApplyMacroToExistingPanel: Fix execution
t-b Sep 4, 2024
a795222
DeepCopyWaveRefWave: Fix assertion message
t-b Sep 4, 2024
2b8c2b1
DeepCopyWaveRefWave: Allow src to contain null waves
t-b Sep 6, 2024
db5632b
DeepCopyWaveRefWave: Nicify the code
t-b Sep 6, 2024
61b0cdc
PSX_OperationImpl: Always return a result
t-b Sep 4, 2024
ea1bb49
PSX: Change order of offsetting and filtering
t-b Sep 4, 2024
68b0ff6
Sweepbrowser: Avoid too old dialog on closing
t-b Dec 18, 2024
bf6e81b
AB_WindowHook: Save list of files and folders on kill vote
t-b Dec 18, 2024
0a8758f
PSX: Add panel version
t-b Dec 17, 2024
c695b20
SF_GetTraceColor: Add missing /Z
t-b Dec 18, 2024
b7e3912
SFH_GetArgumentAsText: Don't try to find unique abbreviations for exa…
t-b Dec 19, 2024
7418adb
PSX: Completely overhaul the psx detection algorithm
timjarsky Sep 9, 2024
9dc4e20
Packages/doc/SweepFormula_PSX.rst: Explain the algorithm a bit
t-b Dec 19, 2024
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
3 changes: 3 additions & 0 deletions Packages/MIES/MIES_AnalysisBrowser.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -3497,6 +3497,9 @@ End
Function AB_WindowHook(STRUCT WMWinHookStruct &s)

switch(s.eventCode)
case EVENT_WINDOW_HOOK_KILLVOTE:
AB_SaveSourceListInSettings()
break
case EVENT_WINDOW_HOOK_KILL:

AB_MemoryFreeMappedDF()
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_BrowserSettingsPanel.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ static Function BSP_MemoryFreeMappedDF(string win)

variable dim, index

DFREF sweepBrowserDFR = BSP_GetFolder(win, MIES_BSP_PANEL_FOLDER)
DFREF sweepBrowserDFR = BSP_GetFolder(win, MIES_BSP_PANEL_FOLDER, versionCheck = 0)
WAVE/T map = GetSweepBrowserMap(sweepBrowserDFR)
dim = FindDimLabel(map, COLS, "DataFolder")
Duplicate/FREE/RMD=[][dim] map, dfList
Expand Down
20 changes: 11 additions & 9 deletions Packages/MIES/MIES_Cache.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ Function/S CA_AveragingWaveModKey(WAVE wv)
return num2istr(CA_RecursiveWavemodCRC(wv)) + "Version 1"
End

/// @brief Cache key generator for the tau range calculation
/// of psx events
Function/S CA_PSXEventGoodTauRange(WAVE wv)

return num2istr(CA_RecursiveWavemodCRC(wv)) + "Version 1"
End

/// @brief Calculated a CRC from non wave reference waves using modification data, wave modification count and wave location.
/// If the given wave is a wave reference wave, then the CRC is calculated recursively from
/// all non wave reference waves and null wave references found.
Expand Down Expand Up @@ -415,7 +422,7 @@ Function/S CA_PSXKernelOperationKey(variable riseTau, variable decayTau, variabl
crc = StringCRC(crc, num2strHighPrec(dt, precision = MAX_DOUBLE_PRECISION))
crc = WaveCRC(crc, range)

return num2istr(crc) + "PSX Kernel Version 1"
return num2istr(crc) + "PSX Kernel Version 2"
End

static Function/S CA_PSXBaseKey(string comboKey, string psxParameters)
Expand All @@ -433,22 +440,17 @@ 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 1"
return CA_PSXBaseKey(comboKey, psxParameters) + " Events " + ":Version 2"
End

Function/S CA_PSXOperationKey(string comboKey, string psxParameters)

return CA_PSXBaseKey(comboKey, psxParameters) + " Operation " + ":Version 1"
End

Function/S CA_PSXRiseTimeKey(string comboKey, string psxParameters)

return CA_PSXBaseKey(comboKey, psxParameters) + " PSX Rise time " + ":Version 1"
return CA_PSXBaseKey(comboKey, psxParameters) + " Operation " + ":Version 3"
End

Function/S CA_PSXAnalyzePeaks(string comboKey, string psxParameters)

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

/// @brief Return the key for the igor info entries
Expand Down
11 changes: 8 additions & 3 deletions Packages/MIES/MIES_Constants.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Constant DA_EPHYS_PANEL_VERSION = 64
Constant DATA_SWEEP_BROWSER_PANEL_VERSION = 51
Constant WAVEBUILDER_PANEL_VERSION = 14
Constant ANALYSISBROWSER_PANEL_VERSION = 5
Constant PSX_PLOT_PANEL_VERSION = 1

/// Version of the stimset wave note
Constant STIMSET_NOTE_VERSION = 11
Expand Down Expand Up @@ -2032,6 +2033,7 @@ StrConstant CO_EMPTY_DAC_LIST = "emptyDACList"
StrConstant CO_SF_TOO_MANY_TRACES = "SF_tooManyTraces"
StrConstant CO_PSX_CLIPPED_STATS = "psx_clippedStats"
StrConstant CO_ARCHIVE_ONCE = "ArchiveLogs"
StrConstant CO_PSX_UPGRADE_EVENT = "psx_updateEvent"
///@}

/// @name Constants for SweepFormula Meta data in JSON format
Expand Down Expand Up @@ -2347,11 +2349,14 @@ StrConstant PSX_STATS_LABELS = "Average;Median;Average Deviation;Standard deviat
///@{
Constant PSX_HORIZ_OFFSET_ONSET = 0
Constant PSX_HORIZ_OFFSET_PEAK = 1
Constant PSX_HORIZ_OFFSET_SLEW = 2
///@}

Constant PSX_DECONV_FILTER_DEF_LOW = 0.002
Constant PSX_DECONV_FILTER_DEF_HIGH = 0.004
Constant PSX_DECONV_FILTER_DEF_ORDER = 101
Constant PSX_DECONV_FILTER_DEF_LOW = 500
Constant PSX_DECONV_FILTER_DEF_HIGH = 50
Constant PSX_DECONV_FILTER_DEF_ORDER = 7

StrConstant PSX_JWN_COMBO_KEYS_NAME = "ComboKeys"

StrConstant SF_OP_MERGE = "merge"
StrConstant SF_OP_FIT = "fit"
Expand Down
9 changes: 7 additions & 2 deletions Packages/MIES/MIES_SweepFormula.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ Function [STRUCT RGBColor s] SF_GetTraceColor(string graph, string opStack, WAVE
return [s]
endif

WAVE numericalValues = SFH_GetLabNoteBookForSweep(graph, sweepNo, mapIndex, LBN_NUMERICAL_VALUES)
WAVE/Z numericalValues = SFH_GetLabNoteBookForSweep(graph, sweepNo, mapIndex, LBN_NUMERICAL_VALUES)
if(!WaveExists(numericalValues))
return [s]
endif
Expand Down Expand Up @@ -1670,6 +1670,8 @@ static Function [WAVE/T plotGraphs, WAVE/WAVE infos] SF_PreparePlotter(string wi

win = winNameTemplate
if(WindowExists(win))
TUD_Clear(win, recursive = 1)

WAVE/T allWindows = ListToTextWave(GetAllWindows(win), ";")

for(subWindow : allWindows)
Expand All @@ -1679,6 +1681,9 @@ static Function [WAVE/T plotGraphs, WAVE/WAVE infos] SF_PreparePlotter(string wi
KillWindow/Z $subWindow
endif
endfor

RemoveAllControls(win)
RemoveAllDrawLayers(win)
else
NewPanel/N=$win/K=1/W=(150, 400, 1000, 700)
win = S_name
Expand Down Expand Up @@ -3678,7 +3683,7 @@ static Function/WAVE SF_OperationEpochsImpl(string graph, WAVE/T epochPatterns,
WAVE/T epNames = SFH_GetEpochNamesFromInfo(epochInfo)
WAVE/Z epIndices = SFH_GetEpochIndicesByWildcardPatterns(epNames, epochPatterns)
if(!WaveExists(epIndices))
break
continue
endif

numEntries = DimSize(epIndices, ROWS)
Expand Down
50 changes: 31 additions & 19 deletions Packages/MIES/MIES_SweepFormula_Helpers.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ End
Function/S SFH_GetArgumentAsText(variable jsonId, string jsonPath, string graph, string opShort, variable argNum, [string defValue, WAVE/Z/T allowedValues, FUNCREF SFH_StringChecker_Prototype checkFunc, variable checkDefault])

string msg, result, sep, allowedValuesAsStr
variable checkExist, numArgs, idx, ret
variable checkExist, numArgs, idx, ret, matchIndex

if(ParamIsDefault(checkDefault))
checkDefault = 1
Expand Down Expand Up @@ -178,22 +178,30 @@ Function/S SFH_GetArgumentAsText(variable jsonId, string jsonPath, string graph,
if(!ParamIsDefault(allowedValues))
ASSERT(WaveExists(allowedValues) && IsTextWave(allowedValues), "allowedValues must be a text wave")

// search are allowed entries and try to match a unique abbreviation
WAVE/Z/T matches = GrepTextWave(allowedValues, "(?i)^\\Q" + result + "\\E.*$")
if(!WaveExists(matches))
sep = ", "
allowedValuesAsStr = TextWaveToList(allowedValues, sep, trailSep = 0)
sprintf msg, "Argument #%d of operation %s: The text argument \"%s\" is not one of the allowed values (%s)", argNum, opShort, result, allowedValuesAsStr
SFH_ASSERT(0, msg)
elseif(DimSize(matches, ROWS) > 1)
sep = ", "
allowedValuesAsStr = TextWaveToList(matches, sep, trailSep = 0)
sprintf msg, "Argument #%d of operation %s: The abbreviated text argument \"%s\" is not unique and could be (%s)", argNum, opShort, result, allowedValuesAsStr
SFH_ASSERT(0, msg)
else
ASSERT(DimSize(matches, ROWS) == 1, "Unexpected match")
// replace possibly abbreviated argument with its full name
result = matches[0]
// result can be either an exact match or a unique abbreviation
// need to check the exact match first as otherwise we find two
// abbreviations when given `a` with allowedValues `a`, `aXXX`

matchIndex = GetRowIndex(allowedValues, str = result)

if(IsNaN(matchIndex))
// no exact match, search allowed entries and try to match a unique abbreviation
WAVE/Z/T matches = GrepTextWave(allowedValues, "(?i)^\\Q" + result + "\\E.*$")
if(!WaveExists(matches))
sep = ", "
allowedValuesAsStr = TextWaveToList(allowedValues, sep, trailSep = 0)
sprintf msg, "Argument #%d of operation %s: The text argument \"%s\" is not one of the allowed values (%s)", argNum, opShort, result, allowedValuesAsStr
SFH_ASSERT(0, msg)
elseif(DimSize(matches, ROWS) > 1)
sep = ", "
allowedValuesAsStr = TextWaveToList(matches, sep, trailSep = 0)
sprintf msg, "Argument #%d of operation %s: The abbreviated text argument \"%s\" is not unique and could be (%s)", argNum, opShort, result, allowedValuesAsStr
SFH_ASSERT(0, msg)
else
ASSERT(DimSize(matches, ROWS) == 1, "Unexpected match")
// replace possibly abbreviated argument with its full name
result = matches[0]
endif
endif
endif

Expand Down Expand Up @@ -362,9 +370,13 @@ Function/WAVE SFH_AsDataSet(WAVE data)
End

/// @brief Formula "cursors(A,B)" can return NaNs if no cursor(s) are set.
static Function SFH_ExtendIncompleteRanges(WAVE ranges)
static Function SFH_ExtendIncompleteRanges(WAVE/WAVE ranges)

for(WAVE/Z wv : ranges)
if(!WaveExists(wv))
continue
endif

for(WAVE wv : ranges)
if(IsNumericWave(wv))
SFH_ASSERT(DimSize(wv, ROWS) == 2, "Numerical range must have two rows in the form [start, end].")
wv[0][] = IsNaN(wv[0][q]) ? -Inf : wv[0][q]
Expand Down
Loading