Skip to content

Major overhaul to improve types #38

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

Merged
merged 10 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/lit/examples/02-ellipse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This page was generated from a single Julia file:

# Packages needed here.

using ImagePhantoms: Ellipse, phantom, radon, spectrum
using ImagePhantoms: ellipse, phantom, radon, spectrum
using ImageGeoms: ImageGeom, axesf
using MIRTjim: jim, prompt
using FFTW: fft, fftshift
Expand Down Expand Up @@ -54,7 +54,7 @@ using physical units.
=#

radii = (20mm, 80mm)
ob = Ellipse((40mm, 30mm), radii, π/6, 1.0f0)
ob = ellipse((40mm, 30mm), radii, π/6, 1.0f0)


# ### Phantom image using `phantom`
Expand Down Expand Up @@ -176,5 +176,5 @@ The good agreement between the analytical spectra (solid lines)
and the DFT samples (disks)
validates that `phantom`, `radon`, and `spectrum`
are all self consistent
for this `Ellipse` object.
for this `Ellipse` shape.
=#
6 changes: 3 additions & 3 deletions docs/lit/examples/03-rect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This page was generated from a single Julia file:

# Packages needed here.

using ImagePhantoms: Rect, phantom, radon, spectrum
using ImagePhantoms: rect, phantom, radon, spectrum
using ImageGeoms: ImageGeom, axesf
using MIRTjim: jim, prompt
using FFTW: fft, fftshift
Expand Down Expand Up @@ -54,7 +54,7 @@ using physical units.
=#

width = (20mm, 80mm)
ob = Rect((40mm, 30mm), width, π/6, 1.0f0)
ob = rect((40mm, 30mm), width, π/6, 1.0f0)


# ### Phantom image using `phantom`
Expand Down Expand Up @@ -174,5 +174,5 @@ The good agreement between the analytical spectra (solid lines)
and the DFT samples (disks)
validates that `phantom`, `radon`, and `spectrum`
are all self consistent
for this `Rect` object.
for this `Rect` shape.
=#
6 changes: 3 additions & 3 deletions docs/lit/examples/04-gauss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This page was generated from a single Julia file:

# Packages needed here.

using ImagePhantoms: Gauss2, phantom, radon, spectrum
using ImagePhantoms: gauss2, phantom, radon, spectrum
import ImagePhantoms as IP
using ImageGeoms: ImageGeom, axesf
using MIRTjim: jim, prompt
Expand Down Expand Up @@ -56,7 +56,7 @@ using physical units.
=#

width = (50mm, 20mm) # full-width at half-maximum (FHWM)
ob = Gauss2((20mm, 30mm), width, π/6, 1.0f0)
ob = gauss2((20mm, 30mm), width, π/6, 1.0f0)


# ### Phantom image using `phantom`
Expand Down Expand Up @@ -176,5 +176,5 @@ The good agreement between the analytical spectra (solid lines)
and the DFT samples (disks)
validates that `phantom`, `radon`, and `spectrum`
are all self consistent
for this `Gauss2` object.
for this `Gauss2` shape.
=#
8 changes: 4 additions & 4 deletions docs/lit/examples/05-triangle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This page was generated from a single Julia file:

# Packages needed here.

using ImagePhantoms: Triangle, phantom, radon, spectrum
using ImagePhantoms: triangle, phantom, radon, spectrum
using ImageGeoms: ImageGeom, axesf
using MIRTjim: jim, prompt
using FFTW: fft, fftshift
Expand All @@ -48,7 +48,7 @@ for constructing 2D digital image phantoms.
The basic shape here is an equilateral triangle
whose base is [-1/2,1/2] along the x axis,
pointing upwards along the y axis.
When defining such a `Triangle` object one can specify
When defining such a `Triangle` shape one can specify
its center, widths, angle and value.
All of the methods in `ImagePhantoms` support physical units,
so we use such units throughout this example.
Expand All @@ -59,7 +59,7 @@ using physical units.
=#

width = (20mm, 80mm)
ob = Triangle((40mm, 30mm), width, π/6, 1.0f0)
ob = triangle((40mm, 30mm), width, π/6, 1.0f0)


# ### Phantom image using `phantom`
Expand Down Expand Up @@ -180,7 +180,7 @@ The good agreement between the analytical spectra (solid lines)
and the DFT samples (disks)
validates that `phantom`, `radon`, and `spectrum`
are all self consistent
for this `Triangle` object.
for this `Triangle` shape.
=#


Expand Down
6 changes: 4 additions & 2 deletions docs/lit/examples/07-shepp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ This page was generated from a single Julia file:

# Packages needed here.

using ImagePhantoms
using ImagePhantoms: shepp_logan, SouthPark
using ImagePhantoms: SheppLoganToft, SheppLoganEmis, SheppLoganBrainWeb
using ImagePhantoms: ellipse_parameters, ellipse, phantom
using ImageGeoms: ImageGeom, axesf
using MIRTjim: jim, prompt
using Unitful: g, cm
Expand Down Expand Up @@ -159,7 +161,7 @@ to have the middle ellipses be non-overlapping:

ob = ellipse_parameters(SheppLoganBrainWeb(), disjoint=true)
ob[:,end] = 1:10
ob = Ellipse(ob)
ob = ellipse(ob)
x = LinRange(-0.4, 0.4, 206)
y = LinRange(-0.5, 0.5, 256)
oversample = 3
Expand Down
4 changes: 2 additions & 2 deletions docs/lit/examples/09-disk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This page was generated from a single Julia file:

# Packages needed here.

using ImagePhantoms: Ellipse, phantom, disk_phantom_params
using ImagePhantoms: ellipse, phantom, disk_phantom_params
using ImageGeoms: ImageGeom
using MIRTjim: jim, prompt
using Plots # @animate, gif
Expand Down Expand Up @@ -57,7 +57,7 @@ function disk_phantom(title::String)
x = (-M÷2:M÷2-1) * dx
y = (-N÷2:N÷2-1) * dy
params = disk_phantom_params( ; rhead = () -> rand(100:105))
objects = Ellipse(params) # vector of Ellipse objects
objects = ellipse(params) # vector of Object{Ellipse}
oversample = 3
img = phantom(x, y, objects, oversample)
jim(x, y, img; title, clim=(0,1300))
Expand Down
16 changes: 9 additions & 7 deletions docs/lit/examples/10-mri-sense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This page was generated from a single Julia file:

# Packages needed here.

using ImagePhantoms: ellipse_parameters, SheppLoganBrainWeb, Ellipse
using ImagePhantoms: ellipse_parameters, SheppLoganBrainWeb, ellipse
using ImagePhantoms: phantom, mri_smap_fit, mri_spectra
using FFTW: fft, fftshift
using ImageGeoms: embed
Expand All @@ -42,9 +42,9 @@ using Unitful: mm
isinteractive() ? jim(:prompt, true) : prompt(:draw);


# ### Overview

#=
### Overview

Modern MRI scanners use multiple receive coils
each of which has its own "sensitivity map" (or "coil profile").
Realistic MRI simulations should account for the effects of those
Expand Down Expand Up @@ -82,14 +82,16 @@ dx, dy = fovs ./ (nx,ny)
x = (-(nx÷2):(nx÷2-1)) * dx
y = (-(ny÷2):(ny÷2-1)) * dy

# Define Shepp-Logan phantom object,
# with random complex phases
# to make it a bit more realistic.
#=
Define Shepp-Logan phantom object,
with random complex phases
to make it a bit more realistic.
=#

oa = ellipse_parameters(SheppLoganBrainWeb() ; disjoint=true, fovs)
seed!(0)
oa[:,end] = [1; randn(ComplexF32, 9)] # random phases
oa = Ellipse(oa)
oa = ellipse(oa)
oversample = 3
image0 = phantom(x, y, oa, oversample)
cfun = z -> cat(dims = ndims(z)+1, real(z), imag(z))
Expand Down
30 changes: 9 additions & 21 deletions docs/lit/examples/30-3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ This page was generated from a single Julia file:

# Packages needed here.

using ImagePhantoms
using ImageGeoms: ImageGeom, axesf
using MIRTjim: jim, prompt
using UnitfulRecipes
using Unitful: mm
using InteractiveUtils: versioninfo
#src using ImagePhantoms
#src using ImageGeoms: ImageGeom, axesf
#src using MIRTjim: jim, prompt
#src using UnitfulRecipes
#src using Unitful: mm

# The following line is helpful when running this file as a script;
# this way it will prompt user to hit a key after each figure is displayed.

isinteractive() ? jim(:prompt, true) : prompt(:draw);
#src # The following line is helpful when running this file as a script;
#src # this way it will prompt user to hit a key after each figure is displayed.

#src isinteractive() ? jim(:prompt, true) : prompt(:draw);


#=
Expand Down Expand Up @@ -115,15 +115,3 @@ For example projection views,
see the Ellipsoid examples.

=#


# ## Reproducibility

# This page was generated with the following version of Julia:

io = IOBuffer(); versioninfo(io); split(String(take!(io)), '\n')


# And with the following package versions

import Pkg; Pkg.status()
12 changes: 7 additions & 5 deletions docs/lit/examples/32-ellipsoid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ This page was generated from a single Julia file:

# Packages needed here.

using ImagePhantoms: Ellipsoid, phantom, radon, spectrum
using ImagePhantoms: ellipsoid, phantom, radon, spectrum
using ImagePhantoms: Object, Ellipsoid
using ImageGeoms: ImageGeom, axesf
using MIRTjim: jim, prompt, mid3
using FFTW: fft, fftshift
Expand Down Expand Up @@ -53,17 +54,18 @@ All of the methods in `ImagePhantoms` support physical units,
so we use such units throughout this example.
(Using units is recommended but not required.)

Here are 3 ways to define an ellipsoid object,
Here are 4 ways to define an `Object{Ellipsoid}`,
using physical units.
=#

center = (20mm, 10mm, 5mm)
radii = (25mm, 35mm, 15mm)
ϕ0s = :(π/6) # symbol version for nice plot titles
angles = (eval(ϕ0s), 0)
Ellipsoid([20mm, 10mm, 5mm, 25mm, 35mm, 15mm, π/6, 0, 1.0f0]) # Vector{Number}
Ellipsoid( 20mm, 10mm, 5mm, 25mm, 35mm, 15mm, π/6, 0, 1.0f0 ) # 9 arguments
ob = Ellipsoid(center, radii, angles, 1.0f0) # tuples (recommended use)
Object(Ellipsoid(), center, radii, angles, 1.0f0) # top-level constructor
ellipsoid([20mm, 10mm, 5mm, 25mm, 35mm, 15mm, π/6, 0, 1.0f0]) # Vector{Number}
ellipsoid( 20mm, 10mm, 5mm, 25mm, 35mm, 15mm, π/6, 0, 1.0f0 ) # 9 arguments
ob = ellipsoid(center, radii, angles, 1.0f0) # tuples (recommended use)


#=
Expand Down
10 changes: 5 additions & 5 deletions docs/lit/examples/33-cuboid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This page was generated from a single Julia file:

# Packages needed here.

using ImagePhantoms: Cuboid, phantom, radon, spectrum
using ImagePhantoms: cuboid, phantom, radon, spectrum
import ImagePhantoms as IP
using ImageGeoms: ImageGeom, axesf
using MIRTjim: jim, prompt, mid3
Expand Down Expand Up @@ -54,7 +54,7 @@ All of the methods in `ImagePhantoms` support physical units,
so we use such units throughout this example.
(Using units is recommended but not required.)

Here are 3 ways to define a 3D cuboid object,
Here are 3 ways to define a 3D `Object{Cuboid}`,
using physical units.
=#

Expand All @@ -63,9 +63,9 @@ width = (35mm, 25mm, 15mm)
ϕ0s = :(π/6) # symbol version for nice plot titles
ϕ0 = eval(ϕ0s)
angles = (ϕ0, 0)
Cuboid([10mm, 8mm, 6mm, 35mm, 25mm, 15mm, π/6, 0, 1.0f0]) # Vector{Number}
Cuboid( 10mm, 8mm, 6mm, 35mm, 25mm, 15mm, π/6, 0, 1.0f0 ) # 9 arguments
ob = Cuboid(center, width, angles, 1.0f0) # tuples (recommended use)
cuboid([10mm, 8mm, 6mm, 35mm, 25mm, 15mm, π/6, 0, 1.0f0]) # Vector{Number}
cuboid( 10mm, 8mm, 6mm, 35mm, 25mm, 15mm, π/6, 0, 1.0f0 ) # 9 arguments
ob = cuboid(center, width, angles, 1.0f0) # tuples (recommended use)


#=
Expand Down
10 changes: 5 additions & 5 deletions docs/lit/examples/34-gauss3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This page was generated from a single Julia file:

# Packages needed here.

using ImagePhantoms: Gauss3, phantom, radon, spectrum
using ImagePhantoms: gauss3, phantom, radon, spectrum
import ImagePhantoms as IP
using ImageGeoms: ImageGeom, axesf
using MIRTjim: jim, prompt, mid3
Expand Down Expand Up @@ -54,17 +54,17 @@ All of the methods in `ImagePhantoms` support physical units,
so we use such units throughout this example.
(Using units is recommended but not required.)

Here are 3 ways to define a 3D gaussian object,
Here are 3 ways to define a 3D `Object{Gauss3}`,
using physical units.
=#

center = (20mm, 10mm, 5mm)
width = (25mm, 35mm, 15mm)
ϕ0s = :(π/6) # symbol version for nice plot titles
angles = (eval(ϕ0s), 0)
Gauss3([40mm, 20mm, 2mm, 25mm, 35mm, 12mm, π/6, 0, 1.0f0]) # Vector{Number}
Gauss3(20mm, 20mm, 2mm, 25mm, 35mm, 12mm, π/6, 0, 1.0f0) # 9 arguments
ob = Gauss3(center, width, angles, 1.0f0) # tuples (recommended use)
gauss3([40mm, 20mm, 2mm, 25mm, 35mm, 12mm, π/6, 0, 1.0f0]) # Vector{Number}
gauss3(20mm, 20mm, 2mm, 25mm, 35mm, 12mm, π/6, 0, 1.0f0) # 9 arguments
ob = gauss3(center, width, angles, 1.0f0) # tuples (recommended use)


#=
Expand Down
Loading