How to conduct the inverse of '3dWarp -oblique2card'?

Hi AFNI experts,
The anatomy dataset had been deobliqued using 3dWarp for each subject firstly:

3dWarp -oblique2card -prefix card OriginalAnatomy+orig.

And then many ROIs were drawn on card+orig.
Now I want to transform these cardinal ROIs back to match the original oblique dataset (OriginalAnatomy+orig) perfectly.
And I have tried the method like this:

3dWarp -card2oblique OriginalAnatomy+orig. -prefix reoblique card+orig.

But it doesn’t work because the afni GUI said there is still oblique angle difference of 2.97 degrees between reoblique+orig. and OriginalAnatomy+orig.
Do you know how to process the ROIs to make them match the original oblique dataset perfectly?
I’m very sorry to disturb you.
Best regards,

Use the -gridset option to force the grid to the original dataset and use 3drefit to copy the IJK_TO_DICOM_REAL attribute from the original dataset to the output dataset You can see the xyz->xyz transformation matrix used with the “-verb” option and invert that with cat_matvec.

Hi Daniel,
Thank you!
I seem to have found an easy way to do the inversion:
As mentioned before, I got the deobliqued dataset using the code:

[size=small]3dWarp -oblique2card -prefix card OriginalAnatomy+orig.[/size]

When I open the card+orig.HEAD file now, I find two new attributes that are different from the attributes in OriginalAnatomy+orig.HEAD:

 [size=small]type  = float-attribute
count = 12
      0.9955035    -0.03815642     0.08670011       1.430454     0.05067991
      0.9878103     -0.1471824      -17.53901     -0.0800273      0.1509146
      0.9853023       28.11709
type  = float-attribute
count = 12
      0.9955035     0.05067991     -0.0800273       1.714989    -0.03815642
      0.9878101      0.1509145       13.13652     0.08670011     -0.1471824
      0.9853022      -30.40928[/size] 

I think WARPDRIVE_MATVEC_INV_000000 is the attribute of inversion matrix.
And I can transform card+orig back to match OriginalAnatomy+orig using these codes:

[size=small]cat_matvec card+orig::WARPDRIVE_MATVEC_INV_000000 > inverion.1D
3dAllineate -1Dmatrix_apply inversion.1D -prefix reoblique+orig -source card+orig -master OriginalAnatomy+orig[/size]

Unfortunately, the afni GUI say reoblique+orig and OriginalAnatomy+orig still have an angle difference of 9.835 degrees.
This warning makes me very sad !! :-(:frowning:
So I compare the matrix outputted by 3dWarp -verb and the matrix stored in card+orig.HEAD for checking:

[size=small]3dWarp -verb -oblique2card -prefix card OriginalAnatomy+orig. >forward_verb.1D
cat_matvec -ONELINE forward_verb.1D
     0.995503   0.05068  -0.080027   1.71499   -0.038156   0.98781   0.150915    13.1365    0.0867   -0.147182  0.985302   -30.4093
cat_matvec -ONELINE card+orig::WARPDRIVE_MATVEC_FOR_000000
    0.995503   -0.0381564    0.0867001     1.43045   0.0506799    0.98781   -0.147182    -17.539   -0.0800273     0.150915    0.985302    28.1171
cat_matvec -ONELINE card+orig::WARPDRIVE_MATVEC_INV_000000
    0.995503    0.0506799    -0.0800273       1.71499    -0.0381564     0.98781    0.150915   13.1365    0.0867001    -0.147182     0.985302    -30.4093[/size]

This makes me very confused! :-S:-S
Because I thought the matrix outputted by 3dWarp -verb is the forward matrix. It is unexpectedly the same as the inversion matrix stored in the HEAD file now.
What do you think?

You need to use 3drefit to modify the header of the reoblique dataset to include the same “IJK_TO_DICCOM_REAL” attribute of the original dataset.

I am very sorry for so many questions. But now I have only the last two questions to verify:

  1. The inverse matrix, NOT the forward matrix is outputted to the terminal by 3dWarp -verb?
  2. I can change the deobliqued dataset to match the original dataset perfectly using the following codes?

#3dWarp -oblique2card -prefix card OriginalAnatomy+orig.
cat_matvec -ONELINE card+orig::WARPDRIVE_MATVEC_INV_000000 > inversion.1D
3dAllineate -1Dmatrix_apply inversion.1D -prefix reoblique+orig -source card+orig -master OriginalAnatomy+orig
3drefit -atrcopy OriginalAnatomy+orig. IJK_TO_DICOM_REAL reoblique+orig

Am I right about these two questions?
Best regards,

It’s best to check this out with obviously oblique data. I just tried your example, and this works!

Hi Daniel,
At the last step of inverse processing, we copied the attribute IJK_TO_DICOM_REAL from the original dataset to the reobliqued dataset using:

3drefit -atrcopy OriginalAnatomy+orig. IJK_TO_DICOM_REAL reoblique+orig

And the Afni GUI didn’t give an angle difference warning anymore.

But just now, I find the help files of 3drefit say the option -atrcopy can’t really change an attribute without the option -saveatr ?
I am very confused.
Maybe I should do the last step using:

3drefit -saveatr -atrcopy OriginalAnatomy+orig. IJK_TO_DICOM_REAL reoblique+orig

Which is the right one?
With anticipation,

While “-saveatr” won’t hurt, it isn’t necessary for this kind of dataset attribute. The atrcopy is good enough here.