tlnagy / OMETIFF.jl

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

Opening OME TIFF files without `.ome.tif` extension #99

Closed BioTurboNick closed 1 year ago

BioTurboNick commented 1 year ago

Simple question: How?

FileIO.load just sees .tif and uses TiffImages.

I don't want to rename all the files I need to open.

BioTurboNick commented 1 year ago

Side issue - even if I do rename it, OMETIFF isn't able to load the OME XML.

BioFormats in ImageJ can load the metadata just fine.

tlnagy commented 1 year ago

Given that there is essentially no difference between OMETIFFs and regular TIFFs beside the presence of the OMEXML data, FileIO uses the file-ending as a crutch. We could be more flexible with checking the file endings to allow people to do something like the following:

julia> f = "colorized-1.tif" # a standard tiff

julia> img = FileIO.load(Stream{format"OMETIFF"}(open(f), f)) # Force FileIO to delegate to OMETIFF

Currently this doesn't work (EDIT: see below) because we have a secondary check at https://github.com/tlnagy/OMETIFF.jl/blob/7134699511ba12864a3b1a3b74331f40636e8f1c/src/loader.jl#L30-L32 which is quite over the top.

Could you post the error with the metadata? It's hard to diagnose without an error message or a minimal working example.

tlnagy commented 1 year ago

Once I merge #102 and push OMETIFF v0.4.3 out you'll be able to do:

julia> f = "rename_test.ome.tif" # a standard ome file
"rename_test.ome.tif"

julia> newf = cp(f, "rename_test.tif", force = true) # rename without ome extension
"rename_test.tif"

julia> img = FileIO.load(Stream{format"OMETIFF"}(open(newf), newf)) # force fileio to use ometiff to open it
Gray ImageMeta with:
  data: 2-dimensional AxisArray{Gray{Q0f7},2,...} with axes:
    :y, 1:167
    :x, 1:439
And data, a 167×439 Array{Gray{Q0f7},2} with eltype ColorTypes.Gray{FixedPointNumbers.Q0f7}
  properties:
    Description: 
    Elapsed_Times: Array{Quantity{Float64, 𝐓, FreeUnits{(s,), 𝐓, nothing}}, 0}(UndefInitializer())
tlnagy commented 1 year ago

OMETIFF v0.4.3 is in the next round for release with the aforementioned ability to open file with alternative file endings. Please open a new issue with more details about the metadata problem that you ran into and I'll do my best to diagnose it.

BioTurboNick commented 1 year ago

Will do, thanks!