imagej / imagej/pyimagej

Trouble loading TIFF files

Open
#218 4 comments 0 reactions 0 assignees View on GitHub
tech-support
Dominant language
Python
Stars
534
Forks
95
PR merge metrics
No merged PRs in 30d

Description

Dear PyImageJ team,

I am currently trying to use PyImageJ on a local linux server with the hope of analysing some z-stack data using TrackMate. I mmanaged to install PyImageJ as per the [instructions](https://pyimagej.readthedocs.io/en/latest/Install.html#installing-via-conda-mamba) via conda/mamba and the installation appears to work via the recommended [test](https://pyimagej.readthedocs.io/en/latest/Install.html#testing-your-installation).

However, when I try to load any TIFF files, for example, using the following Python code:

```
import imagej
ij = imagej.init('/data/axela/Fiji.app')

im = ij.io().open('test_timeseries.tif')
```

I get the following error

```
Traceback (most recent call last):
File "DefaultIOService.java", line 68, in org.scijava.io.DefaultIOService.open
File "DefaultIOService.java", line 93, in org.scijava.io.DefaultIOService.open
File "DatasetIOPlugin.java", line 52, in io.scif.io.DatasetIOPlugin.open
File "DatasetIOPlugin.java", line 94, in io.scif.io.DatasetIOPlugin.open
File "DefaultDatasetIOService.java", line 133, in io.scif.services.DefaultDatasetIOService.open
File "DefaultDatasetIOService.java", line 152, in io.scif.services.DefaultDatasetIOService.open
File "ImgOpener.java", line 243, in io.scif.img.ImgOpener.openImgs
File "ImgOpener.java", line 487, in io.scif.img.ImgOpener.createReader
File "DefaultInitializeService.java", line 91, in io.scif.services.DefaultInitializeService.initializeReader
File "AbstractReader.java", line 271, in io.scif.AbstractReader.setSource
File "AbstractParser.java", line 53, in io.scif.AbstractParser.parse
File "AbstractParser.java", line 314, in io.scif.AbstractParser.parse
File "AbstractParser.java", line 244, in io.scif.AbstractParser.parse
File "TIFFFormat.java", line 939, in io.scif.formats.TIFFFormat$BaseTIFFParser.typedParse
File "TIFFFormat.java", line 957, in io.scif.formats.TIFFFormat$BaseTIFFParser.typedParse
File "MinimalTIFFFormat.java", line 412, in io.scif.formats.MinimalTIFFFormat$Parser.typedParse
io.scif.FormatException: io.scif.FormatException: Invalid TIFF file

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "DefaultIOService.java", line 68, in org.scijava.io.DefaultIOService.open
File "DefaultIOService.java", line 93, in org.scijava.io.DefaultIOService.open
File "DatasetIOPlugin.java", line 52, in io.scif.io.DatasetIOPlugin.open
File "DatasetIOPlugin.java", line 94, in io.scif.io.DatasetIOPlugin.open
File "DefaultDatasetIOService.java", line 133, in io.scif.services.DefaultDatasetIOService.open
File "DefaultDatasetIOService.java", line 152, in io.scif.services.DefaultDatasetIOService.open
File "ImgOpener.java", line 243, in io.scif.img.ImgOpener.openImgs
File "ImgOpener.java", line 487, in io.scif.img.ImgOpener.createReader
File "DefaultInitializeService.java", line 91, in io.scif.services.DefaultInitializeService.initializeReader
File "AbstractReader.java", line 279, in io.scif.AbstractReader.setSource
java.io.IOException: java.io.IOException: io.scif.FormatException: Invalid TIFF file

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "DefaultIOService.java", line 68, in org.scijava.io.DefaultIOService.open
File "DefaultIOService.java", line 93, in org.scijava.io.DefaultIOService.open
File "DatasetIOPlugin.java", line 52, in io.scif.io.DatasetIOPlugin.open
File "DatasetIOPlugin.java", line 94, in io.scif.io.DatasetIOPlugin.open
File "DefaultDatasetIOService.java", line 133, in io.scif.services.DefaultDatasetIOService.open
File "DefaultDatasetIOService.java", line 152, in io.scif.services.DefaultDatasetIOService.open
File "ImgOpener.java", line 243, in io.scif.img.ImgOpener.openImgs
File "ImgOpener.java", line 493, in io.scif.img.ImgOpener.createReader
io.scif.img.ImgIOException: io.scif.img.ImgIOException: java.io.IOException: io.scif.FormatException: Invalid TIFF file

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "DefaultIOService.java", line 68, in org.scijava.io.DefaultIOService.open
File "DefaultIOService.java", line 93, in org.scijava.io.DefaultIOService.open
File "DatasetIOPlugin.java", line 52, in io.scif.io.DatasetIOPlugin.open
File "DatasetIOPlugin.java", line 94, in io.scif.io.DatasetIOPlugin.open
File "DefaultDatasetIOService.java", line 133, in io.scif.services.DefaultDatasetIOService.open
File "DefaultDatasetIOService.java", line 163, in io.scif.services.DefaultDatasetIOService.open
Exception: Java Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "test_imagej.py", line 14, in
dataset = ij.io().open('test_image.tif')
java.io.IOException: java.io.IOException: io.scif.img.ImgIOException: java.io.IOException: io.scif.FormatException: Invalid TIFF file
```

I find that a current workfound is replacing `io().open` with the legacy command `ij.IJ.openImage('test_timeseries.tif'). Then, however, I cannot run TrackMate via the following code:
```
import imagej
ij = imagej.init('/data/axela/Fiji.app', mode='interactive')

im = ij.IJ.openImage('test_image.tif')

plugin = 'TrackMate' # Set plugin for imagej
args = {} # Set the arguments
ij.py.run_plugin(plugin, args, image)
```

Because I will get the following error:

```
Please open an image before running TrackMate.
[java.lang.Enum.toString] Please open an image before running TrackMate.[java.lang.Enum.toStrin
```

Examining this, it appears when I use `IJ.openImage` and check `type(im)`, the variable `im` is defined as a ``. Do you have any advice on how to get around this? Thanks very much for your time!

Best wishes,
Axel.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure from test_imagej.py at the ij.io().open call, using the local Fiji.app initialization and TIFF example described in the issue. Compare that path with IJ.openImage and the subsequent TrackMate invocation. Done means TIFF loading returns a usable image object and TrackMate can run on it without reporting that no image is open.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.