Skip to content

Commit be53dd2

Browse files
committed
feat: iter_frames can also yield with shot dim
1 parent 50ad951 commit be53dd2

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/snake/mrd_utils/loader.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,31 @@ def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any):
8585
self._file = None
8686

8787
def iter_frames(
88-
self, start: int | None = None, stop: int | None = None, step: int | None = None
88+
self,
89+
start: int | None = None,
90+
stop: int | None = None,
91+
step: int | None = None,
92+
shot_dim: bool = False,
8993
) -> Generator[tuple[int, NDArray[np.float32], NDArray[np.complex64]], None, None]:
90-
"""Iterate over kspace frames of the dataset."""
94+
"""Iterate over kspace frames of the dataset.
95+
96+
Parameters
97+
---------
98+
start : int, optional
99+
Start index of the iteration.
100+
stop : int, optional
101+
Stop index of the iteration.
102+
step: int, optional
103+
Step of the iteration.
104+
shot_dim: bool, optional
105+
Return the data reshaped with the shot dimension first.
106+
107+
Yields
108+
-----
109+
tuple[int, np.ndarray, np.ndarray]
110+
The index of the frame, the trajectory and the kspace data.
111+
112+
"""
91113
if start is None:
92114
start = 0
93115
if stop is None:
@@ -96,7 +118,7 @@ def iter_frames(
96118
step = 1
97119
with self:
98120
for i in np.arange(start, stop, step):
99-
yield i, *self.get_kspace_frame(i)
121+
yield i, *self.get_kspace_frame(i, shot_dim=shot_dim)
100122

101123
def get_kspace_frame(
102124
self, idx: int

0 commit comments

Comments
 (0)