From 1e8678128eaff2451b7b6379304c06bb52390c27 Mon Sep 17 00:00:00 2001 From: korbinian90 Date: Mon, 14 Oct 2024 17:29:06 +0200 Subject: [PATCH] add B0 weighting options; add B0_snr output --- ext/RomeoApp/argparse.jl | 4 ++++ ext/RomeoApp/caller.jl | 6 ++++-- test/RomeoApp/dataset_small.jl | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ext/RomeoApp/argparse.jl b/ext/RomeoApp/argparse.jl index aa4a065..76a3a1c 100644 --- a/ext/RomeoApp/argparse.jl +++ b/ext/RomeoApp/argparse.jl @@ -56,6 +56,10 @@ function getargs(args::AbstractVector, version) default = "" nargs = '?' constant = "B0" + "--B0-phase-weighting" + help = """phase_snr | average | TEs | mag | magTEs | simulated_mag + Set the weighting for the B0 calculation.""" + default = "phase_snr" "--phase-offset-correction" help = """on | off | bipolar. Applies the MCPC3Ds method to perform phase offset diff --git a/ext/RomeoApp/caller.jl b/ext/RomeoApp/caller.jl index 7174d5a..1906bb2 100644 --- a/ext/RomeoApp/caller.jl +++ b/ext/RomeoApp/caller.jl @@ -1,4 +1,4 @@ -function ROMEO.unwrapping_main(args; version="App 4.4") +function ROMEO.unwrapping_main(args; version="App 4.5") settings = getargs(args, version) data = load_data_and_resolve_args!(settings) @@ -242,8 +242,10 @@ function computeB0(settings, data) end data["mag"] = to_dim(exp.(-settings["TEs"]/20), 4) # T2*=20ms decay (low value to reduce noise contribution of later echoes) end - B0 = calculateB0_unwrapped(data["phase"], data["mag"], settings["TEs"]) + B0 = calculateB0_unwrapped(data["phase"], data["mag"], settings["TEs"], Symbol(settings["B0-phase-weighting"])) save(B0, settings["compute-B0"], settings) + snr = get_B0_snr(data["mag"], settings["TEs"], Symbol(settings["B0-phase-weighting"])) + save(snr, settings["compute-B0"]*"_snr", settings) end function write_qualitymap(settings, data, keyargs) diff --git a/test/RomeoApp/dataset_small.jl b/test/RomeoApp/dataset_small.jl index 0597cf4..1281fc0 100644 --- a/test/RomeoApp/dataset_small.jl +++ b/test/RomeoApp/dataset_small.jl @@ -84,6 +84,12 @@ configurations_me(pm) = [ [pm..., "--phase-offset-correction", "bipolar", "-t", "[2,4,6]"], [pm..., "--phase-offset-correction", "-t", "[2,4,6]", "--phase-offset-smoothing-sigma-mm", "[5,8,4]"], [pm..., "--phase-offset-correction", "-t", "[2,4,6]", "--write-phase-offsets"], + [pm..., "-t", "[2,4,6]", "-B", "--B0-phase-weighting", "phase_snr"], + [pm..., "-t", "[2,4,6]", "-B", "--B0-phase-weighting", "average"], + [pm..., "-t", "[2,4,6]", "-B", "--B0-phase-weighting", "TEs"], + [pm..., "-t", "[2,4,6]", "-B", "--B0-phase-weighting", "mag"], + [pm..., "-t", "[2,4,6]", "-B", "--B0-phase-weighting", "magTEs"], + [pm..., "-t", "[2,4,6]", "-B", "--B0-phase-weighting", "simulated_mag"], ] files = [(phasefile_1eco, magfile_1eco), (phasefile_1arreco, magfile_1arreco), (phasefile_1eco, magfile_1arreco), (phasefile_1arreco, magfile_1eco), (phasefile_2D, magfile_2D)] @@ -192,11 +198,13 @@ unwrapping_main([phasefile_me, "-o", testpath, "-m", magfile_me, "-t", "[2,4,6]" testpath = joinpath(tmpdir, "testB0_1") unwrapping_main([phasefile_me, "-o", testpath, "-m", magfile_me, "-t", "[2,4,6]", "-B"]) @test isfile(joinpath(testpath, "B0.nii")) +@test isfile(joinpath(testpath, "B0_snr.nii")) testpath = joinpath(tmpdir, "testB0_2") name = "B0_output" unwrapping_main([phasefile_me, "-o", testpath, "-m", magfile_me, "-t", "[2,4,6]", "-B", name]) @test isfile(joinpath(testpath, "$name.nii")) +@test isfile(joinpath(testpath, "$(name)_snr.nii")) ## TODO add and test homogeneity corrected output