# Manipulating list based on Euclidean distance

I have an array of 101 matrices. Each matrix contains information like id, position (x,y,z), time etc about a collection of particles, looks like this

{{{9.*10^7, 1.13076*10^6, 0.56, 0.56, 1.05, 1.31518, 25.}, {3.33657*10^8,
1.23356*10^6, 0.91, 0.79, 3.98, 4.15844, 25.}, {2.21834*10^8,
2.42599*10^6, 0.08, 1.85, 2.56, 3.15951, 25.}, {1.02159*10^8,
1.33635*10^6, 0.19, 3.05, 1.27, 3.30931, 25.}, {1.11154*10^8,
1.08964*10^6, 0.24, 3., 1.37, 3.30674, 25.}, {2.49596*10^8,
1.0074*10^6, 0.17, 3.6, 2.94, 4.65108, 25.}, {1.33363*10^8,
1.15132*10^6, 1.38, 0.46, 1.57, 2.1403, 25.}, {1.60336*10^8,
2.15872*10^6, 1.75, 0.29, 1.9, 2.59935, 25.}, {1.63155*10^8,
1.02796*10^6, 1.73, 0.31, 1.91, 2.59559, 25.}, {5.755*10^7,
1.43915*10^6, 1.59, 1.51, 0.7, 2.30178, 25.}, {4.03166*10^8,
1.04852*10^6, 1.3, 3.73, 4.8, 6.21634, 25.}, {1.0938*10^8,
1.02796*10^6, 2.92, 2.19, 1.26, 3.86136, 25.}, {1.41208*10^8,
1.06908*10^6, 4.3, 0.22, 1.68, 4.62177, 25.}, {2.33642*10^8,
1.04852*10^6, 4.97, 1.82, 2.7, 5.94166, 25.}, {2.35328*10^8,
1.45971*10^6, 4.98, 1.81, 2.72, 5.95608, 25.}, {1.38724*10^8,
1.23356*10^6, 0.07, 3.05, 1.65, 3.46841, 25.}, {1.35352*10^8,
2.48767*10^6, 0.05, 3.08, 1.63, 3.48508, 25.}, {2.78341*10^8,
2.56991*10^6, 0.01, 4.15, 3.3, 5.30213, 25.}}, {{8.61278*10^7,
1.13076*10^6, 0.56, 0.56, 1.05, 1.31518, 25.1}, {3.33657*10^8,
1.23356*10^6, 0.91, 0.79, 3.97, 4.14887, 25.1}, {2.21834*10^8,
2.38487*10^6, 0.08, 1.85, 2.56, 3.15951, 25.1}, {1.02159*10^8,
1.33635*10^6, 0.19, 3.05, 1.27, 3.30931, 25.1}, {1.33363*10^8,
1.15132*10^6, 1.38, 0.46, 1.57, 2.1403, 25.1}, {1.60336*10^8,
1.93257*10^6, 1.75, 0.29, 1.9, 2.59935, 25.1}, {5.755*10^7,
1.41859*10^6, 1.59, 1.51, 0.7, 2.30178, 25.1}, {4.03166*10^8,
1.04852*10^6, 1.3, 3.73, 4.8, 6.21634, 25.1}, {1.0938*10^8,
1.0074*10^6, 2.92, 2.19, 1.26, 3.86136, 25.1}, {1.41208*10^8,
1.06908*10^6, 4.3, 0.22, 1.68, 4.62177, 25.1}, {2.33642*10^8,
1.04852*10^6, 4.97, 1.82, 2.7, 5.94166, 25.1}, {2.35328*10^8,
1.31579*10^6, 4.98, 1.81, 2.72, 5.95608, 25.1}, {1.38724*10^8,
1.23356*10^6, 0.07, 3.05, 1.65, 3.46841, 25.1}, {1.35352*10^8,
2.40543*10^6, 0.05, 3.08, 1.63, 3.48508, 25.1}, {2.78341*10^8,
2.52879*10^6, 0.01, 4.15, 3.3, 5.30213, 25.1}}, {{8.61278*10^7,
1.1102*10^6, 0.56, 0.56, 1.05, 1.31518, 25.2}, {3.33657*10^8,
1.23356*10^6, 0.91, 0.79, 3.97, 4.14887, 25.2}, {2.21834*10^8,
2.36431*10^6, 0.08, 1.85, 2.56, 3.15951, 25.2}, {1.02159*10^8,
1.31579*10^6, 0.19, 3.05, 1.27, 3.30931, 25.2}, {1.33363*10^8,
1.15132*10^6, 1.38, 0.46, 1.57, 2.1403, 25.2}, {1.60336*10^8,
1.93257*10^6, 1.75, 0.29, 1.9, 2.59935, 25.2}, {5.755*10^7,
1.41859*10^6, 1.59, 1.51, 0.7, 2.30178, 25.2}, {4.03166*10^8,
1.0074*10^6, 1.31, 3.73, 4.8, 6.21844, 25.2}, {1.41208*10^8,
1.06908*10^6, 4.3, 0.22, 1.68, 4.62177, 25.2}, {2.33642*10^8,
1.04852*10^6, 4.97, 1.82, 2.7, 5.94166, 25.2}, {2.35328*10^8,
1.29523*10^6, 4.98, 1.81, 2.72, 5.95608, 25.2}, {1.38724*10^8,
1.213*10^6, 0.07, 3.05, 1.65, 3.46841, 25.2}, {1.35352*10^8,
2.34376*10^6, 0.05, 3.08, 1.63, 3.48508, 25.2}, {2.78341*10^8,
2.50823*10^6, 0.01, 4.15, 3.3, 5.30213, 25.2}}, {{8.61278*10^7,
1.1102*10^6, 0.56, 0.56, 1.05, 1.31518, 25.3}, {3.33657*10^8,
1.13076*10^6, 0.91, 0.79, 3.97, 4.14887, 25.3}, {2.21834*10^8,
2.30264*10^6, 0.08, 1.85, 2.56, 3.15951, 25.3}, {1.02159*10^8,
1.31579*10^6, 0.19, 3.05, 1.27, 3.30931, 25.3}, {1.33363*10^8,
1.15132*10^6, 1.38, 0.46, 1.57, 2.1403, 25.3}, {1.60336*10^8,
1.89145*10^6, 1.75, 0.29, 1.9, 2.59935, 25.3}, {5.755*10^7,
1.41859*10^6, 1.59, 1.51, 0.7, 2.30178, 25.3}, {1.41208*10^8,
1.06908*10^6, 4.3, 0.22, 1.68, 4.62177, 25.3}, {2.33642*10^8,
1.04852*10^6, 4.97, 1.82, 2.7, 5.94166, 25.3}, {2.35328*10^8,
1.29523*10^6, 4.98, 1.81, 2.72, 5.95608, 25.3}, {1.38724*10^8,
1.19244*10^6, 0.07, 3.05, 1.65, 3.46841, 25.3}, {1.35352*10^8,
2.3232*10^6, 0.05, 3.08, 1.63, 3.48508, 25.3}, {2.78341*10^8,
2.46711*10^6, 0.01, 4.15, 3.3, 5.30213, 25.3}}, {{8.61278*10^7,
1.1102*10^6, 0.56, 0.56, 1.05, 1.31518, 25.4}, {2.21834*10^8,
2.15872*10^6, 0.08, 1.85, 2.56, 3.15951, 25.4}, {1.02159*10^8,
1.31579*10^6, 0.18, 3.05, 1.27, 3.30875, 25.4}, {1.33363*10^8,
1.15132*10^6, 1.38, 0.46, 1.57, 2.1403, 25.4}, {1.60336*10^8,
1.89145*10^6, 1.75, 0.29, 1.9, 2.59935, 25.4}, {5.755*10^7,
1.37747*10^6, 1.59, 1.51, 0.7, 2.30178, 25.4}, {1.41208*10^8,
1.06908*10^6, 4.3, 0.22, 1.68, 4.62177, 25.4}, {2.35328*10^8,
1.29523*10^6, 4.98, 1.81, 2.72, 5.95608, 25.4}, {1.38724*10^8,
1.15132*10^6, 0.07, 3.05, 1.65, 3.46841, 25.4}, {1.35352*10^8,
2.26152*10^6, 0.05, 3.08, 1.63, 3.48508, 25.4}, {2.78341*10^8,
2.38487*10^6, 0.01, 4.15, 3.3, 5.30213, 25.4}}, {{8.61278*10^7,
1.08964*10^6, 0.56, 0.56, 1.05, 1.31518, 25.5}, {2.21834*10^8,
2.13816*10^6, 0.08, 1.85, 2.56, 3.15951, 25.5}, {1.02159*10^8,
1.27467*10^6, 0.18, 3.05, 1.27, 3.30875, 25.5}, {1.33363*10^8,
1.15132*10^6, 1.38, 0.46, 1.57, 2.1403, 25.5}, {1.60336*10^8,
1.85033*10^6, 1.75, 0.29, 1.9, 2.59935, 25.5}, {5.755*10^7,
1.25411*10^6, 1.59, 1.51, 0.7, 2.30178, 25.5}, {1.41208*10^8,
1.02796*10^6, 4.3, 0.22, 1.68, 4.62177, 25.5}, {2.35328*10^8,
1.29523*10^6, 4.98, 1.81, 2.72, 5.95608, 25.5}, {1.38724*10^8,
1.13076*10^6, 0.07, 3.05, 1.65, 3.46841, 25.5}, {1.35352*10^8,
2.2204*10^6, 0.05, 3.08, 1.63, 3.48508, 25.5}, {2.78341*10^8,
2.36431*10^6, 0.01, 4.15, 3.3, 5.30213, 25.5}}, {{8.61278*10^7,
1.08964*10^6, 0.56, 0.56, 1.05, 1.31518, 25.6}, {2.21834*10^8,
2.09704*10^6, 0.08, 1.85, 2.56, 3.15951, 25.6}, {1.02159*10^8,
1.23356*10^6, 0.18, 3.05, 1.27, 3.30875, 25.6}, {1.33363*10^8,
1.15132*10^6, 1.38, 0.46, 1.57, 2.1403, 25.6}, {1.60336*10^8,
1.37747*10^6, 1.75, 0.28, 1.9, 2.59825, 25.6}, {5.755*10^7,
1.19244*10^6, 1.59, 1.52, 0.7, 2.30835, 25.6}, {1.41208*10^8,
1.02796*10^6, 4.3, 0.22, 1.68, 4.62177, 25.6}, {2.35328*10^8,
1.25411*10^6, 4.98, 1.81, 2.72, 5.95608, 25.6}, {1.38724*10^8,
1.13076*10^6, 0.07, 3.05, 1.65, 3.46841, 25.6}, {1.35352*10^8,
2.1176*10^6, 0.05, 3.08, 1.63, 3.48508, 25.6}, {2.78341*10^8,
2.28208*10^6, 0.01, 4.15, 3.3, 5.30213, 25.6}}, {{8.61278*10^7,
1.08964*10^6, 0.56, 0.56, 1.05, 1.31518, 25.7}, {2.21834*10^8,
2.01481*10^6, 0.08, 1.85, 2.56, 3.15951, 25.7}, {1.02159*10^8,
1.213*10^6, 0.18, 3.05, 1.27, 3.30875, 25.7}, {1.33363*10^8,
1.15132*10^6, 1.38, 0.46, 1.57, 2.1403, 25.7}, {1.60336*10^8,
1.33635*10^6, 1.75, 0.28, 1.9, 2.59825, 25.7}, {5.755*10^7,
1.15132*10^6, 1.59, 1.52, 0.7, 2.30835, 25.7}, {1.41208*10^8,
1.0074*10^6, 4.3, 0.22, 1.68, 4.62177, 25.7}, {2.35328*10^8,
1.213*10^6, 4.98, 1.81, 2.72, 5.95608, 25.7}, {1.38724*10^8,
1.06908*10^6, 0.07, 3.05, 1.65, 3.46841, 25.7}, {1.35352*10^8,
2.09704*10^6, 0.05, 3.08, 1.63, 3.48508, 25.7}, {2.78341*10^8,
2.26152*10^6, 0.01, 4.15, 3.3, 5.30213, 25.7}}, {{8.61278*10^7,
1.08964*10^6, 0.55, 0.56, 1.05, 1.31095, 25.8}, {2.21834*10^8,
1.99425*10^6, 0.08, 1.85, 2.56, 3.15951, 25.8}, {1.02159*10^8,
1.19244*10^6, 0.18, 3.05, 1.27, 3.30875, 25.8}, {1.33363*10^8,
1.13076*10^6, 1.38, 0.46, 1.57, 2.1403, 25.8}, {1.60336*10^8,
1.33635*10^6, 1.75, 0.28, 1.9, 2.59825, 25.8}, {5.755*10^7,
1.15132*10^6, 1.59, 1.52, 0.7, 2.30835, 25.8}, {1.41208*10^8,
1.0074*10^6, 4.29, 0.22, 1.68, 4.61247, 25.8}, {2.35328*10^8,
1.19244*10^6, 4.98, 1.81, 2.72, 5.95608, 25.8}, {1.38724*10^8,
1.06908*10^6, 0.07, 3.05, 1.65, 3.46841, 25.8}, {1.35352*10^8,
1.99425*10^6, 0.05, 3.08, 1.63, 3.48508, 25.8}, {2.78341*10^8,
2.19984*10^6, 0.01, 4.15, 3.3, 5.30213, 25.8}}, {{8.61278*10^7,
1.08964*10^6, 0.55, 0.56, 1.05, 1.31095, 25.9}, {2.21834*10^8,
1.97369*10^6, 0.08, 1.85, 2.56, 3.15951, 25.9}, {1.02159*10^8,
1.15132*10^6, 0.18, 3.05, 1.27, 3.30875, 25.9}, {1.33363*10^8,
1.13076*10^6, 1.38, 0.46, 1.57, 2.1403, 25.9}, {1.60336*10^8,
1.33635*10^6, 1.75, 0.28, 1.9, 2.59825, 25.9}, {5.755*10^7,
1.06908*10^6, 1.59, 1.52, 0.7, 2.30835, 25.9}, {1.41208*10^8,
1.0074*10^6, 4.29, 0.22, 1.68, 4.61247, 25.9}, {2.35328*10^8,
1.15132*10^6, 4.98, 1.81, 2.72, 5.95608, 25.9}, {1.38724*10^8,
1.0074*10^6, 0.07, 3.05, 1.65, 3.46841, 25.9}, {1.35352*10^8,
1.91201*10^6, 0.05, 3.08, 1.63, 3.48508, 25.9}, {2.78341*10^8,
2.1176*10^6, 0.01, 4.15, 3.3, 5.30213, 25.9}}, {{8.61278*10^7,
1.06908*10^6, 0.55, 0.56, 1.05, 1.31095, 26.}, {2.21834*10^8,
1.97369*10^6, 0.08, 1.85, 2.56, 3.15951, 26.}, {1.02159*10^8,
1.08964*10^6, 0.18, 3.05, 1.27, 3.30875, 26.}, {1.33363*10^8,
1.13076*10^6, 1.38, 0.46, 1.57, 2.1403, 26.}, {1.60336*10^8,
1.33635*10^6, 1.75, 0.28, 1.9, 2.59825, 26.}, {2.35328*10^8,
1.15132*10^6, 4.98, 1.81, 2.72, 5.95608, 26.}, {1.35352*10^8,
1.80921*10^6, 0.05, 3.08, 1.63, 3.48508, 26.}, {2.78341*10^8,
2.07648*10^6, 0.01, 4.15, 3.3, 5.30213, 26.}}, {{8.61278*10^7,
1.0074*10^6, 0.55, 0.56, 1.05, 1.31095, 26.1}, {2.21834*10^8,
1.97369*10^6, 0.08, 1.85, 2.56, 3.15951, 26.1}, {1.02159*10^8,
1.0074*10^6, 0.18, 3.05, 1.27, 3.30875, 26.1}, {1.33363*10^8,
1.08964*10^6, 1.38, 0.46, 1.57, 2.1403, 26.1}, {1.60336*10^8,
1.31579*10^6, 1.75, 0.28, 1.9, 2.59825, 26.1}, {2.35328*10^8,
1.15132*10^6, 4.98, 1.81, 2.72, 5.95608, 26.1}, {1.35352*10^8,
1.74754*10^6, 0.05, 3.08, 1.63, 3.48508, 26.1}, {2.78341*10^8,
2.07648*10^6, 0.01, 4.15, 3.3, 5.30213, 26.1}}, {{2.21834*10^8,
1.97369*10^6, 0.08, 1.85, 2.56, 3.15951, 26.2}, {1.33363*10^8,
1.06908*10^6, 1.38, 0.46, 1.57, 2.1403, 26.2}, {1.60336*10^8,
1.08964*10^6, 1.75, 0.28, 1.9, 2.59825, 26.2}, {2.35328*10^8,
1.15132*10^6, 4.98, 1.81, 2.72, 5.95608, 26.2}, {1.35352*10^8,
1.72698*10^6, 0.05, 3.08, 1.63, 3.48508, 26.2}, {2.78341*10^8,
2.07648*10^6, 0.01, 4.15, 3.3, 5.30213, 26.2}}, {{2.21834*10^8,
1.89145*10^6, 0.08, 1.85, 2.56, 3.15951, 26.3}, {1.33363*10^8,
1.06908*10^6, 1.38, 0.46, 1.57, 2.1403, 26.3}, {1.60336*10^8,
1.08964*10^6, 1.75, 0.28, 1.9, 2.59825, 26.3}, {2.35328*10^8,
1.15132*10^6, 4.98, 1.81, 2.72, 5.95608, 26.3}, {1.35352*10^8,
1.72698*10^6, 0.05, 3.08, 1.63, 3.48508, 26.3}, {2.78341*10^8,
2.07648*10^6, 0.01, 4.15, 3.3, 5.30213, 26.3}}, {{2.21834*10^8,
1.87089*10^6, 0.08, 1.85, 2.56, 3.15951, 26.4}, {1.33363*10^8,
1.04852*10^6, 1.38, 0.46, 1.57, 2.1403, 26.4}, {2.35328*10^8,
1.15132*10^6, 4.98, 1.81, 2.72, 5.95608, 26.4}, {1.35352*10^8,
1.62418*10^6, 0.05, 3.08, 1.63, 3.48508, 26.4}, {2.78341*10^8,
1.95313*10^6, 0.01, 4.15, 3.3, 5.30213, 26.4}}, {{2.21834*10^8,
1.87089*10^6, 0.08, 1.85, 2.56, 3.15951, 26.5}, {1.33363*10^8,
1.02796*10^6, 1.38, 0.46, 1.57, 2.1403, 26.5}, {2.35328*10^8,
1.15132*10^6, 4.98, 1.81, 2.72, 5.95608, 26.5}, {1.35352*10^8,
1.58306*10^6, 0.05, 3.08, 1.63, 3.48508, 26.5}, {2.78341*10^8,
1.93257*10^6, 0.01, 4.15, 3.3, 5.30213, 26.5}}, {{2.21834*10^8,
1.87089*10^6, 0.08, 1.85, 2.57, 3.16762, 26.6}, {1.33363*10^8,
1.02796*10^6, 1.38, 0.46, 1.57, 2.1403, 26.6}, {2.35328*10^8,
1.06908*10^6, 4.98, 1.81, 2.72, 5.95608, 26.6}, {1.35352*10^8,
1.58306*10^6, 0.05, 3.08, 1.63, 3.48508, 26.6}, {2.78341*10^8,
1.89145*10^6, 0.01, 4.15, 3.3, 5.30213, 26.6}}, {{2.21834*10^8,
1.87089*10^6, 0.08, 1.85, 2.57, 3.16762, 26.7}, {1.33363*10^8,
1.02796*10^6, 1.38, 0.46, 1.57, 2.1403, 26.7}, {2.35328*10^8,
1.06908*10^6, 4.98, 1.81, 2.72, 5.95608, 26.7}, {1.35352*10^8,
1.5625*10^6, 0.05, 3.08, 1.63, 3.48508, 26.7}, {2.78341*10^8,
1.89145*10^6, 0.01, 4.15, 3.3, 5.30213, 26.7}}, {{2.21834*10^8,
1.87089*10^6, 0.08, 1.85, 2.57, 3.16762, 26.8}, {1.33363*10^8,
1.02796*10^6, 1.38, 0.46, 1.57, 2.1403, 26.8}, {2.35328*10^8,
1.04852*10^6, 4.98, 1.81, 2.72, 5.95608, 26.8}, {1.35352*10^8,
1.5625*10^6, 0.05, 3.08, 1.63, 3.48508, 26.8}, {2.78341*10^8,
1.89145*10^6, 0.01, 4.14, 3.3, 5.29431, 26.8}}, {{2.21834*10^8,
1.87089*10^6, 0.08, 1.85, 2.57, 3.16762, 26.9}, {2.35328*10^8,
1.02796*10^6, 4.98, 1.81, 2.72, 5.95608, 26.9}, {1.35352*10^8,
1.25411*10^6, 0.05, 3.08, 1.63, 3.48508, 26.9}, {2.78341*10^8,
1.58306*10^6, 0.01, 4.15, 3.3, 5.30213, 26.9}}, {{2.21834*10^8,
1.87089*10^6, 0.08, 1.85, 2.57, 3.16762, 27.}, {1.35352*10^8,
1.17188*10^6, 0.05, 3.08, 1.63, 3.48508, 27.}, {2.78341*10^8,
1.58306*10^6, 0.01, 4.15, 3.3, 5.30213, 27.}}, {{2.21834*10^8,
1.87089*10^6, 0.08, 1.85, 2.57, 3.16762, 27.1}, {1.35352*10^8,
1.17188*10^6, 0.05, 3.08, 1.63, 3.48508, 27.1}, {2.78341*10^8,
1.43915*10^6, 0.01, 4.15, 3.3, 5.30213, 27.1}}, {{2.21834*10^8,
1.85033*10^6, 0.08, 1.85, 2.57, 3.16762, 27.2}, {1.35352*10^8,
1.17188*10^6, 0.05, 3.08, 1.63, 3.48508, 27.2}, {2.78341*10^8,
1.35691*10^6, 0.01, 4.15, 3.3, 5.30213, 27.2}}, {{2.21834*10^8,
1.82977*10^6, 0.08, 1.85, 2.57, 3.16762, 27.3}, {1.35352*10^8,
1.17188*10^6, 0.05, 3.08, 1.63, 3.48508, 27.3}, {2.78341*10^8,
1.33635*10^6, 0.01, 4.15, 3.3, 5.30213, 27.3}}, {{2.21834*10^8,
1.78866*10^6, 0.08, 1.85, 2.57, 3.16762, 27.4}, {1.35352*10^8,
1.15132*10^6, 0.04, 3.08, 1.63, 3.48495, 27.4}, {2.78341*10^8,
1.25411*10^6, 0.01, 4.15, 3.3, 5.30213, 27.4}}, {{2.21834*10^8,
1.60362*10^6, 0.08, 1.85, 2.57, 3.16762, 27.5}, {1.35352*10^8,
1.1102*10^6, 0.04, 3.08, 1.63, 3.48495, 27.5}, {2.78341*10^8,
1.25411*10^6, 0.01, 4.15, 3.3, 5.30213, 27.5}}, {{2.21834*10^8,
1.5625*10^6, 0.08, 1.85, 2.57, 3.16762, 27.6}, {1.35352*10^8,
1.06908*10^6, 0.04, 3.08, 1.63, 3.48495, 27.6}, {2.78341*10^8,
1.23356*10^6, 0.01, 4.15, 3.3, 5.30213, 27.6}}, {{2.21834*10^8,
1.52139*10^6, 0.08, 1.85, 2.57, 3.16762, 27.7}, {1.35352*10^8,
1.04852*10^6, 0.04, 3.08, 1.63, 3.48495, 27.7}, {2.78341*10^8,
1.15132*10^6, 0.01, 4.15, 3.3, 5.30213, 27.7}}, {{2.78341*10^8,
1.15132*10^6, 0.01, 4.15, 3.3, 5.30213, 27.8}}, {{2.78341*10^8,
1.15132*10^6, 0.01, 4.15, 3.3, 5.30213, 27.9}}, {{2.78341*10^8,
1.15132*10^6, 0.01, 4.15, 3.3, 5.30213, 28.}}, {{2.78341*10^8,
1.13076*10^6, 0.01, 4.15, 3.3, 5.30213, 28.1}}, {{2.78341*10^8,
1.08964*10^6, 0.01, 4.15, 3.3, 5.30213, 28.2}}}


The first column is the ID, 2nd its mass, 3,4,5th are its x,y,z coordinates and the last column is its time.

Each matrix is a snapshot of the system of particles at different time. I am trying to sort those particles whose inter-particle distance is never less than say 0.01 (in units of this output). With the help of this forum Modifying a list of matrices with conditional statement I was able to sort particles based on their interparticle distance being greater than 0.01 at each time, independent of their proximity during other time.

However, now I want to refine this further. I want to run a similar conditional sort to pick particles which "never" came closer to any other particle by more than a distance of 0.01. For this I would like to start at the earliest time and identify each particle with its halo id (1st column) which were at least at a distance of 0.01 from all other particle, if they were less than 0.01 apart, I ignore those particles from further sorting. This way I will make sure that at the end of sorting, I have only those particles at each time which never came closer to any other particle in its history.

EDIT: I should note that the particles can merge to form another particle. So let's say at time t1, there are two particles A and B, 0.01 apart, at t2, a third particle closes in on B. At t3, the third particle merges with B and retains the particle ID B. And let's also assume that A and B are still more than 0.01 apart. Now based on my previous sorting code, I would get 2 particles to be at least 0.01 apart, however in the new code, I want to exclude B as it did come in close proximity to another particle in its history.

• First, reduce your matrix to just sets of {x,y,z} as ID, time, etc. are irrelevant. (You could help us by posting just such minimal data.) – David G. Stork Apr 4 '15 at 0:42
• I think particle ID is important, as otherwise it's not possible to pinpoint whether a particular particle was ever in closer proximity than 0.01 with any other particle. – HuShu Apr 4 '15 at 0:53
• Hello @Bill please see the edited post. – HuShu Apr 4 '15 at 1:37
• B is not included because it was in close proximity to the third merging particle at some point in its history, as the third particle merged into B. Making list and intersecting is not going to work because of the reason I stated : Particles merge, and retain the ID of the more massive particle, and both the merging particles should not be sorted. – HuShu Apr 4 '15 at 5:14
• This might be an application of Dataset. I tried with your data but reading in was was not successful. The lengths of your data are: In[11]:= Length /@ data Out[11]= {18, 15, 14, 13, 11, 11, 11, 11, 11, 11, 8, 8, 6, 6, 5, 5, \ 5, 5, 5, 4, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1}. But once the data is in a Dataset you can manage to calculate with this data quite easy. – mgamer Apr 4 '15 at 12:23

