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  

3dAFNIto3D.c

Go to the documentation of this file.
00001 #include "mrilib.h"
00002 
00003 int main( int argc , char *argv[] )
00004 {
00005    THD_3dim_dataset *dset ;
00006    char *prefix=NULL ;
00007    int narg=1 , ii ;
00008 
00009    if( argc < 2 || strcmp(argv[1],"-help") == 0 ){
00010       printf("Usage: 3dAFNIto3D [options] dataset\n"
00011              "Reads in an AFNI dataset, and writes it out as a 3D file.\n"
00012              "\n"
00013              "OPTIONS:\n"
00014              " -prefix ppp  = Write result into file ppp.3D;\n"
00015              "                  default prefix is same as AFNI dataset's.\n"
00016              " -bin         = Write data in binary format, not text.\n"
00017              " -txt         = Write data in text format, not binary.\n"
00018              "\n"
00019              "NOTES:\n"
00020              "* At present, all bricks are written out in float format.\n"
00021             ) ;
00022       exit(0) ;
00023    }
00024 
00025    mainENTRY("3dAFNIto3D main"); machdep(); PRINT_VERSION("3dAFNIto3D");
00026 
00027    while( narg < argc && argv[narg][0] == '-' ){
00028 
00029      if( strncmp(argv[narg],"-bin",4) == 0 ){         /* 03 Jun 2005 */
00030        (void) AFNI_setenv( "AFNI_3D_BINARY  YES" ) ;
00031        narg++ ; continue ;
00032      }
00033 
00034      if( strcmp(argv[narg],"-txt") == 0 || strcmp(argv[narg],"-text") == 0 ){
00035        (void) AFNI_setenv( "AFNI_3D_BINARY  NO" ) ;
00036        narg++ ; continue ;
00037      }
00038 
00039      if( strcmp(argv[narg],"-prefix") == 0 ){
00040         prefix = argv[++narg] ;
00041         if( !THD_filename_ok(prefix) || prefix[0] == '-' ){
00042           fprintf(stderr,"** Prefix string is illegal: %s\n",prefix) ;
00043           exit(1) ;
00044         }
00045         narg++ ; continue ;
00046      }
00047 
00048      fprintf(stderr,"** ERROR: unknown option: %s\n",argv[narg]); exit(1);
00049    }
00050 
00051    if( narg >= argc ){
00052      fprintf(stderr,"** ERROR: no dataset on command line?\n"); exit(1);
00053    }
00054 
00055    dset = THD_open_dataset( argv[narg] ) ;
00056    if( !ISVALID_DSET(dset) ){
00057      fprintf(stderr,"** ERROR: can't open dataset %s\n",argv[narg]); exit(1);
00058    }
00059    DSET_load(dset) ;
00060    if( !DSET_LOADED(dset) ){
00061      fprintf(stderr,"** ERROR: can't load dataset %s\n",argv[narg]); exit(1);
00062    }
00063    if( prefix == NULL ){                       /* 03 Jun 2005 */
00064      prefix = strdup( DSET_PREFIX(dset) ) ;
00065      if( STRING_HAS_SUFFIX(prefix,".1D") ){    /* don't overwrite .1D files! */
00066        char *cpt = strstr(prefix,".1D") ;
00067        strcpy(cpt,".3D") ;
00068      }
00069    }
00070 
00071    THD_use_3D_format( 1 ) ;
00072    THD_write_3dim_dataset( NULL , prefix , dset , True ) ;
00073    THD_use_3D_format( 0 ) ;
00074    exit(0) ;
00075 }
 

Powered by Plone

This site conforms to the following standards: