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_center.c

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------
00002   01 Feb 2001: compute the center of a dataset (DICOM coord order)
00003   Adapted from part of thd_info.c -- RWCox
00004 -----------------------------------------------------------------------*/
00005 
00006 #include "mrilib.h"
00007 
00008 THD_fvec3 THD_dataset_center( THD_3dim_dataset * dset )
00009 {
00010    THD_dataxes * daxes ;
00011    THD_fvec3 fv1 , fv2 ;
00012 
00013 ENTRY("THD_dataset_center") ;
00014 
00015    if( !ISVALID_DSET(dset) ){ LOAD_FVEC3(fv1,0,0,0); RETURN(fv1); }
00016 
00017    daxes = dset->daxes ;
00018 
00019    LOAD_FVEC3(fv1 , daxes->xxorg , daxes->yyorg , daxes->zzorg) ;
00020    fv1 = THD_3dmm_to_dicomm( dset , fv1 ) ;
00021 
00022    LOAD_FVEC3(fv2 , daxes->xxorg + (daxes->nxx-1)*daxes->xxdel ,
00023                     daxes->yyorg + (daxes->nyy-1)*daxes->yydel ,
00024                     daxes->zzorg + (daxes->nzz-1)*daxes->zzdel  ) ;
00025    fv2 = THD_3dmm_to_dicomm( dset , fv2 ) ;
00026 
00027    fv1.xyz[0] = 0.5*(fv1.xyz[0]+fv2.xyz[0]) ;
00028    fv1.xyz[1] = 0.5*(fv1.xyz[1]+fv2.xyz[1]) ;
00029    fv1.xyz[2] = 0.5*(fv1.xyz[2]+fv2.xyz[2]) ;
00030 
00031    RETURN(fv1) ;
00032 }
 

Powered by Plone

This site conforms to the following standards: