Skip to content

Commit

Permalink
Merge pull request #32 from bmorris3/docs_updates
Browse files Browse the repository at this point in the history
Docs updates
  • Loading branch information
Brett M. Morris committed Nov 30, 2016
2 parents b7fb0ec + 28eca98 commit 88d2af6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
12 changes: 11 additions & 1 deletion shampoo/fftutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ def fft2(self, array):
Parameters
----------
array : `~numpy.ndarray`
array : `~numpy.ndarray` (real)
Input array
Returns
-------
ft_array : `~numpy.ndarray` (complex)
Fourier transform of the input array
"""
self._fft2.input_array[:] = array
return self._fft2()
Expand All @@ -57,6 +62,11 @@ def ifft2(self, array):
----------
array : `~numpy.ndarray`
Input array
Returns
-------
ift_array : `~numpy.ndarray`
Inverse Fourier transform of input array
"""
self._ifft2.input_array[:] = array
return self._ifft2()
Expand Down
25 changes: 13 additions & 12 deletions shampoo/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _reconstruct(self, propagation_distance,
mask = self.real_image_mask(x_peak, y_peak, mask_radius)

# Calculate Fourier transform of impulse response function
G = self.fourier_trans_of_impulse_resp_func(propagation_distance)
G = self.ft_impulse_resp_func(propagation_distance)

# Now calculate digital phase mask. First center the spectral peak:
shifted_ft_hologram = fftshift(ft_hologram * mask, [-x_peak, -y_peak])
Expand Down Expand Up @@ -388,7 +388,7 @@ def apodize(self, array, alpha=0.075):
apodized_array = array * self.apodization_window_function
return apodized_array

def fourier_trans_of_impulse_resp_func(self, propagation_distance):
def ft_impulse_resp_func(self, propagation_distance):
"""
Calculate the Fourier transform of impulse response function, sometimes
represented as ``G`` in the literature.
Expand Down Expand Up @@ -496,7 +496,7 @@ def fourier_peak_centroid(self, fourier_arr, mask_radius=None,
plt.show()
return spectrum_centroid

def reconstruct_multithread(self, propagation_distances, threads=4):
def _reconstruct_multithread(self, propagation_distances, threads=4):
"""
Reconstruct phase or intensity for multiple distances, for one hologram.
Expand All @@ -521,22 +521,22 @@ def reconstruct_multithread(self, propagation_distances, threads=4):
wave_cube = np.zeros((n_z_slices, wave_shape[0], wave_shape[1]),
dtype=np.complex128)

def _reconstruct(index):
def __reconstruct(index):
# Reconstruct image, add to data cube
wave = self.reconstruct(propagation_distances[index])
wave_cube[index, ...] = wave._reconstructed_wave

# Make the Pool of workers
pool = ThreadPool(threads)
pool.map(_reconstruct, range(n_z_slices))
pool.map(__reconstruct, range(n_z_slices))

# close the pool and wait for the work to finish
pool.close()
pool.join()

return wave_cube

def detect_specimens(self, reconstructed_wave, propagation_distance,
def _detect_specimens(self, reconstructed_wave, propagation_distance,
margin=100, kernel_radius=4.0, save_png_to_disk=None):
cropped_img = reconstructed_wave.phase[margin:-margin, margin:-margin]
best_convolved_phase = convolve_fft(cropped_img,
Expand Down Expand Up @@ -611,6 +611,7 @@ def unwrap_phase(reconstructed_wave, seed=random_seed):
reconstructed_wave.real),
seed=seed)


class ReconstructedWave(object):
"""
Container for reconstructed waves and their intensity and phase
Expand All @@ -625,7 +626,7 @@ def __init__(self, reconstructed_wave):
@property
def intensity(self):
"""
`~numpy.ndarray` of the reconstructed intensity
Reconstructed intensity (`~numpy.ndarray`, real)
"""
if self._intensity_image is None:
self._intensity_image = np.abs(self._reconstructed_wave)
Expand All @@ -634,9 +635,9 @@ def intensity(self):
@property
def phase(self):
"""
`~numpy.ndarray` of the reconstructed, unwrapped phase.
Reconstructed, unwrapped phase (`~numpy.ndarray`, real)
Returns the unwrapped phase using `~skimage.restoration.unwrap_phase`.
Phase unwrapping comes from `~skimage.restoration.unwrap_phase`.
"""
if self._phase_image is None:
self._phase_image = unwrap_phase(self._reconstructed_wave)
Expand All @@ -646,7 +647,7 @@ def phase(self):
@property
def reconstructed_wave(self):
"""
`~numpy.ndarray` of the complex reconstructed wave
Reconstructed wave (`~numpy.ndarray`, complex)
"""
return self._reconstructed_wave

Expand All @@ -668,9 +669,9 @@ def plot(self, phase=False, intensity=False, all=False,
Returns
-------
fig : `~matplotlib.figure.Figure`
Figure
Matplotlib figure object
ax : `~matplotlib.axes.Axes`
Axis
Matplotlib axis object
"""

all_kwargs = dict(origin='lower', interpolation='nearest', cmap=cmap)
Expand Down

0 comments on commit 88d2af6

Please sign in to comment.