If your data will always look similar to this (notch filter), try this: 1) After converting to dB, find the index of the min value of the array using the min/max function. 2) Split the array at that index using the split array function. 3) For each of these two arrays, do what you already did: find the max value, threshold and interpolate.
Dave.
