Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asense comments and Slices #138

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/system/Asense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ and coil sensitivity maps `smaps`.

The input `smaps` can either be a `D+1` dimensional array
of size `(size(samp)..., ncoil)`,
or a Vector of `ncoil` arrays of size `size(samp)`.
or a Vector (or `Slices`) of `ncoil` arrays of size `size(samp)`.

# Input
- `samp::AbstractArray{<:Bool}` `D`-dimensional sampling pattern.
Expand All @@ -37,7 +37,7 @@ Returns a `LinearMapsAA.LinearMapAO` object.
"""
function Asense(
samp::AbstractArray{<:Bool, D},
smaps::Vector{<:AbstractArray{<:Number}},
smaps::AbstractVector{<:AbstractArray{<:Number}},
;
dims = 1:D,
T::Type{<:Complex{<:AbstractFloat}} = ComplexF32,
Expand All @@ -48,9 +48,9 @@ function Asense(
kwargs...
) where {D, Tw <: Number}

all(in(1:D), dims) || error("dims $dims")
promote_type(Tw, T) == Tw || error("type Tw=$Tw cannot hold T=$T")
axes(work1) == axes(work2) == axes(samp) || error("axes mismatch: samp work")
all(in(1:D), dims) || throw(DimensionMismath("dims $dims"))
promote_type(Tw, T) == Tw || throw("type Tw=$Tw cannot hold T=$T")
axes(work1) == axes(work2) == axes(samp) || throw("axes mismatch: samp work")
all(==(axes(samp)), axes.(smaps)) || throw("axes mismatch: samp smaps")

sdim = size(samp)
Expand All @@ -66,12 +66,12 @@ function Asense(

function forw!(y, x)
for ic in 1:ncoil
@. work1 = x * smaps[ic]
@. work1 = x * smaps[ic] # apply sensitivity map
ifftshift!(work2, work1)
mul!(work2, pf, work2)
mul!(work2, pf, work2) # FFT
fftshift!(work1, work2)
if factor == 1
y[:,ic] .= work1[samp]
y[:,ic] .= work1[samp] # sampling
else
@. y[:,ic] = work1[samp] * factor
end
Expand Down Expand Up @@ -111,13 +111,14 @@ function Asense(
end


# handle typical array version of `smaps` efficiently
function Asense(
samp::AbstractArray{<:Bool, D},
smaps::AbstractArray{<:Number},
;
kwargs...
) where D
ndims(smaps) == D+1 || error("dimension mismatch")
smapv = [eachslice(smaps, dims = D+1)...]
ndims(smaps) == D+1 || throw(DimensionMismatch("$(ndims(smaps)) ≠ $(D+1)"))
smapv = eachslice(smaps, dims = D+1) # Slices
return Asense(samp, smapv; kwargs...)
end
Loading