Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/aspire/source/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ def angles(self, values):
:param values: Rotation angles in radians, as a n x 3 array
:return: None
"""

values = values.astype(self.dtype)
self._rotations = Rotation.from_euler(values)
self.set_metadata(
["_rlnAngleRot", "_rlnAngleTilt", "_rlnAnglePsi"], np.rad2deg(values)
Expand All @@ -282,6 +284,8 @@ def rotations(self, values):
:param values: Rotation matrices as a n x 3 x 3 array
:return: None
"""

values = values.astype(self.dtype)
self._rotations = Rotation.from_matrix(values)
self.set_metadata(
["_rlnAngleRot", "_rlnAngleTilt", "_rlnAnglePsi"],
Expand Down Expand Up @@ -1080,7 +1084,7 @@ def __init__(self, src, indices, memory=None):
# here, but it returns a Numpy array, which would need to be
# converted back into Pandas for use below. So here we'll just
# use `loc` to return a dataframe.
metadata = self.src._metadata.loc[self.index_map]
metadata = self.src._metadata.loc[self.index_map].copy()

# Construct a fully formed ImageSource with this metadata
super().__init__(
Expand All @@ -1091,6 +1095,11 @@ def __init__(self, src, indices, memory=None):
memory=memory,
)

# Create filter indices, these are required to pass unharmed through filter eval code
# that is potentially called by other methods later.
self.filter_indices = np.zeros(self.n, dtype=int)
self.unique_filters = [IdentityFilter()]

def _images(self, indices):
"""
Returns images from `self.src` corresponding to `indices`
Expand All @@ -1100,7 +1109,13 @@ def _images(self, indices):
:return: An `Image` object.
"""
mapped_indices = self.index_map[indices]
return self.src.images[mapped_indices]
# Load previous source image data and apply any transforms
# belonging to this IndexedSource. Note the previous source
# requires remapped indices, while the current source uses the
# `indices` arg directly.
return self.generation_pipeline.forward(
self.src.images[mapped_indices], indices
)

def __repr__(self):
return f"{self.__class__.__name__} mapping {self.n} of {self.src.n} indices from {self.src.__class__.__name__}."
Expand Down