1
$\begingroup$

I have bivariate data representing the position of an identified reference point along a y axis which ranges from -100 to 100 mm. When I plot this data in a scatter plot I can see outliers and groups of wrongfully identified reference points. I know that since it is a spatial use case a continous track of points must exist along the x axis without large jumps in y. So using a computer vision algorithm I can identify a largest connected component with a very wide (large x component) and short (small y component) kernel using some erosion beforehand. However I dont know how to extract the information from the computer vision approach such that I can use it in my original data which is in x and y representing milimiters. The other alternative I am thinking about is using some sort of clustering or other type of (path) finding algorithm which could identify for me what the largest connected component horizontally wise is.

Orignal Data

General Ideas are much appreciated.

I tried a largest connected component algorithm from opencv and some DBSCAN / OPTICS approaches. I expect a output which tells me which points are outliers, considering that outliers might even be denser point clouds based on the notion of one connected component going from start to end of my scatter plot. Thus I can remove these points from my bivariate data.

HDBSCAN with only noise

Maybe I do not understand HDBSCAN correctly, but the results are the same as with DBSCAN or Optics for me. The key is that my constraint is not only density but it also needs to span the entire x axis. HDBSCAN identifies over 30 what clusters and the largest cluster is noise. I tried several hyperparam choices, however I am not an expert on this

black track marked

The Black marked area shows where the actual track is running along. I am fine with a certain uncertainty at the current stage I am at, so i marked the upper and lower boundaries of that track

$\endgroup$
4
  • $\begingroup$ Could you share the data as a mat, npz or csv file? $\endgroup$
    – Royi
    Commented Nov 4 at 6:11
  • $\begingroup$ sure i iwll add a link in the post $\endgroup$ Commented Nov 4 at 21:37
  • $\begingroup$ Great. Ping me when you do post it. $\endgroup$
    – Royi
    Commented Nov 5 at 6:24
  • $\begingroup$ Are you posting the data? $\endgroup$
    – Royi
    Commented Nov 8 at 21:09

1 Answer 1

0
$\begingroup$

Don't use a computer vision approach to data that is decidedly not a 2D image but a track of data. The fact that this works somewhat (it doesn't really work, as you notice) is that for this specific realization of the data, you chose visual points "large" enough for them to overlap.

That's not a robust approach.

So, many ways to cluster points: k-means clustering is the classical approach. But quite frankly, that still assumes you have points that freely distribute on the 2D plane.

That's just not the case for you! You have a 1D signal. So treat it like one.

In your case, a median filter, rejecting any smaples that are more than, say, 2 standard deviations of the last last 100 samples away from the median of the last 100 samples (adjust "2" and "100") should work rather well. You could even adaptively adjust these parameters based on some other "goodness" criterion (like the standard deviation of the samples post-cleanup).

$\endgroup$
5
  • $\begingroup$ Thanks a lot I will try ! Do you have any recommendation for a python library that does this already? scipy seems to only do vanilla median. if not I will build it my self, just didnt want to reinvent the wheel here. $\endgroup$ Commented Nov 3 at 22:03
  • $\begingroup$ And how would i deal with larger "miss sections" in my data? So say I have 100 points which are wrong but together they form a cluster of their own which will get picked up by the median filter and destroy my data $\endgroup$ Commented Nov 3 at 22:48
  • $\begingroup$ if that happens, then the "window length" (so the 100 in my example) weren't long enough. $\endgroup$ Commented Nov 4 at 8:44
  • $\begingroup$ But if my window length is too large than true ups or downs of my track get smoothed away. So for example the track coming down from 60 to 20 in the beginning at 400 would get smoothed away since the overall median is much lower. However the clusters around 60 in general should be removed. the rule is that a cluster can only belong to the track if there are points that lead up to and back from that cluster. $\endgroup$ Commented Nov 4 at 21:48
  • $\begingroup$ that's what I said about adaptivity. Start with something that works in most places, then figure out how you can determine whether the median size is correct. Trick: if you're processing recordings (and not live data as it comes in), you get to choose the point in the recording where you want to start your processing! You can apply the same principle in both forward and backwards directions, especially if you make the window centered around the current samples (and not just like I described in my answer above looking back at the last N samples) $\endgroup$ Commented Nov 5 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.