-
Notifications
You must be signed in to change notification settings - Fork 3
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
scaled_he_image error #18
Comments
Alright, let's do some diagnostics. img = b2c.load_image(source_image_path)
img.shape
np.max(adata.obsm["spatial"], axis=0) |
You stumbled upon some strange cv2 error. I found this, not that it explicitly helps you. import cv2
img = cv2.imread(source_image_path)
img.dtype It's very strange that it loads but then explodes when attempting to reorder the channels. |
I am unable to read the image using cv2 "cv2.imread(source_image_path)"—the same error occurs. It seems this issue is related to the H&E image itself. I will discuss this with my lab scientist to check the image. |
What happens when you try to |
Ah, I see. Sorry, it's quite late here. You could technically try experimenting with PIL: from PIL import Image
img = np.array(Image.open(source_image_path)) If this whines about the image being too big run |
Interesting, why are there 4 channels in this thing? What happens if you try to load your other images that worked before, be it via cv2 or PIL? |
Alright, some things are starting to come together. 21035 * 22993 * 4 = 1934631020, which is one of the numbers mentioned in the error message. Another number mentioned in the error message is 1073741824, which is 2^30, which is the default maximum pixel count cv2 works with. Thing is, I do I get a different, more sensible error when I try to load my image without flipping the setting (and everything loads fine once configured properly): Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv2.error: OpenCV(4.10.0) /io/opencv/modules/imgcodecs/src/loadsave.cpp:79: error: (-215:Assertion failed) pixels <= CV_IO_MAX_IMAGE_PIXELS in function 'validateInputImageSize' The exact thing you're running into remains very arcane, I found this while trying to dig more stuff up. The fact you're seeing four channels when you PIL it in might be sending it to a different part of the cv2 library somehow where that setting has no power? What comes up when you $ identify Visium_HD_Mouse_Brain_tissue_image.tif
Visium_HD_Mouse_Brain_tissue_image.tif TIFF 18872x23947 18872x23947+0+0 8-bit sRGB 137.865MiB 0.000u 0:00.033 As for proceeding, I think the most robust way would be for me to add an optional way to just pass the full resolution loaded image into the custom resolution functions. |
Hi Actually, I successfully ran the entire bin2cell pipeline using two 10x Visium HD demo datasets (samples P1 and P3, available at https://www.10xgenomics.com/products/visium-hd-spatial-gene-expression/dataset-human-crc). The BTF images for those samples are much larger, at 12.6 GB (sample P1) and 10.4 GB (sample P3). The problematic sample image is only 1.7 GB, which is puzzling. $ identify Visium_HD_Human_Colon_Normal_P3_tissue_image.btf Do you think I should try saving the image in BTF format to see if that resolves the issue? |
Hi, it does seem something is off with the images... can you try to open these in fiji https://imagej.net/software/fiji/downloads and have a look if it's an RGB image as expected? If not you can convert to rgb and save as a tiff. It's a long shot but in case you didn't try something similar already. |
Hi, thank you for your great suggestion, yes, i just notice that the image is not RGB. |
Hello, I've run into this issue too. Could you please tell me how to configure the parameters? Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv2.error: OpenCV(4.10.0) /io/opencv/modules/imgcodecs/src/loadsave.cpp:79: error: (-215:Assertion failed) pixels <= CV_IO_MAX_IMAGE_PIXELS in function 'validateInputImageSize' Thank you for your response. |
You've ran into a different issue, not the same one as OP. I was illustrating a more common cv2 problem, and how to fix it. This fix is already worked into bin2cell. Are you loading cv2 before you load b2c? |
Hi,I adjusted the loading order of the modules, placing bin2cell at the front, and now it runs normally. Thank you so much for you help. |
Hi,
Thank you for developing the amazing software bin2cell.
I am currently using bin2cell with my Visium HD 2µm data. While I successfully ran the pipeline on two samples, I encountered an error with my one liver sample during the “b2c.scaled_he_image(adata, mpp=mpp, save_path='stardist/he.tiff')” step. (Sell below)
The image appears normal (1.7 GB) and is the input used in Spaceranger (via --image). I’ve attempted to resolve the issue by adjusting the mpp (trying values of 0.3, 0.4, 0.5, 0.8, 1.0, 1.8, 2.0, etc.) and reducing the image size, but unfortunately, none of these solutions have worked.
I would greatly appreciate any guidance or suggestions you might have to help resolve this issue.
Thank you for your assistance!
The text was updated successfully, but these errors were encountered: