diff --git a/NEWS.md b/NEWS.md index c37a185..8101d8f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# version 3.0 + +## Breaking changes + +- RegisterQD now requires an extra step because of enhancements that support either CPU and GPU processing. For CPU processing (formerly the only option), now you must manually load the [RegisterMismatch package](https://github.com/HolyLab/RegisterMismatch.jl): `using RegisterMismatch, RegisterQD`. For GPU processing, you should instead load the [RegisterMismatchCuda package](https://github.com/HolyLab/RegisterMismatchCuda.jl): `using RegisterMismatchCuda, RegisterQD`. *Note that loading both mismatch packages in the same session will cause method conflicts.* Both mismatch packages are registered in the publicly-available [HolyLabRegistry](https://github.com/HolyLab/HolyLabRegistry), and users are advised to add that registry. + # version 0.2 ## Breaking changes diff --git a/Project.toml b/Project.toml index 133219d..2d30473 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "RegisterQD" uuid = "ac24ea0c-1830-11e9-18d4-81f172323054" -version = "0.2.7" +version = "0.3.0" [deps] CenterIndexedArrays = "46a7138f-0d70-54e1-8ada-fb8296f91f24" @@ -14,13 +14,17 @@ PaddedViews = "5432bcbf-9aad-5242-b902-cca2824c8663" QuadDIRECT = "dae52e8d-d666-5120-a592-9e15c33b8d7a" RegisterCore = "67712758-55e7-5c3c-8e85-dda1d7758434" RegisterDeformation = "c19381b7-cf49-59d7-881c-50dfbd227eaf" -RegisterMismatch = "3c0dd727-6833-5f5d-a1e8-c0d421935c74" +RegisterMismatchCommon = "abb2e897-52bf-5d28-a379-6ca321e3b878" Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [compat] +AxisArrays = "0.3, 0.4" CenterIndexedArrays = "0.2" CoordinateTransformations = "0.5, 0.6" +Distributions = "0.20, 0.21, 0.22, 0.23, 0.24, 0.25" +ImageMagick = "0.7, 1" +ImageMetadata = "0.9" Images = "0.20, 0.21, 0.22, 0.23, 0.24, 0.25" Interpolations = "0.12, 0.13" MappedArrays = "0.2, 0.3, 0.4" @@ -32,6 +36,8 @@ RegisterDeformation = "0.3, 0.4" RegisterMismatch = "0.3, 0.4" Rotations = "0.12, 0.13, 1" StaticArrays = "0.11, 0.12, 1" +TestImages = "0.5, 0.6, 1" +Unitful = "0.17, 0.18, 1" julia = "1" [extras] @@ -39,10 +45,12 @@ AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" ImageMetadata = "bc367c6b-8a6b-528e-b4bd-a4b897500b49" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +RegisterMismatch = "3c0dd727-6833-5f5d-a1e8-c0d421935c74" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [targets] -test = ["Test", "ImageMagick", "TestImages", "Random", "AxisArrays", "ImageMetadata", "Unitful", "Distributions"] +test = ["Test", "ImageMagick", "TestImages", "Random", "AxisArrays", "ImageMetadata", "Unitful", "Distributions", "LinearAlgebra", "RegisterMismatch"] diff --git a/README.md b/README.md index 80e1f20..9ed7b5c 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ RegisterQD performs image registration using the global optimization routine [QuadDIRECT](https://github.com/timholy/QuadDIRECT.jl). Unlike many other registration packages, this is not "greedy" descent based on an initial guess---it attempts to find the globally-optimal alignment of your images. +To use this package, users must choose between using either the CPU or the GPU. For CPU processing, you must manually load the [RegisterMismatch package](https://github.com/HolyLab/RegisterMismatch.jl): `using RegisterMismatch, RegisterQD`. For GPU processing, you should instead load the [RegisterMismatchCuda package](https://github.com/HolyLab/RegisterMismatchCuda.jl): `using RegisterMismatchCuda, RegisterQD`. *Note that loading both mismatch packages in the same session will cause method conflicts.* Both mismatch packages are registered in the publicly-available [HolyLabRegistry](https://github.com/HolyLab/HolyLabRegistry), and users are advised to add that registry. +In the current absense of Github resources for GPU code, "gpu_test.jl" should be run on your personal machine as required. + This package exports the following registration functions: - `qd_translate`: register images by shifting one with respect to another (translations only) - `qd_rigid`: register images using rotations and translations diff --git a/src/RegisterQD.jl b/src/RegisterQD.jl index 4e7c320..4bf5135 100644 --- a/src/RegisterQD.jl +++ b/src/RegisterQD.jl @@ -1,8 +1,8 @@ module RegisterQD using Images, CoordinateTransformations, QuadDIRECT -using RegisterMismatch -using RegisterCore #just for indmin_mismatch? +using RegisterMismatchCommon +using RegisterCore using RegisterDeformation, PaddedViews, MappedArrays using Rotations using Interpolations, CenterIndexedArrays, StaticArrays, OffsetArrays diff --git a/src/rigid.jl b/src/rigid.jl index 83b95ef..eaf3436 100644 --- a/src/rigid.jl +++ b/src/rigid.jl @@ -187,6 +187,7 @@ function qd_rigid(fixed, moving, mxshift::VecLike, mxrot::Union{Number,VecLike}; if initial_tfm == IdentityTransformation() || isrotation(initial_tfm.linear) else @show "WARNING: initial_tfm is not a rigid transformation" + # @warn "initial_tfm is not a rigid transformation" end fixed, moving = float(fixed), float(moving) if presmoothed diff --git a/test/Project.toml b/test/Project.toml deleted file mode 100644 index 769577c..0000000 --- a/test/Project.toml +++ /dev/null @@ -1,20 +0,0 @@ -[deps] -AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9" -Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" -ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" -ImageMetadata = "bc367c6b-8a6b-528e-b4bd-a4b897500b49" -LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -RegisterQD = "ac24ea0c-1830-11e9-18d4-81f172323054" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990" -Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" - -[compat] -AxisArrays = "0.3, 0.4" -Distributions = "0.20, 0.21, 0.22, 0.23, 0.24, 0.25" -ImageMagick = "0.7, 1" -ImageMetadata = "0.9" -TestImages = "0.5, 0.6, 1" -Unitful = "0.17, 0.18, 1" -julia = "1" diff --git a/test/gpu_tests.jl b/test/gpu_tests.jl new file mode 100644 index 0000000..c870b3c --- /dev/null +++ b/test/gpu_tests.jl @@ -0,0 +1,161 @@ +using CUDA, RegisterMismatchCuda, RegisterQD +using LinearAlgebra +using ImageMagick +using Distributions #what is this? +using RegisterQD.StaticArrays +using RegisterQD.Interpolations +using RegisterQD.Images +using RegisterQD.CoordinateTransformations +using RegisterQD.Rotations +using RegisterQD.OffsetArrays +using RegisterQD.RegisterMismatchCommon + +using TestImages +using Test + +# CUDA.GPUArrays.default_scalar_indexing[] = CUDA.GPUArrays.ScalarDisallowed +# CUDA.GPUArrays.default_scalar_indexing[] = CUDA.GPUArrays.ScalarAllowed + + +#Helper to generate test image pairs +function fixedmov(img, tfm) + img = float(img) + img2 = warp(img,tfm) + inds = OffsetArrays.IdentityUnitRange.(intersect.(axes(img), axes(img2))) + fixed = img[inds...] + moving = img2[inds...] + return fixed, moving +end + +#Helpers to convert Transformations to AffineMaps +to_affine(tfm::Translation) = AffineMap(Matrix{Float64}(LinearAlgebra.I, length(tfm.translation), length(tfm.translation)), tfm.translation) +to_affine(tfm::LinearMap) = AffineMap(Matrix{Float64}(LinearAlgebra.I, length(tfm.translation), 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. +function tfmtest(tfm, tfminv) + comp = to_affine(tfm ∘ tfminv) #should be the identity transform + diagtol = 0.005 + offdiagtol = 0.005 + vtol = 0.1 + @test all(x->(1-diagtol < x < 1+diagtol), diag(comp.linear)) + @test all(x->(-offdiagtol < x < offdiagtol), comp.linear.-Matrix(Diagonal(diag(comp.linear)))) + @test all(x-> x.