Extract Z-Stacks from 5D stack per timepoint and per channel using python script

Hi all,

I hope that somebody can point me into the right direction. Here is what I want to do using Python Scripting:

  • split a 5D stack with dimensions TZCYX into single timpoints
  • split timepints into single channels
  • process the z-stack for every channel
  • merge all single stacks per channel into a multichannel image
  • merge all multichannel images back into a timeseries
  • the resulting stack should have the dimensions T1CYX

This sounds to like like a problem somebody else already solved for sure. It is a bit like a “Z-Projection” but instead of projecting I need to do some more fancy processing.

Can anyone provide an example or point em into the right direction?

Just to clarify, do you mean Python or do you mean Jython inside Fiji/ImageJ?

Hi @jni,

good point. I mean Jython aka Python scripts in Fiji. In normal python this would be lot easier (at least for someone like me … :slight_smile:

That raises another question: Do you work with ImageJ classes such as ImagePlus and friends or do you prefer an imglib2/ImageJ2 solution?

Hmmm…

ImagePlus would be OK for me, This is what I more or less understand.

But learrning something new using imglib2 is also fine for me.

Alright, the ImagePlus way in Jython looks like this:

from ij import IJ
from ij.plugin import Duplicator

imp = IJ.openImage("http://imagej.nih.gov/ij/images/Spindly-GFP.zip")
imp.show()

frame = 7

imp2 = Duplicator().run(imp, 1, imp.getNChannels(), 1, imp.getNSlices(), frame, frame)
imp2.show()

In Imglib2, the function for doing similar stuff is Views.hyperslice. I must admit, I would not know how to determine which of the 5 axes is the time-axis. I’d assume it’s the fourth if the image comes from ImageJ.