diff --git a/Project.toml b/Project.toml index 8468417..0672382 100644 --- a/Project.toml +++ b/Project.toml @@ -9,14 +9,24 @@ MRICoilSensitivities = "c57eb701-aafc-44a2-a53c-128049758959" MRIFiles = "5a6f062f-bf45-497d-b654-ad17aae2a530" MRIReco = "bdf86e05-2d2b-5731-a332-f3fe1f9e047f" NIfTI = "a3a9e032-41b5-5fc4-967a-a6b7a19844d3" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" QuantitativeMRI = "659767e3-31a7-4dc1-8563-6e03f484b231" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] +JSON = "0.21" +MRICoilSensitivities = "0.1.3" +MRIFiles = "0.3.2" +MRIReco = "0.9.0" +NIfTI = "0.6.0" +Pkg = "1.10" +QuantitativeMRI = "0.1.3" +Statistics = "1.10" julia = "1.10" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3" [targets] -test = ["Test"] +test = ["Test","LazyArtifacts"] diff --git a/src/BIDS.jl b/src/BIDS.jl index 10ac10d..2de1388 100644 --- a/src/BIDS.jl +++ b/src/BIDS.jl @@ -74,6 +74,11 @@ function write_bids_MP2RAGE(d::Dict,subname::AbstractString,folder="") p_MP2 = d["params_MP2RAGE"] # define JSON dict + proj = Pkg.project() + gen_dict = Dict{Any,Any}() + gen_dict["Name"] = proj.name + gen_dict["Version"] = string(proj.version) + JSON_dict = Dict{Any,Any}() JSON_dict["InversonTime"]= [p_MP2.TI₁,p_MP2.TI₂] #s JSON_dict["RepetitionTimeExcitation"]= p_MP2.TR @@ -82,10 +87,19 @@ function write_bids_MP2RAGE(d::Dict,subname::AbstractString,folder="") JSON_dict["FlipAngle"]= [p_MP2.α₁,p_MP2.α₂] JSON_dict["MagneticFieldStrength"] = MagneticField JSON_dict["Units"] = "arbitrary" + JSON_dict["GeneratedBy"]=gen_dict + # Write the dictionary to a JSON file open(joinpath(folder,subname,"MP2RAGE.json"), "w") do f JSON.print(f, JSON_dict, 4) # Indent 4 spaces for readability end + # Write dataset description + + + JSON_dict = Dict{Any,Any}() + JSON_dict["generatedBy"] = proj.name + JSON_dict["version"] = proj.version + end \ No newline at end of file diff --git a/src/SEQ_BRUKER_a_MP2RAGE_CS_360.jl b/src/SEQ_BRUKER_a_MP2RAGE_CS_360.jl index 9707ff7..2ba81f1 100644 --- a/src/SEQ_BRUKER_a_MP2RAGE_CS_360.jl +++ b/src/SEQ_BRUKER_a_MP2RAGE_CS_360.jl @@ -8,9 +8,11 @@ using QuantitativeMRI using Statistics using JSON using NIfTI +using Pkg # Write your package code here. include("bruker_sequence.jl") include("reconstruction.jl") include("BIDS.jl") + end diff --git a/src/reconstruction.jl b/src/reconstruction.jl index aa9ce26..0630fd7 100644 --- a/src/reconstruction.jl +++ b/src/reconstruction.jl @@ -58,6 +58,7 @@ function reconstruction_MP2RAGE(path_bruker;mean_NR::Bool = false,paramsCS=Dict( params = merge(params,paramsCS) x_approx = reconstruction(acq, params).data + if mean_NR x_approx = mean(x_approx,dims=6) # average accross repetition end diff --git a/test/Artifacts.toml b/test/Artifacts.toml new file mode 100644 index 0000000..c3e4bfa --- /dev/null +++ b/test/Artifacts.toml @@ -0,0 +1,6 @@ +[MP2RAGE_data] +git-tree-sha1 = "04cd4c29bb9e2aeb5384fbc70a9af0e1a37ca369" + + [[MP2RAGE_data.download]] + sha256 = "1f1b703c79db66ba6ef620651eca431cb0319d87f1eafa53826cb11a93afe4a8" + url = "https://zenodo.org/records/14051522/files/data.tar.gz" diff --git a/test/runtests.jl b/test/runtests.jl index 7372d48..75a9438 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,24 @@ using SEQ_BRUKER_a_MP2RAGE_CS_360 using Test +using LazyArtifacts +using SEQ_BRUKER_a_MP2RAGE_CS_360.NIfTI +using SEQ_BRUKER_a_MP2RAGE_CS_360.JSON @testset "SEQ_BRUKER_a_MP2RAGE_CS_360.jl" begin - # Write your tests here. + datadir = artifact"MP2RAGE_data" + @info "The test data is located at $datadir." + + path_bruker = joinpath(datadir, "MP2RAGE_FULLY") + d = reconstruction_MP2RAGE(path_bruker; mean_NR=true) + + @test size(d["im_reco"]) == (128,128,96,1,2) + @test size(d["T1map"]) == (128,128,96,1) + + write_bids_MP2RAGE(d,"sub","") + + ni = niread(joinpath("sub","anat","sub_T1map.nii.gz")).raw + @test d["T1map"] == ni + + JSON_dict = JSON.parsefile(joinpath("sub","MP2RAGE.json")) + @test JSON_dict["RepetitionTimePreparation"] == 5000 end