Skip to content

Commit

Permalink
changes deconvolved filter, trace filter, and histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
timjarsky authored and t-b committed Nov 15, 2024
1 parent 4838597 commit 850c460
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions Packages/MIES/MIES_SweepFormula_PSX.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static Function/WAVE PSX_FilterSweepData(WAVE sweepData, variable low, variable

// print low, high, samp
// Abort
FilterIIR/ENDV=(filtered[0])/LO=(low / samp)/HI=(high / samp)/DIM=(ROWS)/ORD=6 filtered; err = GetRTError(1)
FilterIIR/LO=(low / samp)/HI=(high / samp)/DIM=(ROWS)/ORD=6 filtered; err = GetRTError(1)
SFH_ASSERT(!err, "Error filtering the data, msg: " + GetErrMessage(err))

return filtered
Expand Down Expand Up @@ -333,8 +333,8 @@ static Function/WAVE PSX_DeconvoluteSweepData(WAVE sweepData, WAVE/C psxKernelFF
high = deconvFilter[%$"Filter High"]
order = deconvFilter[%$"Filter Order"]

low = 200
high = 20
// low = 200
// high = 20

if(IsNaN(low))
lowFrac = PSX_DECONV_FILTER_DEF_LOW
Expand Down Expand Up @@ -368,9 +368,12 @@ static Function/WAVE PSX_DeconvoluteSweepData(WAVE sweepData, WAVE/C psxKernelFF
ASSERT(V_Value == -1, "Can not handle NaN in the deconvoluted wave")

CopyScales sweepData, Deconv

// todo remove low frequencies here with a bandpass filter, always bandpass
FilterFIR/ENDV={3}/LO={lowFrac, highFrac, order}/HI={20/samp, 10/samp, 7} Deconv
//
// Duplicate/O deconv, root:deconv
// print lowFrac, highFrac, order
// Abort
// todo remove low frequencies here with a bandpass filter, always b
FilterFIR/LO={lowFrac, highFrac, order}/HI={200/samp, 300/samp, order} Deconv

return Deconv
End
Expand All @@ -382,12 +385,13 @@ static Function/WAVE PSX_CreateHistogramOfDeconvSweepData(WAVE deconvSweepData)

// we take +/- 80% of the average deviation around the average value
WaveStats/Q deconvSweepData
binWidth = 0.0001
range = V_adev * 0.8
// binWidth = 0.00005
range = V_adev * 2
start = V_avg - range
n_bins = 2 * range / binWidth
n_bins = 20
binWidth = 2 * range / n_bins

SFH_ASSERT(n_bins > 10, "Histogram creation failed due to too few data points")
// SFH_ASSERT(n_bins > 10, "Histogram creation failed due to too few data points")

Make/D/FREE/N=0 hist
Histogram/B={start, binWidth, n_bins}/DEST=hist deconvSweepData
Expand Down Expand Up @@ -4644,7 +4648,7 @@ static Function [WAVE hist, WAVE fit, variable peakThresh, string dataUnit] PSX_
[WAVE coef, WAVE fit] = PSX_FitHistogram(hist)

if(WaveExists(coef) && WaveExists(fit))
peakThresh = RoundNumber(coef[3] * numSDs, 3)
peakThresh = coef[3] * numSDs // RoundNumber(coef[3] * numSDs, 3)
dataUnit = WaveUnits(sweepDataOffFiltDeconv, -1)

return [hist, fit, peakThresh, dataUnit]
Expand Down

0 comments on commit 850c460

Please sign in to comment.