Doxygen Source Code Documentation
3dMINCtoAFNI.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Functions | |
int | main (int argc, char *argv[]) |
Function Documentation
|
---------- Adapted from 3dZeropad.c by RWCox - 08 Aug 2001 ----------* Definition at line 3 of file 3dMINCtoAFNI.c. References ADN_none, ADN_prefix, argc, THD_3dim_dataset::dblk, THD_datablock::diskptr, DSET_BRIKNAME, DSET_IS_MINC, DSET_load, DSET_LOADED, DSET_write, EDIT_dset_items(), THD_3dim_dataset::idcode, MCW_new_idcode, STORAGE_BY_BRICK, THD_diskptr::storage_mode, THD_filename_ok(), THD_open_minc(), and tross_Make_History().
00004 { 00005 THD_3dim_dataset *dset ; 00006 char *prefix ; 00007 int narg=1 ; 00008 00009 if( argc < 2 || strcmp(argv[1],"-help") == 0 ){ 00010 printf("Usage: 3dMINCtoAFNI [-prefix ppp] dataset.mnc\n" 00011 "Reads in a MINC formatted file and writes it out as an\n" 00012 "AFNI dataset file pair with the given prefix. If the\n" 00013 "prefix option isn't used, the input filename will be\n" 00014 "used, after the '.mnc' is chopped off.\n" 00015 "\n" 00016 "NOTES:\n" 00017 "* Setting environment variable AFNI_MINC_FLOATIZE to Yes\n" 00018 " will cause MINC datasets to be converted to floats on\n" 00019 " input. Otherwise, they will be kept in their 'native'\n" 00020 " data type if possible, which may cause problems with\n" 00021 " scaling on occasion.\n" 00022 "* The TR recorded in MINC files is often incorrect. You may\n" 00023 " need to fix this (or other parameters) using 3drefit.\n" 00024 ) ; 00025 exit(0) ; 00026 } 00027 00028 if( strcmp(argv[narg],"-prefix") == 0 ){ 00029 prefix = argv[++narg] ; 00030 if( !THD_filename_ok(prefix) ){ 00031 fprintf(stderr,"** Prefix string is illegal: %s\n",prefix) ; 00032 exit(1) ; 00033 } 00034 narg++ ; 00035 } else { 00036 int ii ; 00037 prefix = strdup(argv[narg]) ; 00038 ii = strlen(prefix) ; 00039 if( ii > 5 ) prefix[ii-4] = '\0' ; 00040 if( !THD_filename_ok(prefix) ){ 00041 fprintf(stderr,"** Prefix string is illegal: %s\n",prefix) ; 00042 exit(1) ; 00043 } 00044 } 00045 00046 dset = THD_open_minc( argv[narg] ) ; 00047 if( dset == NULL ){ 00048 fprintf(stderr,"** Can't open dataset %s\n",argv[narg]) ; 00049 exit(1) ; 00050 } 00051 if( !DSET_IS_MINC(dset) ){ 00052 fprintf(stderr,"** Not a MINC dataset: %s\n",argv[narg]) ; 00053 exit(1) ; 00054 } 00055 DSET_load(dset) ; 00056 if( !DSET_LOADED(dset) ){ 00057 fprintf(stderr,"** Can't read MINC dataset %s\n",argv[narg]) ; 00058 exit(1) ; 00059 } 00060 00061 EDIT_dset_items( dset , ADN_prefix,prefix , ADN_none ) ; 00062 dset->idcode = MCW_new_idcode() ; 00063 00064 dset->dblk->diskptr->storage_mode = STORAGE_BY_BRICK ; 00065 00066 tross_Make_History( "3dMINCtoAFNI" , argc,argv , dset ) ; 00067 00068 DSET_write(dset) ; 00069 fprintf(stderr,"++ Wrote dataset %s\n",DSET_BRIKNAME(dset)) ; 00070 exit(0) ; 00071 } |