Skip to content

Commit

Permalink
add B0 weighting options;
Browse files Browse the repository at this point in the history
add B0_snr output
  • Loading branch information
korbinian90 committed Oct 14, 2024
1 parent aafac97 commit 1e86781
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ext/RomeoApp/argparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions ext/RomeoApp/caller.jl
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions test/RomeoApp/dataset_small.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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

Expand Down

2 comments on commit 1e86781

@korbinian90
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/117265

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.3.0 -m "<description of version>" 1e8678128eaff2451b7b6379304c06bb52390c27
git push origin v1.3.0

Please sign in to comment.