soft-matter / trackpy

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

[Question] How to add optional arguments in after_locate function in tp.batch #764

Closed JulietteSavoye closed 5 months ago

JulietteSavoye commented 6 months ago

Hello, According to the documentation of tp.batch, we can add a custom after_locate function to refine the features detection. This after_locate function needs 2 arguments : frame_no and features. However, in the refining i'm trying to perform, i also need the current frame in my function : how can i add an additional argument in after_locate ? Thanks in advance!

nkeim commented 5 months ago

To keep trackpy simple and avoid adding more optional arguments to batch, your refine function only gets the arguments that are absolutely necessary. I recommend writing your refine function so that it accesses your original image data. You can also use preprocess there if necessary.

The alternative is to write your own for loop to process each frame with preprocess, locate, and whatever else you'd like, instead of using batch. You can use pandas.concat to assemble the features from each frame into one large DataFrame.