From 2a8c1b466c76b10a522e55e52e8cd478353ef8e2 Mon Sep 17 00:00:00 2001 From: aTrotier Date: Thu, 19 Dec 2024 10:48:21 +0100 Subject: [PATCH] fix coil compression for Multi-slice + test --- MRICoilSensitivities/src/CoilCompression.jl | 3 +- .../test/testCoilCompression.jl | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/MRICoilSensitivities/src/CoilCompression.jl b/MRICoilSensitivities/src/CoilCompression.jl index 41cdbaf6..f04f4a31 100644 --- a/MRICoilSensitivities/src/CoilCompression.jl +++ b/MRICoilSensitivities/src/CoilCompression.jl @@ -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 """ diff --git a/MRICoilSensitivities/test/testCoilCompression.jl b/MRICoilSensitivities/test/testCoilCompression.jl index 6db60f3b..743205a6 100644 --- a/MRICoilSensitivities/test/testCoilCompression.jl +++ b/MRICoilSensitivities/test/testCoilCompression.jl @@ -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 @@ -107,4 +152,5 @@ end @testset "CoilCompression" begin test2DCC() test3DCC() + test2DMSCC() end