Skip to content

Commit

Permalink
try fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tknopp committed Feb 10, 2024
1 parent 7097103 commit 867e6c7
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions examples/MotionCompensation/example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ c = reconstruction(bSF, bMeas, periodicMotionCorrection = true,
SNRThresh=2,minFreq=80e3,recChannels=[1,2,3]) #frequency selection

figure(2)
imshow( maximum(arraydata(c[1,:,:,:,1]),dims=3)[:,:,1] )
imshow( maximum(Array(c[1,:,:,:,1]),dims=3)[:,:,1] )



Expand All @@ -79,7 +79,7 @@ cStatic = reconstructionMultiPatch(bSF, bStatic, bgCorrection=false,
λ=lambda, iterations=iterations)

figure(3)
imshow( maximum(arraydata(cStatic[1,:,:,:,1]),dims=3)[:,:,1] )
imshow( maximum(Array(cStatic[1,:,:,:,1]),dims=3)[:,:,1] )



8 changes: 4 additions & 4 deletions test/Cartesian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ using MPIReco
setAll!(plan, :fov, calibFov(bSF))
@time c1 = reconstruct(build(plan), b)

exportImage(joinpath(imgdir, "Cartesian1.png"), arraydata(c1[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Cartesian1.png"), Array(c1[1,:,:,1,1]))
@test compareImg("Cartesian1.png")

# SP Reco
setAll!(plan, :numPeriodGrouping, numPatches)
#setAll!(plan, :maxMixingOrder, 12) # see above
@time c2 = reconstruct(build(plan), b)
exportImage(joinpath(imgdir, "Cartesian2.png"), arraydata(c2[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Cartesian2.png"), Array(c2[1,:,:,1,1]))
@test compareImg("Cartesian2.png")

# from Postprocessed
Expand All @@ -53,7 +53,7 @@ using MPIReco
plan.parameter.pre.numPeriodAverages = 65
@time c3 = reconstruct(build(plan), b)

exportImage(joinpath(imgdir, "Cartesian3.png"), arraydata(c3[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Cartesian3.png"), Array(c3[1,:,:,1,1]))
@test compareImg("Cartesian3.png")

#### Low Level ####
Expand Down Expand Up @@ -105,7 +105,7 @@ using MPIReco
setAll!(plan, :numPeriodAverages, numPeriodAverages)
@time c6 = reconstruct(build(plan), b)

exportImage(joinpath(imgdir, "Cartesian6.png"), arraydata(c6[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Cartesian6.png"), Array(c6[1,:,:,1,1]))
@test compareImg("Cartesian6.png")

end
4 changes: 2 additions & 2 deletions test/MotionCompensation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ using MPIReco
setAll!(plan, , 0.0f0)

c = reconstruct(build(plan), bMeas)
exportImage(joinpath(imgdir, "Motion1.png"), maximum(arraydata(c[1,:,:,:,1]),dims=3)[:,:,1])
exportImage(joinpath(imgdir, "Motion1.png"), maximum(Array(c[1,:,:,:,1]),dims=3)[:,:,1])
@test compareImg("Motion1.png")

setAll!(plan, :bgParams, SimpleExternalBackgroundCorrectionParameters(;emptyMeas = bBG, bgFrames = bgFrames))
c = reconstruct(build(plan), bMeas)
exportImage(joinpath(imgdir, "Motion2.png"), maximum(arraydata(c[1,:,:,:,1]),dims=3)[:,:,1])
exportImage(joinpath(imgdir, "Motion2.png"), maximum(Array(c[1,:,:,:,1]),dims=3)[:,:,1])
@test compareImg("Motion2.png")

end
8 changes: 4 additions & 4 deletions test/MultiPatch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using MPIReco
c1 = reconstruct(build(plan), b)
@test axisnames(c1) == names
@test axisvalues(c1) == values1
exportImage(joinpath(imgdir, "MultiPatch1.png"), arraydata(c1[1,:,:,1,1]))
exportImage(joinpath(imgdir, "MultiPatch1.png"), Array(c1[1,:,:,1,1]))
@test compareImg("MultiPatch1.png")

# TODO test description
Expand All @@ -36,7 +36,7 @@ using MPIReco
setAll!(plan, :roundPatches, false)
@test axisnames(c2) == names
@test axisvalues(c2) == values1
exportImage(joinpath(imgdir, "MultiPatch2.png"), arraydata(c2[1,:,:,1,1]))
exportImage(joinpath(imgdir, "MultiPatch2.png"), Array(c2[1,:,:,1,1]))
@test compareImg("MultiPatch2.png")

# multi-patch reconstruction using multiple system matrices
Expand All @@ -46,7 +46,7 @@ using MPIReco
c3 = reconstruct(build(plan), b)
@test axisnames(c3) == names
@test axisvalues(c3) == values2
exportImage(joinpath(imgdir, "MultiPatch3.png"), arraydata(c3[1,:,:,1,1]))
exportImage(joinpath(imgdir, "MultiPatch3.png"), Array(c3[1,:,:,1,1]))
@test compareImg("MultiPatch3.png")

# flexible multi-patch reconstruction
Expand All @@ -69,7 +69,7 @@ using MPIReco
c4 = reconstruct(build(plan), b)
@test axisnames(c4) == names
@test axisvalues(c4) == values2
exportImage(joinpath(imgdir, "MultiPatch4.png"), arraydata(c4[1,:,:,1,1]))
exportImage(joinpath(imgdir, "MultiPatch4.png"), Array(c4[1,:,:,1,1]))
@test compareImg("MultiPatch4.png")
# TODO the last test shows odd results

Expand Down
20 changes: 10 additions & 10 deletions test/Reconstruction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using MPIReco
c1 = reconstruct(build(plan), b)
@test axisnames(c1) == names
@test axisvalues(c1) == values
exportImage(joinpath(imgdir, "Reconstruction1.png"), arraydata(c1[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Reconstruction1.png"), Array(c1[1,:,:,1,1]))
@test compareImg("Reconstruction1.png")

# fused lasso
Expand All @@ -43,15 +43,15 @@ using MPIReco
#setAll!(plan, :normalizeReg, SystemMatrixBasedNormalization())
#@test axisnames(c2) == names
#@test axisvalues(c2) == values
#exportImage(joinpath(imgdir, "Reconstruction2.png"), arraydata(c2[1,:,:,1,1]))
#exportImage(joinpath(imgdir, "Reconstruction2.png"), Array(c2[1,:,:,1,1]))
#@test compareImg("Reconstruction2.png")

# with interpolation
setAll!(plan, :gridding, SystemMatrixGriddingParameter(;gridsize=[100,100,1], fov = calibFov(bSF)))
c3 = reconstruct(build(plan), b)
@test axisnames(c3) == names
@test axisvalues(c3) == (values[1], -27.8u"mm":0.4u"mm":11.8u"mm", -11.8u"mm":0.4u"mm":27.8u"mm", values[4:5]...)
exportImage(joinpath(imgdir, "Reconstruction3.png"), arraydata(c3[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Reconstruction3.png"), Array(c3[1,:,:,1,1]))
@test compareImg("Reconstruction3.png")

# with fov adpation and center shift
Expand All @@ -60,7 +60,7 @@ using MPIReco
@test axisnames(c4) == names
# TODO Tobi: does this make sense?
@test axisvalues(c4) == (values[1], -27.6u"mm":0.8u"mm":11.6u"mm", -11.6u"mm":0.8u"mm":27.6u"mm", 499.5u"mm":1000.0u"mm":499.5u"mm", values[5])
exportImage(joinpath(imgdir, "Reconstruction4.png"), arraydata(c4[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Reconstruction4.png"), Array(c4[1,:,:,1,1]))
@test compareImg("Reconstruction4.png")

setAll!(plan, :gridding, SystemMatrixGriddingParameter(;gridsize=calibSize(bSF), fov = calibFov(bSF)))
Expand All @@ -70,9 +70,9 @@ using MPIReco
c5 = reconstruct(build(plan), b)
@test axisnames(c5) == names
@test axisvalues(c5) == (1:2,values[2:end]...)
exportImage(joinpath(imgdir, "Reconstruction5a.png"), arraydata(c5[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Reconstruction5a.png"), Array(c5[1,:,:,1,1]))
@test compareImg("Reconstruction5a.png")
exportImage(joinpath(imgdir, "Reconstruction5b.png"), arraydata(c5[2,:,:,1,1]))
exportImage(joinpath(imgdir, "Reconstruction5b.png"), Array(c5[2,:,:,1,1]))
@test compareImg("Reconstruction5b.png")
#=
# dict based reco
Expand All @@ -87,7 +87,7 @@ using MPIReco
c6 = reconstruction(r)
@test axisnames(c6) == names
@test axisvalues(c6) == values
exportImage(joinpath(imgdir, "Reconstruction6.png"), arraydata(c6[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Reconstruction6.png"), Array(c6[1,:,:,1,1]))
@test compareImg("Reconstruction6.png")
=#

Expand All @@ -97,17 +97,17 @@ using MPIReco
# channel weighting
setAll!(plan, :weightingParams, ChannelWeightingParameters(channelWeights = [1.0, 1.0, 1.0]))
c7a = reconstruct(build(plan), b)
exportImage(joinpath(imgdir, "Reconstruction7a.png"), arraydata(c7a[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Reconstruction7a.png"), Array(c7a[1,:,:,1,1]))
@test compareImg("Reconstruction7a.png")

setAll!(plan, :weightingParams, ChannelWeightingParameters(channelWeights = [1.0,0.001,1.0]))
c7b = reconstruct(build(plan), b)
exportImage(joinpath(imgdir, "Reconstruction7b.png"), arraydata(c7b[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Reconstruction7b.png"), Array(c7b[1,:,:,1,1]))
@test compareImg("Reconstruction7b.png")

setAll!(plan, :weightingParams, ChannelWeightingParameters(channelWeights = [0.001,1.0,1.0]))
c7c = reconstruct(build(plan), b)
exportImage(joinpath(imgdir, "Reconstruction7c.png"), arraydata(c7c[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Reconstruction7c.png"), Array(c7c[1,:,:,1,1]))
@test compareImg("Reconstruction7c.png")

end
6 changes: 3 additions & 3 deletions test/SMExtrapolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ using MPIReco
setAll!(plan, :fov, calibFov(bSF).+[0.006,0.006,0])
c_extr = reconstruct(build(plan), b)
@test size(c1[1,:,:,:,1]) .+ (4,4,0) == size(c_extr[1,:,:,:,1])
exportImage(joinpath(imgdir, "Extrapolated1.png"), arraydata(c_extr[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Extrapolated1.png"), Array(c_extr[1,:,:,1,1]))
@test compareImg("Extrapolated1.png")

setAll!(plan, :gridsize, calibSize(bSF))
setAll!(plan, :fov, calibFov(bSF).+[0.006,0.006,0])
c_extr2 = reconstruct(build(plan), b)
@test size(c1[1,:,:,:,1]) == size(c_extr2[1,:,:,:,1])
exportImage(joinpath(imgdir, "Extrapolated2.png"), arraydata(c_extr2[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Extrapolated2.png"), Array(c_extr2[1,:,:,1,1]))
@test compareImg("Extrapolated2.png")

SFdirs = ["8.mdf", "9.mdf", "10.mdf", "11.mdf"]
Expand Down Expand Up @@ -72,7 +72,7 @@ using MPIReco
setAll!(plan, :mapping, 1:4)
c_extr3 = reconstruct(build(plan), b)
@test size(c2[1,:,:,:,1]) .+ (6,6,0) == size(c_extr3[1,:,:,:,1])
exportImage(joinpath(imgdir, "ExtrapolatedMultiPatch1.png"), arraydata(c_extr3[1,:,:,1,1]))
exportImage(joinpath(imgdir, "ExtrapolatedMultiPatch1.png"), Array(c_extr3[1,:,:,1,1]))
@test compareImg("ExtrapolatedMultiPatch1.png")

SM[vec([495:505;527:537]),:] .= 0.0 + 0.0im
Expand Down
14 changes: 7 additions & 7 deletions test/Sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using MPIReco
c1 = reconstruct(build(plan), b)
@test axisnames(c1) == names
@test axisvalues(c1) == values
exportImage(joinpath(imgdir, "Sparse1.png"), arraydata(c1[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Sparse1.png"), Array(c1[1,:,:,1,1]))
@test compareImg("Sparse1.png")

plan = getPlan("Sparse")
Expand All @@ -53,15 +53,15 @@ using MPIReco
c2 = reconstruct(build(plan), b)
@test axisnames(c2) == names
@test axisvalues(c2) == values
exportImage(joinpath(imgdir, "Sparse2.png"), arraydata(c2[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Sparse2.png"), Array(c2[1,:,:,1,1]))
@test compareImg("Sparse2.png")

setAll!(plan, :sparseTrafo, "FFT")
setAll!(plan, :useDFFoV, true)
c3 = reconstruct(build(plan), b)
@test axisnames(c3) == names
@test axisvalues(c3) == valuesDF
exportImage(joinpath(imgdir, "Sparse3.png"), arraydata(c3[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Sparse3.png"), Array(c3[1,:,:,1,1]))
@test compareImg("Sparse3.png")

setAll!(plan, :SNRThresh, 3)
Expand All @@ -72,7 +72,7 @@ using MPIReco
c4 = reconstruct(build(plan), b)
@test axisnames(c4) == names
@test axisvalues(c4) == values
exportImage(joinpath(imgdir, "Sparse4.png"), arraydata(c4[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Sparse4.png"), Array(c4[1,:,:,1,1]))
@test compareImg("Sparse4.png")

setAll!(plan, :spectralLeakageCorrection, true)
Expand All @@ -82,15 +82,15 @@ using MPIReco
setAll!(plan, :spectralLeakageCorrection, false)
@test axisnames(c5) == names
@test axisvalues(c5) == valuesDF
exportImage(joinpath(imgdir, "Sparse5.png"), arraydata(c5[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Sparse5.png"), Array(c5[1,:,:,1,1]))
@test compareImg("Sparse5.png")

setAll!(plan, :sparseTrafo, "DST")
setAll!(plan, :useDFFoV, false)
c6 = reconstruct(build(plan), b)
@test axisnames(c6) == names
@test axisvalues(c6) == values
exportImage(joinpath(imgdir, "Sparse6.png"), arraydata(c6[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Sparse6.png"), Array(c6[1,:,:,1,1]))
@test compareImg("Sparse6.png")

setAll!(plan, :spectralLeakageCorrection, true)
Expand All @@ -99,6 +99,6 @@ using MPIReco
c7 = reconstruct(build(plan), b)
@test axisnames(c7) == names
@test axisvalues(c7) == valuesDF
exportImage(joinpath(imgdir, "Sparse7.png"), arraydata(c7[1,:,:,1,1]))
exportImage(joinpath(imgdir, "Sparse7.png"), Array(c7[1,:,:,1,1]))
@test compareImg("Sparse7.png")
end

0 comments on commit 867e6c7

Please sign in to comment.