Skip to content

Commit

Permalink
fix: when n_coils=1 no smaps computation is required.
Browse files Browse the repository at this point in the history
  • Loading branch information
paquiteau committed Feb 11, 2025
1 parent 3a9b0d1 commit 3008a33
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
39 changes: 21 additions & 18 deletions src/snake/core/handlers/fov.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,6 @@ def get_static(self, phantom: Phantom, sim_conf: SimConfig) -> Phantom:
),
dtype=phantom.masks.dtype,
)
new_smaps = np.zeros(
(
phantom.smaps.shape[0],
*tuple(round(size_vox[i] / zoom_factor[i]) for i in range(3)),
),
dtype=phantom.smaps.dtype,
)

run_parallel(
_apply_transform,
Expand All @@ -149,17 +142,27 @@ def get_static(self, phantom: Phantom, sim_conf: SimConfig) -> Phantom:
angles=self.angles,
zoom_factor=zoom_factor,
)

run_parallel(
_apply_transform,
phantom.smaps,
new_smaps,
parallel_axis=0,
center=center_vox,
size=size_vox,
angles=self.angles,
zoom_factor=zoom_factor,
)
if phantom.smaps is not None:
return Phantom.from_masks(new_masks, sim_conf)
new_smaps = np.zeros(
(
phantom.smaps.shape[0],
*tuple(round(size_vox[i] / zoom_factor[i]) for i in range(3)),
),
dtype=phantom.smaps.dtype,
)
run_parallel(
_apply_transform,
phantom.smaps,
new_smaps,
parallel_axis=0,
center=center_vox,
size=size_vox,
angles=self.angles,
zoom_factor=zoom_factor,
)
else:
new_smaps = None

# Create a new phantom with updated masks
new_phantom = phantom.copy()
Expand Down
11 changes: 8 additions & 3 deletions src/snake/core/phantom/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,19 @@ def from_brainweb(
)
tissues_mask = tissue_resized

smaps=None
if sim_conf.hardware.n_coils > 1:
smaps=get_smaps(
tissues_mask.shape[1:],
n_coils=sim_conf.hardware.n_coils,
)

return cls(
"brainweb",
tissues_mask,
labels=np.array([t[0] for t in tissues_list]),
props=np.array([t[1:] for t in tissues_list]),
smaps=get_smaps(
tissues_mask.shape[1:],
n_coils=sim_conf.hardware.n_coils,
smaps=smaps,
),
)

Expand Down

0 comments on commit 3008a33

Please sign in to comment.