Skip to content

Commit d139f73

Browse files
chaithyagrchaithyagrpaquiteau
authored
Fix gridder (#279)
* Added * Fix * Remove bymistake add * Fix * Fixed lint * Lint * Added refbackend * Fix NDFT * feat: use finufft as ref backend. * feat(tests): move ndft vs nufft tests to own file. * Added a bunch of extra codes * PEP fixes * Update siemens.py * Added fixes * add [docs] * Fixes and updates on the locatuions * Fix display3D * Fix style [doc] --------- Co-authored-by: chaithyagr <[email protected]> Co-authored-by: Pierre-antoine Comby <[email protected]>
1 parent 19c673d commit d139f73

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

src/mrinufft/trajectories/display3D.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def get_gridded_trajectory(
101101
np.tile(np.linspace(1, 10, trajectory.shape[1]), (trajectory.shape[0],)),
102102
None,
103103
True,
104-
)
104+
) / (gridded_ones + np.finfo(np.float32).eps)
105105
elif grid_type == "inversion":
106106
data = grid_op.raw_op.adj_op(
107107
np.repeat(
@@ -110,7 +110,7 @@ def get_gridded_trajectory(
110110
)[: samples.shape[0]],
111111
None,
112112
True,
113-
)
113+
) / (gridded_ones + np.finfo(np.float32).eps)
114114
elif grid_type == "holes":
115115
data = np.abs(gridded_ones).squeeze() < threshold
116116
if elliptical_samp:
@@ -143,5 +143,5 @@ def get_gridded_trajectory(
143143
data = np.hstack([slews, np.zeros((slews.shape[0], 2, slews.shape[2]))])
144144
data = grid_op.raw_op.adj_op(
145145
np.linalg.norm(data, axis=-1).flatten(), None, True
146-
)
146+
) / (gridded_ones + np.finfo(np.float32).eps)
147147
return np.squeeze(np.abs(data))

src/mrinufft/trajectories/inits/travelling_salesman.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,22 @@ def _sort_by_coordinate(array: NDArray, coord: Coordinate) -> NDArray:
3030
f"Invalid `coord`='{coord}' for arrays with less than 3 dimensions."
3131
)
3232

33-
match coord.lower():
34-
case "x":
35-
coord = array[..., 0]
36-
case "y":
37-
coord = array[..., 1]
38-
case "z":
39-
coord = array[..., 2]
40-
case "r":
41-
coord = np.linalg.norm(array, axis=-1)
42-
case "phi":
43-
coord = np.sign(array[..., 1]) * np.arccos(
44-
array[..., 0] / nl.norm(array[..., :2], axis=-1)
45-
)
46-
case "theta":
47-
coord = np.arccos(array[..., 2] / nl.norm(array, axis=-1))
48-
case _:
49-
raise ValueError(f"Unknown coordinate `{coord}`")
33+
if coord == "x":
34+
coord = array[..., 0]
35+
elif coord == "y":
36+
coord = array[..., 1]
37+
elif coord == "z":
38+
coord = array[..., 2]
39+
elif coord == "r":
40+
coord = np.linalg.norm(array, axis=-1)
41+
elif coord == "phi":
42+
coord = np.sign(array[..., 1]) * np.arccos(
43+
array[..., 0] / nl.norm(array[..., :2], axis=-1)
44+
)
45+
elif coord == "theta":
46+
coord = np.arccos(array[..., 2] / nl.norm(array, axis=-1))
47+
else:
48+
raise ValueError(f"Unknown coordinate `{coord}`")
5049
order = np.argsort(coord)
5150
return array[order]
5251

0 commit comments

Comments
 (0)