How to extract z-layer from image series in Jython

Sample image and/or macro code

z_coord = 3 * 1431.5
layer = layerset.getLayer(z_coord)


Analysis goals

I am trying to extract an arbitrary z-layer from my image stack.


I’ve tried calculating the z-coordinate of the layer (say, layer 3 = 1431.5), but it seems that number is not exact enough to extract that layer (it will say that the layer does not exist). How do I get the z-coordinate of a layer so that I can obtain the layer as an object?

Hi @AngelaZ,

Are you working with TrakEM2?


Yes, I am using TrakEM2.


If you know the index of the layer you can also use that.
i.e. layer = layerset.getLayer(z_index) which looks like 3 in your case?

Will that suit your needs?

Hi John,

That doesn’t work for me. I get the error:

Traceback (most recent call last):
  File "/media/angela/gdrive/", line 52, in <module>
    tiles = layer.getDisplayables(Patch)

AttributeError: 'NoneType' object has no attribute 'getDisplayables'

Which I take to mean it could not find the layer, even though it exists. Please advise. Thanks!

Hi, still no solution. Any automated analysis solutions are useless without the ability to extract arbitrary z layers. This should be doable. Please advise, thanks!