Skip to content

Commit

Permalink
fix doc
Browse files Browse the repository at this point in the history
  • Loading branch information
paquiteau committed Apr 25, 2024
1 parent ea67670 commit 7827b50
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 42 deletions.
8 changes: 0 additions & 8 deletions docs/advanced_guide/writing_config_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,3 @@

```

<!-- #raw -->
```{include} ../../../src/snkf/conf/simulation/sl_basic.yaml
```
<!-- #endraw -->

<!-- #raw -->

<!-- #endraw -->
11 changes: 5 additions & 6 deletions docs/examples/example_big.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# %% [markdown]
"""
# Custom Phantom and ROI
# # Custom Phantom and ROI

In this example we are going to show the different way to generate phantom data, using
the BIG phantom.
This phantom is more realistic than the Shepp-Logan Phantom, but is a 2D phantom.
"""
# In this example we are going to show the different way to generate phantom data, using
# the BIG phantom.
# This phantom is more realistic than the Shepp-Logan Phantom, but is a 2D phantom.

# %%
import matplotlib.pyplot as plt
from snkf.handlers.phantom._big import generate_phantom, raster_phantom

Expand Down
9 changes: 4 additions & 5 deletions docs/examples/example_shepp_logan.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# %% [markdown]
"""
# Generate a 3d+t Simple Phantom
In this example we simulate a 3D phantom and add a simple activation pattern.
"""
# # Generate a 3d+t Simple Phantom
#
# In this example we simulate a 3D phantom and add a simple activation pattern.

# %%
import matplotlib.pyplot as plt

from snkf.simulation import SimData
Expand Down
22 changes: 13 additions & 9 deletions docs/examples/example_simulation_with_factory.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# %% [markdown]
"""
# Using a simulation configuration file
# # Using a simulation configuration file

This example present how to use a simulation config file.
"""
# This example present how to use a simulation config file.
# %%

import io # to simulate a file access.

from snkf import load_from_yaml

Expand All @@ -18,6 +16,7 @@
#
# For instance to create a 2D+T

# %%
sim_config = """
### Simulation for a Shepp Logan phantom with activation.
Expand Down Expand Up @@ -47,17 +46,22 @@

# %% [markdown]
# ```{note}
# In the handlers section, the name of each handler matter!
# it is the key for finding the related handler object.
# They will be processed in order.
# In the handlers section, the name of each handler matter!
# it is the key for finding the related handler object.
# They will be processed in order.
# ```
#
# ## Launching the simulation
#
# Thanks to the detailled configuration it is as simple as:

# equivalent to
# %%

# The two following lines are equivalent to
# with open("your_config.yaml") as config_file:

import io # to simulate a file access.

with io.StringIO(sim_config) as config_file:

simulator, sim = load_from_yaml(config_file)
Expand Down
15 changes: 7 additions & 8 deletions docs/examples/example_vds_simrec.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# %% [markdown]
"""
# Simulation and Reconstruction
This example shows how to simulate and reconstruct a simple 2D vds simulation.
"""
# # Simulation and Reconstruction
# This example shows how to simulate and reconstruct a simple 2D vds simulation.

# %%

Expand Down Expand Up @@ -40,7 +37,7 @@
#
# We initialize the simulator from the availables handlers

# %%
# %% execution={"timeout": "1000"}
print(list_handlers())

simulator = (
Expand Down Expand Up @@ -80,7 +77,7 @@
#
# Simple adjoint fourier transform.

# %%
# %% execution={"timeout": "1000"}

adj_data = ZeroFilledReconstructor().reconstruct(sim)

Expand All @@ -89,7 +86,8 @@
# %% [markdown]
# ### Sequential Reconstruction

# %%
# %% execution={"timeout": "1000"}

seq_data = SequentialReconstructor(
max_iter_per_frame=20, threshold="sure", compute_backend="numpy"
).reconstruct(sim)
Expand All @@ -98,6 +96,7 @@
# %% [markdown]
# ### LowRank + Sparse Reconstruction

# %% execution={"timeout": "1000"}
lr_s = LowRankPlusSparseReconstructor(
lambda_l=0.1, lambda_s="sure", algorithm="otazo_raw", max_iter=20
).reconstruct(sim)
Expand Down
4 changes: 4 additions & 0 deletions src/snkf/handlers/acquisition/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,14 @@ class NonCartesianAcquisitionHandler(BaseAcquisitionHandler):
The MRI acquisition is modelled as follows:
.. math::
s(t) = \int_{\Omega} \rho(x,t) \exp(-2i\pi k(t) \cdot x) dx
where :math:`\rho` is the object, :math:`k(t)` is the k-space trajectory.
In practice:
.. math::
s(t) = \sum_{x \in \Omega} \rho(x,t) \exp(-2i\pi k(t) \cdot x) \Delta x
"""

Expand Down
3 changes: 3 additions & 0 deletions src/snkf/handlers/motion/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""Motion Module."""

from .image import RandomMotionImageHandler
from .kspace import RandomMotionKspaceHandler

__all__ = ["RandomMotionImageHandler", "RandomMotionKspaceHandler"]
2 changes: 0 additions & 2 deletions src/snkf/handlers/motion/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import numpy as np
from numpy.typing import NDArray

from snkf.base import validate_rng

from ...simulation import SimData
from ..base import AbstractHandler, requires_field
from .utils import apply_shift, apply_rotation_at_center, motion_generator
Expand Down
8 changes: 4 additions & 4 deletions src/snkf/handlers/motion/kspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"""

import numpy as np
from np.typing import NDArray
from numpy.typing import NDArray

from ...simulation import SimData
from ..base import AbstractHandler, requires_field
from .utils import motion_generator, rotation3D
from .utils import motion_generator, rotation3d


@requires_field(["kspace_data", "kspace_mask"])
Expand All @@ -36,7 +36,7 @@ class RandomMotionKspaceHandler(AbstractHandler):
time resolution for the simulation.
"""

__handler_name__ = "motion-image"
__handler_name__ = "motion-kspace"

ts_std_mm: tuple[float, float, float]
rs_std_mm: tuple[float, float, float]
Expand Down Expand Up @@ -104,7 +104,7 @@ def rotate(kspace_loc_to_corrupt: NDArray, rotation: NDArray) -> NDArray:
"""
new_loc = np.zeros_like(kspace_loc_to_corrupt)
for t in range(kspace_loc_to_corrupt.shape[0]):
R = rotation3D(rotation[:, t])
R = rotation3d(rotation[:, t])
new_loc[t, :, :] = np.matmul(kspace_loc_to_corrupt[t, :, :], R)

return new_loc

0 comments on commit 7827b50

Please sign in to comment.