Skip to content

Commit

Permalink
Merge pull request #555 from py4dstem/phase_contrast
Browse files Browse the repository at this point in the history
I write bugs not tragedies
  • Loading branch information
gvarnavi authored Nov 7, 2023
2 parents 2bd2fa6 + 54ab753 commit fc93069
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions py4DSTEM/process/phase/iterative_base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,7 @@ def to_h5(self, group):
"num_diffraction_patterns": self._num_diffraction_patterns,
"sampling": self.sampling,
"angular_sampling": self.angular_sampling,
"positions_mask": self._positions_mask,
},
)

Expand Down Expand Up @@ -1501,6 +1502,7 @@ def _populate_instance(self, group):
self._angular_sampling = preprocess_md["angular_sampling"]
self._region_of_interest_shape = preprocess_md["region_of_interest_shape"]
self._num_diffraction_patterns = preprocess_md["num_diffraction_patterns"]
self._positions_mask = preprocess_md["positions_mask"]

# Reconstruction metadata
reconstruction_md = _read_metadata(group, "reconstruction_metadata")
Expand Down Expand Up @@ -1596,7 +1598,9 @@ def _calculate_scan_positions_in_pixels(
x = (x - np.ptp(x) / 2) / self.sampling[0]
y = (y - np.ptp(y) / 2) / self.sampling[1]
x, y = np.meshgrid(x, y, indexing="ij")

if positions_mask is not None:
x = x[positions_mask]
y = y[positions_mask]
else:
positions -= np.mean(positions, axis=0)
x = positions[:, 0] / self.sampling[1]
Expand All @@ -1613,9 +1617,6 @@ def _calculate_scan_positions_in_pixels(
positions = np.array([x.ravel(), y.ravel()]).T
positions -= np.min(positions, axis=0)

if positions_mask is not None:
positions = positions[positions_mask.ravel()]

if self._object_padding_px is None:
float_padding = self._region_of_interest_shape / 2
self._object_padding_px = (float_padding, float_padding)
Expand Down

0 comments on commit fc93069

Please sign in to comment.