quantumjot / btrack

Bayesian multi-object tracking
https://btrack.readthedocs.io
MIT License
309 stars 50 forks source link

Nuclei mask slightly overlap, causing btrack to assign them the same ID #318

Closed HaoranYueRyan closed 1 year ago

HaoranYueRyan commented 1 year ago

Hi author,

Thank you for providing the amazing tracking algorithms. I was trying to run btrack with my image data (1080, 1024, 1024) and encountered an issue where cells slightly overlap, causing btrack to assign them the same ID. Subsequently, when cells move to different areas, their IDs change to different ones.

For example, ID 1 overlaps with ID 7, they are assigned the same ID, and then ID 1 becomes ID 126. Screenshot 2023-05-09 at 12 51 45 Screenshot 2023-05-09 at 12 51 52 Screenshot 2023-05-09 at 12 52 01 Screenshot 2023-05-09 at 12 52 11 Screenshot 2023-05-09 at 12 52 22

To address this issue, I tried adjusting the maximum search radius from 50 to 25 and 16, and also used more features in the feature list:

tracker.features=["area", "perimeter", "solidity", "major_axis_length", "minor_axis_length", "orientation", 'intensity_max', 'intensity_mean', 'intensity_min'] Additionally, I doubled the values of lambda_dist, lambda_time, theta_dist, and theta_time in the hypothesis parameters.

If you have any suggestions on how to resolve this error, please let me know.

quantumjot commented 1 year ago

Hi @HaoranYueRyan - this looks like an issue with your segmentation. btrack is working as expected. I would suggest you perform a watershed segmentation, to separate the nuclei, before you run the tracking:

https://scikit-image.org/docs/stable/auto_examples/segmentation/plot_watershed.html

HaoranYueRyan commented 1 year ago

Hi @quantumjot Thanks for your promet respone. l appreciate your insight on segmentation and l'd like to provide more information to clarify my suitation.

I utilized Cellpose for the segmentation, which generall produces separeated masks for individual nuclei. However, as shown in the images below, there are still a few cases where slight overlaps occur between nuclei in the original images, leading to connect regions in the segmenated mask Screenshot 2023-05-10 at 21 55 28 These connected regions are then input into btrack as binary masks: Screenshot 2023-05-10 at 22 03 43 Subsequently, in btrack, they are assigned the same ID: Screenshot 2023-05-09 at 12 51 52

Considering that the overlap in the segmented masks is relatively minor, would it's still necessary to apply watershed segmentation, or are there any btrack parameters adjustments that can handle such slight overlaps ?

Additionally, would you recommend providing btrack with the original multi-colored segmented masks (labeled mask) from Cellpose instead of the binary masks to improve tracking?

I would greatly appreciate any guidance you can offer on managing these minor overlaps and attaining more accurate tracking results with btrack.

Thank you!

quantumjot commented 1 year ago

Ah -- OK! That clarifies things a lot, thanks. You should just be able to pass the cellpose output (labeled mask; with the unique labels) directly to btrack.

HaoranYueRyan commented 1 year ago

Hi @quantumjot

Thank you for providing the guidance on this issue. Your method was indeed helpful!

quantumjot commented 1 year ago

Great! I will convert this issue to a discussion so that others can see the solution, even if the issue gets closed.