Hi, I wouldn't use convert_xfm or avscale for this at all. You can align images based on the orientation information by doing: flirt -in imageA -ref imageB -usesqform -applyxfm -out imageA2B -omat imageA2B.mat All the best, Mark On 18 Dec 2012, at 18:54, Lazar Fleysher <[log in to unmask]> wrote: > Dear Mark Jenkinson > > I am trying to overlay, not coregister two images based on orientation information. > Image A has matrix A > Image B-matrix B > I want to compute B*inv(A) using > convert_xfm and feed the result to flirt to get the overlay. > I reasoned matrices A and B can be obtained with avscale. > This is when I stumbled on the problem. > Is there a better way to do overlay? > > Thanks > Lazar > > On Dec 18, 2012 10:18 AM, "Lazar Fleysher" <[log in to unmask]> wrote: > Dear Stephen Smith > > Thank you for your clarifications. > unfortunately, I think I did not pose my question correctly. > > Yes output of avscale is different from fslhd to take into account scaling. > > But, it looks like avscale flipped directions of axes (see my example). I would think that direction of translation should also change, but it did not. otherwise,i cannot understand what avscale its doing. I do not understand why it flipped the axes... > > The reason I asked is that I used avscale-generated translation/rotation matrix in my script and got wrong results. I traced it back to (what I think is) an inconsistency between rotation and translation as output by avscale..other explanation is that I do not understand the output of avscale at all. That is why I am asking for help on this. > > Thank you again > > lazar > > On Dec 17, 2012 7:57 PM, "Lazar Fleysher" <[log in to unmask]> wrote: > Hello > > I cannot seem to understand what avscale output should be. > The documentation of the function is rather terse. > > I would think that one of the outputs of > avscale (orientation and translation matrix) > should be simialr to that of > > fslhd | grep sto_xyz > > Of course, the difference is that in fslhd the orientation matrix is scaled by > the pixel size. > > However, It looks to me that avscale changes the direction of axes. > This of course > is not a problem, but then, the translations have to be changed also > and it does not change that. > > example: > > here is the output of fslhd|grep sto_xyz voxel size is 3x3x3.75 > > > -2.998657 0.000000 0.112186 101.292267 > -0.014799 2.958933 -0.618085 -87.238136 > 0.088520 0.494690 3.697010 -41.763031 > 0.000000 0.000000 0.000000 1.000000 > > avscale acts on this matrix and outputs > > -0.999552 0.000000 0.029916 101.292267 > -0.004933 -0.986311 -0.164823 -87.238136 > 0.029507 -0.164897 0.985869 -41.763031 > 0.000000 0.000000 0.000000 1.000000 > > Notice that the sign of the second column is reversed, but nothing is > done to translation. > The question is that I cannot seem to understand what the output of > avscale should be. > > Thank you very much for your help > > Lazar