Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
3dAFNItoMINC.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 , *fname ;
00007 int narg=1 , flags=0 , ii ;
00008
00009 if( argc < 2 || strcmp(argv[1],"-help") == 0 ){
00010 printf("Usage: 3dAFNItoMINC [options] dataset\n"
00011 "Reads in an AFNI dataset, and writes it out as a MINC file.\n"
00012 "\n"
00013 "OPTIONS:\n"
00014 " -prefix ppp = Write result into file ppp.mnc;\n"
00015 " default prefix is same as AFNI dataset's.\n"
00016 " -floatize = Write MINC file in float format.\n"
00017 "\n"
00018 "NOTES:\n"
00019 "* Multi-brick datasets are written as 4D (x,y,z,t) MINC\n"
00020 " files.\n"
00021 "* If the dataset has complex-valued sub-bricks, then this\n"
00022 " program won't write the MINC file.\n"
00023 "* If any of the sub-bricks have floating point scale\n"
00024 " factors attached, then the output will be in float\n"
00025 " format (regardless of the presence of -floatize).\n"
00026 "* This program uses the MNI program 'rawtominc' to create\n"
00027 " the MINC file; rawtominc must be in your path. If you\n"
00028 " don't have rawtominc, you must install the MINC tools\n"
00029 " software package from MNI. (But if you don't have the\n"
00030 " MINC tools already, why do you want to convert to MINC\n"
00031 " format anyway?)\n"
00032 "* At this time, you can find the MINC tools at\n"
00033 " ftp://ftp.bic.mni.mcgill.ca/pub/minc/\n"
00034 " You need the latest version of minc-*.tar.gz and also\n"
00035 " of netcdf-*.tar.gz.\n"
00036 "\n"
00037 "-- RWCox - April 2002\n"
00038 ) ;
00039 exit(0) ;
00040 }
00041
00042 mainENTRY("3dAFNItoMINC main"); machdep(); PRINT_VERSION("3dAFNItoMINC");
00043
00044 while( narg < argc && argv[narg][0] == '-' ){
00045
00046 if( strcmp(argv[narg],"-prefix") == 0 ){
00047 prefix = argv[++narg] ;
00048 if( !THD_filename_ok(prefix) || prefix[0] == '-' ){
00049 fprintf(stderr,"** Prefix string is illegal: %s\n",prefix) ;
00050 exit(1) ;
00051 }
00052 narg++ ; continue ;
00053 }
00054
00055 if( strcmp(argv[narg],"-floatize") == 0 ){
00056 flags |= MINC_FLOATIZE_MASK ;
00057 narg++ ; continue ;
00058 }
00059
00060 fprintf(stderr,"** ERROR: unknown option: %s\n",argv[narg]); exit(1);
00061 }
00062
00063 if( narg >= argc ){
00064 fprintf(stderr,"** ERROR: no dataset on command line?\n"); exit(1);
00065 }
00066
00067 dset = THD_open_dataset( argv[narg] ) ;
00068 if( !ISVALID_DSET(dset) ){
00069 fprintf(stderr,"** ERROR: can't open dataset %s\n",argv[narg]); exit(1);
00070 }
00071
00072 if( prefix == NULL ) prefix = DSET_PREFIX(dset) ;
00073
00074 fname = malloc( strlen(prefix)+16 ) ;
00075 strcpy(fname,prefix) ;
00076 if( strstr(fname,".mnc") == NULL ) strcat(fname,".mnc") ;
00077
00078 ii = THD_write_minc( fname , dset , flags ) ;
00079 exit(0) ;
00080 }