Take the 2-minute tour ×  I am a new Python user and would like
to do some simple image processing. Essentially I will have a
dynamic medical image - a series of 2D images at different time
points which I would like to store as a 3D array. Due to the
nature of the scanning technique there is likely to be
occasional patient motion during certain imaging frames which
makes the data unusable. I would like to delete such frames and
recast the array - new dimensions (n-1, 256, 256). After
deletion of the frame I would like to update the image display.
What is the best way to achieve this goal? Here is the skeleton
code I have so far:  import dicom import numpy as np import
pylab  from matplotlib.widgets import Slider, Button  ds =
dicom.read_file("/home/moadeep/Dropbox/FS1.dcm") #data =
ds.pixel_array data = np.random.rand(16,256,256) nframes =
data.shape[0]  ax = pylab.subplot(111)
pylab.subplots_adjust(left=0.25, bottom=0.25)  frame = 0 l =
pylab.imshow(data[frame,:,:]) #shows 1024x256 imagge, i.e. 0th
frame*  a