rajewsky-lab / novosparc

BSD 3-Clause "New" or "Revised" License
125 stars 41 forks source link

problem with create_target_space_from_image() function #13

Closed tramdoan closed 4 years ago

tramdoan commented 4 years ago

Hi,

Thank you so much for developing this useful package. I am keen to apply it to our single cell data. I would like to use a circle instead of the default square grid as a target tissue space so I have followed your advice to create a png image of a black circle on white background and used the create_target_space_from_image() function to read it. However I get the following error: geometry_circle

File "/usr/local/lib/python3.6/site-packages/novosparc/geometry/_geometry.py", line 42, in create_target_space_from_image locations = np.array([(x, y) for x in range(img_width) for y in range(img_height) File "/usr/local/lib/python3.6/site-packages/novosparc/geometry/_geometry.py", line 43, in if sum(img[y, x, :] == np.array([0, 0, 0]))]) TypeError: 'bool' object is not iterable

I have also attached the image file I used. Would you be able to help look into it to see what may be wrong please?

Many thanks,

Tram

nukappa commented 4 years ago

Hi Tram, I cannot reproduce this, your image reads fine when I read it with the function. Could you check with the following environment: novosparc v.0.3.9 numpy v.1.16.1 matplotlib v.2.2.2

tramdoan commented 4 years ago

Thank you for getting back to me. I found out that the error I got was due to using a different image file to the one I attached here in which the black circle touches the border of the image (ie. the black circle was not entirely surrounded with white background). A silly mistake on my part.

I have another question I hope you can help with. How can I specify the number of locations to be equals to the number of single cells I have ?

nukappa commented 4 years ago

Typically the target space you create will have many more locations than cells (actually depends on your image size). You can therefore randomly downsample the number of locations to any number you like. See also the tutorial I just pushed in the repo.

YiweiNiu commented 4 years ago

Hi,

Sorry to interrupt a closed thread. I had the same error and could not solve by myself.

Here is the image (a sketch of lymph node) I used for function nc.geometry.create_target_space_from_image(). lymph_node_black_white

And the package versions

Could you please help to check this?

Many thanks!

phantom323 commented 3 years ago

Hi,

Sorry to interrupt a closed thread. I had the same error and could not solve by myself.

Here is the image (a sketch of lymph node) I used for function nc.geometry.create_target_space_from_image(). lymph_node_black_white

And the package versions

  • novosparc v0.3.10
  • numpy v1.16.1
  • matplotlib v2.2.2

Could you please help to check this?

Many thanks!

Hi I also meet the same problem, I cant't solve it by myself. Did you have solved this problem?

Many thanks!