Allen Cell Discussion Forum

Writing to a TIFF File with Voxel Spacing [Error in Codebase]

I noticed a few things. The metadata for my image does not come from the TIFF file even after using AICSImage.

Also, how do I specify the metadata in the exported tiff file. I was digging through your code base and noticed that I could specify a pixel_physical_size. However, I think that there’s an error (attached below).

This is the save function in the omeTifWriter class:

The _make_meta function will not save the pixel physical size you save to the self.omeMetadata attribute.

Hi Dylan - Thank you for posting.

It wasn’t 100% clear what is happening because we can’t see the parameters you are passing in when you call save. Could you provide an example of how you are calling ome tiff writer’s save function?

Also, please make sure you are using the latest possible version of the library and consider posting this as an issue on our github page as well.


Sorry for the unclear description of the problem. I have the latest package of aicssegmentation - I downloaded the package today.

I am trying to save a segmentation from my Jupyter Notebook to my computer as TIFF. Below is the code that I am trying to use to do so (I took this from one of your tutorials):

I have tried to modify these save instructions by incorporating the pixel_physical_size but it’s not applying the pixel spacing to the saved 3D image. I have confirmed this error by taking the save image and observing it on ImageJ: ImageJ thinks that the voxel spacing is 1x1x1.

Is there something that I am doing wrong? Please let me know if you need any additional clarifications.


A couple of ideas here.

  1. When you open in ImageJ, using Import->BioFormats should ensure that the OME metadata is read and applied correctly. It could also help to save the file with .ome.tiff as the extension instead of plain tiff - it will serve as a hint to some readers.

  2. It looks like you are passing the dimensions in Z,Y,X order but they should be X,Y,Z for this parameter. In your case, [0.497, 0.497, 1.9]. (I’m making an assumption based on what those values look like.)

  3. This is not the most current OmeTiffWriter - I can tell by the spelling. This is probably an issue with which version aicssegmentation toolkit is requiring, but to the best of my knowledge shouldn’t impact how the pixels_physical_size gets saved.

Let me know if you try some of these things and it’s still not working as expected.

“This is not the most current OmeTiffWriter”

This is weird because I did a pip install of aicssegmentation today from here ( I’m not sure why this is happening.

Otherwise, you’re a legend. I just needed to follow Steps 1 and 2. One thing to note, regardless of how you save the file (.tiff or .ometiff), you need to use the File->Import->BioFormats function. My drag and drop doesn’t register the voxel spacing correctly for some reason. I’m unsure why that is.

Thanks a lot for your help!

Thanks a lot!

You’re welcome!
ImageJ by itself doesn’t know about the OME XML metadata format, but the BioFormats import plugin does, and is able to communicate that info into ImageJ when it reads the file. There may be a way to configure drag and drop to automatically go through BioFormats, but I’m not sure how.

A quick comment: aicssegmentation is NOT using the latest version of aicsimageio.

If you are simply using certain segmentation algorithms in aicssegmentation, you may upgrade aicsimageio to the lastest in order to utilize the most recent io functions.

We will need some time to re-write some of the batch-processing scripts in aicssegmentation to accomendate new syntax in aicsimageio.