diff --git a/README.md b/README.md index 429c6b0..dc81699 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,12 @@ [![Codecov](https://codecov.io/gh/korbinian90/MriResearchTools.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/korbinian90/MriResearchTools.jl) [![Coveralls](https://coveralls.io/repos/github/korbinian90/MriResearchTools.jl/badge.svg?branch=master)](https://coveralls.io/github/korbinian90/MriResearchTools.jl?branch=master) -### Prerequisites +## Prerequisites A Julia installation v1.x is required. Magnitude and Phase images in NIfTI fileformat (4D images with echoes in the 4th dimension) -### Installing +## Installing Open the Julia REPL and type ```julia @@ -20,25 +20,62 @@ julia> ] # enter julia package manager julia> ``` -### Included Functionality +## Quick Start +Open multi-echo 4D NIfTI phase and magnitude files and perform ROMEO phase unwrapping. -ROMEO 3D/4D Phase Unwrapping +```julia +using MriResearchTools +# input images +TEs = [4,8,12] +nifti_folder = joinpath("test", "data", "small") +magfile = joinpath(nifti_folder, "Mag.nii") # Path to the magnitude image in nifti format, must be .nii or .hdr +phasefile = joinpath(nifti_folder, "Phase.nii") # Path to the phase image +# load images +mag = readmag(magfile) +phase = readphase(phasefile) +# unwrap +unwrapped = romeo(phase; mag=mag, TEs=TEs) +# save unwrapped image +outputfolder = "outputFolder" +mkpath(outputfolder) +savenii(unwrapped, "unwrapped", outputfolder, header(phase)) +``` + +## Included Functionality + +ROMEO 3D/4D Phase Unwrapping\ +`romeo` `unwrap` `unwrap_individual` + +Reading, writing and other functions for NIfTI files (adapted from JuliaIO/NIfTI)\ +`readphase` `readmag` `niread` `savenii` `header` + +Magnitude homogeneity correction ([example](https://github.com/korbinian90/Magnitude-Intensity-Correction/blob/master/Intensity%20Correction.ipynb))\ +`makehomogeneous` + +Simple robust masking (threshold)\ +`robustmask` -Reading and writing NIfTI files (adapted from JuliaIO/NIfTI) +Combine multiple echoes\ +`RSS` -Magnitude homogeneity correction ([example](https://github.com/korbinian90/Magnitude-Intensity-Correction/blob/master/Intensity%20Correction.ipynb)) +Laplacian unwrapping\ +`laplacianunwrap` -Simple robust masking (threshold) +Unwarping of B0 dependent shifts\ +`getVSM` `thresholdforward` `unwarp` -Combine multiple echoes +Fast gaussian smoothing\ +`gaussiansmooth3d` + - standard + - weighted + - with missing values -Laplacian unwrapping +Other functions +`robustrescale` `getHIP` `getsensitivity` `getscaledimage` `estimatequantile` -Unwarping of B0 dependent shifts +## License +This project is licensed under the MIT License - see the [LICENSE](https://github.com/korbinian90/MriResearchTools.jl/blob/master/LICENSE) for details -Fast gaussian smoothing -- standard -- weighted -- with missing values -TODO: Tests and Examples +## TODO +Tests, Examples and Documentation diff --git a/src/MriResearchTools.jl b/src/MriResearchTools.jl index 39e5473..f80c587 100644 --- a/src/MriResearchTools.jl +++ b/src/MriResearchTools.jl @@ -16,10 +16,11 @@ include("romeo.jl") export Data, readphase, readmag, niread, + header, savenii, robustmask, robustmask!, robustrescale, - combine_echoes, + #combine_echoes, getHIP, laplacianunwrap, laplacianunwrap!, getVSM, @@ -31,7 +32,7 @@ export Data, getscaledimage, estimatequantile, RSS, - unwrap, unwrap!, + unwrap, unwrap!, romeo, unwrap_individual, unwrap_individual! end # module diff --git a/src/romeo.jl b/src/romeo.jl index f3ded47..f4a26c2 100644 --- a/src/romeo.jl +++ b/src/romeo.jl @@ -1,3 +1,4 @@ +romeo = unwrap # access unwrap function via alias romeo # multi echo unwrapping function ROMEO.unwrap!( wrapped::AbstractArray{T, 4}; TEs=1:size(wrapped, 4), template=2, p2ref=1, keyargs... diff --git a/src/utility.jl b/src/utility.jl index a78c186..53269cd 100644 --- a/src/utility.jl +++ b/src/utility.jl @@ -19,12 +19,14 @@ end Base.copy(x::NIfTI.NIfTI1Header) = NIfTI.NIfTI1Header([getfield(x, k) for k ∈ fieldnames(NIfTI.NIfTI1Header)]...) function Base.similar(header::NIfTI.NIfTI1Header) - hdr = NIfTI.copy(header) + hdr = copy(header) hdr.scl_inter = 0 hdr.scl_slope = 1 - hdr + return hdr end +header(v::NIfTI.NIVolume) = similar(v.header) + Base.minimum(I::Array{AbstractFloat}) = NaNMath.minimum(I) Base.maximum(I::Array{AbstractFloat}) = NaNMath.maximum(I) diff --git a/test/utility_test.jl b/test/utility_test.jl index 9191a42..6d74544 100644 --- a/test/utility_test.jl +++ b/test/utility_test.jl @@ -27,7 +27,13 @@ GC.gc() @test estimatequantile(1:1000, 0.8) ≈ 800 atol=1 -hdr = similar(mag_nii.header) -@test hdr.scl_inter == 0 -@test hdr.scl_slope == 1 -@test hdr.dim == mag_nii.header.dim +function header_test(hdr, hdr2) + @test hdr.scl_inter == 0 + @test hdr.scl_slope == 1 + @test hdr.dim == hdr2.dim +end +# similar +header_test(similar(mag_nii.header), mag_nii.header) +# header +header_test(header(mag_nii), mag_nii.header) +header_test(header(phase_nii), phase_nii.header)