Hi,
I'm trying to use the movmedian function to denoise and down-sample a large 3D matrix.
This matrix is structured such that each colum represents a signal trace, captured in a specific location. There are a total of 3 repeated signal traces for each location, stored as adjacent columns in dimension 2. Neighbors in dimension 2 outside these groups correspond to repeats from spatially adjacent locations.
I want to use the movmedian function to capture the median from each repeat group and its neighbors, using the spatial correlation to help reject noise, as below:
th = linspace(0, 2*pi, sz1)';
data_clean = repmat(signal, 1, n_repeat*sz2, sz3);
data_noise = data_clean + 0.1*rand(sz1, n_repeat*sz2, sz3);
SamplePoints = 1:n_repeat:sz2;
data_denoise = movmedian(data_noise,[n_repeat, (2*n_repeat) - 1], ...
2, "SamplePoints", SamplePoints);
However, running this code, I receive the error message below:
This seems to be a bug in the input validation logic.
The documentation states that movmedian() is capable of running with non-uniform sample points, provided they are sorted and unique. However, any such vector of sample points would by definition have length less than the dimension along which the filter is applied.
Am I misunderstanding something, or are there any workarounds that I can use to achieve what I want without having to run unnecessary compute operations across the full matrix and discard results or revert to a nested for loop?
Appreciate any help offered,
Robert.