@@ -937,38 +937,31 @@ def normalize_background(self, bg_radius=1.0, do_ramp=True):
937937 LambdaXform (normalize_bg , bg_radius = bg_radius , do_ramp = do_ramp )
938938 )
939939
940- def im_backward (self , idx , im = None , weights = None , symmetry_group = None ):
940+ def im_backward (self , im , start , weights = None , symmetry_group = None ):
941941 """
942- Apply adjoint mapping to set of images identified by indices `idx`.
942+ Apply adjoint mapping to set of images
943943
944- :param idx: Source indices corresponding to a set of images.
945- :param im: An Image instance to which we wish to apply the
946- adjoint of the forward model. When `None`, infers
947- `im=self.images[idx]`.
944+ :param im: An Image instance to which we wish to apply the adjoint of the forward model.
945+ :param start: Start index of image to consider
948946 :param weights: Optional vector of weights to apply to images.
949947 Weights should be length `self.n`.
950948 :param symmetry_group: A SymmetryGroup instance. If supplied, uses symmetry to increase
951949 number of images used in back-projectioon.
952950 :return: An L-by-L-by-L volume containing the sum of the adjoint mappings applied to the start+num-1 images.
953951 """
952+ num = im .n_images
954953
955- if im is None :
956- im = self .images [idx ]
957- elif im .n_images != len (idx ):
958- raise RuntimeError (
959- f"`im_backward` n_images != len(idx): { im .n_images } != { len (idx )} "
960- )
961-
962- im *= self .amplitudes [idx , np .newaxis , np .newaxis ]
963- im = im .shift (- self .offsets [idx , :])
964- im = self ._apply_source_filters (im , idx )
954+ all_idx = np .arange (start , min (start + num , self .n ))
955+ im *= self .amplitudes [all_idx , np .newaxis , np .newaxis ]
956+ im = im .shift (- self .offsets [all_idx , :])
957+ im = self ._apply_source_filters (im , all_idx )
965958
966959 if weights is not None :
967- im *= weights [idx , np .newaxis , np .newaxis ]
960+ im *= weights [all_idx , np .newaxis , np .newaxis ]
968961
969- vol = im .backproject (self . rotations [ idx , :, :], symmetry_group = symmetry_group )[
970- 0
971- ]
962+ vol = im .backproject (
963+ self . rotations [ start : start + num , :, :], symmetry_group = symmetry_group
964+ )[ 0 ]
972965
973966 return vol
974967
0 commit comments