soft-matter / trackpy

Python particle tracking toolkit
http://soft-matter.github.io/trackpy
Other
445 stars 131 forks source link

Trackpy sub-pixel bias #635

Closed praptibajaj28 closed 3 years ago

praptibajaj28 commented 3 years ago

I am using trackpy to locate and link particles in the attached raw image (cropped) . As you can see, the particle diameter is 3 pixels. The region of major interest is the one with very high density of particles. When I use particle size of 5 (for the full raw image and not cropped), trackpy finds reliable particle positions in high density region but it has terrible sub-pixel bias. When I use particle size of 7, trackpy doesn't find many particles in high density region and the ones found are also wrongly located. However, the sub-pixel resolution is good for particle size 7. Is there a method to improve the sub-pixel resolution in trackpy except changing the particle size?

For reference, I am also uploading images showing difference in the particles found using particle size 5 and particle size 7 with the same minmass value. The one with more particle labelled is made with particle size 5.

Thank you. SPB7_sc01fr0_251120 SPB5_sc01fr0_251120

rbnvrw commented 3 years ago

Thank you for your question. In general, the radius that you use should match the feature size. However, in your case, the features are very small (only 2 to 3 pixels). Trackpy is not meant to track features that are this small. It uses the assumption that your features are Gaussian blobs, which does not apply here. You could write your own custom algorithm that detects 2x2 (?) pixel squares and use Trackpy for linking, as in the bubble tutorial: http://soft-matter.github.io/trackpy/dev/tutorial/custom-feature-detection.html But it is doubtful whether you can even get subpixel accuracy from these tiny features. Let me know if this helps!

praptibajaj28 commented 3 years ago

@rbnvrw Thank you very much for your reply. I did make it work for my particles with these parameters : particle_size=5, minmass=15, invert=False, max_iterations=100000, separation=2, characterize=True, noise_size=0.5, threshold=5. I arrived at these results after reading a few papers from my field about sub-pixel bias and then trying different parameters to reach the ideal conditions. And here you can see that the sub-pixel bias is negligible and the particles are also tracked quite well. I think the parameter "separation" was important to reach these results as for smaller particles with such high density, this could be an important parameter. sc01_fr0_subpx_021220