Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/nanopyx/core/analysis/decorr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/nanopyx/core/analysis/frc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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
Expand Down