In [3]:
# Download the data for this notebook
import download
download.run()
In [4]:
# install the dependencies for this notebooks
!conda install -c ericdill clint --yes
!conda install scipy numpy matplotlib --yes
In [5]:
# all the imports
import os
import tempfile
from subprocess import call
import scipy
import numpy as np
import matplotlib.pyplot as plt
from pims import ImageSequence
import zipfile
import time as ttime
from skbeam.core import dpc
%matplotlib notebook
dpc.logger.setLevel(dpc.logging.DEBUG)
In [6]:
# Set parameters
start_point = [1, 0]
first_image = 1
pixel_size = (55, 55)
focus_to_det = 1.46e6
scan_xstep = 0.1
scan_ystep = 0.1
scan_rows = 121
scan_cols = 121
energy = 19.5
roi = None
padding = 0
weighting = 1.
bad_pixels = None
solver = 'Nelder-Mead'
images = ImageSequence(os.path.join('SOFC', '*.tif'))
img_size = images[0].shape
ref_image = np.ones(img_size)
scale = True
negate = True
In [7]:
fig, (ax1, ax2) = plt.subplots(nrows=2)
In [8]:
dpc_gen = dpc.lazy_dpc(ref_image, images, start_point, scan_rows,
scan_cols, solver, roi, bad_pixels)
In [9]:
for idx, intermediate_state in enumerate(dpc_gen):
if idx % 100 == 0:
print('processing %s' % idx)
phase, amplitude = dpc.reconstruct_phase_from_partial_info(
intermediate_state, energy, scan_xstep, scan_ystep, pixel_size[0],
focus_to_det, negate, padding, weighting)
ax1.imshow(phase, cmap='viridis')
ax2.imshow(amplitude, cmap='viridis')
fig.canvas.draw()
ttime.sleep(0.01)
# provide a final update
ax1.imshow(phase, cmap='viridis')
ax2.imshow(amplitude, cmap='viridis')
In [10]:
# Use skxray.dpc.dpc_runner
phase, amplitude = dpc.dpc_runner(
ref_image, images, start_point, pixel_size, focus_to_det, scan_rows,
scan_cols, scan_xstep, scan_ystep, energy, padding, weighting, solver,
roi, bad_pixels, negate, scale)
In [11]:
# display results
fig, ax = plt.subplots(ncols=2)
ax[0].imshow(phase, cmap='gray')
ax[1].imshow(amplitude, cmap='gray')
ax[0].set_title('Phase')
ax[1].set_title('Amplitude')
Out[11]:
In [12]:
import skbeam
In [13]:
skbeam.__version__
Out[13]:
In [ ]: