Skip to content

Commit

Permalink
fix coil compression for Multi-slice + test
Browse files Browse the repository at this point in the history
  • Loading branch information
aTrotier committed Dec 19, 2024
1 parent 1b61f30 commit 2a8c1b4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion MRICoilSensitivities/src/CoilCompression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ end

function geometricCoilCompression(acq::AcquisitionData{T,D}, numVC::Int = size(acq.kdata,2); dim::Int=1,sContr::Int = 1,sRep::Int = 1) where {T,D}
kdata = kDataCart(acq)
D == 2 ? enc2D = true : enc2D = false

kdataCC,ccMat2 = geometricCoilCompression(kdata, numVC, dim=dim,sContr=sContr,sRep=sRep)
return AcquisitionData(kdataCC),ccMat2
return AcquisitionData(kdataCC;enc2D),ccMat2
end

"""
Expand Down
46 changes: 46 additions & 0 deletions MRICoilSensitivities/test/testCoilCompression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,51 @@ function test2DCC(N=64)
@test (norm(vec(x_ori)-vec(x_cc))/norm(vec(x_ori))) < 2e-4
end

function test2DMSCC(N=64,nSl = 3)
#image
img = shepp_logan(N)
msk = zeros(N,N)
msk[findall(x->x!=0,img)] .= 1

# coil sensitivites
smaps = birdcageSensitivity(N, 8, 1.5)
snorm = sqrt.(sum(abs.(smaps).^2,dims=4))
for i=1:8
smaps[:,:,1,i] .= msk .* smaps[:,:,1,i] ./ snorm[:,:,1,1]
end

# simulation
params = Dict{Symbol, Any}()
params[:simulation] = "fast"
params[:trajName] = "Cartesian"
params[:numProfiles] = floor(Int64, N)
params[:numSamplingPerProfile] = N
params[:senseMaps] = smaps

acqData = simulation(img, params)

acqData_MS = deepcopy(acqData)
acqData_MS.kdata = [acqData.kdata[1,1,1] for echo=1:1, sl=1:nSl, rep=1:1]

#reconstruction
params = Dict{Symbol,Any}()
params[:reco] = "direct"
params[:reconSize] = acqData_MS.encodingSize

x_ori = reconstruction(acqData_MS, params)
x_ori = mergeChannels(x_ori)

acqDataCC,ccMat = softwareCoilCompression(acqData_MS, 6)
x_cc = reconstruction(acqDataCC, params)
x_cc = mergeChannels(x_cc)
@test (norm(vec(x_ori)-vec(x_cc))/norm(vec(x_ori))) < 2e-4

acqDataCC,ccMat = geometricCoilCompression(acqData_MS, 6)
x_cc = reconstruction(acqDataCC, params)
x_cc = mergeChannels(x_cc)
@test (norm(vec(x_ori)-vec(x_cc))/norm(vec(x_ori))) < 2e-4
end

function test3DCC(N=64, NSl=64)
## 3D espirit
type = ComplexF32
Expand Down Expand Up @@ -107,4 +152,5 @@ end
@testset "CoilCompression" begin
test2DCC()
test3DCC()
test2DMSCC()
end

0 comments on commit 2a8c1b4

Please sign in to comment.