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

io.masks_flows_to_seg is not working anymore when setting the diameter by hand #256

Closed
rmathieu25 opened this issue May 4, 2021 · 7 comments

Comments

@rmathieu25
Copy link

rmathieu25 commented May 4, 2021

Hello!

Thank you for developing Cellpose. I used it for almost one year now and it is great!

Since your last update, I have an issue when running the io.masks_flows_to_seg. It is working only if the diameter is set to None. If I set the diameter by hand, I get the following issue (I am running Cellpose with colab):


from cellpose import io
io.masks_flows_to_seg(imgs,masks, flows, diams, files, channels)
---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-31-7605babb8af9> in <module>()
      1 from cellpose import io
      2 
----> 3 io.masks_flows_to_seg(imgs,masks, flows, diams, files, channels)

/usr/local/lib/python3.7/dist-packages/cellpose/io.py in masks_flows_to_seg(images, masks, flows, diams, file_names, channels)
    216 
    217     if isinstance(masks, list):
--> 218         for k, [image, mask, flow, diam, file_name] in enumerate(zip(images, masks, flows, diams, file_names)):
    219             channels_img = channels
    220             if channels_img is not None and len(channels) > 2:

TypeError: zip argument #4 must support iteration

@rmathieu25
Copy link
Author

I am sorry but I am still running into the same error despite your commit

@carsen-stringer
Copy link
Member

you're running the github version? can you give me more info about your error please? It should make diameters a list if masks is a list

@rmathieu25
Copy link
Author

rmathieu25 commented May 6, 2021

Hello!

Yes I'm running the github version. The error occurred only if I set a single number for all images for the diameter argument.
for example:

channels = [[1,0]] 
masks, flows, styles, diams = model.eval(imgs, diameter=20, flow_threshold=None,channels=channels, cellprob_threshold=-2)

But giving a list solved the error. By running:

channels = [[1,0]] 

diameter=[20]*nimg
masks, flows, styles, diams = model.eval(imgs, diameter=diameter, flow_threshold=None,channels=channels, cellprob_threshold=-2)

I don't get the error

@carsen-stringer
Copy link
Member

are you sure you are using the latest version of the code?

channels = [[2,3]]
imgs = [io.imread(filename) for filename in files]
masks, flows, styles, diams = model.eval(imgs, diameter=30, channels=channels)
io.masks_flows_to_seg(imgs, masks, flows, diams, files, channels)
io.save_to_png(imgs, masks, flows, files)

the above does not error for me

@carsen-stringer
Copy link
Member

also

io.masks_flows_to_seg(imgs, masks, flows, 30, files, channels)

does not error

@rmathieu25
Copy link
Author

Hello!

I haven't changed anything since yesterday but it is working now...

Thank you very much

@carsen-stringer
Copy link
Member

hurray!

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