Skip to content

Commit

Permalink
Use Type not DataType
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffFessler committed Apr 8, 2024
1 parent 2eebee3 commit c5f3bef
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/lit/examples/2-rotate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion docs/lit/examples/3-psf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/fft_convolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions src/plan-psf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/plan-rotate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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.
Expand All @@ -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(),
)
Expand Down
4 changes: 2 additions & 2 deletions src/psf-gauss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -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 ?")
Expand Down
4 changes: 2 additions & 2 deletions src/rotatez.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions src/spectplan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(),
Expand Down

0 comments on commit c5f3bef

Please sign in to comment.