Skip to content

Commit

Permalink
feat: add rotating spiral
Browse files Browse the repository at this point in the history
  • Loading branch information
paquiteau committed Feb 6, 2024
1 parent 4ff96e0 commit 6eedcd7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/snkf/handlers/acquisition/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ def __init__(
in_out: bool = True,
pdfz: Literal["gaussian", "uniform"] = "gaussian",
constant: bool = False,
rotate_spirals: str | float = 0.0,
smaps: bool = True,
backend: str = "finufft",
shot_time_ms: int = 50,
Expand All @@ -510,6 +511,7 @@ def __init__(
"n_samples": n_samples,
"nb_revolutions": nb_revolutions,
"in_out": in_out,
"rotate_spirals": rotate_spirals,
}

def _handle(self, sim: SimData) -> SimData:
Expand Down
11 changes: 10 additions & 1 deletion src/snkf/handlers/acquisition/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
)

from mrinufft.trajectories.tools import stack, rotate
from mrinufft.trajectories.utils import R2D
from mrinufft.trajectories.utils import (
check_hardware_constraints,
compute_gradients_and_slew_rates,
Expand Down Expand Up @@ -125,6 +126,7 @@ def stack_spiral_factory(
directionz: Literal["center-out", "random"] = "center-out",
pdfz: Literal["gaussian", "uniform"] = "gaussian",
rng: RngType = None,
rotate_spirals: str | float = 0.0,
) -> np.ndarray:
"""Generate a trajectory of stack of spiral."""
sizeZ = shape[-1]
Expand All @@ -133,6 +135,12 @@ def stack_spiral_factory(
sizeZ, acsz, accelz, pdf=pdfz, rng=rng, direction=directionz
)

if isinstance(rotate_spirals, str):
rotate_spirals = ROTATE_ANGLES[rotate_spirals]
elif not isinstance(rotate_spirals, float):
raise ValueError(
"rotate_spirals should be a float or a valid key in ROTATE_ANGLES."
)
spiral2D = initialize_2D_spiral(
Nc=1,
Ns=n_samples,
Expand All @@ -146,7 +154,8 @@ def stack_spiral_factory(
kspace_locs3d = np.zeros((nz, nsamples, 3), dtype=np.float32)
# TODO use numpy api for this ?
for i in range(nz):
kspace_locs3d[i, :, :2] = spiral2D
rotated_spiral = rotate_trajectory(spiral2D)
kspace_locs3d[i, :, :2] = rotated_spiral
kspace_locs3d[i, :, 2] = z_kspace[i]

return kspace_locs3d.astype(np.float32)
Expand Down

0 comments on commit 6eedcd7

Please sign in to comment.