Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
t-b committed Dec 17, 2024
1 parent dc90b22 commit 904e033
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 24 deletions.
96 changes: 80 additions & 16 deletions Packages/MIES/MIES_SweepFormula_PSX.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,24 @@ static Function [WAVE/D results, WAVE eventIndex, WAVE marker, WAVE/T comboKeys]
case "amp":
propLabel = "amplitude"
break
case "peak":
propLabel = "peak"
break
case "peaktime":
propLabel = "peak_t"
break
case "deconvpeak":
propLabel = "deconvpeak"
break
case "deconvpeaktime":
propLabel = "deconvpeak_t"
break
case "baseline":
propLabel = "baseline"
break
case "baselinetime":
propLabel = "baseline_t"
break
case "xinterval":
propLabel = "iei"
break
Expand All @@ -1159,20 +1177,37 @@ static Function [WAVE/D results, WAVE eventIndex, WAVE marker, WAVE/T comboKeys]
case "fitresult":
propLabel = "Fit result"
break
case "slewrate":
propLabel = "Slew Rate"
break
case "slewratetime":
propLabel = "Slew Rate Time"
break
case "risetime":
propLabel = "Rise Time"
break
case "onsettime":
propLabel = "Onset Time"
break
default:
ASSERT(0, "Impossible prop")
ASSERT(0, "Impossible prop: " + prop)
endswitch

// use the correct event/fit state for the property
strswitch(propLabel)
case "amplitude":
case "peak":
case "peak_t":
case "deconvPeak":
case "deconvPeak_t":
case "baseline":
case "baseline_t":
case "iei":
case "Event manual QC call":
case "Slew Rate":
case "Slew Rate Time":
case "Rise Time":
case "Onset Time":
stateType = "Event manual QC call"
break
case "Fit result":
Expand All @@ -1181,7 +1216,7 @@ static Function [WAVE/D results, WAVE eventIndex, WAVE marker, WAVE/T comboKeys]
stateType = "Fit manual QC call"
break
default:
ASSERT(0, "Unknown propLabel")
ASSERT(0, "Unknown propLabel: " + propLabel)
endswitch

Make/FREE/N=0 allEventIndex, allMarkers
Expand Down Expand Up @@ -1428,9 +1463,24 @@ static Function/WAVE PSX_OperationStatsImpl(string graph, string id, WAVE/WAVE r
case "amp":
propLabelAxis = "Amplitude" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_Y_DATA_UNIT) + ")"
break
case "xpos":
case "peak":
propLabelAxis = "Event" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_Y_DATA_UNIT) + ")"
break
case "peaktime":
propLabelAxis = "Event time" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_X_DATA_UNIT) + ")"
break
case "deconvpeak":
propLabelAxis = "Deconvoluted peak" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_Y_DATA_UNIT) + ")"
break
case "deconvpeaktime":
propLabelAxis = "Deconvoluted peak time" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_X_DATA_UNIT) + ")"
break
case "baseline":
propLabelAxis = "Baseline" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_Y_DATA_UNIT) + ")"
break
case "baselinetime":
propLabelAxis = "Baseline time" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_X_DATA_UNIT) + ")"
break
case "xinterval":
propLabelAxis = "Event interval" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_X_DATA_UNIT) + ")"
break
Expand All @@ -1446,11 +1496,21 @@ static Function/WAVE PSX_OperationStatsImpl(string graph, string id, WAVE/WAVE r
case "fitresult":
propLabelAxis = "Fit result" + " (0/1)"
break
case "slewrate":
propLabelAxis = "Slew Rate" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_Y_DATA_UNIT) + ")"
break
case "slewratetime":
propLabelAxis = "Slew Rate time" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_X_DATA_UNIT) + ")"
break
case "risetime":
propLabelAxis = "Rise time" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_X_DATA_UNIT) + ")"
break
case "onsettime":
propLabelAxis = "Onset time" + " (" + JWN_GetStringFromWaveNote(allEvents[0], PSX_X_DATA_UNIT) + ")"
break

default:
ASSERT(0, "Impossible prop")
ASSERT(0, "Impossible prop: " + prop)
endswitch

