From b778a85b4a22259957afc4360a43c9ff0ca88ffd Mon Sep 17 00:00:00 2001 From: Cody-G Date: Tue, 21 Aug 2018 10:35:59 -0400 Subject: [PATCH 1/2] update for interface change in CoordinateTransformations --- src/qd_rigid.jl | 2 +- test/register_affine.jl | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/qd_rigid.jl b/src/qd_rigid.jl index 6c85f0e..6963e17 100644 --- a/src/qd_rigid.jl +++ b/src/qd_rigid.jl @@ -139,7 +139,7 @@ end ########### Rigid Transformation (rotation + translation) Search ############ -update_SD(SD, tfm::Union{LinearMap, AffineMap}) = update_SD(SD, tfm.m) +update_SD(SD, tfm::Union{LinearMap, AffineMap}) = update_SD(SD, tfm.linear) update_SD(SD, tfm::Transformation) = SD update_SD(SD::AbstractArray, m::StaticArray) = update_SD(SD, Array(m)) update_SD(SD::AbstractArray, m::AbstractArray) = m\SD*m diff --git a/test/register_affine.jl b/test/register_affine.jl index b6603a7..998e2db 100644 --- a/test/register_affine.jl +++ b/test/register_affine.jl @@ -53,7 +53,7 @@ end tfm, mm = qd_translate(fixed, moving, mxshift; maxevals=1000, thresh=thresh, rtol=0) - @test sum(abs.(tfm0.v - tfm.v)) < 1e-3 + @test sum(abs.(tfm0.translation - tfm.translation)) < 1e-3 #3D moving = rand(30,30,30) @@ -67,7 +67,7 @@ end tfm, mm = qd_translate(fixed, moving, mxshift; maxevals=1000, thresh=thresh, rtol=0) - @test sum(abs.(tfm0.v - tfm.v)) < 0.1 + @test sum(abs.(tfm0.translation - tfm.translation)) < 0.1 ######Rotations + Translations #2D @@ -85,7 +85,7 @@ end tfm, mm = qd_rigid(centered(fixed), moving, mxshift, mxrot, minwidth_rot, SD; thresh=thresh, maxevals=1000, rtol=0, fvalue=1e-8) - @test sum(abs.(tfm0.m - tfm.m)) < 1e-3 + @test sum(abs.(tfm0.linear - tfm.linear)) < 1e-3 #3D moving = centered(rand(30,30,30)) @@ -102,7 +102,7 @@ end tfm, mm = qd_rigid(centered(fixed), moving, mxshift, mxrot, minwidth_rot, SD; thresh=thresh, maxevals=1000, rtol=0) - @test sum(abs.(vcat(tfm0.m[:], tfm0.v) - vcat(RotXYZ(tfm.m)[:], tfm.v))) < 0.1 + @test sum(abs.(vcat(tfm0.linear[:], tfm0.translation) - vcat(RotXYZ(tfm.linear)[:], tfm.translation))) < 0.1 #NOTE: the 2D test below fails rarely and the 3D test fails often, apparently because full affine is too difficult with these images #####General Affine Transformations @@ -122,7 +122,7 @@ end tfm, mm = qd_affine(centered(fixed), moving, mxshift, SD; thresh=thresh, maxevals=1500, rtol=0, fvalue=1e-6) - @test sum(abs.(vcat(tfm0.m[:], tfm0.v) - vcat(tfm.m[:], tfm.v))) < 0.1 + @test sum(abs.(vcat(tfm0.linear[:], tfm0.translation) - vcat(tfm.linear[:], tfm.translation))) < 0.1 #The tests below fail. Probably two factors contributing to failure: # 1) Full affine 3D is a lot of parameters so it's just difficuilt (12 parameters) @@ -146,7 +146,7 @@ end #tfm, mm = qd_affine(centered(fixed), centered(moving), mxshift, SD; thresh=thresh, rtol=0, fvalue=1e-4); #@test mm <= 1e-4 - #@test sum(abs.(vcat(tfm0.m[:], tfm0.v) - vcat(tfm.m[:], tfm.v))) < 0.1 + #@test sum(abs.(vcat(tfm0.linear[:], tfm0.translation) - vcat(tfm.linear[:], tfm.translation))) < 0.1 #not random #moving = zeros(10,10,10); @@ -165,12 +165,12 @@ end #thresh = 0.5 * sum(abs2.(fixed[.!(isnan.(fixed))])); #mxshift = [5;5;5]; #SD = eye(ndims(fixed)); - #@test RegisterOptimize.aff(vcat(tfm00.v[:], tfm00.m[:]), fixed, SD) == tfm0 + #@test RegisterOptimize.aff(vcat(tfm00.translation[:], tfm00.linear[:]), fixed, SD) == tfm0 #tfm, mm = qd_affine(centered(fixed), centered(moving), mxshift, SD; thresh=thresh, rtol=0, fvalue=1e-4); #@test mm <= 1e-4 - #@test sum(abs.(vcat(tfm0.m[:], tfm0.v) - vcat(tfm.m[:], tfm.v))) < 0.1 + #@test sum(abs.(vcat(tfm0.linear[:], tfm0.translation) - vcat(tfm.linear[:], tfm.translation))) < 0.1 end #tests with random images @@ -185,8 +185,8 @@ function fixedmov(img, tfm) end #helpers to convert Transformations to AffineMaps -to_affine(tfm::Translation) = AffineMap(eye(length(tfm.v)), tfm.v) -to_affine(tfm::LinearMap) = AffineMap(eye(length(tfm.v)), tfm.v) +to_affine(tfm::Translation) = AffineMap(eye(length(tfm.translation)), tfm.translation) +to_affine(tfm::LinearMap) = AffineMap(eye(length(tfm.translation)), tfm.translation) to_affine(tfm::AffineMap) = tfm #Helper to test that a found transform is (roughly) the inverse of the original transform @@ -195,9 +195,9 @@ function tfmtest(tfm, tfminv) diagtol = 0.005 offdiagtol = 0.005 vtol = 0.1 - @test all(x->(1-diagtol < x < 1+diagtol), diag(comp.m)) - @test all(x->(-offdiagtol < x < offdiagtol), comp.m.-diagm(diag(comp.m))) - @test all(abs.(comp.v) .< vtol) + @test all(x->(1-diagtol < x < 1+diagtol), diag(comp.linear)) + @test all(x->(-offdiagtol < x < offdiagtol), comp.linear.-diagm(diag(comp.linear))) + @test all(abs.(comp.translation) .< vtol) end # tests with standard images @@ -235,7 +235,7 @@ end #make it harder with nonuniform scaling scale = @SMatrix [1.005 0; 0 0.995] SD = eye(2) - tfm = AffineMap(tfm.m*scale, tfm.v) + tfm = AffineMap(tfm.linear*scale, tfm.translation) mxshift = (100,100) #make sure this isn't too small fixed, moving = fixedmov(centered(img), tfm) tform, mm = qd_affine(centered(fixed), centered(moving), mxshift, SD; maxevals=1000, rtol=0, fvalue=0.0002) @@ -245,7 +245,7 @@ end SD = diagm([0.5; 1.0]) tfm = Translation(@SVector([14.3, 17.8]))∘LinearMap(SD\RotMatrix(0.01)*SD) scale = @SMatrix [1.005 0; 0 0.995] - tfm = AffineMap(tfm.m*scale, tfm.v) + tfm = AffineMap(tfm.linear*scale, tfm.translation) fixed, moving = fixedmov(centered(img), tfm) tform, mm = qd_affine(centered(fixed), centered(moving), mxshift, SD; maxevals=1000, rtol=0, fvalue=0.0002) tfmtest(tfm, tform) From 4b878c8032fe408cfae3d819c9034b414442ec55 Mon Sep 17 00:00:00 2001 From: Cody-G Date: Tue, 21 Aug 2018 17:39:15 -0500 Subject: [PATCH 2/2] Pin packages for julia 0.6 --- REQUIRE | 36 ++++++++++++++++++------------------ deps/build.jl | 5 +++++ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/REQUIRE b/REQUIRE index e570459..1192018 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,24 +1,24 @@ julia 0.6 -Images -Interpolations -AffineTransforms 0.2.1 -StaticArrays +Images 0.14.0 0.15.0 +Interpolations 0.7.3 0.7.3+ +AffineTransforms 0.2.3 0.2.3+ +StaticArrays 0.7.2 0.7.2+ NLsolve -MathProgBase 0.4 -Ipopt -IterativeSolvers 0.3 +MathProgBase 0.7.2 0.7.2+ +Ipopt 0.4.0 0.4.0+ +IterativeSolvers 0.6.0 0.6.0+ CUDArt -CUFFT -HDF5 -JLD -Reexport +CUFFT 0.0.4 0.0.4+ +HDF5 0.9.3 0.9.3+ +JLD 0.8.3 0.8.3+ +Reexport 0.1.0 0.1.0+ ForwardDiff 0.2.0 -ProgressMeter -AxisArrays -Ratios -Compat 0.44 -ColorTypes -OffsetArrays +ProgressMeter 0.5.6 0.5.6+ +AxisArrays 0.2.1 0.2.1+ +Ratios 0.3.0 0.3.0+ +Compat 1.0.1 1.0.1+ +ColorTypes 0.6.7 0.6.7+ +OffsetArrays 0.6.0 0.6.0+ Optim CoordinateTransformations -Rotations +Rotations 0.7.2 0.7.2+ diff --git a/deps/build.jl b/deps/build.jl index 12eb846..1b8843a 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -22,6 +22,11 @@ else end end +if VERSION < v"0.7.0" + Pkg.checkout("ImageAxes", "julia0.6") + Pkg.pin("ImageAxes") +end + basedir = splitdir(splitdir(@__FILE__)[1])[1] cd(joinpath(basedir, "src")) do run(`make`)