-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Korbinian Eckstein
committed
Jan 26, 2024
1 parent
4dcfaee
commit b7e6703
Showing
6 changed files
with
125 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env -S julia --color=yes --startup-file=no --threads=auto | ||
|
||
## Usage | ||
|
||
# Call with: `<path-to-file>/tgv_qsm_amdgpu.jl ARGS` | ||
# On windows use: `julia --threads=auto <path-to-file>/tgv_qsm_amdgpu.jl ARGS` | ||
|
||
# Example call: | ||
# `./tgv_qsm_amdgpu.jl phase.nii.gz mask.nii.gz --TE 0.025 --output output.nii.gz | ||
|
||
import Pkg | ||
|
||
## Uncomment to use a local julia package directory instead of the global one | ||
# package_dir = joinpath(@__DIR__, ".tgv_cmd_packages") | ||
# mkpath(package_dir) | ||
# Pkg.activate(package_dir) | ||
|
||
try | ||
using AMDGPU, QuantitativeSusceptibilityMappingTGV, MriResearchTools, Comonicon | ||
catch | ||
Pkg.add(["AMDGPU", "QuantitativeSusceptibilityMappingTGV", "MriResearchTools", "Comonicon"]) | ||
using AMDGPU, QuantitativeSusceptibilityMappingTGV, MriResearchTools, Comonicon | ||
end | ||
|
||
version = Comonicon.get_version(QuantitativeSusceptibilityMappingTGV) | ||
Comonicon.get_version(::Module) = version | ||
|
||
@main function tgv_qsm(fn_phase, fn_mask; TE::Float64, output::String="output.nii.gz", fieldstrength::Float64=3.0, regularization::Float64=2.0, erosions::Int=3, B0_dir::Array{Int}=[0,0,1], dedimensionalize::Bool=false, no_laplacian_correction::Bool=false, step_size::Float64=3.0, type::DataType=Float32, nblocks::Int=32) | ||
println("Starting calculation...") | ||
phase = readphase(fn_phase) | ||
mask = niread(fn_mask) .!= 0 | ||
res = header(phase).pixdim[2:4] | ||
println("Resolution from NIfTI header [mm]: $(round.(Float64.(res); digits=2))") | ||
chi = qsm_tgv(phase, mask, res; TE, B0_dir, fieldstrength, regularization, erosions, dedimensionalize, correct_laplacian=!no_laplacian_correction, gpu=AMDGPU, step_size, type, nblocks) | ||
println("Writing output") | ||
savenii(chi, output; header=header(phase)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env -S julia --color=yes --startup-file=no --threads=auto | ||
|
||
## Usage | ||
|
||
# Call with: `<path-to-file>/tgv_qsm_metal.jl ARGS` | ||
# On windows use: `julia --threads=auto <path-to-file>/tgv_qsm_metal.jl ARGS` | ||
|
||
# Example call: | ||
# `./tgv_qsm_metal.jl phase.nii.gz mask.nii.gz --TE 0.025 --output output.nii.gz | ||
|
||
import Pkg | ||
|
||
## Uncomment to use a local julia package directory instead of the global one | ||
# package_dir = joinpath(@__DIR__, ".tgv_cmd_packages") | ||
# mkpath(package_dir) | ||
# Pkg.activate(package_dir) | ||
|
||
try | ||
using Metal, QuantitativeSusceptibilityMappingTGV, MriResearchTools, Comonicon | ||
catch | ||
Pkg.add(["Metal", "QuantitativeSusceptibilityMappingTGV", "MriResearchTools", "Comonicon"]) | ||
using Metal, QuantitativeSusceptibilityMappingTGV, MriResearchTools, Comonicon | ||
end | ||
|
||
version = Comonicon.get_version(QuantitativeSusceptibilityMappingTGV) | ||
Comonicon.get_version(::Module) = version | ||
|
||
@main function tgv_qsm(fn_phase, fn_mask; TE::Float64, output::String="output.nii.gz", fieldstrength::Float64=3.0, regularization::Float64=2.0, erosions::Int=3, B0_dir::Array{Int}=[0,0,1], dedimensionalize::Bool=false, no_laplacian_correction::Bool=false, step_size::Float64=3.0, type::DataType=Float32, nblocks::Int=32) | ||
println("Starting calculation...") | ||
phase = readphase(fn_phase) | ||
mask = niread(fn_mask) .!= 0 | ||
res = header(phase).pixdim[2:4] | ||
println("Resolution from NIfTI header [mm]: $(round.(Float64.(res); digits=2))") | ||
chi = qsm_tgv(phase, mask, res; TE, B0_dir, fieldstrength, regularization, erosions, dedimensionalize, correct_laplacian=!no_laplacian_correction, gpu=Metal, step_size, type, nblocks) | ||
println("Writing output") | ||
savenii(chi, output; header=header(phase)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env -S julia --color=yes --startup-file=no --threads=auto | ||
|
||
## Usage | ||
|
||
# Call with: `<path-to-file>/tgv_qsm_oneapi.jl ARGS` | ||
# On windows use: `julia --threads=auto <path-to-file>/tgv_qsm_oneapi.jl ARGS` | ||
|
||
# Example call: | ||
# `./tgv_qsm_oneapi.jl phase.nii.gz mask.nii.gz --TE 0.025 --output output.nii.gz | ||
|
||
import Pkg | ||
|
||
## Uncomment to use a local julia package directory instead of the global one | ||
# package_dir = joinpath(@__DIR__, ".tgv_cmd_packages") | ||
# mkpath(package_dir) | ||
# Pkg.activate(package_dir) | ||
|
||
try | ||
using oneAPI, QuantitativeSusceptibilityMappingTGV, MriResearchTools, Comonicon | ||
catch | ||
Pkg.add(["oneAPI", "QuantitativeSusceptibilityMappingTGV", "MriResearchTools", "Comonicon"]) | ||
using oneAPI, QuantitativeSusceptibilityMappingTGV, MriResearchTools, Comonicon | ||
end | ||
|
||
version = Comonicon.get_version(QuantitativeSusceptibilityMappingTGV) | ||
Comonicon.get_version(::Module) = version | ||
|
||
@main function tgv_qsm(fn_phase, fn_mask; TE::Float64, output::String="output.nii.gz", fieldstrength::Float64=3.0, regularization::Float64=2.0, erosions::Int=3, B0_dir::Array{Int}=[0,0,1], dedimensionalize::Bool=false, no_laplacian_correction::Bool=false, step_size::Float64=3.0, type::DataType=Float32, nblocks::Int=32) | ||
println("Starting calculation...") | ||
phase = readphase(fn_phase) | ||
mask = niread(fn_mask) .!= 0 | ||
res = header(phase).pixdim[2:4] | ||
println("Resolution from NIfTI header [mm]: $(round.(Float64.(res); digits=2))") | ||
chi = qsm_tgv(phase, mask, res; TE, B0_dir, fieldstrength, regularization, erosions, dedimensionalize, correct_laplacian=!no_laplacian_correction, gpu=oneAPI, step_size, type, nblocks) | ||
println("Writing output") | ||
savenii(chi, output; header=header(phase)) | ||
end |