Demo: Apply trained CARE model for isotropic reconstruction of Zebrafish retina

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 my_model.

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

In [1]:
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 import save_tiff_imagej_compatible
from csbdeep.models import IsotropicCARE
Using TensorFlow backend.

Download example data

The example data (also for testing) should have been downloaded in 1_datagen.ipynb.
Just in case, we will download it here again if it's not already present.

In [2]:
download_and_extract_zip_file (
    url       = '',
    targetdir = 'data',
Files found, nothing to download.

- retina
- retina/cropped_farred_RFP_GFP_2109175_2color_sub_10.20.tif

Raw 3D image stack with low axial resolution

We plot XY and XZ slices of the stack and define the image axes and subsampling factor, which will be needed later for prediction.

In [3]:
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)

          title_list=[['XY slice','XY slice']],

          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