diff --git a/Packages/MIES/MIES_SweepFormula_PSX.ipf b/Packages/MIES/MIES_SweepFormula_PSX.ipf index 1fe32562be..85fa946c5a 100644 --- a/Packages/MIES/MIES_SweepFormula_PSX.ipf +++ b/Packages/MIES/MIES_SweepFormula_PSX.ipf @@ -1128,9 +1128,8 @@ static Function [WAVE/D results, WAVE eventIndex, WAVE marker, WAVE/T comboKeys] case "amp": propLabel = "amplitude" break - case "xpos": - propLabel = "onset_t" - break + // add peak, peak_t, deconvPeak, deconvPeak_t, baseline_t, baseline + // add slew rate and slew rate time case "xinterval": propLabel = "iei" break @@ -1146,6 +1145,7 @@ static Function [WAVE/D results, WAVE eventIndex, WAVE marker, WAVE/T comboKeys] case "fitresult": propLabel = "Fit result" break + // add onset time case "risetime": propLabel = "Rise Time" break @@ -1937,12 +1937,16 @@ static Function PSX_UpdateOffsetInAllEventGraph(string win) switch(offsetMode) case PSX_HORIZ_OFFSET_ONSET: xOffset = 0 - yOffset = sweepDataOffFilt(psxEvent[i][%onset_t]) + yOffset = sweepDataOffFilt(psxEvent[i][%$"Onset Time"]) break case PSX_HORIZ_OFFSET_PEAK: - xOffset = first - psxEvent[i][%onset_t] + xOffset = first - psxEvent[i][%peak_t] yOffset = 0 break +// case PSX_HORIZ_OFFSET_SLEW: // call it Slew Rate +// xOffset = first - psxEvent[i][%$"Slew Rate Time"] +// yOffset = 0 +// break default: ASSERT(0, "Invalid offset mode") endswitch @@ -2740,7 +2744,7 @@ static Function PSX_UpdateSingleEventTextbox(string win, [variable eventIndex]) Make/FREE/T/N=(8, 2) input - input[0][0] = {"Event State:", "Fit State:", "Fit Result:", "Event:", "Onset:", "IeI:", "Amp (rel.):", "Tau:", "Rise time:"} + input[0][0] = {"Event State:", "Fit State:", "Fit Result:", "Event:", "Deconv Peak:", "IeI:", "Amp (rel.):", "Tau:", "Rise time:"} input[0][1] = {PSX_StateToString(psxEvent[eventIndex][%$"Event manual QC call"]), \ PSX_StateToString(psxEvent[eventIndex][%$"Fit manual QC call"]), \ PSX_FitResultToString(psxEvent[eventIndex][%$"Fit Result"]), \ @@ -2750,6 +2754,7 @@ static Function PSX_UpdateSingleEventTextbox(string win, [variable eventIndex]) num2str(psxEvent[eventIndex][%amplitude], "%8.02f") + " [" + yUnit + "]", \ num2str(psxEvent[eventIndex][%tau], "%8.02f") + " [ms]", \ num2str(psxEvent[eventIndex][%$"Rise Time"], "%8.02f") + " [ms]"} + // TODO add onset time before rise time str = "\F'Consolas'" + FormatTextWaveForLegend(input) @@ -4698,6 +4703,7 @@ Function/WAVE PSX_OperationStats(variable jsonId, string jsonPath, string graph) WAVE/Z selectData = selectDataComp[%SELECTION] WAVE/WAVE range = selectDataComp[%RANGE] + // TODO add onsetTime and slew rate, slew Make/FREE/T allProps = {"amp", "xpos", "xinterval", "tau", "estate", "fstate", "fitresult", "risetime"} prop = SFH_GetArgumentAsText(jsonID, jsonPath, graph, SF_OP_PSX_STATS, 2, allowedValues = allProps) Make/FREE/T allStates = {"accept", "reject", "undetermined", "all", "every"} diff --git a/Packages/MIES/MIES_WaveDataFolderGetters.ipf b/Packages/MIES/MIES_WaveDataFolderGetters.ipf index bd8d87c89b..499de49684 100644 --- a/Packages/MIES/MIES_WaveDataFolderGetters.ipf +++ b/Packages/MIES/MIES_WaveDataFolderGetters.ipf @@ -8212,6 +8212,64 @@ Function UpgradePSXEventWave(WAVE psxEvent) endif End ++static Function/WAVE PSX_CalculateOnsetTimeImpl(WAVE psxEvent, WAVE sweepData, variable kernelAmp, variable diffThreshPerc) ++ ++ variable numEvents ++ ++ Make/FREE/D/N=0 diff ++ Differentiate/EP=1 sweepData/D=diff ++ ++ numEvents = DimSize(psxEvent, ROWS) ++ Make/FREE/D/N=(numEvents) onset ++ ++ Multithread onset[] = PSX_CalculateOnsetTimeImplEvent(diff, psxEvent[p][%peak_t], psxEvent[p][%baseline_t], kernelAmp, diffThreshPerc) ++ ++ return onset ++End ++ ++threadsafe static Function PSX_CalculateOnsetTimeImplEvent(WAVE diff, variable peak_t, variable baseline_t, variable kernelAmp, variable diffThreshPerc) ++ ++ variable diffPeak, diffPeak_t, level ++ ++ ASSERT_TS(peak_t < baseline_t, "Unexpected ordering of peak_t and baseline_t") ++ ++ WaveStats/Q/M=1/R=(peak_t, baseline_t) diff ++ if(kernelAmp > 0) ++ diffPeak = V_max ++ diffPeak_t = V_maxLoc ++ elseif(kernelAmp < 0) ++ diffPeak = V_min ++ diffPeak_t = V_minLoc ++ else ++ ASSERT_TS(0, "Unsupported case: kernelAmp being zero") ++ endif ++ // TODO store diffPeak, diffPeak_t in psxEvent ++ // Names: "Slew Rate" and "Slew Rate Time" ++ ++ // TODO check sign ++ level = diffThreshPerc * (diffPeak - diff(baseline_t)) ++ ++ // search backwards in time ++ FindLevel/R=(diffPeak_t, baseline_t) diff, level ++ ++ if(V_flag) + return NaN + endif + + return V_levelX ++End ++ ++// New function: ++// PSX_OnsetTime(peak_t, baseline_t, DiffV) ++/// onset_t = time of the percentDiffThresh amplitude of the 1st differential of the event ++/// percentDiffThresh taken from psxRiseTime user input, default to 5% ++// Order of operations: ++// 1. DiffV = Differentiated sweep trace ++// 2. DiffPeak = the peak of the differentiated trace between [peak_t - baseline_t], peak = min for (–) kernel sign, max for (+) kernel sign ++// 3. DiffPeak_t = time of DiffPeak ++// 4. onset_t = findlevel/R= (DiffPeak_t, baseline_t) wave = DiffV, level=(percentDiffThresh * DiffPeak) ++// 5. Return onset_t ++ /// @brief Return a 2D events wave as free wave /// /// Rows: