I have a list that consists of certain number of coordinates sub-lists (here 8).
(The following data are only an example to describe my problem.)
list={
{1,{{1.00,1.00},{2.00,2.00},{3.00,3.00},{4.00,4.00},{5.00,5.00}}},
{2,{{2.01,2.01},{3.01,3.01},{1.01,1.01},{5.01,5.01},{4.01,4.01}}},
{3,{{1.02,1.02},{3.02,3.02},{4.02,4.02},{6.02,6.02},{5.02,5.02}}},
{4,{{7.00,7.00},{1.03,1.03},{6.03,6.03}}},
{5,{{1.50,1.50},{4.04,4.04},{6.04,6.04},{7.04,7.04}}},
{6,{{1.51,1.51},{4.05,4.05},{7.03,7.03},{6.05,6.05}}},
{7,{{2.50,2.50},{7.00,7.00},{5.01,5.01},{4.03,4.03},{8.01,8.01}}},
{8,{{2.51,2.51},{6.00,6.00},{7.01,7.01},{4.04,4.04},{8.02,8.02}}}
};
Each coordinate sub-list can have a different length.
Depending on the next-neareast coordinate between neighboured sub-lists (which should be below a certain threshold distance, here I assume 0.2) the list
should be reformed, so that tracks
is obtained.
tracks={
{{1,{1.,1.}},{2,{1.01,1.01}},{3,{1.02,1.02}},{4,{1.03,1.03}}},
{{1,{2.,2.}},{2,{2.01,2.01}}},{{1,{3.,3.}},{2,{3.01,3.01}},{3,{3.02,3.02}}},
{{1,{4.,4.}},{2,{4.01,4.01}},{3,{4.02,4.02}}},
{{1,{5.,5.}},{2,{5.01,5.01}},{3,{5.02,5.02}}},
{{3,{6.02,6.02}},{4,{6.03,6.03}},{5,{6.04,6.04}},{6,{6.05,6.05}}},
{{4,{7.,7.}},{5,{7.04,7.04}},{6,{7.03,7.03}},{7,{7.,7.}},{8,{7.01,7.01}}},
{{5,{1.5,1.5}},{6,{1.51,1.51}}},
{{5,{4.04,4.04}},{6,{4.05,4.05}},{7,{4.03,4.03}},{8,{4.04,4.04}}},
{{7,{2.5,2.5}},{8,{2.51,2.51}}},
{{7,{5.01,5.01}}},
{{7,{8.01,8.01}},{8,{8.02,8.02}}},
{{8,{6.,6.}}}
}
Please use (also for speed testing) a set of some real data which are available here: https://pastebin.com/rEzbC1kH.
Since I am not experienced enough with mathematica the only way what I can do is to use a do loop and then compare each coordinate of sub-list i
(1=<i<=8)
with the coordinates of sub-list i+1
, determine the corresponding nearest neighbour (always only one is existing) and then continute this way ...
How would you solve this?
Background information:
I am using a high speed camera and recording laser illuminated dust-like particles in a plasma. They all usually have a nearly constant spacing whereby they randomly move in small steps around their mean positions (step width << mean particle distance). During the observation time some can be lost since they move out of the laser beam and others can appear. One main part after finding the objects coordinates is to track them in time. The problem (“object/particle detection and tracking”) is very important e.g. in physics, biology and medicine.
In Matlab, Python (here trackpy is very famous) and IDL there are many (sophisticated) solutions for this problem, but until now I did not find anything in mathematica which solves this problem. I am surprised about that because mathematica is very strong in images analysis as well in list operations.
Example movie:
list
where6.01
should be6.02
? Also, intracks
, shouldn't{7,{7.00,7.00}
and{8,{7.01,7.01}}
be on the line starting with{4,{7.00,7.00}}
? $\endgroup$