You are right about the format of your data, it is the right and the best format for this question. I imagine that a solution could look like this:

findCollisions[collided_, pts_] := Module[
{npts = DeleteCases[pts, {Alternatives @@ collided, __}, {2}]},
collided~Union~Select[npts, withinRange[npts, 0.1]][[All, 1]]
]
withinRange[pts_, threshold_][pt_] := Length@Nearest[Complement[pts, {pt}][[All, {3, 4, 5}]], pt[[{3, 4, 5}]], {1, threshold}] > 0
ids = Fold[findCollisions, {}, data]


where data is your list and ids are the IDs of particles that ever came within the specified distance from another particle. However upon running this code you will find that ids is an empty list. You have to increase the range from 0.01 to for example 0.1 before you get a list non-empty list. This could either mean that I've made a mistake or that the sample data doesn't include any situations where particles are within 0.01 of each other.

The idea is to delete the particles corresponding to ids from your original data:

DeleteCases[data, {Alternatives @@ ids, __}, {2}]

• Thank you very much for your reply. I think there is something wrong. I used a mock data which is very similar to the example that I gave and the id list is empty. – HuShu Apr 5 '15 at 0:34
• MockData1 = {{{9.*10^7, 1.13076*10^6, 0.56, 0.56, 1.05, 1.31518, 25.}, {3.33657*10^8, 1.23356*10^6, 0.91, 0.79, 3.98, 4.15844, 25.}}, {{9.*10^7, 1.13076*10^6, 0.56, 0.56, 1.05, 1.31518, 24.9}, {3.33657*10^8, 1.23356*10^6, 0.91, 0.79, 3.90, 4.15844, 24.9}, {3.33634*10^8, 1.23356*10^6, 0.90, 0.79, 3.90, 4.15844, 24.9}}, {{9.*10^7, 1.13076*10^6, 0.56, 0.56, 1.05, 1.31518, 24.8}, {3.33657*10^8, 1.23356*10^6, 0.91, 0.79, 3.90, 4.15844, 24.8}}} – HuShu Apr 5 '15 at 0:34
• @NilanjanBanik It depends on your threshold. 0.01 versus 0.1 versus 1. You have to try it on a sample where you know what the result should be to make sure it works. – C. E. Apr 5 '15 at 0:40
• Yes I did try it with 0.1 instead of 0.01, I also tried with 1, but then I get all the particles in the collided list, which should not be the case as the first particle is always away from all the others by at least >1. – HuShu Apr 5 '15 at 0:45
• Yes, I used the MockData1 to test the code out. I should expect only the first particle to be untouched and the collided list should the remaining two particles. See comments. – HuShu Apr 5 '15 at 0:53