Problem with Trakem2 Elastic Stack Alignment when applying transformations to binary mask images


I’m trying to use Elastic Stack Alignment (ESA) algorithm from Trakem2 to apply transformation to binary mask images but the output images are completely black. The goal is to be able to use the method to register some images and apply the same transformations to binary mask images that contain regions of interest in the images. Registration works well producing registered images and a project xml file with the transformations.

I have a script that takes this project file and some mask images and modifies the project file by changing file names, titles and z coordinates to match the inputted mask images. This works fine for some registrations & masks but for some it doesn’t. When it doesn’t, the mask images contain only zeroes and all the white (255) is missing. And when this happens, no errors relating to this is shown in the log files, and execution succeeds as if everything is ok (There are some other errors, e.g. null pointer exception but this occurs also when the outputted mask images are fine so believe this is not related to the issue).

I made an experiment where the same mask images didn’t work with one project file but gave good outputs on other, so it seems the issue is not in the input images but perhaps in the modified project file. I compared these two project files with a diff tool and tried to manually make the failing project file more similar with the succeeding one but the output images where always black.

I have included an example code that reprocduces the error.
Structure of the zip is as follows:
├── intermediate_masks
│ ├── preprocessed : input mask images
│ └── reapplied : output directory for transformed masks
├── Modified_tempproject.xml : modified project file
├── params.txt : ESA parameters used in registration
├── reapply : bash script to call Just run ./reapply
├── : jython script to apply transformation to mask images
└── transforms
└── tempproject.xml : original unmodified project file

Download link:

The script is written in Jython and Fiji has version 2.0.0-rc-64/1.51s.

Next I will probably try to open the project with Fiji GUI to spot any issues and export the masks from there. If this doesn’t help, I’ll try to use a debugger to find out if the ImagePlus object contain any data before exporting to further narrow down the issue. What could be the issue here? Any ideas are welcome.


By updating Fiji and removing ict_transforms_list tags and ct_id attributes from the project file, I am now able to export images via GUI. Although, bio-formats exporter now crashes when trying to do this with the script