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_editdaxes.c File Reference

#include "mrilib.h"
#include "thd.h"

Go to the source code of this file.


Functions

void THD_edit_dataxes (float resam, THD_dataxes *daxes, THD_dataxes *wod_daxes)

Function Documentation

void THD_edit_dataxes float    resam,
THD_dataxes   daxes,
THD_dataxes   wod_daxes
 

Definition at line 15 of file thd_editdaxes.c.

References ISVALID_DATAXES, THD_dataxes::nxx, THD_dataxes::nyy, THD_dataxes::nzz, THD_dataxes::xxdel, THD_dataxes::xxmax, THD_dataxes::xxmin, THD_dataxes::xxorg, THD_dataxes::yydel, THD_dataxes::yymax, THD_dataxes::yymin, THD_dataxes::yyorg, THD_dataxes::zzdel, THD_dataxes::zzmax, THD_dataxes::zzmin, and THD_dataxes::zzorg.

Referenced by AFNI_do_many_writes(), AFNI_setup_viewing(), AFNI_write_dataset_CB(), and main().

00017 {
00018    float lxx , lyy , lzz ;
00019    float rex , rey , rez ;
00020 
00021    if( ! ISVALID_DATAXES(daxes) || ! ISVALID_DATAXES(wod_daxes) ) return ;
00022 
00023    *wod_daxes = *daxes ;       /* copy insides, then edit them */
00024 
00025    if( resam <= 0.0 ) return ; /* error */
00026 
00027    rex = (daxes->xxdel > 0) ? resam : -resam ;  /* signed resampled */
00028    rey = (daxes->yydel > 0) ? resam : -resam ;  /* voxel sizes */
00029    rez = (daxes->zzdel > 0) ? resam : -resam ;
00030 
00031    lxx = daxes->nxx * daxes->xxdel ;    /* signed lengths of data box */
00032    lyy = daxes->nyy * daxes->yydel ;
00033    lzz = daxes->nzz * daxes->zzdel ;
00034 
00035    wod_daxes->nxx = (int)( lxx/rex + 0.499 ) ;  /* new dimensions */
00036    wod_daxes->nyy = (int)( lyy/rey + 0.499 ) ;  /* (will be > 0) */
00037    wod_daxes->nzz = (int)( lzz/rez + 0.499 ) ;
00038 
00039    /* go to old middle, then back out to get new edge */
00040 
00041    wod_daxes->xxorg = daxes->xxorg + 0.5*(lxx - daxes->xxdel)
00042                                    - 0.5*(wod_daxes->nxx - 1)*rex ;
00043 
00044    wod_daxes->yyorg = daxes->yyorg + 0.5*(lyy - daxes->yydel)
00045                                    - 0.5*(wod_daxes->nyy - 1)*rey ;
00046 
00047    wod_daxes->zzorg = daxes->zzorg + 0.5*(lzz - daxes->zzdel)
00048                                    - 0.5*(wod_daxes->nzz - 1)*rez ;
00049 
00050    /* new dimensions of the voxels */
00051 
00052    wod_daxes->xxdel = rex ;
00053    wod_daxes->yydel = rey ;
00054    wod_daxes->zzdel = rez ;
00055 
00056    /* do the bounding box thing again */
00057 
00058    wod_daxes->xxmin = wod_daxes->xxorg ;
00059    wod_daxes->xxmax = wod_daxes->xxorg + (wod_daxes->nxx-1)*wod_daxes->xxdel ;
00060    if( wod_daxes->xxmin > wod_daxes->xxmax ){
00061       float temp = wod_daxes->xxmin ;
00062       wod_daxes->xxmin = wod_daxes->xxmax ; wod_daxes->xxmax = temp ;
00063    }
00064 
00065    wod_daxes->yymin = wod_daxes->yyorg ;
00066    wod_daxes->yymax = wod_daxes->yyorg + (wod_daxes->nyy-1)*wod_daxes->yydel ;
00067    if( wod_daxes->yymin > wod_daxes->yymax ){
00068       float temp = wod_daxes->yymin ;
00069       wod_daxes->yymin = wod_daxes->yymax ; wod_daxes->yymax = temp ;
00070    }
00071 
00072    wod_daxes->zzmin = wod_daxes->zzorg ;
00073    wod_daxes->zzmax = wod_daxes->zzorg + (wod_daxes->nzz-1)*wod_daxes->zzdel ;
00074    if( wod_daxes->zzmin > wod_daxes->zzmax ){
00075       float temp = wod_daxes->zzmin ;
00076       wod_daxes->zzmin = wod_daxes->zzmax ; wod_daxes->zzmax = temp ;
00077    }
00078 
00079 #ifdef EXTEND_BBOX
00080    wod_daxes->xxmin -= 0.5 * wod_daxes->xxdel ;
00081    wod_daxes->xxmax += 0.5 * wod_daxes->xxdel ;
00082    wod_daxes->yymin -= 0.5 * wod_daxes->yydel ;
00083    wod_daxes->yymax += 0.5 * wod_daxes->yydel ;
00084    wod_daxes->zzmin -= 0.5 * wod_daxes->zzdel ;
00085    wod_daxes->zzmax += 0.5 * wod_daxes->zzdel ;
00086 #endif
00087 
00088    return ;
00089 }
 

Powered by Plone

This site conforms to the following standards: