Skip to content

Commit

Permalink
Merge pull request #231 from cncastillo/komaio
Browse files Browse the repository at this point in the history
KomaMRIIO subpackage
  • Loading branch information
cncastillo authored Dec 1, 2023
2 parents 8e6ac21 + 435f8f8 commit 879894a
Show file tree
Hide file tree
Showing 44 changed files with 20,545 additions and 1,884 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,26 @@ jobs:
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: "KomaMRICore dev setup"
shell: bash
run: |
julia --color=yes --project="KomaMRICore" -e "using Pkg; Pkg.develop(PackageSpec(; path=\"./KomaMRIIO\"));"
- uses: julia-actions/julia-buildpkg@v1
with:
project: KomaMRICore
- uses: julia-actions/julia-runtest@v1
with:
project: KomaMRICore
- name: "KomaMRIIO dev setup"
shell: bash
run: |
julia --color=yes --project="KomaMRIIO" -e "using Pkg; Pkg.develop(PackageSpec(; path=\"./KomaMRICore\"));"
- uses: julia-actions/julia-buildpkg@v1
with:
project: KomaMRIIO
- uses: julia-actions/julia-runtest@v1
with:
project: KomaMRIIO
- name: "KomaMRIPlots dev setup"
shell: bash
run: |
Expand All @@ -61,6 +75,7 @@ jobs:
shell: julia --color=yes --project {0}
run: |
using Pkg
Pkg.develop(PackageSpec(path=pwd(), subdir="KomaMRIIO"))
Pkg.develop(PackageSpec(path=pwd(), subdir="KomaMRICore"))
Pkg.develop(PackageSpec(path=pwd(), subdir="KomaMRIPlots"))
- uses: julia-actions/julia-buildpkg@v1
Expand Down Expand Up @@ -88,6 +103,13 @@ jobs:
with:
files: lcov.info
flags: plots
- uses: julia-actions/julia-processcoverage@v1
with:
directories: KomaMRIIO/src
- uses: codecov/codecov-action@v3
with:
files: lcov.info
flags: io
docs:
name: Documentation
runs-on: ubuntu-latest
Expand All @@ -99,6 +121,9 @@ jobs:
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd(), subdir="KomaMRIIO"))
Pkg.develop(PackageSpec(path=pwd(), subdir="KomaMRICore"))
Pkg.develop(PackageSpec(path=pwd(), subdir="KomaMRIPlots"))
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*.jl.cov
*.jl.mem
.DS_Store
*Manifest.toml
**/Manifest.toml
/test/Manifest.toml
/dev/
.vscode/settings.json
Expand Down
8 changes: 0 additions & 8 deletions KomaMRICore/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ version = "0.7.7"
[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
MAT = "23992714-dd62-5051-b70f-ba57cb901cac"
MRIBase = "f7771a9a-6e57-4e71-863b-6e4b6a2f17df"
MRIFiles = "5a6f062f-bf45-497d-b654-ad17aae2a530"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Expand All @@ -24,14 +20,10 @@ ThreadsX = "ac1d9e8a-700a-412c-b207-f0111f4b6c0d"
[compat]
Adapt = "3"
CUDA = "3, 4, 5"
FileIO = "1"
Functors = "0.4"
HDF5 = "0.16, 0.17"
Interpolations = "0.13, 0.14"
JLD2 = "0.4"
MAT = "0.10"
MRIBase = "0.3, 0.4"
MRIFiles = "0.1, 0.2"
Parameters = "0.12"
Pkg = "1.4"
ProgressMeter = "1"
Expand Down
20 changes: 7 additions & 13 deletions KomaMRICore/src/KomaMRICore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ using Parameters
using Interpolations
using CUDA
#Reconstruction
using MRIBase, MRIFiles
using MRIBase
@reexport using MRIBase: Profile, RawAcquisitionData, AcquisitionData, AcquisitionHeader
@reexport using MRIFiles: ISMRMRDFile
#IO
using FileIO, HDF5, MAT, JLD2
using MAT # For loading example phantoms

global γ = 42.5774688e6; #Hz/T gyromagnetic constant for H1, JEMRIS uses 42.5756 MHz/T

Expand All @@ -29,11 +27,10 @@ include("datatypes/sequence/ADC.jl")
include("simulation/KeyValuesCalculation.jl")
include("datatypes/Sequence.jl")
include("datatypes/sequence/Delay.jl")
include("io/Pulseq.jl")
#Phantom
include("datatypes/Phantom.jl")
include("io/JEMRIS.jl")
include("io/MRiLab.jl")
#Rawdata
include("rawdata/ISMRMRD.jl")
#Simulator
include("datatypes/simulation/DiscreteSequence.jl")
include("datatypes/simulation/Spinor.jl")
Expand All @@ -43,23 +40,20 @@ include("simulation/GPUFunctions.jl")
# include("simulation/other/OffResonanceModel.jl")
include("simulation/TrapezoidalIntegration.jl")
include("simulation/SimulatorCore.jl")
include("io/ISMRMRD.jl")

#Main
export γ #gyro-magnetic ratio [Hz/T]
export Scanner, Sequence, Phantom
export Grad, RF, ADC, Delay
export Mag, dur
#Pulseq
export read_seq
#ISMRMRD
export signal_to_raw_data
#Phantom
export brain_phantom2D, brain_phantom3D, read_phantom_jemris, read_phantom_MRiLab
export brain_phantom2D, brain_phantom3D
#Spinors
export Spinor, Rx, Ry, Rz, Q, Un
#Secondary
export get_kspace, rotx, roty, rotz
#ISMRMRD
export signal_to_raw_data
#Simulator
export simulate, simulate_slice_profile

Expand Down
76 changes: 76 additions & 0 deletions KomaMRICore/src/datatypes/Phantom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,79 @@ function brain_phantom3D(;ss=4,start_end=[160, 200])
)
return obj
end

"""
obj = pelvis_phantom2D(; ss=4)
Creates a two-dimensional pelvis Phantom struct.
# Keywords
- `ss`: (`::Integer`, `=4`) subsampling parameter
# Returns
- `obj`: (`::Phantom`) Phantom struct
# Examples
```julia-repl
julia> obj = pelvis_phantom2D(; ss=1)
julia> pelvis_phantom2D(obj, :ρ)
```
"""
function pelvis_phantom2D(; ss=4)

# Get data from .mat file
path = @__DIR__
data = MAT.matread(path*"/phantom/pelvis2D.mat")
class = data["pelvis3D_slice"][1:ss:end,1:ss:end]

# Define spin position vectors
Δx = .5e-3*ss
M, N = size(class)
FOVx = (M-1)*Δx # [m]
FOVy = (N-1)*Δx # [m]
x = -FOVx/2:Δx:FOVx/2 # spin coordinates
y = -FOVy/2:Δx:FOVy/2 # spin coordinates
x, y = x .+ y'*0, x*0 .+ y' # grid points

# Define spin property vectors
ρ = (class.==51)*.001 .+ # Air
(class.==102)*.86 .+ # Fat
(class.==153)*.9 .+ # SoftTissue
(class.==204)*.4 .+ # SpongyBone
(class.==255)*.2 # CorticalBone
T1 = (class.==51)*.001 .+ # Air
(class.==102)*366 .+ # Fat
(class.==153)*1200 .+ # SoftTissue
(class.==204)*381 .+ # SpongyBone
(class.==255)*100 # CorticalBone
T2 = (class.==51)*.001 .+ # Air
(class.==102)*70 .+ # Fat
(class.==153)*80 .+ # SoftTissue
(class.==204)*52 .+ # SpongyBone
(class.==255)*.3 # CorticalBone
T2s = (class.==51)*.001 .+ # Air
(class.==102)*70 .+ # Fat
(class.==153)*80 .+ # SoftTissue
(class.==204)*52 .+ # SpongyBone
(class.==255)*.3 # CorticalBone
Δw_fat = -220 * 2π
Δw = (class.==102) * Δw_fat # FAT1
T1 = T1*1e-3
T2 = T2*1e-3
T2s = T2s*1e-3

# Define and return the Phantom struct
obj = Phantom{Float64}(
name = "pelvis2D",
x = y[ρ.!=0],
y = x[ρ.!=0],
z = 0*x[ρ.!=0],
ρ = ρ[ρ.!=0],
T1 = T1[ρ.!=0],
T2 = T2[ρ.!=0],
T2s = T2s[ρ.!=0],
Δw = Δw[ρ.!=0],
)
return obj
end
Binary file added KomaMRICore/src/datatypes/phantom/pelvis2D.mat
Binary file not shown.
Loading

2 comments on commit 879894a

@beorostica
Copy link
Contributor

Choose a reason for hiding this comment

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

@JuliaRegistrator register subdir=KomaMRIIO

@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/96325

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 KomaMRIIO-v0.7.7 -m "<description of version>" 879894a7cfd7eb3dd4d4085361c3f33f06c17516
git push origin KomaMRIIO-v0.7.7

Also, note the warning: This looks like a new registration that registers version 0.7.7.
Ideally, you should register an initial release with 0.0.1, 0.1.0 or 1.0.0 version numbers
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

Please sign in to comment.