I’ve been trying to figure out this issue for a while and I’ve gotten pretty stumped, so I figured I would ask here to see if anyone can help. I have a feeling the fix isn’t that hard, I’m just not very experienced dealing with image metadata.
The background: I’m trying to train a deep learning model to segment cell membranes in my tissue of interest. I did a trial run of this some time ago using outputs from one of the classic segmentation workflows provided in the Allen Cell Segmenter. These initial segmentations that I used to train the model had some imperfections.
I am now using a different method that I created myself to initially segment the cell membranes with the hope of using this to train a better deep learning model. The new initial segmentation method I am using outputs single channel .tiff files that have ~100 z slices. The shapes of these images are given in the metadata like [1, 126, 856, 856]. The version of aicsimageio I am using is 3.3.1. I am also using version 0.0.8.dev0 of the aics-ml-segmenter (with the fixes implemented here).
When I try to run curator_sorting (with the --d flag), the following shows up in my terminal:
[2020-12-15 12:00:45,478 - aicsimageio.readers.tiff_reader - 236][INFO] Unsure how to handle dimension: Q. Replaced with guess: C
[2020-12-15 12:00:45,478 - aicsimageio.readers.tiff_reader - 236][INFO] Unsure how to handle dimension: Q. Replaced with guess: Z
…but this doesn’t prevent me from creating excluding masks, and the side-by-side images that pop up in the curator screen look normal. (One thing I am confused about is where “dimension: Q” is coming from.) However, once the excluding masks are created, the following error occurs during training data creation:
IndexError: boolean index did not match indexed array along dimension 0; dimension is 126 but corresponding boolean dimension is 1
If I open up the excluding mask .tiffs in ImageJ and look at the metadata, I can see that the dimensions were guessed incorrectly, probably because the default order for the ome_tiff_writer is STZCXY but mine are arranged with Z and C switched.
It seems like if I could resave my original segmentation images so that C and Z are explicitly defined in the metadata in the OME-TIFF format, I would be able to fix this problem (in the future, I will likely implement this in the original segmentation code, but for now I was hoping to just fix the images I already have). However, it seems like no matter what I do, even changing the original order of dimensions in the numpy array corresponding to the image, when I go to save the image the values for C and Z are still switched.
How can I go about explicitly defining the values for C and Z in my images so that they get saved correctly in the image metadata?