Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example Python code snippet to read in the 25µm template and annotation volumes:

Code Block

# -------------------------------
#
# Install pynrrd: https://github.com/mhe/pynrrd
#
# Download average_template_25.nrrd,
#          ara_nissl_25.nrrd,
#          ccf_2015/annotation_25.nrrd
#
# ---------------------------------
import nrrd
import numpy as np
import matplotlib.pyplot as plt
import Image

#
# Read image volume with NRRD reader
# Note that reader swaps the order of the first two axes
#
# AVGT = 3-D matrix of average_template
# NISSL = 3-D matrix of ara_nissl
# ANO = 3-D matrix of ccf_2015/anntotation
#

AVGT, metaAVGT = nrrd.read('average_template_25.nrrd');
NISSL, metaNISSL = nrrd.read('ara_nissl_25.nrrd');
ANO, metaANO = nrrd.read('annotation_25.nrrd');

# Save one coronal section as PNG
slice = AVGT[264,:,:].astype(float)
slice /= np.max(slice)
im = Image.fromarray(np.uint8(plt.cm.gray(slice)*255))
im.save('output/avgt_coronal.png')

slice = NISSL[264,:,:].astype(float)
slice /= np.max(slice)
im = Image.fromarray(np.uint8(plt.cm.gray(slice)*255))
im.save('output/nissl_coronal.png')

slice = ANO[264,:,:].astype(float)
slice /= 2000
im = Image.fromarray(np.uint8(plt.cm.jet(slice)*255))
im.save('output/ano_coronal.png')

# Save one sagittal section as PNG
slice = AVGT[:,:,220].astype(float)
slice /= np.max(slice)
im = Image.fromarray(np.uint8(plt.cm.gray(slice)*255))
im.save('output/avgt_sagittal.png')

slice = NISSL[:,:,220].astype(float)
slice /= np.max(slice)
im = Image.fromarray(np.uint8(plt.cm.gray(slice)*255))
im.save('output/nissl_sagittal.png')

slice = ANO[:,:,220].astype(float)
slice /= 2000
im = Image.fromarray(np.uint8(plt.cm.jet(slice)*255))
im.save('output/ano_sagittal.png')

Anchor
ImageSynch
ImageSynch
Image Alignment

...