if(!cmpstr(stateAsStr, "every"))
Expand Down Expand Up @@ -4740,6 +4800,21 @@ Function/WAVE PSX_OperationDeconvFilter(variable jsonId, string jsonPath, string
return SFH_GetOutputForExecutor(output, graph, SF_OP_PSX_DECONV_FILTER)
End

static Function/WAVE PSX_GetAllStatsProperties()

Make/FREE/T allProps = {"amp", \
"peak", "peaktime", \
"deconvpeak", "deconvpeaktime", \
"baseline", "baselinetime", \
"xinterval", \
"tau", \
"estate", "fstate", "fitresult", \
"slewrate", "slewratetime", \
"risetime", "onsettime"}

return allProps
End

Function/WAVE PSX_OperationStats(variable jsonId, string jsonPath, string graph)

string stateAsStr, postProc, id, prop
Expand All @@ -4756,18 +4831,7 @@ Function/WAVE PSX_OperationStats(variable jsonId, string jsonPath, string graph)
WAVE/Z selectData = selectDataComp[%SELECTION]
WAVE/WAVE range = selectDataComp[%RANGE]

// TODO add onsetTime
// TODO add peak, peak_t, deconvPeak, deconvPeak_t, baseline_t, baseline
// TODO add slew rate and slew rate time
Make/FREE/T allProps = {"amp", \
"peak", "peaktime", \
"deconvpeak", "deconvpeaktime", \
"baseline", "baselinetime", \
"xinterval", \
"tau", \
"estate", "fstate", "fitresult", \
"slewrate", "slewratetime", \
"risetime", "onsettime"}
WAVE allProps = PSX_GetAllStatsProperties()
prop = SFH_GetArgumentAsText(jsonID, jsonPath, graph, SF_OP_PSX_STATS, 2, allowedValues = allProps)
Make/FREE/T allStates = {"accept", "reject", "undetermined", "all", "every"}
stateAsStr = SFH_GetArgumentAsText(jsonID, jsonPath, graph, SF_OP_PSX_STATS, 3, allowedValues = allStates)
Expand Down
38 changes: 30 additions & 8 deletions Packages/tests/Basic/UTF_SweepFormula_PSX.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -651,19 +651,20 @@ static Function FillEventWave_IGNORE(WAVE psxEvent, string id, string comboKey)

variable jsonID

CHECK_EQUAL_VAR(DimSize(psxEvent, COLS), 14) // test needs update if that fails
CHECK_EQUAL_VAR(DimSize(psxEvent, COLS), 17) // test needs update if that fails

psxEvent[][%index] = p
psxEvent[][%peak_t] = 100 * p
psxEvent[][%deconvpeak_t] = 100 * p
psxEvent[][%deconvpeak] = NaN
psxEvent[][%peak] = NaN
psxEvent[][%post_min] = NaN
psxEvent[][%post_min_t] = -10 * p
psxEvent[][%pre_max] = NaN
psxEvent[][%pre_max_t] = NaN
psxEvent[][%rel_peak] = p == 0 ? NaN : 10 * p
psxEvent[][%isi] = 1000 * p
psxEvent[][%peak_t] = -10 * p
psxEvent[][%baseline] = NaN
psxEvent[][%baseline_t] = NaN
psxEvent[][%amplitude] = p == 0 ? NaN : 10 * p
psxEvent[][%iei] = 1000 * p
psxEvent[][%tau] = 1e-6 * p
psxEvent[][%$"Rise Time"] = p == 0 ? NaN : 0.1 * p
// TODO fill new entries
// PSX_ACCEPT:1
// PSX_REJECT:2
// PSX_UNDET: 4
Expand Down Expand Up @@ -1233,6 +1234,27 @@ static Function StatsComplainsAboutIntersectingRanges()
endtry
End

/// IUTF_TD_GENERATOR s0:MIES_PSX#PSX_GetAllStatsProperties
static Function StatsAllProperties([STRUCT IUTF_mData &m])

string browser, device, formulaGraph, comboKey, id, error, prop

prop = m.s0

[browser, device, formulaGraph] = CreateFakeDataBrowserWithSweepFormulaGraph()

[WAVE range, WAVE selectData] = GetFakeRangeAndSelectData()

// 1st event wave
WAVE/Z psxEvent = GetEventWave(comboIndex = 0)
comboKey = MIES_PSX#PSX_GenerateComboKey(browser, selectData, range)
id = "myID"
FillEventWave_IGNORE(psxEvent, id, comboKey)

MIES_PSX#PSX_OperationStatsImpl(browser, id, {range}, selectData, prop, "all", "nothing")
CHECK_NO_RTE()
End

Function/WAVE FakeSweepDataGeneratorPSXKernel(WAVE sweep, variable numChannels)

variable pnts = 1001
Expand Down

0 comments on commit 904e033

Please sign in to comment.