Skip to content

Commit 3008a33

Browse files
committed
fix: when n_coils=1 no smaps computation is required.
1 parent 3a9b0d1 commit 3008a33

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

src/snake/core/handlers/fov.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,6 @@ def get_static(self, phantom: Phantom, sim_conf: SimConfig) -> Phantom:
131131
),
132132
dtype=phantom.masks.dtype,
133133
)
134-
new_smaps = np.zeros(
135-
(
136-
phantom.smaps.shape[0],
137-
*tuple(round(size_vox[i] / zoom_factor[i]) for i in range(3)),
138-
),
139-
dtype=phantom.smaps.dtype,
140-
)
141134

142135
run_parallel(
143136
_apply_transform,
@@ -149,17 +142,27 @@ def get_static(self, phantom: Phantom, sim_conf: SimConfig) -> Phantom:
149142
angles=self.angles,
150143
zoom_factor=zoom_factor,
151144
)
152-
153-
run_parallel(
154-
_apply_transform,
155-
phantom.smaps,
156-
new_smaps,
157-
parallel_axis=0,
158-
center=center_vox,
159-
size=size_vox,
160-
angles=self.angles,
161-
zoom_factor=zoom_factor,
162-
)
145+
if phantom.smaps is not None:
146+
return Phantom.from_masks(new_masks, sim_conf)
147+
new_smaps = np.zeros(
148+
(
149+
phantom.smaps.shape[0],
150+
*tuple(round(size_vox[i] / zoom_factor[i]) for i in range(3)),
151+
),
152+
dtype=phantom.smaps.dtype,
153+
)
154+
run_parallel(
155+
_apply_transform,
156+
phantom.smaps,
157+
new_smaps,
158+
parallel_axis=0,
159+
center=center_vox,
160+
size=size_vox,
161+
angles=self.angles,
162+
zoom_factor=zoom_factor,
163+
)
164+
else:
165+
new_smaps = None
163166

164167
# Create a new phantom with updated masks
165168
new_phantom = phantom.copy()

src/snake/core/phantom/static.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,19 @@ def from_brainweb(
151151
)
152152
tissues_mask = tissue_resized
153153

154+
smaps=None
155+
if sim_conf.hardware.n_coils > 1:
156+
smaps=get_smaps(
157+
tissues_mask.shape[1:],
158+
n_coils=sim_conf.hardware.n_coils,
159+
)
160+
154161
return cls(
155162
"brainweb",
156163
tissues_mask,
157164
labels=np.array([t[0] for t in tissues_list]),
158165
props=np.array([t[1:] for t in tissues_list]),
159-
smaps=get_smaps(
160-
tissues_mask.shape[1:],
161-
n_coils=sim_conf.hardware.n_coils,
166+
smaps=smaps,
162167
),
163168
)
164169

0 commit comments

Comments
 (0)