Doxygen Source Code Documentation
thd_timeof.c
Go to the documentation of this file.00001 /***************************************************************************** 00002 Major portions of this software are copyrighted by the Medical College 00003 of Wisconsin, 1994-2000, and are released under the Gnu General Public 00004 License, Version 2. See the file README.Copyright for details. 00005 ******************************************************************************/ 00006 00007 #include "mrilib.h" 00008 #include "thd.h" 00009 00010 00011 /***************************************************************** 00012 Time at the z-coordinate "z", at the it-th time step 00013 ******************************************************************/ 00014 00015 float THD_timeof( int it, float z, THD_timeaxis * tax ) 00016 { 00017 float sl , tof ; 00018 int isl ; 00019 00020 if( ! ISVALID_TIMEAXIS(tax) ) return 0.0 ; 00021 00022 tof = tax->ttorg + it * tax->ttdel ; 00023 00024 if( tax->nsl <= 0 || tax->toff_sl == NULL ) return tof ; 00025 00026 isl = (z - tax->zorg_sl) / tax->dz_sl + 0.5 ; 00027 00028 if( isl < 0 || isl >= tax->nsl ) return tof ; 00029 00030 return tof + tax->toff_sl[isl] ; 00031 } 00032 00033 /*-------------------------------------------------------------- 00034 Get the time at voxel # nvox, at the it-th time step. 00035 22 July 1998 -- RWCox 00036 ----------------------------------------------------------------*/ 00037 00038 float THD_timeof_vox( int it , int nvox , THD_3dim_dataset * dset ) 00039 { 00040 float sl , tof ; 00041 int isl ; 00042 00043 if( !ISVALID_DSET(dset) || !ISVALID_TIMEAXIS(dset->taxis) ) return 0.0 ; 00044 00045 tof = dset->taxis->ttorg + it * dset->taxis->ttdel ; 00046 00047 if( dset->taxis->nsl <= 0 || dset->taxis->toff_sl == NULL ) return tof ; 00048 00049 isl = nvox / ( DSET_NX(dset) * DSET_NY(dset) ) ; 00050 00051 if( isl < 0 || isl >= dset->taxis->nsl ) return tof ; 00052 00053 return tof + dset->taxis->toff_sl[isl] ; 00054 } 00055 00056 00057 /*---------------------------------------------------------------------------*/ 00058 /* 00059 Get the time at slice # isl, at the it-th time step. 00060 21 October 1999 -- B.D.Ward 00061 */ 00062 00063 float THD_timeof_slice( int it , int isl , THD_3dim_dataset * dset ) 00064 { 00065 float tof ; 00066 00067 if( !ISVALID_DSET(dset) || !ISVALID_TIMEAXIS(dset->taxis) ) return 0.0 ; 00068 00069 tof = dset->taxis->ttorg + it * dset->taxis->ttdel ; 00070 00071 if( dset->taxis->nsl <= 0 || dset->taxis->toff_sl == NULL ) return tof ; 00072 00073 if( isl < 0 || isl >= dset->taxis->nsl ) return tof ; 00074 00075 return tof + dset->taxis->toff_sl[isl] ; 00076 }