Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BoundsError when accessing Tag #109

Closed
RpfR2000 opened this issue Mar 24, 2024 · 6 comments
Closed

BoundsError when accessing Tag #109

RpfR2000 opened this issue Mar 24, 2024 · 6 comments
Labels

Comments

@RpfR2000
Copy link

Hi, I'm getting the following error when trying to load a .ome.tif image with coords (X,Y,C,Z,T): LoadError: BoundsError: attempt to access 0-element Vector{TiffImages.Tag} at index [1]. I am able to open this image in Fiji/ImageJ without an issues. How can I go about figuring out what is wrong? Thanks!

@tlnagy
Copy link
Owner

tlnagy commented Mar 26, 2024

Unfortunately, it's really difficult to figure out what the problem might be with the information you provided. Do you have a minimal example that you can send me that reproduces the problem? If you can share a file that causes this problem that would be ideal.

Does TiffImages.jl open the file? OMETIFF.jl is a wrapper with some extra processing of the OME rich metadata that is embedded in the TIFF, but TiffImages does all the heavy lifting.

@RpfR2000
Copy link
Author

I did try with TiffImages.jl and ran into the same issue. I'll send you an example.

@RpfR2000
Copy link
Author

RpfR2000 commented Apr 1, 2024

Just checking -- did you get the file I sent?

@tlnagy
Copy link
Owner

tlnagy commented Apr 1, 2024

Using

julia> using TiffImages, ImageView

julia> img = TiffImages.load("/home/tlnagy/Downloads/Reporter_check_0321_test.ome.tif")
Loading: 100%|███████████████████████████████████████████| Time: 0:00:03
2304×2304×29 TiffImages.DenseTaggedImage{ColorTypes.Gray{FixedPointNumbers.N0f16}, 3, UInt32, Array{ColorTypes.Gray{FixedPointNumbers.N0f16}, 3}}:
...

julia> imshow(img[:, :, 1])

image

This looks correct?

It does look that OMETIFF.jl is heavily out-dated with respect to what TiffImages versions are considered "compatible":

TiffImages = "^0.5.1, 0.6"

#110 may fix this.

@tlnagy
Copy link
Owner

tlnagy commented Apr 1, 2024

Actually, I can reproduce this error with OMETIFF v0.4.4:

julia> img = load("/home/tlnagy/Downloads/Reporter_check_0321_test.ome.tif")
Error encountered while load File{DataFormat{:OMETIFF}, String}("/home/tlnagy/Downloads/Reporter_check_0321_test.ome.tif").

Fatal error:
ERROR: BoundsError: attempt to access 0-element Vector{TiffImages.Tag} at index [1]
Stacktrace:
  [1] getindex
    @ ./essentials.jl:13 [inlined]
  [2] first
    @ ./abstractarray.jl:452 [inlined]
  [3] getindex
    @ ~/.julia/packages/TiffImages/yETMK/src/ifds.jl:69 [inlined]
  [4] getindex
    @ ~/.julia/packages/TiffImages/yETMK/src/ifds.jl:68 [inlined]
  [5] read!(target::Matrix{ColorTypes.Gray{…}}, tf::TiffImages.TiffFile{UInt32, Stream{…}}, ifd::TiffImages.IFD{UInt32})
    @ TiffImages ~/.julia/packages/TiffImages/yETMK/src/ifds.jl:207
  [6] macro expansion
    @ ~/.julia/packages/OMETIFF/3RcZb/src/loader.jl:131 [inlined]
  [7] macro expansion
    @ ~/.julia/packages/ProgressMeter/dMfiC/src/ProgressMeter.jl:1010 [inlined]
  [8] inmemoryarray(ifds::OrderedCollections.OrderedDict{…}, dims::@NamedTuple{}; verbose::Bool)
    @ OMETIFF ~/.julia/packages/OMETIFF/3RcZb/src/loader.jl:130
  [9] load(io::Stream{DataFormat{:OMETIFF}, IOStream, String}; dropunused::Bool, verbose::Bool, inmemory::Bool)
    @ OMETIFF ~/.julia/packages/OMETIFF/3RcZb/src/loader.jl:90

TiffImages can properly load the file (if OMETIFF/FileIO isn't loaded), so this is definitely a bug in OMETIFF.

@tlnagy
Copy link
Owner

tlnagy commented Apr 1, 2024

Great news, #110 fixes this. OMETIFF v0.4.5 has no issues:

julia> using FileIO

julia> load("/home/tlnagy/Downloads/Reporter_check_0321_test.ome.tif")
Progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████| Time: 0:00:01
Gray ImageMeta with:
  data: 3-dimensional AxisArray{Gray{N0f16},3,...} with axes:
    :y, (0.0:0.325:748.475) μm
    :x, (0.0:0.325:748.475) μm
    :z, 1:29
And data, a 2304×2304×29 Array{Gray{N0f16},3} with eltype ColorTypes.Gray{FixedPointNumbers.N0f16}
  properties:
    Description: 
    Elapsed_Times: Quantity{Float64, 𝐓, FreeUnits{(s,), 𝐓, nothing}}[3.2821 s, 3.38214 s, 3.48218 s, 3.58222 s, 3.68226 s, 3.78231 s, 3.88235 s, 3.98239 s, 4.08243 s, 4.18247 s    5.18289 s, 5.28293 s, 5.38297 s, 5.48301 s, 5.58305 s, 5.68309 s, 5.78314 s, 5.88318 s, 5.98322 s, 6.08326 s]

I'm going to go ahead and close this issue. Please open a new one if it doesn't resolve your problem.

@tlnagy tlnagy closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants