Skip to content

Computing mismatch with OffsetArrays #83

@Cody-G

Description

@Cody-G

Continued from #81 (comment)

It seems that we're not handling OffsetArrays correctly. The full stacktrace I get when changing that particular line is:

QuadDIRECT tests with random images: Error During Test
  Got an exception of type ErrorException outside of a @test
  size not supported for arrays with axes (0:51, 0:51); see http://docs.julialang.org/en/latest/devdocs/offset-arrays/
  Stacktrace:
   [1] errmsg(::OffsetArrays.OffsetArray{Float64,2,Array{Float64,2}}) at /home/cody/.julia/v0.6/OffsetArrays/src/OffsetArrays.jl:91
   [2] safe_get!(::Array{Float64,2}, ::SubArray{Float64,2,OffsetArrays.OffsetArray{Float64,2,Array{Float64,2}},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::Tuple{UnitRange{Int64},UnitRange{Int64}}, ::Float64) at /home/cody/.julia/v0.6/BlockRegistration/src/RegisterMismatchCommon.jl:406
   [3] #mismatch!#46(::Symbol, ::Function, ::CenterIndexedArrays.CenterIndexedArray{RegisterCore.NumDenom{Float64},2,Array{RegisterCore.NumDenom{Float64},2}}, ::RegisterMismatch.CMStorage{Float64,2}, ::SubArray{Float64,2,OffsetArrays.OffsetArray{Float64,2,Array{Float64,2}},Tuple{UnitRange{Int64},UnitRange{Int64}},false}) at /home/cody/.julia/v0.6/BlockRegistration/src/RegisterMismatch.jl:136
   [4] (::RegisterMismatch.#kw##mismatch!)(::Array{Any,1}, ::RegisterMismatch.#mismatch!, ::CenterIndexedArrays.CenterIndexedArray{RegisterCore.NumDenom{Float64},2,Array{RegisterCore.NumDenom{Float64},2}}, ::RegisterMismatch.CMStorage{Float64,2}, ::SubArray{Float64,2,OffsetArrays.OffsetArray{Float64,2,Array{Float64,2}},Tuple{UnitRange{Int64},UnitRange{Int64}},false}) at ./<missing>:0
   [5] #mismatch#43(::Symbol, ::Function, ::Type{Float64}, ::SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::SubArray{Float64,2,OffsetArrays.OffsetArray{Float64,2,Array{Float64,2}},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::Array{Int64,1}) at /home/cody/.julia/v0.6/BlockRegistration/src/RegisterMismatch.jl:121
   [6] (::RegisterMismatch.#kw##mismatch)(::Array{Any,1}, ::RegisterMismatch.#mismatch, ::Type{Float64}, ::SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::SubArray{Float64,2,OffsetArrays.OffsetArray{Float64,2,Array{Float64,2}},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::Array{Int64,1}) at ./<missing>:0 (repeats 2 times)
   [7] #best_shift#1(::Symbol, ::CoordinateTransformations.IdentityTransformation, ::Function, ::SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::SubArray{Float64,2,OffsetArrays.OffsetArray{Float64,2,Array{Float64,2}},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::Array{Int64,1}, ::Float64) at /home/cody/.julia/v0.6/BlockRegistration/src/qd_rigid.jl:19
   [8] (::RegisterOptimize.#kw##best_shift)(::Array{Any,1}, ::RegisterOptimize.#best_shift, ::SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::SubArray{Float64,2,OffsetArrays.OffsetArray{Float64,2,Array{Float64,2}},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::Array{Int64,1}, ::Float64) at ./<missing>:0
   [9] #rigid_mm_fast#23(::CoordinateTransformations.IdentityTransformation, ::Function, ::Array{Float64,1}, ::Array{Int64,1}, ::Array{Float64,2}, ::Array{Float64,2}, ::Float64, ::Array{Float64,2}) at /home/cody/.julia/v0.6/BlockRegistration/src/qd_rigid.jl:157
   [10] (::RegisterOptimize.#kw##rigid_mm_fast)(::Array{Any,1}, ::RegisterOptimize.#rigid_mm_fast, ::Array{Float64,1}, ::Array{Int64,1}, ::Array{Float64,2}, ::Array{Float64,2}, ::Float64, ::Array{Float64,2}) at ./<missing>:0
   [11] split!(::QuadDIRECT.Box{Float64,1}, ::RegisterOptimize.#f#29{CoordinateTransformations.IdentityTransformation,Float64,Array{Float64,2},Array{Float64,2},Array{Int64,1},Array{Float64,2}}, ::Array{Float64,1}, ::Int64, ::Array{Float64,1}, ::Float64, ::Float64, ::Float64, ::Float64) at /home/cody/.julia/v0.6/QuadDIRECT.jl/src/algorithm.jl:48
   [12] _init(::Function, ::Array{Float64,1}, ::Tuple{Array{Float64,1}}, ::Array{Float64,1}, ::Array{Float64,1}) at /home/cody/.julia/v0.6/QuadDIRECT.jl/src/algorithm.jl:31
   [13] init(::Function, ::Tuple{Array{Float64,1}}, ::Array{Float64,1}, ::Array{Float64,1}) at /home/cody/.julia/v0.6/QuadDIRECT.jl/src/algorithm.jl:20
   [14] #analyze#45(::Array{Any,1}, ::Function, ::Function, ::Tuple{Array{Float64,1}}, ::Array{Float64,1}, ::Array{Float64,1}) at /home/cody/.julia/v0.6/QuadDIRECT.jl/src/algorithm.jl:515
   [15] (::QuadDIRECT.#kw##analyze)(::Array{Any,1}, ::QuadDIRECT.#analyze, ::Function, ::Tuple{Array{Float64,1}}, ::Array{Float64,1}, ::Array{Float64,1}) at ./<missing>:0
   [16] #_analyze#8(::Array{Any,1}, ::Function, ::Function, ::Array{Float64,1}, ::Array{Float64,1}) at /home/cody/.julia/v0.6/BlockRegistration/src/qd_rigid.jl:72
   [17] (::RegisterOptimize.#kw##_analyze)(::Array{Any,1}, ::RegisterOptimize.#_analyze, ::Function, ::Array{Float64,1}, ::Array{Float64,1}) at ./<missing>:0
   [18] #qd_rigid_coarse#25(::CoordinateTransformations.IdentityTransformation, ::Float64, ::Array{Any,1}, ::Function, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Int64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,2}) at /home/cody/.julia/v0.6/BlockRegistration/src/qd_rigid.jl:190
   [19] (::RegisterOptimize.#kw##qd_rigid_coarse)(::Array{Any,1}, ::RegisterOptimize.#qd_rigid_coarse, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Int64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,2}) at ./<missing>:0
   [20] #qd_rigid#37(::Float64, ::CoordinateTransformations.IdentityTransformation, ::Array{Any,1}, ::Function, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Int64,1}, ::Float64, ::Array{Float64,1}, ::Array{Float64,2}) at /home/cody/.julia/v0.6/BlockRegistration/src/qd_rigid.jl:240
   [21] (::RegisterOptimize.#kw##qd_rigid)(::Array{Any,1}, ::RegisterOptimize.#qd_rigid, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Int64,1}, ::Float64, ::Array{Float64,1}, ::Array{Float64,2}) at ./<missing>:0
   [22] macro expansion at /home/cody/.julia/v0.6/BlockRegistration/test/register_affine.jl:88 [inlined]
   [23] macro expansion at ./test.jl:860 [inlined]
   [24] anonymous at ./<missing>:?
   [25] include_from_node1(::String) at ./loading.jl:576
   [26] include(::String) at ./sysimg.jl:14
   [27] eval(::Module, ::Any) at ./boot.jl:235
   [28] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
   [29] macro expansion at ./REPL.jl:97 [inlined]
   [30] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73

...but a minimal case to trigger the error is:

using BlockRegistration, RegisterMismatch, OffsetArrays
a = OffsetArray(ones(10,10), (-1:8, -1:8))
b = copy(a)
mismatch(a,b,(2,2))

The issue comes from calling size on an OffsetArray here, and I think we'll also need a new fillfixed! method because it relies on size as well: https://github.com/HolyLab/BlockRegistration/blob/master/src/RegisterMismatch.jl#L259-L271

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions