This notebook demonstrates training data generation for an isotropic reconstruction task, where the anisotropic distortions along the undersampled Z axis are simulated from isotropic 2D slices.
Note that training data can be created from existing acquisitions.
We will use a single Retina stack for training data generation, whereas in your application you should aim to use stacks from different developmental timepoints to ensure a well trained model.
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 download_and_extract_zip_file, plot_some, axes_dict
from csbdeep.io import save_training_data
from csbdeep.data import RawData, create_patches
from csbdeep.data.transform import anisotropic_distortions
First we download some example data, consisting of a single 3D Zebrafish retina stack.
download_and_extract_zip_file (
url = 'http://csbdeep.bioimagecomputing.com/example_data/retina.zip',
targetdir = 'data',
)
We plot XY and XZ slices of the training stack:
x = imread('data/retina/cropped_farred_RFP_GFP_2109175_2color_sub_10.20.tif')
subsample = 10.2
print('image size =', x.shape)
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);