MouseLand / cellpose

a generalist algorithm for cellular segmentation with human-in-the-loop capabilities
https://www.cellpose.org/
BSD 3-Clause "New" or "Revised" License
1.33k stars 382 forks source link

[BUG] "ERROR: no image in npy" after saving with masks_flows_to_seg #934

Closed SamHawkens2 closed 4 months ago

SamHawkens2 commented 4 months ago

I saved .npy files with the "masks_flows_to_seg" function and tried to open them later in cellpose. Here cellpose is complaining, that "no image file found and no image in npy". I know, that on the image_path I provided, there is not the image. But I thought in the .npy file, there should be the image provided. The function itself is importing the image, even recreating single images from a stack of images. But during the actual creating of the save data (dat) no image is saved. Is there the "image": part missing, and if not, why do I have to provide an image for the function at all? image

I would realy like to have the image included, maybe not mandatory, but optional :)

SamHawkens2 commented 4 months ago

In cellpose 2.3 the Image parameter was still in: image

SamHawkens2 commented 4 months ago

by adding the "img" into the function I came across another potential bug:

in gui/io.py --> def _load_seg(): image parent.stack_filtered is only defined "if parent.restore is not None:". So I would recommend to add that.

image

mrariden commented 4 months ago

We removed the img entry to (1) make the .npy file smaller which sped up writing repeatedly during GUI annotation and (2) because users should have the original image anyway so it was redundant. We're not going to add it back to the .npy file until we have a better solution for saving the GUI annotations, something that we're working on now.

You're free to modify cellpose as you'd like for your purposes, but we won't integrate these specific changes into the repo at the moment. Please close if this answers your questions.

SamHawkens2 commented 4 months ago

Thank you for the answer! So the import of the image into the function itself is deprecated than as well. I'll modify it then for my own needs. There is not an easy way at the moment, to get a different path for the image into the function, right? Since my images and the resulting .npy files are laying in different folders...

FrickTobias commented 4 months ago

@SamHawkens2 You could maybe try to link to your files (if you don't want to move/copy them)?

ln -s original/dir/myfile.txt new/dir/myfile.txt 
SamHawkens2 commented 4 months ago

Thanks for the answer! Ill try :)

I guess we can close here.