Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create the affinity? #7

Closed
celinezou opened this issue Apr 8, 2021 · 6 comments
Closed

How to create the affinity? #7

celinezou opened this issue Apr 8, 2021 · 6 comments

Comments

@celinezou
Copy link

Hi, thank you for sharing. I wonder how do you create the ground truth affinity from the segmentation. I wrote a "segmentation_to_affinity" function on my own, and use this function to get the affinity of the segmentation groundtruth of isbi data (which you provides in this repo). But when I used the mutex watershed on these affinity graphs, I got some weird results. So I think I might write a "segmentation_to_affinity" function different from yours. Below shows the results of using the predicted affinities you provided and using my own affinities correspondingly. Any comments will be helpful! Thanks!

Screen Shot 2021-04-07 at 23 52 34
Screen Shot 2021-04-07 at 23 52 39

@constantinpape
Copy link
Contributor

We use shift kernels to compute the affinities from ground-truth, see https://github.com/inferno-pytorch/neurofire/blob/master/neurofire/transform/segmentation.py#L110.

@celinezou
Copy link
Author

Hi! Thanks for the quick reply. I am sorry but I met another problem when abstracting groud truth affinity. I found you used "train_loader = get_isbi_loader_3d(data_config)" in your code to get the training data and its label(ground truth affinity), so I used the same code and converted this torch dataloader to NumPy to get the ground truth affinity. But the data configuration template file has the following configurations. In this case, the size of ground truth affinity is (17, 12, 459, 459) not (17, 30, 512, 512) , which is the size of the raw data and predicted affinity you provide.
Screen Shot 2021-04-08 at 16 34 01

How can I generate ground truth affinity in size(17, 30, 512, 512)? I have tried to set the window size as (30, 512, 512), but the ground truth affinity I got from this setting has an invalid value on the boundary, like this (on the top):
Screen Shot 2021-04-08 at 16 43 48

It will be great if you can explain what does every parameter means in slicing_config and how should I set these parameters to get ground truth affinity in size(17, 30, 512, 512) like yours?

I really appreciate your time and help. Thank you so much!

Best

@constantinpape
Copy link
Contributor

The affinities at the borders of the volume are invalid. That's why we use the padding.
Why do you need the affinities for the full volume? Training can only be done on smaller patches anyways.

In the slicing_config the parameters mean the following: window_size: size of the patch to be extracted. stride: the stride used to iterate the patch through the whole volume in order to extract patches. data_slice: the subvolume used for extracting patches in numpy slice syntax. Here, the whole volume is used. padding: padding applied to the volume, in np.pad syntax.

@celinezou
Copy link
Author

Thank you so so so much! It works in my case now. One final question: is there a GPU version of mutex watershed?

@constantinpape
Copy link
Contributor

Thank you so so so much! It works in my case now.

Great!

One final question: is there a GPU version of mutex watershed?

No, the mutex watershed is based on building a spanning forest using a version of kruskal's algorithm that can express repulsive interactions. This is a sequential algorithm and not suited for GPU computing.

@celinezou
Copy link
Author

Thank you so much! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants