Skip to content

Commit

Permalink
Merge pull request #2 from korbinian90/development
Browse files Browse the repository at this point in the history
Merge new developments
  • Loading branch information
korbinian90 committed Mar 23, 2020
2 parents 7f66bcf + 64a4b33 commit 95f5889
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 23 deletions.
67 changes: 52 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
5 changes: 3 additions & 2 deletions src/MriResearchTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -31,7 +32,7 @@ export Data,
getscaledimage,
estimatequantile,
RSS,
unwrap, unwrap!,
unwrap, unwrap!, romeo,
unwrap_individual, unwrap_individual!

end # module
1 change: 1 addition & 0 deletions src/romeo.jl
Original file line number Diff line number Diff line change
@@ -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...
Expand Down
6 changes: 4 additions & 2 deletions src/utility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 10 additions & 4 deletions test/utility_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 95f5889

Please sign in to comment.