soft-matter / trackpy

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

Need different diameter in tp.locate on different computer? #653

Closed hmx0979 closed 3 years ago

hmx0979 commented 3 years ago

Hello everyone,

Recently, I'm trying to run trackpy on two of my computers.

The code runs good, but I need to use different diameters in tp.locate to find particles.

In my image, there are about 20 particles.

1, on my macbook pro, 2017, 13-inch

diameter = 5, gives the reasonable tracking result, and it runs fast.

2, on my mac mini (2020) with 24 inch monitor, better CPU, newer version.

diameter = 151, gives the same tracking result but it runs slow, if I use diameter = 5, I will get ~20K particles.

I wonder what causes the problem?

nkeim commented 3 years ago

Interesting! What other arguments are you passing to locate? And how are you reading the image files?

Nathan

On Mar 26, 2021, at 9:58 AM, hmx0979 @.***> wrote:



Hello everyone,

Recently, I'm trying to run trackpy on two of my computers.

The code runs good, but I need to use different diameters in tp.locate to find particles.

In my image, there are about 20 particles.

1, on my macbook pro, 2017

diameter = 5, gives the reasonable tracking result, and it runs fast.

2, on my mac mini (2020) with 24 inch monitor, better CPU, newer version.

diameter = 151, gives the same tracking result but it runs slow, if I use diameter = 5, I will get ~20K particles.

I wonder what causes the problem?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/soft-matter/trackpy/issues/653, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAWY23PVHJPOF6TIN7VKGHTTFSHGPANCNFSM4Z3OHG5Q.

hmx0979 commented 3 years ago

frames = pims.open('*.tif') f = tp.locate(frames[0], 5, invert=False)

That's my code reading tif files (converted from avi) and my tp.locate function

nkeim commented 3 years ago

Thanks! One thing to check would be the gray values in your images (for instance, peek at frames[0][0, 0]). Depending on what optional dependencies are installed for PIMS, sometimes PIMS returns integer gray values in the range [0, 255], and sometimes it returns floats in [0, 1].

I'm assuming that you have the same trackpy.__version__ on both computers!

hmx0979 commented 3 years ago

Thanks!

You raised a good point, my computers don't have the same version of trackpy.

My MacBook Pro is 0.3.3 and my mac mini is 0.4.2.

I have upgraded trackpy on my macbook to 0.4.2, so they have the same diameter now. d = 151,

This solves the problem that different computer requires different number. However, the diameter in pixel (d = 151) is too big. My particles are be no bigger than a few pixels, but here if I use d = 151, it is going to be very slow.

My images are dark-field images, particles are bright, background black. The particles are only several pixels in diameter.

nkeim commented 3 years ago

The diameter should be close to the actual diameter of the particles. At that large diameter the coordinates are almost certainly meaningless.

Your particles should be circular blobs on a dark background. Is that true? It might help to post a sample here.

On Mar 26, 2021, at 12:53 PM, hmx0979 @.***> wrote:



Thanks!

You raised a good point, my computers don't have the same version of trackpy.

My MacBook Pro is 0.3.3 and my mac mini is 0.4.2.

I have upgraded trackpy on my macbook to 0.4.2, so they have the same diameter now. d = 151,

This solves the problem that different computer requires different number. However, the diameter in pixel (d = 151) is too big. My particles are be no bigger than a few pixels, but here if I use d = 151, it is going to be very slow.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/soft-matter/trackpy/issues/653#issuecomment-808368892, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAWY23LVVCA6GEPRT6FXCW3TFS3WXANCNFSM4Z3OHG5Q.

hmx0979 commented 3 years ago

Hi,

Although I don't quite understand what causes the difference in diameter arguments, I think I solved the problem by adding minmass argument in tp.locate, this works fine for me, and it is fast.

1_1_80nm_Gold_45C_20fps_white_view_1_0000

Here is a sample image, it is polydisperse nanoparticles.

Well, I don't quite sure why diameter = 5 gives me about 20 particles in 0.3.3 but ~20K here, but adding a minmass argument filters out most of them.

Thank you very much

nkeim commented 3 years ago

In v0.4 we switched to minmass=0 as the default because there are other, more scale-free ways to filter. But it is perfectly fine to use it.

Be sure to check that the coordinates you do get are valid, as shown by e.g. tp.annotate().