tlnagy / OMETIFF.jl

I/O operations for OME-TIFF files in Julia
Other
24 stars 7 forks source link

Handle multipage TIFF files #1

Closed tlnagy closed 7 years ago

tlnagy commented 7 years ago

See https://www-legacy.openmicroscopy.org/site/support/ome-model/ome-tiff/specification.html#multi-file-ome-tiff for details

tlnagy commented 7 years ago

This might require some rearchitecting of loadtiff. Inside the OME-XML, the TiffData node has a UUID node that contains the UUID of the file in which the IFD that it corresponds to is located. I'll have to build a mapping of dimension indices (e.g. XYZCT indices) to files to offsets instead of the current XYZCT => offsets. It looks as though the Filename attribute isn't guaranteed to be there so I shouldn't rely on that. That said,

The FileName attribute of the UUID is optional, but strongly recommended—otherwise, the OME-TIFF reader must scan OME-TIFF files in the working directory looking for matching UUID signatures. https://www-legacy.openmicroscopy.org/site/support/ome-model/ome-tiff/specification.html#multi-file-ome-tiff

So it might be best to use FileName in the first version and then eventually writing a backup routine in case the filename attributes are missing.

So the process might be as follows:

  1. Load file, scan magic bytes, and read the first ifd
  2. Parse OME-XML in ImageDescription and build a ZCT index -> filename -> intrafile offset mapping
  3. Finish reading IFDs in first file and filling in the offsets into the structure above
  4. Close first file and load next file and fill out the above mapping further. Repeat as many times as necessary.
  5. Iterate over the ZCT mapping and open each file in order and read their data using the offset information
  6. Construct and return the high dimensional array built from data