Methods list
SPECTrecon.SPECTreconSPECTrecon.Rotate1DSPECTrecon.Rotate2DSPECTrecon.PlanPSFSPECTrecon.PlanRotateSPECTrecon.RotateModeSPECTrecon.SPECTplanBase.showBase.showBase.showBase.showBase.showBase.sizeofBase.sizeofBase.sizeofSPECTrecon.AblockSPECTrecon.backprojectSPECTrecon.backprojectSPECTrecon.backproject!SPECTrecon.backproject!SPECTrecon.backproject!SPECTrecon.copy3dj!SPECTrecon.fft_convSPECTrecon.fft_conv!SPECTrecon.fft_conv!SPECTrecon.fft_conv_adjSPECTrecon.fft_conv_adj!SPECTrecon.fft_conv_adj!SPECTrecon.fft_conv_adj2!SPECTrecon.fftshift2!SPECTrecon.imfilterz!SPECTrecon.imrotateSPECTrecon.imrotate!SPECTrecon.imrotate!SPECTrecon.imrotate!SPECTrecon.imrotate!SPECTrecon.imrotate_adjSPECTrecon.imrotate_adj!SPECTrecon.imrotate_adj!SPECTrecon.imrotate_adj!SPECTrecon.imrotate_adj!SPECTrecon.linearinterp!SPECTrecon.mlemSPECTrecon.mlem!SPECTrecon.mul3dj!SPECTrecon.osemSPECTrecon.osem!SPECTrecon.pad2sizezero!SPECTrecon.pad_it!SPECTrecon.padrepl!SPECTrecon.padzero!SPECTrecon.plan_psfSPECTrecon.plan_rotateSPECTrecon.plus1di!SPECTrecon.plus1dj!SPECTrecon.plus2di!SPECTrecon.plus2dj!SPECTrecon.plus3di!SPECTrecon.plus3dj!SPECTrecon.plus3dk!SPECTrecon.projectSPECTrecon.projectSPECTrecon.project!SPECTrecon.project!SPECTrecon.project!SPECTrecon.psf_gaussSPECTrecon.rot180!SPECTrecon.rot_f90!SPECTrecon.rot_f90_adj!SPECTrecon.rotate_x!SPECTrecon.rotate_x_adj!SPECTrecon.rotate_y!SPECTrecon.rotate_y_adj!SPECTrecon.rotl90!SPECTrecon.rotr90!SPECTrecon.scale3dj!SPECTrecon.spawner
Methods usage
SPECTrecon.SPECTrecon — ModuleSPECTreconSystem matrix (forward and back-projector) for SPECT image reconstruction.
SPECTrecon.Rotate1D — ConstantRotate1D = RotateMode{:one}()Rotate using 3-pass 1D interpolation
SPECTrecon.Rotate2D — ConstantRotate2D = RotateMode{:two}()Rotate using 1-pass 2D bilinear interpolation
SPECTrecon.PlanPSF — TypePlanPSF{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
Tdatatype of work arrays (subtype ofAbstractFloat)nx::Int = 128(nyimplicitly the same)nz::Int = nximage size is[nx,nx,nz]px::Int = 1pz::Int = px(PSF size)padsize::Tuple:(padup, paddown, padleft, padright)workmat [nx+padup+paddown, nz+padleft+padright]2D padded image for FFT convolutionworkvecx [nx+padup+paddown,]: 1D work vectorworkvecz [nz+padleft+padright,]: 1D work vectorimg_compl [nx+padup+paddown, nz+padleft+padright]: 2D [complex] padded image for FFTker_compl [nx+padup+paddown, nz+padleft+padright]: 2D [complex] padded image for FFTfft_plan::Tfplan for doing FFT; seeplan_fft!ifft_plan::Tiplan for doing IFFT; seeplan_ifft!
SPECTrecon.PlanRotate — TypePlanRotate{T, R}Struct for storing work arrays and factors for 2D square image rotation for one thread
Tdatatype of work arrays (defaultFloat32)R::RotateModenx::Intimage sizepadsize::Int: pad each side of image by this muchworkmat1 [nx + 2 * padsize, nx + 2 * padsize]padded work matrixworkmat2 [nx + 2 * padsize, nx + 2 * padsize]padded work matrixinterp::SparseInterpolator{T, 2, 1}
SPECTrecon.RotateMode — TypeRotateModeType to control image rotation method.
Rotate1D: 3-pass 1D interpolationRotate2D: 1-pass 2D bilinear interpolation
SPECTrecon.SPECTplan — TypeSPECTplanStruct for storing key factors for a SPECT system model
Tdatatype of work arraysimgsizesize of imagepx,pzpsf dimensionimgr [nx, ny, nz]3D rotated version of imageadd_img [nx, ny, nz]3D image for adding views and backprojectionmumap [nx,ny,nz]attenuation map, must be 3D, possibly zeros()mumapr [nx, ny, nz]3D rotated mumapexp_mumapr [nx, nz]2D exponential rotated mumappsfs [px,pz,ny,nview]point spread function, must be 4D, withpx andpz` odd, and symmetric for each slicenviewnumber of views, must be integerviewangleset of view angles, must be from 0 to 2πinterpmethinterpolation method::onemeans 1d;:twomeans 2dmodepre-allocation method::fastmeans faster;:memmeans use less memorydyvoxel size in y direction (dxis the same value)nthreadnumber of CPU threads used to process data; must be integerplanrotVector of structPlanRotateplanpsfVector of structPlanPSF
Currently code assumes the following:
- each of the
nviewprojection views is[nx,nz] nx = ny- uniform angular sampling
psfis symmetric- multiprocessing using # of threads specified by
Threads.nthreads()
Constructor is not type stable due to the Union, but this is OK because construction is done just once before iterating.
Base.show — Methodshow(io::IO, mime::MIME"text/plain", vp::Vector{<:PlanPSF})Base.show — Methodshow(io::IO, mime::MIME"text/plain", vp::Vector{<:PlanRotate})Base.show — Methodshow(io::IO, ::MIME"text/plain", plan::PlanRotate)Base.show — Methodshow(io::IO, ::MIME"text/plain", plan::PlanPSF)Base.show — Methodshow(io::IO, ::MIME"text/plain", plan::SPECTplan)Base.sizeof — Methodsizeof(::PlanPSF)Show size in bytes of PlanPSF object.
Base.sizeof — Methodsizeof(::SPECTplan)Show size in bytes of SPECTplan object.
Base.sizeof — Methodsizeof(::PlanRotate)Show size in bytes of PlanRotate object.
SPECTrecon.Ablock — MethodAblock(plan, nblocks)Generate a vector of linear maps for OSEM. -plan: SPECTrecon plan -nblocks: Number of blocks in OSEM
SPECTrecon.backproject! — Methodbackproject!(image, views, plan ; index)Backproject multiple views into image. Array image is not initialized to zero; caller must do that.
SPECTrecon.backproject! — Methodbackproject!(image, view, plan, buffer_id, viewidx)Backproject a single view.
SPECTrecon.backproject! — Methodbackproject!(image, view, plan, viewidx)Backproject a single view.
SPECTrecon.backproject — Methodimage = backproject(views, mumap, psfs, dy; interpmeth, kwargs...)SPECT backproject views using attenuation map mumap and PSF array psfs for pixel size dy. This method initializes the plan as a convenience. Most users should use backproject! instead after initializing those, for better efficiency.
SPECTrecon.backproject — Methodimage = backproject(views, plan ; kwargs...)SPECT backproject views; this allocates the returned 3D array.
SPECTrecon.copy3dj! — Methodcopy3dj!(mat2d, mat3d, j)Non-allocating mat2d .= mat3d[:,j,:]
SPECTrecon.fft_conv! — Methodfft_conv!(output, image3, ker3, plans)Mutating version of convolving a 3D image3 with a set of 2D symmetric kernels stored in 3D array ker3 using foreach.
SPECTrecon.fft_conv! — Methodfft_conv!(output, img, ker, plan)Convolve 2D image img with 2D (symmetric!) kernel ker using FFT, storing the result in output.
SPECTrecon.fft_conv — Methodfft_conv(img, ker; T)Convolve 2D image img with 2D (symmetric!) kernel ker using FFT.
SPECTrecon.fft_conv_adj! — Methodfft_conv_adj!(output, image3, ker3, plans)Adjoint of fft_conv.
SPECTrecon.fft_conv_adj! — Methodfft_conv_adj!(output, img, ker, plan)Adjoint of fft_conv!.
SPECTrecon.fft_conv_adj — Methodfft_conv_adj(img, ker; T)Adjoint of fft_conv.
SPECTrecon.fft_conv_adj2! — Methodfft_conv_adj2!(output, image2, ker3, plans)Mutating version of adjoint of convolving a 2D image2 with each 2D kernel in the 3D array ker3.
SPECTrecon.fftshift2! — Methodfftshift2!(dst, src)Same as fftshift in 2d, but non-allocating
SPECTrecon.imfilterz! — Methodimfilterz!(plan)FFT-based convolution of plan.img_compl and kernel plan.ker_compl (not centered), storing result in plan.workmat. Over-writes plan.ker_compl.
SPECTrecon.imrotate! — Functionimrotate!(output, image3, θ, plans, ntasks=nthreads)In-place version of rotating a 3D image3 by θ in counter-clockwise direction (opposite to imrotate in Julia) using foreach with ntasks.
SPECTrecon.imrotate! — Methodimrotate!(output, image3, θ, plans, :thread)Mutating version of rotating a 3D image3 by θ in counter-clockwise direction (opposite of imrotate in Julia) writing result into output, using Threads.@threads.
SPECTrecon.imrotate! — Methodimrotate!(output, img, θ, plan)Rotate a 2D image img by angle θ ∈ [0,2π] in counter-clockwise direction (opposite to imrotate in Julia) using 3-pass 1d linear interpolations.
SPECTrecon.imrotate! — Methodimrotate!(output, img, θ, plan)Rotate a 2D image img by angle θ ∈ [0,2π] in counter-clockwise direction (opposite to imrotate in Julia) using 2d bilinear interpolation.
SPECTrecon.imrotate — Methodimrotate(img, θ; method::Symbol=:two)Rotate a 2D image img by angle θ ∈ [0,2π] in counter-clockwise direction (opposite to imrotate in Julia) using either 2d linear interpolation (for :two) or 3-pass 1D interpolation (for :one)
SPECTrecon.imrotate_adj! — Functionimrotate_adj!(output, image3, θ, plans, ntasks=nthreads)Adjoint of imrotate! using foreach.
SPECTrecon.imrotate_adj! — Methodimrotate_adj!(output, image3, θ, plans, :thread)Adjoint of imrotate! using @threads.
SPECTrecon.imrotate_adj! — Methodimrotate_adj!(output, img, θ, plan)Adjoint of imrotate! for a 2D image using 3-pass 1d linear interpolations.
SPECTrecon.imrotate_adj! — Methodimrotate_adj!(output, img, θ, plan)Adjoint of imrotate! for a 2D image using 2D bilinear interpolation.
SPECTrecon.imrotate_adj — Methodimrotate_adj(img, θ; method::Symbol=:two)Adjoint of rotating a 2D image img by angle θ ∈ [0,2π] in counter-clockwise direction (opposite to imrotate in Julia) using either 2d linear interpolations or 3-pass 1D interpolation.
SPECTrecon.linearinterp! — Methodlinearinterp!(A, s, e, len)Assign key values in SparseInterpolator (linear) A that are calculated from s, e and len. s means start (x[1]) e means end (x[end]) len means length (length(x))
SPECTrecon.mlem! — Methodmlem!(out, x0, ynoisy, background, A; niter = 20)Inplace version of ML-EM algorithm for emission tomography image reconstruction.
out: Outputx0: Initial guessynoisy: (Noisy) measurementsbackground: Background effects, e.g., scattersA: System matrixniter: Number of iterations
SPECTrecon.mlem — Methodmlem(x0, ynoisy, background, A; niter = 20)ML-EM algorithm for emission tomography image reconstruction.
x0: Initial guessynoisy: (Noisy) measurementsbackground: Background effects, e.g., scattersA: System matrixniter: Number of iterations
SPECTrecon.mul3dj! — Methodmul3dj!(mat3d, mat2d, j)Non-allocating mat3d[:,j,:] *= mat2d
SPECTrecon.osem! — Methodosem!(out, x0, ynoisy, background, Ab; niter = 20)OS-EM algorithm for SPECT reconstruction.
out: Outputx0: Initial estimateynoisy: (Noisy) measurementsbackground: Background effects, e.g., scattersAb: Vector of system matrixniter: Number of iterations
SPECTrecon.osem — Methodosem(x0, ynoisy, background, Ab; niter = 20)OS-EM algorithm for SPECT reconstruction.
x0: Initial guessynoisy: (Noisy) measurementsbackground: Background effects, e.g., scattersAb: Vector of system matrixniter: Number of iterations
SPECTrecon.pad2sizezero! — Methodpad2sizezero!(output, img, padsize)Non-allocating version of padding: `output[paddims[1]+1 : paddims[1]+dims[1], paddims[2]+1 : paddims[2]+dims[2]]) .= img
SPECTrecon.pad_it! — Methodpad_it!(X, padsize)Zero-pad X to padsize
SPECTrecon.padrepl! — Methodpadrepl!(output, img, padsize)Pad with replication from img into output
SPECTrecon.padzero! — Methodpadzero!(output, img, pad_x, pad_y)Mutating version of padding a 2D image by filling zeros. Output has size (size(img, 1) + padsize[1] + padsize[2], size(img, 2) + padsize[3] + padsize[4]).
SPECTrecon.plan_psf — Methodplan_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. Option
nx::Int = 128nz::Int = nxpx::Int = 1pz::Int = pxPSF size ispx × pzT: datatype of work arrays, defaults toFloat32nthread::Int# of threads, defaults toThreads.nthreads()
SPECTrecon.plan_rotate — Methodplan_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.
Input
nx::Intmust equal tony(square images only)
Option
T: datatype of work arrays, defaults toFloat32method::Symbol: default is:twofor 2D interpolation; use:onefor 3-pass rotation with 1D interpolationnthread::Int: default toThreads.nthreads()The other useful option is1when rotating just one image.
SPECTrecon.plus1di! — Methodplus1di!(mat2d, mat1d)Non-allocating mat2d[i, :] += mat1d
SPECTrecon.plus1dj! — Methodplus1dj!(mat2d, mat1d)Non-allocating mat2d[:, j] += mat1d
SPECTrecon.plus2di! — Methodplus2di!(mat1d, mat2d, i)Non-allocating mat1d += mat2d[i,:]
SPECTrecon.plus2dj! — Methodplus2dj!(mat1d, mat2d, j)Non-allocating mat1d += mat2d[:,j]
SPECTrecon.plus3di! — Methodplus3di!(mat2d, mat3d, i)Non-allocating mat2d += mat3d[i,:,:]
SPECTrecon.plus3dj! — Methodplus3dj!(mat2d, mat3d, j)Non-allocating mat2d += mat3d[:,j,:]
SPECTrecon.plus3dk! — Methodplus3dk!(mat2d, mat3d, k)Non-allocating mat2d += mat3d[:,:,k]
SPECTrecon.project! — Methodproject!(views, image, plan; index)Project image into multiple views with indexes index (defaults to 1:nview). The 3D views array must be pre-allocated, but need not be initialized.
SPECTrecon.project! — Methodproject!(view, plan, image, buffer_id, viewidx)SPECT projection of image into a single view with index viewidx. The view must be pre-allocated but need not be initialized to zero.
SPECTrecon.project! — Methodproject!(view, plan, image, viewidx)SPECT projection of image into a single view with index viewidx. The view must be pre-allocated but need not be initialized to zero.
SPECTrecon.project — Methodviews = project(image, mumap, psfs, dy; interpmeth, kwargs...)Convenience method for SPECT forward projector that does all allocation including initializing plan.
In
image: 3D array(nx,ny,nz)mumap:(nx,ny,nz)3D attenuation map, possibly zeros()psfs: 4D PSF arraydy::RealU: pixel size
Option
interpmeth::oneor:two
SPECTrecon.project — Methodviews = project(image, plan ; kwargs...)Convenience method for SPECT forward projector that allocates and returns views.
SPECTrecon.psf_gauss — Methodpsf_gauss( ; ny, px, pz, fwhm_start, fwhm_end, fwhm, fwhm_x, fwhm_z, T)Create depth-dependent Gaussian PSFs having specified full-width half-maximum (FHWM) values.
Options
- 'ny::Int = 128'
- 'px::Int = 11' (should be odd)
- 'pz::Int = px' (should be odd)
- 'fwhm_start::Real = 1'
- 'fwhm_end::Real = 4'
- 'fwhm::AbstractVector{<:Real} = range(fwhmstart, fwhmend, ny)'
- 'fwhm_x::AbstractVector{<:Real} = fwhm,
- 'fwhmz::AbstractVector{<:Real} = fwhmx'
- 'T::Type == Float32'
Returned psf is [px, pz, ny] where each PSF sums to 1.
SPECTrecon.rot180! — Methodrot180!(B::AbstractMatrix, A::AbstractMatrix)In place version of rot180, returning rotation of A in B.
SPECTrecon.rot_f90! — Methodrot_f90!(output, img, m)In-place version of rotating an image by 90/180/270 degrees
SPECTrecon.rot_f90_adj! — Methodrot_f90_adj!(output, img, m)
The adjoint of rotating an image by 90/180/270 degreesSPECTrecon.rotate_x! — Methodrotate_x!(output, img, tan_θ, interp)SPECTrecon.rotate_x_adj! — Methodrotate_x_adj!(output, img, tan_θ, interp)SPECTrecon.rotate_y! — Methodrotate_y!(output, img, sin_θ, interp)SPECTrecon.rotate_y_adj! — Methodrotate_y_adj!(output, img, sin_θ, interp)SPECTrecon.rotl90! — Methodrotl90!(B::AbstractMatrix, A::AbstractMatrix)In place version of rotl90, returning rotation of A in B.
SPECTrecon.rotr90! — Methodrotr90!(B::AbstractMatrix, A::AbstractMatrix)In place version of rotr90, returning rotation of A in B.
SPECTrecon.scale3dj! — Methodscale3dj!(mat2d, mat3d, j, s)Non-allocating mat2d = s * mat3d[:,j,:]
SPECTrecon.spawner — Methodspawner(fun!, nthread::Int, ntask::Int)Apply fun!(buffer_id, task) for task in 1:ntask where buffer_id is in {1, …, nthread}
A single-thread version of this would simply be fun!.(1, 1:ntask)