def returnWedgeVolume(self, size, rotation=None): """Return the wedge volume in full size and zero in the center @param size: size of wedge @type size: C{list} @param rotation: rotation (3-dim vector if Euler angles) @type rotation: C{list} @return: wedge volume @rtype: Numpy array """ assert len(size) == 3, "returnWedgeVolume: size must be 3-dim list" if self._volume is not None and np.array_equal(self._volume_shape, size): pass else: self._create_wedge_volume(size) from pytom.tompy.transform import rotate3d, fourier_reduced2full, fftshift isodd = self._volume_shape[2] % 2 wedge_vol = fftshift(fourier_reduced2full(self._volume, isodd)) if rotation is not None: # rotate the wedge first assert len(rotation) == 3 wedge_vol = rotate3d(wedge_vol, rotation[0], rotation[1], rotation[2], order=1) return wedge_vol
def apply(self, data, rotation=None): """ @param rotation: apply rotation to the wedge first """ # if no missing wedge if self.start_ang == -90 and self.end_ang == 90: return data if self._volume is not None and np.array_equal(self._volume_shape, data.shape): pass else: self._create_wedge_volume(data.shape) if rotation is not None: # rotate the wedge first assert len(rotation) == 3 from pytom.tompy.transform import rotate3d, fourier_reduced2full, fourier_full2reduced, fftshift, ifftshift isodd = self._volume_shape[2] % 2 filter_vol = fftshift(fourier_reduced2full(self._volume, isodd)) filter_vol = rotate3d(filter_vol, rotation[0], rotation[1], rotation[2], order=1) # linear interp! filter_vol = fourier_full2reduced(ifftshift(filter_vol)) else: filter_vol = self._volume from pytom.tompy.transform import fourier_filter res = fourier_filter(data, filter_vol, False) return res
def applyTransforms(cls, volume, shifts, angles, axis=None): import transform npVol = transform.translate3d(volume, shifts[0], shifts[1], shifts[2]) volume = transform.rotate3d(npVol, angles[0], angles[1], angles[2], center=axis) return volume
def apply(self, data, rotation=None): if rotation is not None: # rotate the wedge first assert len(rotation) == 3 from transform import rotate3d, fourier_full2reduced, ifftshift filter_vol = rotate3d(self._whole_volume, rotation[0], rotation[1], rotation[2]) filter_vol = fourier_full2reduced(ifftshift(filter_vol)) else: filter_vol = self._volume from transform import fourier_filter res = fourier_filter(data, filter_vol, False) return res