imagej / imagej2

Open scientific N-dimensional image processing :microscope: :sparkler:
https://imagej.net/
BSD 2-Clause "Simplified" License
1.17k stars 332 forks source link

Please support multiple frames in PGM file format #268

Open BarchSteel opened 3 years ago

BarchSteel commented 3 years ago

The PGM file format (http://netpbm.sourceforge.net/doc/pgm.html) allows for multiple frames in one file, called a sequence. The frames are just written, without gaps or padding, sequentially to the file. The number of frames in the file can be determined by the (fileSize - Header)/(size_of_one_frame)

If I open such a file in ImageJ, only the first frame is displayed. Please improve the PGM file reader, so it can read multiple frames as a sequence, just like the RAW importer does. sequence_3_frames_38x38px_8bit.zip

As a work-around, you can import the file using the "RAW" importer. For example, for the attached file, use uint8, size: 38x38 px, 3 frames.

Tested on ImageJ 1.53e.

imagejan commented 3 years ago

That's an issue for the ome/bioformats repository, as PGMReader is implemented there.

ctrueden commented 3 years ago

To complicate matters: because PGM is an open format, there is also a SCIFIO implementation: PGMFormat. Strategically, it is probably time for a conversation about whether to continue maintaining these SCIFIO implementations. Although there are many downsides to discontinuing it, resources-wise, having two implementations to keep synchronized is not really tenable at the moment.

BarchSteel commented 3 years ago

Thank you for the pointers. I will file this bug report there again. I opened bug report in SCIFIO first, because I think this used when ImageJ without Fiji is used: https://github.com/scifio/scifio/issues/445 I also created a bug report for Bio-Formats: https://github.com/ome/bioformats/issues/3649

BarchSteel commented 3 years ago

So, I played a little bit around with SCIFIO and patched the scifio PGMFormat.java to read multi-plane images. On ImageJ 2.1.1-snapshot (compiled from the GIT master branch from ) But my modified class was only called when I used File->Import->"Image...." It would not load when I use File->Open Image. ImageJ used some other class, and not my class.

So is/was there a 3rd class for PGM loading?

Edit: I got confused by the ImageJ "About" dialog. The git snapshot 2.1.1-SNAPSHOT shows in Help->"About ImageJ" the version 1.53c. This can't be good for the user...

imagejan commented 3 years ago

It would not load when I use File->Open Image. ImageJ used some other class, and not my class.

Indeed, ImageJ uses Bio-Formats in that case, unless you specify "Use SCIFIO when opening files (BETA!)" in Edit > Options > ImageJ2...

The git snapshot 2.1.1-SNAPSHOT shows in Help->"About ImageJ" the version 1.53c.

That's unfortunate, but a known issue: Help > About ImageJ is an ImageJ1 command and displays the bundled ImageJ1 version (i.e. the one of your ij.jar file). Clicking on the info bar will tell you the versions of both IJ1 and IJ2, e.g. (Fiji Is Just) ImageJ 2.1.0/1.53c.

BarchSteel commented 3 years ago

Indeed, ImageJ uses Bio-Formats in that case, unless you specify "Use SCIFIO when opening files (BETA!)" in Edit > Options > ImageJ2...

That's an interesting comment. When I first read it, I though: well, when I compiling ImageJ from source, there is no Bio-Format plug-in installed. But then you said that there is a bundled version of ImageJ1... and yes, in then dependency ij-1.5.3c.jar, there is another PGM reader at: ij.plugin.PGM_reader.class (which does not seem to be part of the Bio-Formats package either).

Thank you, I will try your option "Use SCIFIO when opening files (BETA!)", it looks very promising ;-)