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  

SUMA_3dCRUISEtoAFNI.c

Go to the documentation of this file.
00001 #include "SUMA_suma.h"
00002 
00003 SUMA_SurfaceViewer *SUMAg_cSV = NULL; /*!< Global pointer to current Surface Viewer structure*/
00004 SUMA_SurfaceViewer *SUMAg_SVv = NULL; /*!< Global pointer to the vector containing the various Surface Viewer Structures 
00005                                     SUMAg_SVv contains SUMA_MAX_SURF_VIEWERS structures */
00006 int SUMAg_N_SVv = 0; /*!< Number of SVs realized by X */
00007 SUMA_DO *SUMAg_DOv = NULL;   /*!< Global pointer to Displayable Object structure vector*/
00008 int SUMAg_N_DOv = 0; /*!< Number of DOs stored in DOv */
00009 SUMA_CommonFields *SUMAg_CF = NULL; /*!< Global pointer to structure containing info common to all viewers */
00010 
00011 void usage_3dCRUISEtoAFNI (SUMA_GENERIC_ARGV_PARSE *ps)
00012 {
00013       static char FuncName[]={"usage_3dCRUISEtoAFNI"};
00014       char * s = NULL, *sio=NULL, *st = NULL, *sts = NULL;
00015       int i;
00016       s = SUMA_help_basics();
00017       sio  = SUMA_help_IO_Args(ps);
00018       printf ( "\n"
00019                "Usage: 3dCRUISEtoAFNI -input CRUISE_HEADER.dx\n"
00020                " Converts a CRUISE dataset defined by a heder in OpenDX format\n"
00021                " The conversion is based on sample data and information\n"
00022                " provided by Aaron Carass from JHU's IACL iacl.ece.jhu.edu\n" 
00023                "%s"
00024                "%s"
00025                "\n", sio,  s);
00026       SUMA_free(s); s = NULL; SUMA_free(st); st = NULL; SUMA_free(sio); sio = NULL;       
00027       s = SUMA_New_Additions(0, 1); printf("%s\n", s);SUMA_free(s); s = NULL;
00028       printf("       Ziad S. Saad SSCC/NIMH/NIH ziad@nih.gov     \n");
00029       exit(0);
00030 }
00031 
00032 SUMA_GENERIC_PROG_OPTIONS_STRUCT *SUMA_3dCRUISEtoAFNI_ParseInput(char *argv[], int argc, SUMA_GENERIC_ARGV_PARSE *ps)
00033 {
00034    static char FuncName[]={"SUMA_BrainWrap_ParseInput"}; 
00035    SUMA_GENERIC_PROG_OPTIONS_STRUCT *Opt=NULL;
00036    int kar;
00037    SUMA_Boolean brk;
00038    SUMA_Boolean LocalHead = NOPE;
00039 
00040    SUMA_ENTRY;
00041    
00042    Opt = SUMA_Alloc_Generic_Prog_Options_Struct();
00043    kar = 1;
00044    brk = NOPE;
00045         while (kar < argc) { /* loop accross command ine options */
00046                 /*fprintf(stdout, "%s verbose: Parsing command line...\n", FuncName);*/
00047                 if (strcmp(argv[kar], "-h") == 0 || strcmp(argv[kar], "-help") == 0) {
00048                          usage_3dCRUISEtoAFNI(ps);
00049           exit (0);
00050                 }
00051                 
00052                 SUMA_SKIP_COMMON_OPTIONS(brk, kar);
00053       
00054       if (!brk && (strcmp(argv[kar], "-input") == 0)) {
00055          kar ++;
00056                         if (kar >= argc)  {
00057                                 fprintf (SUMA_STDERR, "need argument after -input\n");
00058                                 exit (1);
00059                         }
00060          Opt->in_name = argv[kar];
00061                         brk = YUP;
00062                 }
00063       if (!brk && (strcmp(argv[kar], "-debug") == 0)) {
00064          kar ++;
00065                         if (kar >= argc)  {
00066                                 fprintf (SUMA_STDERR, "need integer argument after -debug\n");
00067                                 exit (1);
00068                         }
00069          Opt->debug = atoi(argv[kar]);
00070                         brk = YUP;
00071                 }
00072       
00073       if (!brk && !ps->arg_checked[kar]) {
00074                         fprintf (SUMA_STDERR,"Error %s:\nOption %s not understood. Try -help for usage\n", FuncName, argv[kar]);
00075                         exit (1);
00076                 } else {        
00077                         brk = NOPE;
00078                         kar ++;
00079                 }
00080    }
00081    
00082    SUMA_RETURN(Opt);
00083 }
00084 
00085 
00086 int main (int argc,char *argv[])
00087 {/* Main */    
00088    static char FuncName[]={"3dCRUISEtoAFNI"}; 
00089    SUMA_GENERIC_PROG_OPTIONS_STRUCT *Opt;  
00090    SUMA_GENERIC_ARGV_PARSE *ps=NULL;
00091    SUMA_OPEN_DX_STRUCT **dx = NULL;
00092    THD_3dim_dataset *dset=NULL;
00093    char *sto3d = NULL;
00094    SUMA_Boolean LocalHead = NOPE;
00095 
00096         SUMA_mainENTRY;
00097    SUMA_STANDALONE_INIT;
00098 
00099    /* Allocate space for DO structure */
00100         SUMAg_DOv = SUMA_Alloc_DisplayObject_Struct (SUMA_MAX_DISPLAYABLE_OBJECTS);
00101    ps = SUMA_Parse_IO_Args(argc, argv, "");
00102    
00103    if (argc < 2) {
00104       usage_3dCRUISEtoAFNI(ps);
00105       exit (1);
00106    }
00107    
00108    Opt = SUMA_3dCRUISEtoAFNI_ParseInput (argv, argc, ps);
00109 
00110    if (Opt->debug > 2) LocalHead = YUP;
00111    
00112    dset = EDIT_empty_copy( NULL ) ;
00113    tross_Make_History( "3dCRUISEtoAFNI" , argc,argv , dset) ;
00114    if (!(sto3d = SUMA_OpenDX_Read_CruiseVolHead(Opt->in_name, dset, 1))) {
00115       if (Opt->debug) SUMA_SL_Err("Failed in SUMA_OpenDX_Read_CruiseVolHead");
00116       exit(1);   
00117    }
00118    if (dset) {
00119       SUMA_LH("Writing Dset");
00120       DSET_write(dset) ;
00121       if (LocalHead) { 
00122          fprintf(SUMA_STDERR,"%s: Can use the following command to create dset with to3d:\n%s\n", FuncName,sto3d); 
00123       } 
00124    } else {
00125       /* the olde way */
00126       if (system(sto3d)) {
00127          fprintf(SUMA_STDERR, "Error %s: Failed while executing shell command:\n%s\n"
00128                               "Check to3d's error messages, and disk writing permissions.\n", FuncName, sto3d);
00129       }
00130    }
00131    
00132    
00133       
00134    if (sto3d) SUMA_free(sto3d); sto3d = NULL;
00135    if (dset) { DSET_delete(dset); dset = NULL; }
00136    if (Opt) Opt = SUMA_Free_Generic_Prog_Options_Struct(Opt);
00137    if (!SUMA_Free_CommonFields(SUMAg_CF)) SUMA_error_message(FuncName,"SUMAg_CF Cleanup Failed!",1);
00138    exit(0);
00139    
00140 } 
 

Powered by Plone

This site conforms to the following standards: