Skip to content

Commit e5bd439

Browse files
Merge pull request #526 from ComputationalCryoEM/eval_filters_43
Docstring for `ImageSource.eval_filters()`
2 parents b610ac9 + 161c144 commit e5bd439

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/aspire/source/image.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,21 @@ def _images(self, start=0, num=np.inf, indices=None):
338338
"Subclasses should implement this and return an Image object"
339339
)
340340

341-
def eval_filters(self, im_orig, start=0, num=np.inf, indices=None):
341+
def _apply_filters(self, im_orig, start=0, num=np.inf, indices=None):
342+
"""
343+
For each image in `im_orig` specified by start, num, or indices,
344+
the unique_filters associated with the corresponding index in the
345+
`ImageSource` are applied. The images are then returned as an `Image`
346+
stack.
347+
:param im_orig: An `Image` object
348+
:param start: Starting index of images in `im_orig`.
349+
:param num: Number of images to work on, starting at `start`.
350+
:param indices: A numpy array of image indices. If specified,`start` and `num` are ignored.
351+
:return: An `Image` instance with the unique filters of the source applied at the given indices.
352+
"""
342353
if not isinstance(im_orig, Image):
343354
logger.warning(
344-
f"eval_filters passed {type(im_orig)} instead of Image instance"
355+
f"_apply_filters() passed {type(im_orig)} instead of Image instance"
345356
)
346357
# for now just convert it
347358
im = Image(im_orig)
@@ -530,7 +541,7 @@ def im_backward(self, im, start):
530541
all_idx = np.arange(start, min(start + num, self.n))
531542
im *= self.amplitudes[all_idx, np.newaxis, np.newaxis]
532543
im = im.shift(-self.offsets[all_idx, :])
533-
im = self.eval_filters(im, start=start, num=num)
544+
im = self._apply_filters(im, start=start, num=num)
534545

535546
vol = im.backproject(self.rots[start : start + num, :, :])[0]
536547

@@ -552,7 +563,7 @@ def vol_forward(self, vol, start, num):
552563
logger.warning(f"Volume.dtype {vol.dtype} inconsistent with {self.dtype}")
553564

554565
im = vol.project(0, self.rots[all_idx, :, :])
555-
im = self.eval_filters(im, start, num)
566+
im = self._apply_filters(im, start, num)
556567
im = im.shift(self.offsets[all_idx, :])
557568
im *= self.amplitudes[all_idx, np.newaxis, np.newaxis]
558569
return im

src/aspire/source/simulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def _images(self, start=0, num=np.inf, indices=None, enable_noise=True):
183183

184184
im = self.projections(start=start, num=num, indices=indices)
185185

186-
im = self.eval_filters(im, start=start, num=num, indices=indices)
186+
im = self._apply_filters(im, start=start, num=num, indices=indices)
187187
im = im.shift(self.offsets[indices, :])
188188

189189
im *= self.amplitudes[indices].reshape(len(indices), 1, 1).astype(self.dtype)

0 commit comments

Comments
 (0)