/* This program is meant be run withOUT SUMA's .hness and libraries */ #ifdef SUMA_COMPILED #undef SUMA_COMPILED #endif #include #include #include #include #include #include #include "mrilib.h" #include "niml.h" #include "../niml/niml_private.h" #include "xutil.h" #include "SUMA_suma.h" void SUMA_TestDataSets_Usage() {/*Usage*/ printf ("\nUsage: \n"); printf ("\t ..... \n\n"); printf ("\t\t\t Ziad S. Saad SSCC/NIMH/NIH saadz@mail.nih.gov \t" "Thu May 29 14:42:58 EDT 2003 \n"); exit (0); }/*Usage*/ int main (int argc,char *argv[]) {/* Main */ static char FuncName[]={"SUMA_TestDataSets-Main-"}; char *VolParName, *specfilename = NULL; int kar, *Node = NULL, N_Node=-1; int SurfIn, brk, LocalHead = 1; /* Example 1: 5 nodes, 3 floats per node */ SUMA_STANDALONE_INIT; SUMA_mainENTRY; /* Work the options */ kar = 1; brk = 0; while (kar < argc) { /* loop accross command line options */ /*fprintf(stdout, "%s verbose: Parsing command line...\n", FuncName);*/ if (strcmp(argv[kar], "-h") == 0 || strcmp(argv[kar], "-help") == 0) { SUMA_TestDataSets_Usage (); exit (1); } SUMA_SKIP_COMMON_OPTIONS(brk, kar); if (!brk) { fprintf (stderr, "Error %s: Option %s not understood. Try -help for usage\n", FuncName, argv[kar]); exit (1); } else { brk = 0; kar ++; } }/* loop accross command ine options */ /* Say you want to save a bunch of node values */ { /* BEGIN: Test to save a data set with a bunch of node values */ int i, i3, *node = NULL, N_Node; float *r=NULL, *g=NULL, *b=NULL, *rgb=NULL; char stmp[500], idcode[50], **s; NI_element *nel=NULL; NI_stream ns; int found = 0, NoStride = 0; UNIQ_idcode_fill (idcode); /* let us create some colors to go on each node */ N_Node = 50; node = (int *)SUMA_malloc(N_Node * sizeof(int)); r = (float *)SUMA_malloc(N_Node * sizeof(float)); g = (float *)SUMA_malloc(N_Node * sizeof(float)); b = (float *)SUMA_malloc(N_Node * sizeof(float)); s = (char **)SUMA_malloc(N_Node * sizeof(char *)); for (i=0; iname, SUMA_Dset_Type(nel->name)); /* What are the columns's types and attributes ? */ for (i=0; i < nel->vec_num; ++i) { sprintf(stmp,"TypeCol_%d", i); fprintf (stderr,"\tColumn %d's name: %s\n", i, NI_get_attribute(nel, stmp)); sprintf(stmp,"attrCol_%d", i); fprintf (stderr,"\tColumn %d's attribute: %s\n", i, NI_get_attribute(nel, stmp)); } /* I want the pointer to the green column but do not know its index */ { int j, *iv, N_i; float *fp; fprintf (stderr,"---Looking for green column ---\n"); iv = SUMA_GetColIndex (nel, SUMA_NODE_G, &N_i); if (!iv) { fprintf (stderr,"Error %s: Failed to find column.\n" , FuncName); } else { fprintf (stderr,"\t%d columns of type SUMA_NODE_G found.\n", N_i); if (N_i) { fprintf (stderr,"\tReporting values at index %d\n", iv[0]); fp = (float *)nel->vec[iv[0]]; /* I know we only have one such col. here */ for (j=0; j < nel->vec_len; ++j) { fprintf (stderr,"%f, ", fp[j]); } SUMA_free(iv); iv = NULL; } } } /* free nel */ NI_free_element(nel) ; nel = NULL; if (LocalHead) fprintf(stderr," %s:-\nFrenching ...\n", FuncName); /* free other stuff */ if (r) SUMA_free(r); r = NULL; if (g) SUMA_free(g); g = NULL; if (b) SUMA_free(b); b = NULL; if (rgb) SUMA_free(rgb); rgb = NULL; if (node) SUMA_free(node); node = NULL; if (s) { for (i=0; i