An imaging task I'm working on requires me to perform maximum intensity projections on multichannel z-stacks. The images are stored in xycz order in a multi-page TIFF container. The two channels are labeled CARS and SRS; in all stacks, I want to throw out the last CARS image but not the last SRS image and then write out the z-projection for each channel to disk. Let's see what this looks like!

https://gist.github.com/tdsmith/6588350

I'm using tifffile.py to open the TIFF container and read out the image data into a 3D numpy array, doing a little bit of fancy indexing to separate the channels. Then, I'm (expensively but concisely) performing the maximum intensity projection by sorting each channel along the Z axis. My images are only 512x512, so I can afford to read the entire stack into memory at once and sorting is pretty quick. Thought this was a cute method; wondered if there's a better way.