3drefit -orient

Hello AFNI team,

I have a simple (but crucial) question concerning 3drefit,
I received a dataset with incorrect header information (in particular L and R are FOR SURE reversed but not only).

Using 3dinfo the original orientation was LPI,

Using the command


3drefit -orient LSP -deoblique

I have now an image in the correct orientation for SI and PA, however, I still don’t know if L and R are correct.
To do so, I checked if the right was still on right by modifying the right hemisphere (I added a sphere of “1”) and then I applied the previous command

It appears that after this transformation the right sphere is on left (despite I didn’t put RSP), which probably makes sense since I guessed, that inverting S and I has changed LR,
so my belief is that L and R are correctly oriented with


3drefit -orient LSP -deoblique

Am I right?

Hi, Clement-

I guess you are asking both if you are right and if your dataset’s right hemisphere is on the right?

Can I ask, is this possibly a sphinx-position dataset that you are aiming to un-sphinxify?

I guess I might do this in steps, because it sounds like you want to:

  1. remove obliquity from the dataset
  2. change definition of planes (so, what is currently an axial slice might become coronal or sagittal, say)
  3. flip what is left and right
    Is that right? Note that #2 and #3 can be a bit related as part of this.

I would start by copying the dataset, because 3drefit changes the header directly, and then do #1 separately (and you can put the coordinate origin in the middle of the volume or center of mass at the end, say):


3dcopy DSET_00 DSET_01
3drefit -deoblique DSET_01

Now it becomes a bit more difficult/open to decide what to do. I might use 3dresample to send the data to RAI orientation also changing the data so things look the same:


3dresample -orient RAI -input DSET_01 -prefix DSET_02

Now, if you only had a L-R flip to make, you could do “3drefit -orient LAI …” on DSET_02. But you have multiple changes to make, I think; so you run the full set of them here:


3dcopy DSET_02 DSET_03
3drefit -orient <your choice of orient> DSET_03

Note that here, I have often used “LSP”, “LIP” or “RIP”, depending on the scanner and original orientation.

At the end, you might want to run this to put the coord origin in the center of the grid:


@Align_Centers -base "RAI:0,0,0" -grid -dset DSET_03 -prefix DSET_04

… or to put it at the dset center of mass, run:


3dCM -set 0 0 0 -automask DSET_03

–pt

Hello Paul,

yes, this is exactly what I am trying to do (the “center of mass” part was also part of my process :)-D).

I am working here with PET FDG dataset on rats, that I believe are in sphinx position (that would make a lot of sense).
However, I am not sure I understand the purpose of the command


3dresample -orient RAI -input DSET_01 -prefix DSET_02

When I apply it (as advised), and then


3dcopy DSET_02 DSET_03
3drefit -orient LIP DSET_03

it seems that the good orientation for 3drefit is: LIP and not LSP anymore.
In this case, L and Right are not changed.

This is where it gets tricky for me:

I don’t understand the purpose of:


3dresample -orient RAI -input DSET_01 -prefix DSET_02

and so, why does applying it, change I to S in 3drefit when compared to my original dataset? and so LR…

Are there any issues applying directly the command 3drefit as I did previously?
(


3drefit -orient LSP -deoblique

)
thank you!

Hi, Clement-

Glad to know the purpose of this—de-sphinxifying.

The reason for 3dresample is that I find it easier to think about using the change in dataset orientation for the purpose of desphinxifying when starting from a “simple” orientation where the L-R axis is in the spot of the x-coord, the A-P axis in that of the y-coord and the I-S axis in that of the z-coord. 3dresample doesn’t do any altering of the data’s appearance, it just sets the header to be more easily visualizable. I still find that useful, from a human point of view. Also, the reason I could recommend a possible way to desphinxify is because I tend to ‘reset’ the orientation to RAI before trying to use orientation to change the way things appear.

So, taking things in steps, and integrating the orientation you said was useful:


# copy the data and remove obliquity
3dcopy DSET_00 DSET_01
3drefit -deoblique DSET_01

# reset the orientation to something simple
3dresample -orient RAI -input DSET_01 -prefix DSET_02

# change the header orientation information to rearrange how the dataset appears
3dcopy DSET_02 DSET_03
3drefit -orient LIP DSET_03

# get a reasonable center of coordinate grid in the center-of-mass of the dset
3dCM -set 0 0 0 -automask DSET_03

–pt

Thank you for your answer pt,
That clarifys the process,
However, I am still not sure which one is the true right and left. Also, link to my first inquiry, I still struggle to understand why 3dresemple change the outcome of this.
Thanks again.

The 3dresample step is not necessary, but it makes this more of a predictable change. If the values on the original grid are shuffled around such that it is as if the original scanner orientation was RAI, then the sphinx position correction should always be the same 3drefit command, which Paul is saying should use -orient LIP. Without the resample step, Paul would not know what to suggest for 3drefit -orient.

At this point, if you are positive of where right is in the original data, that should come out correctly after those operations.

Note that if the obliquity is huge, i.e. more than 45 degrees, it might break this process.

  • rick

Thank you both for your responses,
I think the reason why I could not understand the purpose of:


# reset the orientation to something simple
3dresample -orient RAI -input DSET_01 -prefix DSET_02

is because we may not use the same method to redefine the correct orientation.
What I am doing, is that I identify the brain orientation of y=1 and z=1.

For example in my case:
y=1 correspond to superior (S)
and
z=1 correspond to posterior (P)
original orientation was LPI,

So the new orientation should be either RSP or LSP (I had meaningful results)
Does that seem fine to you?

I was confused with:


# reset the orientation to something simple
3dresample -orient RAI -input DSET_01 -prefix DSET_02

because with my method, 3dresample actually changes the outcome of the “3drefit” since with my image x=1 becomes x=82, y=1 becomes y=64 and z do not change. In consequence, if 3dresemple is applied before orientating the axes base on x=1, z=1, y=1,


-orient RAI

reversed the LR axis (x=1 becomes x=82) since the original orient was LPI.

Three questions related to my original question:

1 - Is the method that I used valid?

2 - if yes,
In my example:

original orientation was LPI
y=1 correspond to the superior part of the brain
z=1 correspond to the inferior part of the brain
the authors said reverse LR

For now this command did work perfectly to reorient SI and PA axis


3drefit -orient LSP -deoblique

except that I still struggle to identify if left and right should be switched?

3 - Maybe ptaylor method with


# reset the orientation to something simple
3dresample -orient RAI -input DSET_01 -prefix DSET_02

help with that issue and I should use it, however, I don’t understand how based on the DSET_02, you define what to put in -orient (of 3drefit) if not based on x=1, z=1…

Sorry of all these questions but I can’t be 100% of what is L and R, without understanding fully the process,

thank you again for your help!

Also,
to start answering question 3 (I may have understood a bit or maybe not (:P))

The idea with the ptaylor strategy is that whatever is the original orientation specified by the scanner (or the header)
if the animal was in sphinx position and if you reorient the dataset in RAI with


# reset the orientation to something simple
3dresample -orient RAI -input DSET_01 -prefix DSET_02

the second step will always be:


# change the header orientation information to rearrange how the dataset appears
3dcopy DSET_02 DSET_03
3drefit -orient LIP DSET_03

or “RIP” if in radiological orientation (LR reversed)


# change the header orientation information to rearrange how the dataset appears
3dcopy DSET_02 DSET_03
3drefit -orient RIP DSET_03

however, I remain confused because ptaylor said:
“Note that here, I have often used “LSP”, “LIP” or “RIP”, depending on the scanner and original orientation.”

To complete these:

I have 3 datasets where the original orientation was RAI for 2 species (pigs and dogs) and LPI in another one (mouse lemurs)
The correct correction (except for LR since I don’t know) was:


3dresample -orient RAI -input DSET_01 -prefix DSET_02
3drefit -orient LSP DSET_03

and 2 species (mice, rats) where the original orientation was LPI.
The correct correction (except for LR since I don’t know) was:


3dresample -orient RAI -input DSET_01 -prefix DSET_02
3drefit -orient LIP DSET_03

Hi, Clement-

I’m a little confused. I guess the main question is: do you know which hemisphere is the participant’s, say, left side of the brain when you open the initial/raw/unchanged dataset? If the answer to that is “yes” (and I hope it is), then it should be fine to verify the final choice of re-orientation.

There are different paths to go through with the altering the header. The one I suggested makes sense to me for being able to reuse over time and a similar protocol.

–pt

I think you are right,
the info I was getting on which hemisphere is which was not clear.
I will test a dataset with noticeable differences LR to check and resolve that issue.
Thank you again and sorry for the confusion =) :)-D

Hi, Clement-

It is always good if you can set up this kind of workflow with a very clear example to test+verify it on first.

You can also do something like use 3dcalc to make 1 hemisphere clearly demarcated. For example, the following will output a copy of the input dataset where all values with x-coord>0 are replaced by 1s:


3dcalc -a DSET -expr 'step(x)*a + not(step(x))*1' -prefix DSET_HALF_ONES

This might be useful to make one hemisphere of a(n origin-centered, RAI-like-oriented) dataset clearly demarcated for testing. You can change the boolean criterion from step(x) to anything else useful, too.

–pt