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

Exporting batch 2D segmentations #14

Closed
JemimaBurden opened this issue May 20, 2022 · 2 comments
Closed

Exporting batch 2D segmentations #14

JemimaBurden opened this issue May 20, 2022 · 2 comments

Comments

@JemimaBurden
Copy link

Firstly, thank you, I am loving Empanda's 2d and 3d predictions!

I have managed to use the 3D predictions (semantic only) with some level of success on 3D (serial 2D) SEM array tomography data and managed to save it and get it into Image J and then Amira (my current go-to 3D visualisation software).

However, when I try the 2D predictions (batch) on a stack of TEM data (not serial images), whilst the segmentation works as before, I can't seem to save it in a way that other software can see the segmentations. Apoolgies - is this a napari question or an empanda question? Alternatively, can you let me know what I am doing wrong and what I need to do to fix it!

Thanks again in advance for all your help!

@conradry
Copy link
Contributor

There seem to be two issues. First, the segmentations are output as 64-bit integers which isn't supported by all software (Fiji loaded the 64-bit images but required clicking through a few menus). Second, each segmentation has an extra dimension in order to correctly render them in the napari viewer (e.g., a 1000x1000 image has a segmentation of shape 1x1000x1000).

I've fixed the first issue such that segmentations will now save as 32-bit unsigned integers. That fix will take effect in a future release coming soon. The second issue is more on napari's side and I'll have to research ways to handle it.

In the meantime, I have a work around:

  1. Open the Python console from the menu in the bottom left:

console

  1. Paste and run this code
import numpy as np
for layer in viewer.layers:
    if type(layer) == napari.layers.Labels:
        layer.data = layer.data.astype(np.uint32).squeeze()

You'll notice that this really screws up the visualization of the segmentations, so only do it right before you're ready for export. I've verified that they will open in Fiji after saving.

@akdess
Copy link

akdess commented Feb 2, 2024

Hi thanks a lot for developing this tool!

I am also trying to save batch-mode MitoNet predictions, I can save them as you suggested through Pythion console but it is saved as tiff. I need to save it as svg. I would appreciate if you can provide a code for saving all segmantations as svg. Thanks!

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

3 participants