# Different slice thickness in stack

Hi All,

I have a 3D data set where the images are the same size (1024x766) but the distance between the slices (z) differ slightly. I know the distance between each slice but I can only add one z value that applies to all images.
eg.
slice 1 = 0um
slice 2 = 1um
slice 3 = 2.1um
slice 4 = 3.3um
slice 5 = 4.2um
slice 6 = 5.2um
slice 7 = 6.4um
as you can see the distances change slightly, between 0.9 and 1.2

Is there a pluging/macro that I can enter the specific z distance for each slice?

thanks
Stu

Hi @Stu, welcome to the forum,

There’s not a built-in way that I’m aware of, but something straight-forward that might serve your purposes would be to:

Create K copies of each slice where K is the slice thickness in tenths of um, then set the z-distance of the new stack to 0.1. In your example there would be 10 copies of slice 1, 11 copies of slice 2, 12 copies of slice 3, etc…

A somewhat quick way of doing this is
Image > Stack > Reslice Z ( and choose 1/12 = 0.083333 )
to duplicate each slice 12 times, then remove slices as appropriate.
Writing a macro would be more flexible in general, of course.

Does this sounds like it could work for you?
John

PS. We have some work that estimates and corrects for inconsistent z-spacing in large datasets, but its a rather “big hammer” and may be more than you need.

Hi,

thanks for the reply. That sounds like a great idea to get around this problem. the data sets would be quite big (+1000 images) and the measurements are to 4 decimal points. I will try a macro method first and see if my computer grinds to a halt.
Thanks for the help.
Stu

Good luck Stu,

My suggestion will indeed be memory-hungry, but if you’re going the macro/script route, it’s possible to re-use the ImageProcessors for each slice so that the big stack won’t need much more memory than was needed for the small one.

Let us know how it goes

The solution is dependant on what analysis you want to perform. I use stacks from energy filtering TEM, that have a unequally spaced z-axis (energy loss). As I need to use self written Plugins/Scripts to process the data, my solution is to use regular expressions the extract the position on the z-axis from the slice labels.
Another solution can be to store the z-data as meta data of the image. If you e.g. want to plot a z-axis profile, you have to write a small plugin/script that generates the plot by using the meta data as x-axis. Writing a plugin that creates a plot is quiet easy as you can see (here and here).