soft-matter / pims

Python Image Sequence: Load video and sequential images in many formats with a simple, consistent interface.
http://soft-matter.github.io/pims/
Other
258 stars 67 forks source link

Problems opening a Nikon .nd2 file #432

Open Clarion opened 1 year ago

Clarion commented 1 year ago

Thank you first of all for putting the pims module together!!

Unfortunately, I am running into problems opening Nikon .nd2 files.

Here is what I do:

mamba create --name imageprocessing python=3.10 -c conda-forge
mamba activate imageprocessing 
mamba install jupyterlab -c conda-forge 
mamba install python-javabridge -c conda-forge  
mamba install pims -c conda-forge   

When I run the following cell in a jupyter notebook, I get the error message below. And I can’t figure out what the problem is:

import pims
import javabridge
import bioformats

javabridge.start_vm(class_path=bioformats.JARS)

a = pims.open('/Users/c_osman/Documents/Python/Lab_scripts/Microscopy/510-150.nd2’)

Error: /Users/c_osman/mambaforge/envs/imageprocessing/lib/python3.10/site-packages/pims/api.py:204: UserWarning: <class 'pims.bioformats.BioformatsReader'> errored: 'NoneType' object has no attribute 'isJVMStarted' warn(message)

UnknownFormatError Traceback (most recent call last) Cell In[1], line 7 3 import bioformats 5 javabridge.start_vm(class_path=bioformats.JARS) ----> 7 a = pims.open('/Users/c_osman/Documents/Python/Lab_scripts/Microscopy/510-150.nd2')

File ~/mambaforge/envs/imageprocessing/lib/python3.10/site-packages/pims/api.py:206, in open(sequence, **kwargs) 204 warn(message) 205 exceptions += message + '\n' --> 206 raise UnknownFormatError("All handlers returned exceptions:\n" + exceptions)

UnknownFormatError: All handlers returned exceptions: <class 'pims.bioformats.BioformatsReader'> errored: 'NoneType' object has no attribute 'isJVMStarted'

Your help would be much appreciated!!

nimaesmaeelpour commented 1 year ago

The problem is that jpype is not installed.

The jpype variable becomes a NoneType and the error is raised. https://github.com/soft-matter/pims/blob/5ec734df60cfc7bc449bdd70bb3e4b90bccb026a/pims/bioformats.py#L8-L11

But after installing jpype, a completely different problem opens up. The loci_tools.jar can't be downloaded.

pims/api.py:204: UserWarning: <class 'pims.bioformats.BioformatsReader'> errored: HTTP Error 404: Not Found
  warn(message)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
File "pims/api.py", line 206, in open
    raise UnknownFormatError("All handlers returned exceptions:\n" + exceptions)
pims.api.UnknownFormatError: All handlers returned exceptions:
<class 'pims.bioformats.BioformatsReader'> errored: HTTP Error 404: Not Found

I think this url is outdated (at least with version 6, which is the default value for version): https://github.com/soft-matter/pims/blob/5ec734df60cfc7bc449bdd70bb3e4b90bccb026a/pims/bioformats.py#L74-L75

Right now the workaround is to install pims-nd2which uses the Nikon SDK to open nd2-files.