This notebook demonstrates applying a CARE model for an isotropic reconstruction task, assuming that training was already completed via 2_training.ipynb.
The trained model is assumed to be located in the folder
models with the name
Note: The CARE model is here applied to the same image that the model was trained on.
Of course, in practice one would typically use it to restore images that the model hasn't seen during training.
More documentation is available at http://csbdeep.bioimagecomputing.com/doc/.
from __future__ import print_function, unicode_literals, absolute_import, division import numpy as np import matplotlib.pyplot as plt %matplotlib inline %config InlineBackend.figure_format = 'retina' from tifffile import imread from csbdeep.utils import Path, download_and_extract_zip_file, plot_some from csbdeep.io import save_tiff_imagej_compatible from csbdeep.models import IsotropicCARE
Using TensorFlow backend.
download_and_extract_zip_file ( url = 'http://csbdeep.bioimagecomputing.com/example_data/retina.zip', targetdir = 'data', )
Files found, nothing to download. data: - retina - retina/cropped_farred_RFP_GFP_2109175_2color_sub_10.20.tif
We plot XY and XZ slices of the stack and define the image axes and subsampling factor, which will be needed later for prediction.
x = imread('data/retina/cropped_farred_RFP_GFP_2109175_2color_sub_10.20.tif') axes = 'ZCYX' subsample = 10.2 print('image size =', x.shape) print('image axes =', axes) print('Z subsample factor =', subsample) plt.figure(figsize=(16,15)) plot_some(np.moveaxis(x,1,-1)[[5,-5]], title_list=[['XY slice','XY slice']], pmin=2,pmax=99.8); plt.figure(figsize=(16,15)) plot_some(np.moveaxis(np.moveaxis(x,1,-1)[:,[50,-50]],1,0), title_list=[['XZ slice','XZ slice']], pmin=2,pmax=99.8, aspect=subsample);
image size = (35, 2, 768, 768) image axes = ZCYX Z subsample factor = 10.2