Skip to content

Commit

Permalink
fix a few isigs in code that were logging warnings;
Browse files Browse the repository at this point in the history
loosen RecStack navigation limit since it was causing error
in hs.plot.plot_images
update example notebook
  • Loading branch information
jat255 committed Nov 4, 2024
1 parent 30f4743 commit f095397
Show file tree
Hide file tree
Showing 6 changed files with 1,807 additions and 1,882 deletions.
3,665 changes: 1,795 additions & 1,870 deletions docs/examples/etspy_demo.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion etspy/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ def tilt_maximage(
shifted = ali.isig[0:nshifts, :].deepcopy()
for i in range(nshifts):
shifted.data[:, :, i] = np.roll(
ali.isig[idx, :].data.squeeze(),
ali.isig[idx:idx+1, :].data.squeeze(),
int(shifts[i]),
)
shifted_rec = shifted.reconstruct("SIRT", 100, constrain=True)
Expand Down
10 changes: 5 additions & 5 deletions etspy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ def recon_error(
else:
cuda = False
logger.info("CUDA not detected with Astra")
sinogram = self.isig[nslice, :].data.squeeze()
sinogram = self.isig[nslice:nslice+1, :].data.squeeze()
rec_stack, error = recon.astra_error(
sinogram,
angles=self.tilts.data,
Expand Down Expand Up @@ -2104,7 +2104,7 @@ def extract_sinogram(
Returns
-------
sino : Signal2D
sino : :py:class:`~hyperspy.api.signals.Signal2D`
A single image representing the single column data over the range of
projections in the original TomoStack.
Expand Down Expand Up @@ -2177,9 +2177,9 @@ def __init__(self, *args, **kwargs):
"""
super().__init__(*args, **kwargs)

if self.axes_manager.navigation_dimension != 1:
msg = ("A RecStack must have a singular navigation axis. Navigation "
f"shape was: {self.axes_manager.navigation_shape}")
if self.axes_manager.navigation_dimension not in (0, 1):
msg = ("A RecStack must have a singular (or no) navigation axis. "
f"Navigation shape was: {self.axes_manager.navigation_shape}")
raise ValueError(msg)

self.inav = _RecStackSlicer(self, isNavigation=True)
Expand Down
2 changes: 1 addition & 1 deletion etspy/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ def test_rec_stack_init_bad_dims(self):
with pytest.raises(
ValueError,
match=re.escape(
"A RecStack must have a singular navigation axis. "
"A RecStack must have a singular (or no) navigation axis. "
"Navigation shape was: (8, 10)",
),
):
Expand Down
4 changes: 2 additions & 2 deletions etspy/tests/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_astra_sirt_error_gpu(self):
stack = ds.get_needle_data(aligned=True)
_, ny, _ = stack.data.shape
angles = stack.tilts.data.squeeze()
stack = stack.isig[120, :].squeeze()
stack = stack.isig[120:121, :].squeeze()
rec_stack, error = recon.astra_error(
stack.data,
angles,
Expand All @@ -109,7 +109,7 @@ def test_astra_sirt_error_gpu_bad_dims(self):
stack = ds.get_needle_data(aligned=True)
_, ny, _ = stack.data.shape
angles = stack.tilts.data.squeeze()
stack = stack.isig[120, :]
stack = stack.isig[120:121, :]
with pytest.raises(ValueError, match=re.escape(
"Sinogram must be two-dimensional (ntilts, y). "
"Provided shape was (77, 256, 1).",
Expand Down
6 changes: 3 additions & 3 deletions etspy/tests/test_recon.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_recon_no_tilts(self):

def test_recon_single_slice(self):
stack = ds.get_needle_data(aligned=True)
slices = stack.isig[120, :]
slices = stack.isig[120:121, :]
tilts = stack.tilts.data.squeeze()
rec = recon.run(slices.data, tilts, "FBP", cuda=False)
assert isinstance(stack, TomoStack)
Expand Down Expand Up @@ -246,7 +246,7 @@ def test_astra_sirt_error_cpu(self):
stack = ds.get_needle_data(aligned=True)
_, ny, _ = stack.data.shape
angles = stack.tilts.data.squeeze()
sino = stack.isig[120, :].data.squeeze()
sino = stack.isig[120:121, :].data.squeeze()
rec_stack, error = recon.astra_error(
sino,
angles,
Expand All @@ -262,7 +262,7 @@ def test_astra_sart_error_cpu(self):
stack = ds.get_needle_data(aligned=True)
_, ny, _ = stack.data.shape
angles = stack.tilts.data.squeeze()
sino = stack.isig[120, :].data.squeeze()
sino = stack.isig[120:121, :].data.squeeze()
rec_stack, error = recon.astra_error(
sino,
angles,
Expand Down

0 comments on commit f095397

Please sign in to comment.