Skip to content

Commit 50ad951

Browse files
committed
fix: more smaps updates required.
1 parent 545ca47 commit 50ad951

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/snake/core/handlers/activations/activations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def get_static(self, phantom: Phantom, sim_config: SimConfig) -> Phantom:
113113
props=np.concatenate(
114114
(phantom.props, phantom.props[tissue_index, :]),
115115
axis=0,
116+
smaps=phantom.smaps,
116117
),
117118
)
118119
new_phantom = phantom.add_tissue(

src/snake/core/phantom/static.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,21 @@ def labels_idx(self) -> dict[str, int]:
7373
"""Get the index of the labels."""
7474
return {label: i for i, label in enumerate(self.labels)}
7575

76-
def get_smaps(
76+
def make_smaps(
7777
self, n_coils: int = None, sim_conf: SimConfig = None, antenna: str = "birdcage"
7878
) -> None:
7979
"""Get coil sensitivity maps for the phantom."""
8080
if n_coils is None and sim_conf is not None:
8181
n_coils = sim_conf.hardware.n_coils
82-
83-
if n_coils > 1 and self.smaps is None:
82+
elif sim_conf is None and n_coils is None:
83+
raise ValueError("Either n_coils or sim_conf must be provided.")
84+
if n_coils == 1:
85+
log.warning("Only one coil, no need for smaps.")
86+
elif n_coils > 1 and self.smaps is None:
8487
self.smaps = get_smaps(self.anat_shape, n_coils=n_coils, antenna=antenna)
88+
log.debug(f"Created smaps for {n_coils} coils.")
89+
elif self.smaps is not None:
90+
log.warning("Smaps already exists.")
8591

8692
@classmethod
8793
def from_brainweb(

src/snake/mrd_utils/loader.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ def iter_frames(
9898
for i in np.arange(start, stop, step):
9999
yield i, *self.get_kspace_frame(i)
100100

101-
def get_kspace_frame(self, idx: int) -> tuple[NDArray[np.float32], NDArray[np.complex64]]:
101+
def get_kspace_frame(
102+
self, idx: int
103+
) -> tuple[NDArray[np.float32], NDArray[np.complex64]]:
102104
"""Get k-space frame trajectory/mask and data."""
103105
raise NotImplementedError()
104106

@@ -233,16 +235,15 @@ def get_phantom(self, imnum: int = 0) -> Phantom:
233235
name = image.meta.pop("name")
234236
labels = np.array(image.meta["labels"].split(","))
235237
props = unserialize_array(image.meta["props"])
236-
238+
smaps = self.get_smaps()
237239
return Phantom(
238240
masks=image.data,
239241
labels=labels,
240242
props=props,
241243
name=name,
244+
smaps=smaps,
242245
)
243246

244-
return Phantom.from_mrd_dataset(self)
245-
246247
@cached_property
247248
def _all_waveform_infos(self) -> dict[int, dict]:
248249
return parse_waveform_information(self.header)

0 commit comments

Comments
 (0)