Closed thanujadax closed 8 years ago
Hey @thanujadax!
We actually dropped support for having a 0 label separating supervoxels/segments in 0.3: https://gala.readthedocs.io/en/latest/release-notes.html
So you need to make supervoxels that don't have a boundary between them, ie their pixels actually touch. The scikit-image skimage.morphology.watershed function can do this.
Also, for future reference, check out gala.features.default
for some default feature managers that perform better than the ones in the example.
I'm closing this for now but feel free to reopen if your problem isn't fixed!
Hi Juan, I produced watershed super-pixels without the 0 labeled separation. The hdf5 files used for training is:
However, there seems to be something wrong as seen by the output for test data, for instance:
The hdf5 files used for testing are: test.zip
What do you think has gone wrong?
Thanks in advance! Thanuja
A priori it seems to me that your fragments (my preferred term for watersheds/supervoxels these days) are completely random. =P Can you show me an example each of:
?
The fragments need to be kinda similar between training and testing volumes!
Training prob map:
Training fragments:
Training ground truth:
Testing prob map:
Testing fragments:
What do you think is wrong? Thanks for looking at it!
Thanuja
I have to see if there was something wrong in the order of the image files included in the hdf5 files. Looks to me the ground truth doesn't correspond to the probability map! I'll check it and re-run it with the right order, and get back to you soon. Thanks
Ah! Ok let me know! btw for visualising segmentations, try:
from gala import viz
viz.imshow_rand(fragments)
They are way more visible that way. =)
Hi Juan, It seems like the problems might be with the watershed fragments. Here is what the fragments look like for the Training prob map shown above:
I generated the fragments using the following code using skimage.morphology.watershed
as suggested by you:
import numpy as np
from skimage.morphology import watershed
from skimage.feature import peak_local_max
from scipy import ndimage
from PIL import Image
image = np.array(Image.open(inputFileName).convert('L'), 'f')
image = (image - 1) * (-1)
distance = ndimage.distance_transform_edt(image)
local_maxi = peak_local_max(distance, indices=False, footprint=np.ones((3, 3)), labels=image)
markers = morphology.label(local_maxi)
labels_ws = watershed(-distance, markers, mask=image)
Would be great if you could tell me how you generate the fragments. Thanks! Thanuja
Hi @thanujadax, sorry for the delay, I've been at a conference.
I think the way you compute the boundary image is a bit weird, and you might have ended up with some negative values there... What's the min and max of image
?
Then, the distance transform expects a bool image with 0 on the boundaries and 1 everywhere else... I don't know what your call of distance transform on a float image does.
To help with this, you could plot the image, the distance transformed image, and the peaks. See this code for how to show the peaks:
peaks = feature.peak_local_max(distance_from_edge, min_distance=10)
plt.imshow(edges, cmap='gray') # show your image here
plt.plot(peaks[:, 1], peaks[:, 0], 'ro'); # this plots markers at each point
I usually use the distance transform only for the markers, not for the boundary map for the watershed... I'm not sure what the problem is but your image definitely looks problematic! =)
Hi @jni
Thanks for your inputs. I made a few corrections to the process.
When you say boundary map/image, did you refer to the membrane probability map (=image)? I assumed yes for now.
image
has a max value of 255 at neuron membranes and a min value of 0 at cell interiors.
This time I used a binary thresholded version of the above image as an input to ndi.distance_transform_edt
. It has 1 for membrane pixels and 0 for non-membrane pixels as suggested by you - if I understood correctly.
Then the distance transformed image is:
.. and the peaks generated and plotted using the code you provided:
Since skimage.morphology.watershed
requires the peaks to be an array with same dimensions as the input image, I regenerated the peaks with indices=False
as follows:
local_maxi = peak_local_max(distance, indices=False, min_distance=10)
Instead of the distance image, this time I generated the watershed fragments using the original probability image
labels_ws = watershed(image, markers, mask=image)
which looks like:
I trained gala on two such images with ground truth. Then I tried the region merging (using the same code as mentioned in my first post above) on the same image I trained on (shown above) to get the following output:
Can you please let me know what you think about this output? Am I still doing something wrong?
Thanks! Thanuja
Hey @thanujadax!
It has 1 for membrane pixels and 0 for non-membrane pixels as suggested by you - if I understood correctly.
That's exactly the opposite of what I said! =P You want seed points to be away from the boundary!
Hi From my tif dataset I created hdf5 files with an identical structure to the ones used in example.py and ran the following code (Appendix 1) similar to example.py with the addition of converting the output into png files. I get the following warning:
Also, the final segmentation seems to be the same as the initial superpixel map:
The probability map for this image is:
with superpixel map obtained by Watershed transform (labeled with integers):
What do you think is the problem?
Thanks in advance!
Appendix 1 (Code)