Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

thd_mnicoords.c

Go to the documentation of this file.
00001 #include "mrilib.h"
00002 
00003 /*-----------------------------------------------------------------------*/
00004 /*! Convert MNI coordinates (LPI) to TT Atlas coordinates (RAI);
00005     cf. http://www.mrc-cbu.cam.ac.uk/Imaging/mnispace.html.
00006 -------------------------------------------------------------------------*/
00007 
00008 THD_fvec3 THD_mni_to_tta( THD_fvec3 mv )
00009 {
00010    float mx,my,mz , tx,ty,tz ;
00011    THD_fvec3 tv ;
00012 
00013    mx = mv.xyz[0] ; my = mv.xyz[1] ; mz = mv.xyz[2] ;
00014 
00015    tx = 0.99 * mx ;
00016 
00017    if( mz > 0.0 ){
00018      ty =  0.9688 * my + 0.0460 * mz ;
00019      tz = -0.0485 * my + 0.9189 * mz ;
00020    } else {
00021      ty =  0.9688 * my + 0.0420 * mz ;
00022      tz = -0.0485 * my + 0.8390 * mz ;
00023    }
00024 
00025    tx = -tx ; ty = -ty ;         /* flip x,y from LPI to RAI */
00026 
00027    LOAD_FVEC3( tv , tx,ty,tz ) ; return tv ;
00028 }
00029 
00030 /*-----------------------------------------------------------------------*/
00031 /*! Convert TTA coordinates (RAI) to MNI coordinates (LPI).
00032 -------------------------------------------------------------------------*/
00033 
00034 THD_fvec3 THD_tta_to_mni( THD_fvec3 tv )
00035 {
00036    float mx,my,mz , tx,ty,tz ;
00037    THD_fvec3 mv ;
00038 
00039    tx = -tv.xyz[0] ; ty = -tv.xyz[1] ;  /* flip xy from RAI to LPI */
00040    tz =  tv.xyz[2] ;
00041 
00042    mx = 1.01010 * tx ;
00043    my = 1.02962 * ty - 0.05154 * tz ;
00044    mz = 0.05434 * ty + 1.08554 * tz ;
00045    if( mz < 0.0 ) mz *= 1.09523 ;
00046    LOAD_FVEC3( mv , mx,my,mz ) ; return mv ;
00047 }
00048 
00049 /*-----------------------------------------------------------------------*/
00050 
00051 void THD_3tta_to_3mni( float *x , float *y , float *z )
00052 {
00053    THD_fvec3 mv , tv ;
00054    LOAD_FVEC3( tv , *x,*y,*z ) ;
00055    mv = THD_tta_to_mni( tv ) ;
00056    *x = mv.xyz[0] ; *y = mv.xyz[1] ; *z = mv.xyz[2] ; return ;
00057 }
00058 
00059 void THD_3mni_to_3tta( float *x , float *y , float *z )
00060 {
00061    THD_fvec3 mv , tv ;
00062    LOAD_FVEC3( mv , *x,*y,*z ) ;
00063    tv = THD_mni_to_tta( mv ) ;
00064    *x = tv.xyz[0] ; *y = tv.xyz[1] ; *z = tv.xyz[2] ; return ;
00065 }
 

Powered by Plone

This site conforms to the following standards: