Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upsample phantoms #319

Merged
merged 6 commits into from
Mar 11, 2024
Merged
35 changes: 21 additions & 14 deletions KomaMRIBase/src/datatypes/Phantom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ end
end

"""
obj = brain_phantom2D(; axis="axial", ss=4)
obj = brain_phantom2D(; axis="axial", ss=4, us=1)

Creates a two-dimensional brain Phantom struct.

Expand All @@ -182,7 +182,8 @@ Creates a two-dimensional brain Phantom struct.

# Keywords
- `axis`: (`::String`, `="axial"`, opts=[`"axial"`, `"coronal"`, `"sagittal"`]) orientation of the phantom
- `ss`: (`::Integer`, `=4`) subsampling parameter in all axis
- `ss`: (`::Integer`, `=4`) subsampling parameter for all axes
- `us`: (`::Integer`, `=1`) upsampling parameter for all axes, if used ss is set to ss=1

# Returns
- `obj`: (`::Phantom`) Phantom struct
Expand All @@ -194,15 +195,16 @@ julia> obj = brain_phantom2D(; axis="sagittal", ss=1)
julia> plot_phantom_map(obj, :ρ)
```
"""
function brain_phantom2D(; axis="axial", ss=4)
function brain_phantom2D(; axis="axial", ss=4, us=1)

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

if us > 1; ss=1; end
class = repeat( data[axis][1:ss:end,1:ss:end], inner=[us, us])

# Define spin position vectors
Δx = .5e-3*ss
Δx = .5e-3*ss/us
M, N = size(class)
FOVx = (M-1)*Δx #[m]
FOVy = (N-1)*Δx #[m]
Expand Down Expand Up @@ -279,7 +281,7 @@ function brain_phantom2D(; axis="axial", ss=4)
end

"""
obj = brain_phantom3D(; ss=4)
obj = brain_phantom3D(; ss=4, us=1)

Creates a three-dimentional brain Phantom struct.

Expand All @@ -292,6 +294,8 @@ Creates a three-dimentional brain Phantom struct.

# Keywords
- `ss`: (`::Integer`, `=4`) subsampling parameter in all axes
- `us`: (`::Integer`, `=1`) upsampling parameter for all axes, if used ss is set to ss=1
- `start_end`: (`::Vector{Integer}`, `=[160,200]`) z index range of presampled phantom, 180 is center

# Returns
- `obj`: (`::Phantom`) 3D Phantom struct
Expand All @@ -303,15 +307,16 @@ julia> obj = brain_phantom3D(; ss=5)
julia> plot_phantom_map(obj, :ρ)
```
"""
function brain_phantom3D(;ss=4,start_end=[160, 200])
function brain_phantom3D(;ss=4,us=1,start_end=[160, 200])

# Get data from .mat file
path = @__DIR__
data = MAT.matread(path*"/phantom/brain3D.mat")
class = data["data"][1:ss:end,1:ss:end,start_end[1]:ss:start_end[2]]
if us > 1; ss=1; end
class = repeat( data["data"][1:ss:end,1:ss:end,start_end[1]:ss:start_end[2]], inner=[us, us, us])

# Define spin position vectors
Δx = .5e-3*ss
Δx = .5e-3*ss/us
M, N, Z = size(class)
FOVx = (M-1)*Δx #[m]
FOVy = (N-1)*Δx #[m]
Expand Down Expand Up @@ -392,12 +397,13 @@ function brain_phantom3D(;ss=4,start_end=[160, 200])
end

"""
obj = pelvis_phantom2D(; ss=4)
obj = pelvis_phantom2D(; ss=4, us=1)

Creates a two-dimensional pelvis Phantom struct.

# Keywords
- `ss`: (`::Integer`, `=4`) subsampling parameter
- `us`: (`::Integer`, `=1`) upsampling parameter for all axes, if used ss is set to ss=1

# Returns
- `obj`: (`::Phantom`) Phantom struct
Expand All @@ -409,15 +415,16 @@ julia> obj = pelvis_phantom2D(; ss=1)
julia> pelvis_phantom2D(obj, :ρ)
```
"""
function pelvis_phantom2D(; ss=4)
function pelvis_phantom2D(; ss=4, us=1)

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

# Define spin position vectors
Δx = .5e-3*ss
Δx = .5e-3*ss/us
M, N = size(class)
FOVx = (M-1)*Δx # [m]
FOVy = (N-1)*Δx # [m]
Expand Down
Loading