Skip to content

Instantly share code, notes, and snippets.

@ptweir
Created January 8, 2015 00:39
Show Gist options
  • Save ptweir/2297c1098be951daa38a to your computer and use it in GitHub Desktop.
Save ptweir/2297c1098be951daa38a to your computer and use it in GitHub Desktop.
Open a LSM image stack and display a maximum Z projection
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
from pylsm import lsmreader
imageFile = lsmreader.Lsmimage(lsmFileName)
imageFile.open()
xLen = imageFile.header['Image'][0]['CZ LSM info']['Dimension X']
yLen = imageFile.header['Image'][0]['CZ LSM info']['Dimension Y']
zLen = imageFile.header['Image'][0]['CZ LSM info']['Dimension Z']
numColors = 3
frames = np.zeros((xLen, yLen, zLen, numColors),dtype='uint16')
for zPos in range(zLen):
redData = np.flipud(imageFile.get_image(stack=zPos, channel=1))
grnData = np.flipud(imageFile.get_image(stack=zPos, channel=0))
frames[:,:,zPos,0] = redData
frames[:,:,zPos,1] = grnData
fig = plt.figure()
ax = fig.add_subplot(111)
ax.imshow(frames.max(2)/4096.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment