fiji / register_virtual_stack_slices

Fiji package for registering and transforming arbitrarily large sequences of images
https://imagej.net/Register_Virtual_Stack_Slices
GNU General Public License v3.0
18 stars 12 forks source link

Transformation Information from XML File #14

Open SDLAndrews opened 2 years ago

SDLAndrews commented 2 years ago

Hello, I had a question regarding the information in the .xml file. I saw issue #8 , but I am still not sure how to extract transformation data from these files. I performed an affine registration on an image stack, and now I want to write an external script that will apply the transformations to a centerline. I have an example .xml file here:

`

<iict_transform invertible="true" class="mpicbg.trakem2.transform.TranslationModel2D" data="-1.0 -6.0" />

`

I am assuming that this data file would include values such as dx, dy, dz, dtheta that I could apply to the centerline. Is there some documentation on the format of this xml file so I can get this information?

bogovicj commented 2 years ago

Hi @SDLAndrews ,

I am assuming that this data file would include values such as dx, dy, dz, dtheta that I could apply to the centerline.

I'm not quite sure what you mean here (what are the dx,dy,dz exactly?), but maybe the explanation below will have the answer for you.

Is there some documentation on the format of this xml file so I can get this information?

There are three transformations there:

The code I linked to above shows you how the transformations are applied to points.

This code shows how to parse the xml for:

I imagine the list and translation will be easy for you to understand (of course, please post back if not). The affine is stored as a "flattened" 2x3 matrix in homogenous coordinate ( with the elements ordered like this m00, m10, m01, m11, m02, m12
e.g. the matrix for your example would be:

  [ 0.9977  -0.0009   0.9995 ]
  [ 0.0027  1.00701   3.4699 ]
SDLAndrews commented 2 years ago

From this, I am able to get a better understanding. To clarify, for the matrix you have listed here, would each term represent the following operations (for [row, column]): [1,1] = Scale along X [2,2] = Scale along Y [1,2] = Shear along X [2,1] = Shear along Y [1,3] = Translation along X [2,3] = Translation along Y

bogovicj commented 2 years ago

@SDLAndrews ,

You have the right idea, yes. It is not generally as simple as what you wrote though. For example, if you scale and rotate and skew, then there is no one number that tells you what the scale of X is.