diff --git a/docs/lit/examples/2-rotate.jl b/docs/lit/examples/2-rotate.jl index 218ed23..6d10d75 100644 --- a/docs/lit/examples/2-rotate.jl +++ b/docs/lit/examples/2-rotate.jl @@ -81,7 +81,7 @@ jim(image, "Original image") # Now plan the rotation # by specifying # * the image size `nx` (it must be square, so `ny=nx` implicitly) -# * the `DataType` used for the work arrays. +# * the `Type` used for the work arrays. plan2 = plan_rotate(size(image, 1); T) diff --git a/docs/lit/examples/3-psf.jl b/docs/lit/examples/3-psf.jl index b047056..badcd7b 100644 --- a/docs/lit/examples/3-psf.jl +++ b/docs/lit/examples/3-psf.jl @@ -77,7 +77,7 @@ Now plan the PSF modeling by specifying * the image size (must be square) * the PSF size: must be `px × pz × ny × nview` -* the `DataType` used for the work arrays. +* the `Type` used for the work arrays. =# plan = plan_psf( ; nx, nz, px, T) diff --git a/src/fft_convolve.jl b/src/fft_convolve.jl index 1a60790..7c972eb 100644 --- a/src/fft_convolve.jl +++ b/src/fft_convolve.jl @@ -57,7 +57,7 @@ Convolve 2D image `img` with 2D (symmetric!) kernel `ker` using FFT. function fft_conv( img::AbstractMatrix{I}, ker::AbstractMatrix{K}; - T::DataType = promote_type(I, K, Float32), + T::Type{<:AbstractFloat} = promote_type(I, K, Float32), ) where {I <: Number, K <: Number} ker ≈ reverse(ker, dims=:) || throw("asymmetric kernel") @@ -132,7 +132,7 @@ Adjoint of `fft_conv`. function fft_conv_adj( img::AbstractMatrix{I}, ker::AbstractMatrix{K}; - T::DataType = promote_type(I, K, Float32), + T::Type{<:AbstractFloat} = promote_type(I, K, Float32), ) where {I <: Number, K <: Number} ker ≈ reverse(ker, dims=:) || throw("asymmetric kernel") diff --git a/src/plan-psf.jl b/src/plan-psf.jl index 6b3460f..445dcdf 100644 --- a/src/plan-psf.jl +++ b/src/plan-psf.jl @@ -5,7 +5,7 @@ import AbstractFFTs import FFTW """ - PlanPSF{T,Tf,Ti}( ; nx::Int, nz::Int, px::Int, pz::Int, T::DataType) + PlanPSF{T,Tf,Ti}( ; nx::Int, nz::Int, px::Int, pz::Int, T::Type) Struct for storing work arrays and factors for 2D convolution for one thread. Each PSF is `px × pz` - `T` datatype of work arrays (subtype of `AbstractFloat`) @@ -41,7 +41,7 @@ struct PlanPSF{T, Tf, Ti} nz::Int = nx, px::Int = 1, pz::Int = px, - T::DataType = Float32, + T::Type{<:AbstractFloat} = Float32, ) T <: AbstractFloat || throw("invalid T=$T") @@ -84,7 +84,7 @@ end """ - plan_psf( ; nx::Int, nz::Int, px::Int, pz::Int, nthread::Int, T::DataType) + plan_psf( ; nx::Int, nz::Int, px::Int, pz::Int, nthread::Int, T::Type) Make Vector of structs for storing work arrays and factors for 2D convolution with SPECT depth-dependent PSF model, threaded across planes parallel to detector. @@ -102,7 +102,7 @@ function plan_psf( ; px::Int = 1, pz::Int = px, nthread::Int = Threads.nthreads(), - T::DataType = Float32, + T::Type{<:AbstractFloat} = Float32, ) return [PlanPSF( ; nx, nz, px, pz, T) for id in 1:nthread] end diff --git a/src/plan-rotate.jl b/src/plan-rotate.jl index f791858..bcb91ad 100644 --- a/src/plan-rotate.jl +++ b/src/plan-rotate.jl @@ -46,7 +46,7 @@ struct PlanRotate{T, R} function PlanRotate( nx::Int ; - T::DataType = Float32, + T::Type{<:AbstractFloat} = Float32, method::Symbol = :two, # :one is for 1d interpolation, :two is for 2d interpolation ) @@ -78,7 +78,7 @@ end """ - plan_rotate(nx::Int; T::DataType, method::Symbol) + plan_rotate(nx::Int; T::Type{<:AbstractFloat}, method::Symbol) Make `Vector` of `PlanRotate` structs for storing work arrays and factors for threaded rotation of a stack of 2D square images. @@ -95,7 +95,7 @@ for threaded rotation of a stack of 2D square images. """ function plan_rotate( nx::Int ; - T::DataType = Float32, + T::Type{<:AbstractFloat} = Float32, method::Symbol = :two, nthread::Int = Threads.nthreads(), ) diff --git a/src/psf-gauss.jl b/src/psf-gauss.jl index 0dbff28..9d38163 100644 --- a/src/psf-gauss.jl +++ b/src/psf-gauss.jl @@ -17,7 +17,7 @@ having specified full-width half-maximum (FHWM) values. - 'fwhm::AbstractVector{<:Real} = range(fwhm_start, fwhm_end, ny)' - 'fwhm_x::AbstractVector{<:Real} = fwhm, - 'fwhm_z::AbstractVector{<:Real} = fwhm_x' -- 'T::DataType == Float32' +- 'T::Type == Float32' Returned `psf` is `[px, pz, ny]` where each PSF sums to 1. """ @@ -30,7 +30,7 @@ function psf_gauss( ; fwhm::AbstractVector{<:Real} = range(fwhm_start, fwhm_end, ny), fwhm_x::AbstractVector{<:Real} = fwhm, fwhm_z::AbstractVector{<:Real} = fwhm_x, - T::DataType = Float32, + T::Type{<:AbstractFloat} = Float32, ) isodd(px) || @warn("even px = $px ?") isodd(pz) || @warn("even pz = $pz ?") diff --git a/src/rotatez.jl b/src/rotatez.jl index 5abd9dc..8ff5495 100644 --- a/src/rotatez.jl +++ b/src/rotatez.jl @@ -371,7 +371,7 @@ function imrotate( img::AbstractMatrix{I}, θ::RealU; method::Symbol=:two, - T::DataType = promote_type(I, Float32), + T::Type{<:AbstractFloat} = promote_type(I, Float32), ) where {I <: Number} output = similar(Matrix{T}, size(img)) plan = plan_rotate(size(img, 1); T, nthread = 1, method)[1] @@ -424,7 +424,7 @@ function imrotate_adj( img::AbstractMatrix{I}, θ::RealU; method::Symbol=:two, - T::DataType = promote_type(I, Float32), + T::Type{<:AbstractFloat} = promote_type(I, Float32), ) where {I <: Number} output = similar(Matrix{T}, size(img)) plan = plan_rotate(size(img, 1); T, nthread = 1, method)[1] diff --git a/src/spectplan.jl b/src/spectplan.jl index 6905626..e0955ff 100644 --- a/src/spectplan.jl +++ b/src/spectplan.jl @@ -30,7 +30,7 @@ Currently code assumes the following: * multiprocessing using # of threads specified by `Threads.nthreads()` """ struct SPECTplan{T} - T::DataType # default type for work arrays etc. + T::Type{<:AbstractFloat} # default type for work arrays etc. imgsize::NTuple{3, Int} px::Int pz::Int @@ -56,7 +56,7 @@ struct SPECTplan{T} mumap::Array{<:RealU, 3}, psfs::Array{<:RealU, 4}, dy::RealU; - T::DataType = promote_type(eltype(mumap), Float32), + T::Type{<:AbstractFloat} = promote_type(eltype(mumap), Float32), viewangle::StepRangeLen{<:RealU} = (0:size(psfs, 4) - 1) / size(psfs, 4) * T(2π), # set of view angles interpmeth::Symbol = :two, # :one is for 1d interpolation, :two is for 2d interpolation nthread::Int = Threads.nthreads(),