tlnagy / OMETIFF.jl

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

Imspectorpro ome.tif file: ERROR: KeyError: key "Type" not found #82

Open james-a-mcmanus opened 3 years ago

james-a-mcmanus commented 3 years ago

I have .ome.tif files exported from lavision biotec's imspectorpro.

using FileIO
tf = load("pathto.ome.tif")

Top part of stack-trace

Fatal error:
ERROR: KeyError: key "Type" not found
Stacktrace:
  [1] getindex(node::EzXML.Node, attr::String)
    @ EzXML ~/.julia/packages/EzXML/ZNwhK/src/node.jl:1200
  [2] load(io::Stream{DataFormat{:OMETIFF}, IOStream, String}; dropunused::Bool, inmemory::Bool)
    @ OMETIFF ~/.julia/packages/OMETIFF/xqGQs/src/loader.jl:57
  [3] #30
    @ ~/.julia/packages/OMETIFF/xqGQs/src/loader.jl:3 [inlined]
  [4] open(f::OMETIFF.var"#30#31"{Bool, Bool}, args::File{DataFormat{:OMETIFF}, String}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./io.jl:330
  [5] open
    @ ./io.jl:328 [inlined]
  [6] #load#29
    @ ~/.julia/packages/OMETIFF/xqGQs/src/loader.jl:2 [inlined]
  [7] load(f::File{DataFormat{:OMETIFF}, String})
    @ OMETIFF ~/.julia/packages/OMETIFF/xqGQs/src/loader.jl:2
  [8] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
  [9] invokelatest
    @ ./essentials.jl:706 [inlined]
 [10] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::Formatted; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})

Is there something I'm doing wrong or is this kind of tif not supported in ometiff? I can load with no problem in python tiffile.

james-a-mcmanus commented 3 years ago

I can share a sample file later today.

tlnagy commented 3 years ago

Is there something I'm doing wrong or is this kind of tif not supported in ometiff?

Nope, it doesn't look like you're doing anything wrong. Could you share an example file either here (if it is small) or my email (on my profile page)?

The error makes it sound like the OMEXML in the image violates the minimum specification since it is missing the type parameter. It should be possible to handle this gracefully.

As an alternative, could you try using TiffImages.jl to load your TIFF? It's my newer, much more general package which will at some point soonish replace OMETIFF.jl's ancient engine.

james-a-mcmanus commented 3 years ago

Thanks for the reply, I've sent you an email - I'll check out TiffImages.jl!

tlnagy commented 3 years ago

So there seems to be multiple funky things going on with this file that are tripping up OMETIFF.jl.

Abbreviated XML below:

<?xml version="1.0" encoding="UTF-8"?>
<OME xmlns="http://www.openmicroscopy.org/Schemas/OME/2008-02" xmlns:ca="http://www.openmicroscopy.org/Schemas/CA/2008-02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2008-02 http://www.openmicroscopy.org/Schemas/OME/2008-02/ome.xsd" UUID="urn:uuid:5D0307F5-69ED-4F32-8110-714DD4ADE779">
   <Experimenter ID="Experimenter:not_specified_not_specified">
      <FirstName>not_specified</FirstName>
      <LastName>not_specified</LastName>
      <Email>not specified</Email>
      <Institution>not specified</Institution>
   </Experimenter>
   <Group ID="urn:lsid:imspector.group.id:Group:not_specified" Name="not specified" />
   <Image ID="Image:5D0307F5-69ED-4F32-8110-714DD4ADE779" Name="210416170642_msr_18-40-13_ResonantPMT_C0.ome.tif" DefaultPixels="Pixels:5D0307F5-69ED-4F32-8110-714DD4ADE779">
      <CreationDate>2021-04-16T18:40:14</CreationDate>
      <Description>not_specified</Description>
      <Pixels ID="Pixels:5D0307F5-69ED-4F32-8110-714DD4ADE779" DimensionOrder="XYTZC" PixelType="uint16" BigEndian="false" SizeX="1024" SizeY="651" SizeZ="1" SizeT="3" SizeC="1" PhysicalSizeX="0.247639" PhysicalSizeY="0.247501" TimeIncrement="2.314590">
         <TiffData>
            <UUID FileName="210416170642_msr_18-40-13_ResonantPMT_C0.ome.tif">urn:uuid:5D0307F5-69ED-4F32-8110-714DD4ADE779</UUID>
         </TiffData>
      </Pixels>
      <ca:CustomAttributes>
         ...
      </ca:CustomAttributes>
   </Image>
   <ca:CustomAttributes>
      ...
   </ca:CustomAttributes>
</OME>

TL;DR: There are a couple interrelated issues that need to be resolved for this to work with OMETIFF.jl and #3 on the list is a big one that I will be solved by my refactoring that I mentioned before. My recommendation is to use TiffImages.jl in the meantime.

james-a-mcmanus commented 3 years ago

Okay, having tried to load it with tiffimages.jl it seems to work just fine - which I'm very grateful for - should I close this for this reason or leave it open b/c it's still broken in ometiff?

tlnagy commented 3 years ago

It's fine to leave it open, there are a couple things here that need to be fixed in OMETIFF.jl