stardist / stardist

StarDist - Object Detection with Star-convex Shapes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

problem to save a predicted big 3d image

rprisca opened this issue · comments

Hi,

I trained my own model and now I would like to predict a big 3d image : 512 slices (for z-axis) and 5888 (for x-axis) * 2048 (for y-axis)
I used the following function “model.predict_instances_big” for the prediction.
The prediction works well.
However when I want to save the predicted image with “save_tiff_imagej_compatible”, I have this warning “tiffwritter : truncating ImageJ file”, I’m afraid to lose some information. How do I fix this ?

Thank you for your help.

Hi and sorry for the late reply.

The resulting image is bigger than 4GB and needs to be saved in the BigTIFF variant, which isn't compatible with saving the image as an ImageJ hyperstack via save_tiff_imagej_compatible (details).

Instead, you could directly use tifffile to save your image.

Hi @uschmidt83,

Finally, i use a function from tifffile

from tifffile import memmap

# reading
#labels : predicted image with StarDist
original_image = memmap('temp-1024slices.tif', shape=np.shape(labels), dtype='int16',
                    bigtiff=True)

# writing
for i in range(labels.shape[0]):
    original_image[i]=(labels[i])
original_image.flush()

and it works.
Thank you !