diff --git a/src/nanopyx/core/analysis/decorr.pyx b/src/nanopyx/core/analysis/decorr.pyx index 07d080c1..3ebc9863 100644 --- a/src/nanopyx/core/analysis/decorr.pyx +++ b/src/nanopyx/core/analysis/decorr.pyx @@ -270,7 +270,7 @@ cdef class DecorrAnalysis: cdef float[:, :] _compute_d(self): cdef float[:] coef, kc, a, dg, result, results_gm, results_max - cdef complex[:, :] fft + cdef float complex[:, :] fft cdef float[:, :] d_curve, img_ref, blurred, mask, fft_real, fft_imag cdef float[:, :, :] normalized_fft cdef int count = 0 @@ -302,7 +302,7 @@ cdef class DecorrAnalysis: blurred = np.copy(self.img_ref) blurred = gaussian_filter(blurred, sig) blurred = np.copy(self.img_ref) - blurred - fft = np.fft.fftshift(np.fft.fft2(blurred)) + fft = np.fft.fftshift(np.fft.fft2(blurred)).astype(np.complex64) fft_real = np.real(fft).astype(np.float32) fft_imag = np.imag(fft).astype(np.float32) normalized_fft = _normalizeFFT(fft_real, fft_imag) @@ -402,7 +402,7 @@ cdef class DecorrAnalysis: cdef _run_analysis(self): cdef float[:] out - cdef complex[:, :] img_fft + cdef float complex[:, :] img_fft cdef float[:, :] img_ref, img_f, temp, fft_real, fft_imag cdef float resolution img_ref = np.copy(self.img) @@ -416,7 +416,7 @@ cdef class DecorrAnalysis: img_f = _apodize_edges(img_f) temp = self._get_preprocessed_image(img_f) self.img_ref = np.copy(temp) - img_fft = np.fft.fftshift(np.fft.fft2(temp)) + img_fft = np.fft.fftshift(np.fft.fft2(temp)).astype(np.complex64) fft_real = np.real(img_fft).astype(np.float32) fft_imag = np.imag(img_fft).astype(np.float32) fft_real[fft_real.shape[0]//2, fft_real.shape[1]//2] = 0 diff --git a/src/nanopyx/core/analysis/frc.pyx b/src/nanopyx/core/analysis/frc.pyx index 25ae1135..a7130110 100644 --- a/src/nanopyx/core/analysis/frc.pyx +++ b/src/nanopyx/core/analysis/frc.pyx @@ -170,7 +170,7 @@ cdef class FIRECalculator: return results def calculate_fft(self, img: np.ndarray): - return np.fft.fftshift(np.fft.fft2(img)) + return np.fft.fftshift(np.fft.fft2(img)).astype(np.complex64) cdef _calculate_frc_curve(self, float[:, :] img1, float[:, :] img2): @@ -189,8 +189,8 @@ cdef class FIRECalculator: img_1 = self._get_squared_tapered_image(img_1) img_2 = self._get_squared_tapered_image(img_2) - cdef complex[:, :] fft_1 = self.calculate_fft(np.array(img_1, dtype=np.float32)) - cdef complex[:, :] fft_2 = self.calculate_fft(np.array(img_2, dtype=np.float32)) + cdef float complex[:, :] fft_1 = self.calculate_fft(np.array(img_1, dtype=np.float32)) + cdef float complex[:, :] fft_2 = self.calculate_fft(np.array(img_2, dtype=np.float32)) cdef int size = fft_1.shape[0] self.field_of_view = size