Skip to content

Commit

Permalink
Merge pull request #2023 from AllenInstitute/bugfix/2023-ignore-too-l…
Browse files Browse the repository at this point in the history
…arge-decay-Tau-in-psx-kernel

SweepFormula/psxKernel: Various fixes
  • Loading branch information
t-b authored Dec 20, 2024
2 parents cfc5401 + 9dc4e20 commit 643478a
Show file tree
Hide file tree
Showing 17 changed files with 1,918 additions and 897 deletions.
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

0 comments on commit 643478a

Please sign in to comment.