Hi,
I'm using CMTK on Windows (via the Cygwin terminal) to register
image stacks of zebrafish brains to a reference atlas. The
registration to the atlas works very well. After registration, I
use the transformation data to apply the inverse
transformation to binary masks originally defined in atlas
space, in order to bring them into the native space of each sample
(each sample has its own transformation, so that each output mask
is aligned to the corresponding brain).
However, I’m encountering problems during this inverse transformation step. When I apply the inverse transformation using the following command:
C:/cygwin64/usr/local/lib/cmtk/bin/reformatx -v -o zf1_tectum.nrrd
--floating D:/Atlas_registration/Reg_folder/images/tectum.nrrd D:/Atlas_registration/Reg_folder/images/zf1_01.nrrd
--inverse D:/Atlas_registration/Reg_folder/Registration/warp/Kunst_zf1_01_warp_m0g80c8e1e-1x52r3.list/registration/registration
the resulting mask is not properly aligned to the sample brain.
First, the orientation of the mask appears to be rotated by 180° compared to the sample (attached image, left). If I manually correct the rotation using ImageJ, I still observe a significant mismatch between the position of the mask and its expected location in the brain (attached image, right). Specifically, there seems to be a translation issue in the XY plane, while the Z position looks approximately correct.
What could be the cause of this misalignment?
Is there a way to avoid it?
Thanks in advance for any help or suggestions.
Hi,
I think If you didn't explicitly meant that, the ". list" file shouldn't be sub indexed in your command. Also re saving all the files involved in Fiji may will just solve your problem by eleminating possible header info mismatches.
I think Sandor is right that you might not want to refer to :
Kunst_zf1_01_warp_m0g80c8e1e-1x52r3.list/registration/registration
In your command but instead just
Kunst_zf1_01_warp_m0g80c8e1e-1x52r3.list
I’m guessing that there was a gzip compressed file like this:
Kunst_zf1_01_warp_m0g80c8e1e-1x52r3.list/registration.gz
and at some point this got expanded making a new registration subfolder with a registration file inside. However I don’t know if that could actually be your problem.
Otherwise I don’t notice anything unusual about your command:
C:/cygwin64/usr/local/lib/cmtk/bin/reformatx -v -o zf1_tectum.nrrd
--floating D:/Atlas_registration/Reg_folder/images/tectum.nrrd D:/Atlas_registration/Reg_folder/images/zf1_01.nrrd
--inverse D:/Atlas_registration/Reg_folder/Registration/warp/Kunst_zf1_01_warp_m0g80c8e1e-1x52r3.list
I would potentially check the headers of your different files. If you have unu installed you can use
unu head zf1_tectum.nrrd
If not then cmtk’s describe gives you some of that info.
cmtk describe zf1_tectum.nrrd
Good luck!
Greg.
Problem solved!
Sandor and Greg, thank you so much for your suggestions! After
checking the .nrrd headers, I realized that the Python script I had
written to convert .tiff files to .nrrd was introducing some header
entries that were not present in the NRRDs saved with Fiji, and
these ended up interfering with the inverse
transformation.
Thanks again for your support and quick responses!
Glad to hear that you were able to track the problem down. I did wonder if there could be an issue with the nrrd headers e.g. because some had an anatomical space or a notional rotation embedded. If you have a clear diagnosis, then perhaps you could leave a note here with some details to help others in future. Best wishes, Greg.
Sure, Greg!
The issue was that during the conversion from TIFF to NRRD, my
Python scritp added a "space" field (set to
"left-posterior-superior"), which was not present in the NRRD files
saved with Fiji. Addittionally, the endian field was missing. This
mismatch in header metadata appears to have disrupted the inverse
transformation.
I hope this helps other facing a similar issue!