python-bioformats icon indicating copy to clipboard operation
python-bioformats copied to clipboard

Unable to load CH5 File

Open roshankern opened this issue 3 years ago • 8 comments

I am trying to analyze a .ch5 (CellH5) file in python. This file opens fine in ImageJ with the Bio Formats plugin, but python-bioformats throws an error when calling bioformats.ImageReader(file.ch5). How can I resolve this error, or is there a better way to analyze .ch5 files with python? The output of the code is below. Thanks!

14:47:09.187 [Thread-0] DEBUG loci.formats.FormatHandler - NDPISReader initializing /home/roshankern/Desktop/NucleusMorphology/phenotypic_profiling/idr_downloads/test.ch5 14:47:09.187 [Thread-0] DEBUG loci.formats.FormatHandler - loci.formats.in.NDPISReader.initFile(/home/roshankern/Desktop/NucleusMorphology/phenotypic_profiling/idr_downloads/test.ch5)


JavaException Traceback (most recent call last) ... JavaException: <Java object at 0x19f14798> During handling of the above exception, another exception occurred: OSError Traceback (most recent call last) ... OSError: [Errno 22] Could not load the file as an image (see log for details): b'/home/roshankern/Desktop/NucleusMorphology/phenotypic_profiling/idr_downloads/test.ch5'

CC @gwaygenomics to keep you in the loop

roshankern avatar Jun 02 '22 17:06 roshankern

thanks for opening this issue @roshankern ! Indeed, this file format has given us some trouble!

@bethac07 - would you know who can help us track this down? Would it be helpful for Roshan to attach the example file (test.ch5) to this issue?

🤞 this is a simple fix!

gwaybio avatar Jun 02 '22 17:06 gwaybio

@gwaygenomics @roshankern a test file would indeed be great. I also hope it's a simple fix but I can't promise that it is so.

bethac07 avatar Jun 02 '22 17:06 bethac07

Thank you for the help @bethac07! The test file is located here.

roshankern avatar Jun 02 '22 18:06 roshankern

It seems the cd5 file can be manipulated in python after being opened with the pyimagej library. The code posted below saves the first frame of the .cd5 file in frame_1. Is there any reason why opening through the pyimagej library would be worse than opening with python-bioformats?

from PIL import Image import matplotlib.pyplot as plt import numpy as np

#Create an ImageJ2 gateway with the newest available version of ImageJ2. import imagej ij = imagej.init('/home/roshankern/Desktop/Fiji.app')

#Load an image. path = '/home/roshankern/Desktop/NucleusMorphology/phenotypic_profiling/downloading/test.ch5' jimage = ij.io().open(path)

#Convert the image from ImageJ2 to xarray image = ij.py.from_java(jimage) frame_1 = Image.fromarray(image.values[0, :, :, 0])

roshankern avatar Jun 03 '22 22:06 roshankern

There is no reason I can think of that it would be inherently worse; in terms of "how long does it take to open X image", I definitely haven't benchmarked it, but I have no reason to believe that they're substantially different and in terms of "days on the calendar until someone can be guaranteed to have it working", probably makes sense to do what's working right now

bethac07 avatar Jun 06 '22 18:06 bethac07

Sounds good, thank you for your help!

roshankern avatar Jun 06 '22 21:06 roshankern

If it's ok, I'd like to keep this open to eventually be able to address the issue of opening it with p-b

bethac07 avatar Jun 07 '22 12:06 bethac07

Of course!

roshankern avatar Jun 07 '22 14:06 roshankern