Doxygen Source Code Documentation
SUMA_3dVol2Surf.h File Reference
Go to the source code of this file.
Define Documentation
|
Definition at line 4 of file SUMA_3dVol2Surf.h. |
|
Definition at line 12 of file SUMA_3dVol2Surf.h. Referenced by init_options(). |
|
Definition at line 13 of file SUMA_3dVol2Surf.h. |
|
Definition at line 15 of file SUMA_3dVol2Surf.h. Referenced by set_smap_opts(). |
|
Definition at line 8 of file SUMA_3dVol2Surf.h. Referenced by init_options(), and usage(). |
|
Definition at line 9 of file SUMA_3dVol2Surf.h. Referenced by init_options(), and usage(). |
|
Definition at line 6 of file SUMA_3dVol2Surf.h. Referenced by init_options(), and usage(). |
|
Definition at line 7 of file SUMA_3dVol2Surf.h. Referenced by init_options(), and usage(). |
|
Definition at line 10 of file SUMA_3dVol2Surf.h. Referenced by init_options(), usage(), and validate_options(). |
Function Documentation
|
Definition at line 2092 of file SUMA_3dSurf2Vol.c. References c, dt, ENTRY, and RETURN. Referenced by set_smap_opts().
02093 { 02094 int c, dt = -1; 02095 02096 ENTRY("check_datum_type"); 02097 02098 if ( datum_str ) 02099 { 02100 for ( c = 0; c <= MRI_rgba; c++ ) 02101 if ( ! strcmp( datum_str, MRI_TYPE_name[c] ) ) 02102 { 02103 dt = c; 02104 break; 02105 } 02106 02107 /* if we didn't find the requested type, inform the user and quit */ 02108 if ( c > MRI_rgba ) 02109 { 02110 fprintf( stderr, "** invalid datum type name '%s'\n", 02111 datum_str ); 02112 RETURN(-1); 02113 } 02114 } 02115 else 02116 { 02117 dt = default_type; 02118 } 02119 02120 if ( ( dt != MRI_byte ) && 02121 ( dt != MRI_short ) && 02122 ( dt != MRI_float ) && 02123 ( dt != MRI_double ) ) 02124 { 02125 fprintf( stderr, "** data type '%s' is not supported\n", 02126 MRI_TYPE_name[dt] ); 02127 RETURN(-1); 02128 } 02129 02130 RETURN(dt); 02131 } |
|
Definition at line 2141 of file SUMA_3dSurf2Vol.c. References E_SMAP_MEDIAN, E_SMAP_MIDPT, E_SMAP_MODE, E_SMAP_SEG_VALS, ENTRY, RETURN, s2v_map_type(), and v2s_map_type(). Referenced by set_smap_opts(), and validate_options().
02142 { 02143 int map; 02144 02145 ENTRY("check_map_func"); 02146 02147 if ( map_str == NULL ) 02148 { 02149 fprintf( stderr, "** missing option: '-map_func FUNCTION'\n" ); 02150 RETURN(E_SMAP_INVALID); 02151 } 02152 02153 map = s2v_map_type( map_str ); 02154 02155 if ( map == E_SMAP_INVALID ) 02156 { 02157 fprintf( stderr, "** invalid map string '%s'\n", map_str ); 02158 RETURN(-1); 02159 } 02160 02161 RETURN(map); 02162 } |
|
Definition at line 387 of file SUMA_3dVol2Surf.c. References c, v2s_opts_t::debug, ENTRY, SUMA_surface::ixyz, SUMA_surface::norm, v2s_opts_t::norm_len, SUMA_surface::num_ixyz, p, RETURN, v2s_param_t::surf, SUMA_ixyz::x, THD_fvec3::xyz, SUMA_ixyz::y, and SUMA_ixyz::z. Referenced by get_surf_data().
00388 { 00389 SUMA_ixyz * coords; 00390 THD_fvec3 * norms; 00391 float fmin[3], fmax[3]; 00392 int min[3], max[3]; 00393 int match[6]; /* +/- 1, for direction match */ 00394 int node, c, ncount; 00395 00396 ENTRY("check_norm_dirs"); 00397 00398 norms = p->surf[surf].norm; /* point to norms for this surface */ 00399 coords = p->surf[surf].ixyz; /* point to coords for this surface */ 00400 00401 /* init mins and max's from node 0 */ 00402 min[0] = max[0] = min[1] = max[1] = min[2] = max[2] = 0; 00403 00404 fmin[0] = fmax[0] = coords->x; 00405 fmin[1] = fmax[1] = coords->y; 00406 fmin[2] = fmax[2] = coords->z; 00407 00408 /* now check the rest of them */ 00409 for ( node = 1; node < p->surf[surf].num_ixyz; node++, coords++ ) 00410 { 00411 if ( fmin[0] > coords[node].x ) /* x min */ 00412 { 00413 min [0] = node; 00414 fmin[0] = coords[node].x; 00415 } 00416 if ( fmax[0] < coords[node].x ) /* x max */ 00417 { 00418 max [0] = node; 00419 fmax[0] = coords[node].x; 00420 } 00421 00422 if ( fmin[1] > coords[node].y ) /* y min */ 00423 { 00424 min [1] = node; 00425 fmin[1] = coords[node].y; 00426 } 00427 if ( fmax[1] < coords[node].y ) /* y max */ 00428 { 00429 max [1] = node; 00430 fmax[1] = coords[node].y; 00431 } 00432 00433 if ( fmin[2] > coords[node].z ) /* z min */ 00434 { 00435 min [2] = node; 00436 fmin[2] = coords[node].z; 00437 } 00438 if ( fmax[2] < coords[node].z ) /* z max */ 00439 { 00440 max [2] = node; 00441 fmax[2] = coords[node].z; 00442 } 00443 } 00444 00445 if ( sopt->debug > 1 ) 00446 fprintf(stderr,"++ normals:\n" 00447 " mins : %d, %d, %d\n" 00448 " min coords : %f, %f, %f\n" 00449 " mins0 : %f, %f, %f\n" 00450 " mins1 : %f, %f, %f\n" 00451 " mins2 : %f, %f, %f\n" 00452 "\n" 00453 " maxs : %d, %d, %d\n" 00454 " max coords : %f, %f, %f\n" 00455 " maxs0 : %f, %f, %f\n" 00456 " maxs1 : %f, %f, %f\n" 00457 " maxs2 : %f, %f, %f\n", 00458 min[0], min[1], min[2], 00459 fmin[0], fmin[1], fmin[2], 00460 coords[min[0]].x, coords[min[0]].y, coords[min[0]].z, 00461 coords[min[1]].x, coords[min[1]].y, coords[min[1]].z, 00462 coords[min[2]].x, coords[min[2]].y, coords[min[2]].z, 00463 max[0], max[1], max[2], 00464 fmax[0], fmax[1], fmax[2], 00465 coords[max[0]].x, coords[max[0]].y, coords[max[0]].z, 00466 coords[max[1]].x, coords[max[1]].y, coords[max[1]].z, 00467 coords[max[2]].x, coords[max[2]].y, coords[max[2]].z); 00468 00469 /* now count the number of normals pointing "away from" the center */ 00470 /* fixed directions - inconsistent usage 07 Apr 2004 [rickr] */ 00471 match[0] = norms[min[0]].xyz[0] < 0; 00472 match[1] = norms[min[1]].xyz[1] < 0; 00473 match[2] = norms[min[2]].xyz[2] < 0; 00474 00475 match[3] = norms[max[0]].xyz[0] > 0; 00476 match[4] = norms[max[1]].xyz[1] > 0; 00477 match[5] = norms[max[2]].xyz[2] > 0; 00478 00479 if ( sopt->debug > 1 ) 00480 fprintf(stderr,"-- matches[0..5] = (%d, %d, %d, %d, %d, %d)\n", 00481 match[0], match[1], match[2], match[3], match[4], match[5] ); 00482 00483 ncount = 0; 00484 for ( c = 0; c < 6; c++ ) 00485 if ( match[c] ) 00486 ncount++; 00487 00488 /* do we fail? */ 00489 if ( (ncount >= 2) && (ncount <= 4) ) 00490 { 00491 fprintf(stderr, "** cannot determine directions for normals:\n" 00492 " To proceed, use one of -keep_norm_dir/-reverse_norm_dir.\n" 00493 " \n" 00494 " It is ~%d%% likely that you will want to negate the\n" 00495 " normal length in '-norm_len'\n", 00496 (int)(100*ncount/6.0) ); 00497 RETURN(-1); 00498 } 00499 00500 /* or do we just warn the user? */ 00501 if ( (ncount == 1) || (ncount == 5) ) 00502 fprintf(stderr,"** warning: only 83%% sure of direction of normals\n"); 00503 00504 /* do we need to reverse the direction? */ 00505 if ( ncount < 2 ) 00506 { 00507 fprintf(stderr,"-- reversing direction of normals\n"); 00508 sopt->norm_len *= -1.0; 00509 } 00510 00511 RETURN(0); 00512 } |
|
Definition at line 1457 of file SUMA_3dVol2Surf.c. References ENTRY, opts_t::outfile_1D, opts_t::outfile_niml, p, RETURN, and THD_is_file(). Referenced by validate_options().
01458 { 01459 ENTRY("check_outfile"); 01460 01461 if ( opts == NULL || p == NULL ) 01462 RETURN(-1); 01463 01464 if ( THD_is_file(opts->outfile_1D) ) 01465 { 01466 fprintf(stderr, "** output file '%s' already exists\n", 01467 opts->outfile_1D); 01468 RETURN(-1); 01469 } 01470 01471 if ( THD_is_file(opts->outfile_niml) ) 01472 { 01473 fprintf(stderr, "** output file '%s' already exists\n", 01474 opts->outfile_niml); 01475 RETURN(-1); 01476 } 01477 01478 RETURN(0); 01479 } |
|
Definition at line 524 of file SUMA_3dVol2Surf.c. References calloc, v2s_opts_t::debug, ENTRY, free, get_mappable_surfs(), v2s_param_t::nsurf, p, RETURN, suma2afni_surf(), surf_ave_radius(), and V2S_MAX_SURFS. Referenced by get_surf_data().
00525 { 00526 SUMA_SurfaceObject ** so; 00527 float radius[V2S_MAX_SURFS]; 00528 int rv, sindex; 00529 00530 ENTRY("copy_surfaces"); 00531 00532 if ( sopt == NULL || p == NULL || nsurf < 0 ) 00533 { 00534 fprintf( stderr, "** anl: bad params (%p,%p,%d)\n", sopt, p, nsurf ); 00535 RETURN(-1); 00536 } 00537 00538 /* create a temporary list of surface pointers */ 00539 so = (SUMA_SurfaceObject **)calloc(nsurf, sizeof(SUMA_SurfaceObject *)); 00540 if ( so == NULL ) 00541 { 00542 fprintf( stderr, "** anl: failed to alloc %d surf pointers\n", nsurf ); 00543 RETURN(-1); 00544 } 00545 00546 if ( (rv = get_mappable_surfs( so, nsurf, sopt->debug )) != nsurf ) 00547 { 00548 fprintf( stderr, "** found %d mappable surfaces (but expected %d)\n", 00549 rv, nsurf ); 00550 free(so); 00551 RETURN(-1); 00552 } 00553 00554 /* fill SUMA_surface structs */ 00555 00556 p->nsurf = nsurf; 00557 for ( sindex = 0; sindex < nsurf; sindex++ ) 00558 { 00559 if ( suma2afni_surf( sopt, p, so[sindex], sindex ) ) 00560 RETURN(-1); 00561 surf_ave_radius(radius+sindex, so[sindex], sopt->debug); 00562 } 00563 00564 if ( sopt->debug ) fprintf(stderr,"-- surfaces converted: suma to afni\n"); 00565 00566 free(so); 00567 00568 RETURN(0); 00569 } |
|
|
|
Definition at line 2377 of file SUMA_SurfMeasures.c.
02378 { 02379 if ( info ) 02380 fputs( info, stderr ); 02381 02382 if ( ! d ) 02383 { 02384 fprintf(stderr,"** disp_opts_t: d == NULL\n"); 02385 return -1; 02386 } 02387 02388 fprintf(stderr, 02389 "opts_t struct at %p:\n" 02390 " spec_file = %s\n" 02391 " sv_file = %s\n" 02392 " out_1D_file = %s\n" 02393 " cmask_cmd = %s\n" 02394 " nodes_1D_file = %s\n" 02395 " surf_names[0,1] = %s, %s\n" 02396 " info = %0x\n" 02397 " debug, dnode = %d, %d\n", 02398 d, 02399 CHECK_NULL_STR(d->spec_file), 02400 CHECK_NULL_STR(d->sv_file), 02401 CHECK_NULL_STR(d->out_1D_file), 02402 CHECK_NULL_STR(d->cmask_cmd), 02403 CHECK_NULL_STR(d->nodes_1D_file), 02404 CHECK_NULL_STR(d->surf_names[0]), 02405 CHECK_NULL_STR(d->surf_names[1]), 02406 d->info, d->debug, d->dnode); 02407 02408 return 0; 02409 } |
|
Definition at line 877 of file SUMA_3dVol2Surf.c. References v2s_param_t::cmask, opts_t::debug, ENTRY, free, SUMA_surface::ixyz, SUMA_surface::norm, v2s_param_t::nsurf, p, RETURN, SUMA_Free_CommonFields(), SUMA_Free_Displayable_Object_Vect(), SUMA_Free_SurfaceViewer_Struct_Vect(), SUMAg_N_DOv, SUMAg_N_SVv, and v2s_param_t::surf. Referenced by main().
00878 { 00879 int surf; 00880 ENTRY("final_clean_up"); 00881 00882 for ( surf = 0; surf < p->nsurf; surf++ ) 00883 { 00884 if ( opts->debug > 2 ) fprintf(stderr,"-- freeing nodes[%d]\n",surf); 00885 if ( p->surf[surf].ixyz ) free(p->surf[surf].ixyz); 00886 if ( opts->debug > 2 ) fprintf(stderr,"-- freeing norms[%d]\n",surf); 00887 if ( p->surf[surf].norm ) free(p->surf[surf].norm); 00888 } 00889 00890 if ( p->cmask ) free(p->cmask); 00891 00892 if ( opts->debug > 2 ) fprintf(stderr,"-- freeing DOV\n"); 00893 if ( ( SUMAg_DOv != NULL ) && 00894 ( SUMA_Free_Displayable_Object_Vect(SUMAg_DOv, SUMAg_N_DOv) == 0 ) ) 00895 fprintf(stderr, "** failed SUMA_Free_Displayable_Object_Vect()\n" ); 00896 00897 if ( opts->debug > 2 ) fprintf(stderr,"-- freeing SVSV\n"); 00898 if ( ( SUMAg_SVv != NULL ) && 00899 ( SUMA_Free_SurfaceViewer_Struct_Vect(SUMAg_SVv, SUMAg_N_SVv) == 0 ) ) 00900 fprintf( stderr, "** failed SUMA_Free_SurfaceViewer_Struct_Vect()\n" ); 00901 00902 if ( opts->debug > 2 ) fprintf(stderr,"-- freeing CF\n"); 00903 if ( ( SUMAg_CF != NULL ) && ( SUMA_Free_CommonFields(SUMAg_CF) == 0 ) ) 00904 fprintf( stderr, "** failed SUMA_Free_CommonFields()\n" ); 00905 00906 if ( opts->debug > 1 ) fprintf(stderr,"-- freeing complete\n"); 00907 00908 RETURN(0); 00909 } |
|
Definition at line 1138 of file SUMA_3dSurf2Vol.c. References SUMA_SurfaceObject::AnatCorrect, CHECK_NULL_STR, ENTRY, SUMA_SurfaceObject::Label, SUMA_DO::OP, RETURN, SUMA_isSO(), SUMA_Print_Surface_Object(), and SUMAg_N_DOv. Referenced by copy_surfaces(), and surf_to_node_list().
01139 { 01140 SUMA_SurfaceObject * so; 01141 int count, socount = 0; 01142 01143 ENTRY("get_mappable_surfts"); 01144 01145 if ( slist == NULL ) 01146 { 01147 fprintf( stderr, "** gms: missing slist!\n" ); 01148 RETURN(-1); 01149 } 01150 01151 for ( count = 0; count < SUMAg_N_DOv; count++ ) 01152 { 01153 if ( ! SUMA_isSO(SUMAg_DOv[count]) ) 01154 continue; 01155 01156 so = (SUMA_SurfaceObject *)SUMAg_DOv[count].OP; 01157 01158 if ( ! so->AnatCorrect ) 01159 { 01160 if ( debug ) 01161 fprintf(stderr,"-- surf #%d '%s', anat not correct, skipping\n", 01162 socount, CHECK_NULL_STR(so->Label)); 01163 if ( debug > 1 ) 01164 fprintf(stderr,"** consider adding the following to the " 01165 "surface definition in the spec file:\n" 01166 " Anatomical = Y\n"); 01167 continue; 01168 } 01169 01170 if ( debug > 1 ) 01171 { 01172 fprintf( stderr, "\n---------- surface #%d '%s' -----------\n", 01173 socount, CHECK_NULL_STR(so->Label) ); 01174 SUMA_Print_Surface_Object( so, stderr ); 01175 } 01176 01177 if ( socount < how_many ) /* store a good surface */ 01178 slist[socount] = so; 01179 01180 socount++; 01181 } 01182 01183 if ( debug > 1 ) 01184 fprintf( stderr, "++ found %d mappable surfaces\n", socount ); 01185 01186 RETURN(socount); 01187 } |
|
Definition at line 329 of file SUMA_3dVol2Surf.c. References check_norm_dirs(), CHECK_NULL_STR, copy_surfaces(), v2s_opts_t::debug, ENTRY, SUMA_surface::label, v2s_opts_t::map, SUMA_surface::norm, v2s_opts_t::norm_dir, v2s_opts_t::norm_len, p, RETURN, v2s_param_t::surf, v2s_opts_t::use_norms, V2S_NORM_DEFAULT, and V2S_NORM_REVERSE.
00330 { 00331 int nsurf = 2; 00332 00333 ENTRY("get_surf_data"); 00334 00335 if ( sopt == NULL || p == NULL ) 00336 { 00337 fprintf( stderr, "** cnl - bad params (%p,%p)\n", sopt, p ); 00338 RETURN(-1); 00339 } 00340 00341 if ( (sopt->map == E_SMAP_MASK) || sopt->use_norms ) 00342 nsurf = 1; 00343 00344 if ( copy_surfaces( sopt, p, nsurf ) ) 00345 RETURN(-1); 00346 00347 if ( sopt->use_norms ) 00348 { 00349 if ( ! p->surf[0].norm ) 00350 { 00351 fprintf(stderr,"** failure: surface '%s' has no normal list\n", 00352 CHECK_NULL_STR(p->surf[0].label)); 00353 RETURN(-1); 00354 } 00355 00356 if ((sopt->norm_dir == V2S_NORM_DEFAULT) && check_norm_dirs(sopt, p, 0)) 00357 RETURN(-1); 00358 else if ( sopt->norm_dir == V2S_NORM_REVERSE) 00359 { 00360 /* okay, reverse the direction */ 00361 sopt->norm_len *= -1; 00362 if ( sopt->debug > 0 ) 00363 fprintf(stderr,"++ reversing normal direction\n"); 00364 } 00365 /* else V2S_NORM_KEEP, i.e. do nothing */ 00366 } 00367 00368 RETURN(0); 00369 } |
|
Definition at line 1387 of file SUMA_SurfMeasures.c.
01388 { 01389 int ac, ind; 01390 01391 ENTRY("init_options"); 01392 01393 if ( argc < 2 ) 01394 RETURN( usage(PROG_NAME, ST_USE_LONG) ); 01395 01396 /* init the structure to empty */ 01397 if ( init_opts_t(opts) != 0 ) 01398 RETURN(-1); 01399 01400 for ( ac = 1; ac < argc; ac++ ) 01401 { 01402 if ( ! strncmp(argv[ac], "-debug", 6) ) 01403 { 01404 CHECK_ARG_COUNT(ac,"option usage: -debug LEVEL\n"); 01405 01406 opts->debug = atoi(argv[++ac]); 01407 if ( opts->debug < 0 || opts->debug > ST_DEBUG_MAX_LEVEL ) 01408 { 01409 fprintf(stderr,"** bad debug level %d, should be in [0,%d]\n", 01410 opts->debug, ST_DEBUG_MAX_LEVEL); 01411 RETURN(-1); 01412 } 01413 } 01414 else if ( ! strncmp(argv[ac], "-cmask", 6) ) 01415 { 01416 CHECK_ARG_COUNT(ac,"option usage: -cmask COMMAND\n"); 01417 opts->cmask_cmd = argv[++ac]; 01418 } 01419 else if ( ! strncmp(argv[ac], "-dnode", 6) ) 01420 { 01421 CHECK_ARG_COUNT(ac,"option usage: -dnode NODE_NUM\n"); 01422 opts->dnode = atoi(argv[++ac]); 01423 } 01424 else if ( ! strncmp(argv[ac], "-func", 5) ) 01425 { 01426 CHECK_ARG_COUNT(ac,"option usage: -func FUNCTION\n"); 01427 ++ac; 01428 if ( add_to_flist(&opts->F, argv[ac]) != 0 ) 01429 RETURN(-1); 01430 } 01431 else if ( ! strncmp(argv[ac], "-help", 5) ) 01432 RETURN(usage(PROG_NAME, ST_USE_LONG)); 01433 else if ( ! strncmp(argv[ac], "-hist", 5) ) 01434 RETURN(usage(PROG_NAME, ST_USE_HIST)); 01435 else if ( ! strncmp(argv[ac], "-info_all",9) ) 01436 { 01437 opts->info |= ST_INFO_ALL; 01438 } 01439 else if ( ! strncmp(argv[ac], "-info_area",10) ) 01440 { 01441 opts->info |= ST_INFO_AREA; 01442 } 01443 else if ( ! strncmp(argv[ac], "-info_norms",10) ) 01444 { 01445 opts->info |= ST_INFO_NORMS; 01446 } 01447 else if ( ! strncmp(argv[ac], "-info_thick",11) ) 01448 { 01449 opts->info |= ST_INFO_THICK; 01450 } 01451 else if ( ! strncmp(argv[ac], "-info_vol",9) ) 01452 { 01453 opts->info |= ST_INFO_VOL; 01454 } 01455 else if ( ! strncmp(argv[ac], "-nodes_1D", 9) ) 01456 { 01457 CHECK_ARG_COUNT(ac,"option usage: -nodes_1D NODE_LIST_FILE\n"); 01458 opts->nodes_1D_file = argv[++ac]; 01459 } 01460 else if ( ! strncmp(argv[ac], "-out_1D", 7) ) 01461 { 01462 CHECK_ARG_COUNT(ac,"option usage: -out_1D OUTPUT_FILE\n"); 01463 opts->out_1D_file = argv[++ac]; 01464 } 01465 else if ( ! strncmp(argv[ac], "-spec", 5) ) 01466 { 01467 CHECK_ARG_COUNT(ac,"option usage: -spec SPEC_FILE\n"); 01468 opts->spec_file = argv[++ac]; 01469 } 01470 else if ( ! strncmp(argv[ac], "-surf_", 6) ) 01471 { 01472 CHECK_ARG_COUNT(ac,"option usage: -surf_X SURF_NAME\n"); 01473 ind = argv[ac][6] - 'A'; 01474 if ( (ind < 0) || (ind >= ST_MAX_SURFS) ) 01475 { 01476 fprintf(stderr,"** -surf_X option '%s' out of range,\n" 01477 " use one of '-surf_A' through '-surf_%c'\n", 01478 argv[ac], 'A'+ST_MAX_SURFS-1); 01479 RETURN(-1); 01480 } 01481 opts->surf_names[ind] = argv[++ac]; 01482 } 01483 else if ( ! strncmp(argv[ac], "-sv", 3) ) 01484 { 01485 CHECK_ARG_COUNT(ac,"option usage: -sv SURF_VOLUME\n"); 01486 opts->sv_file = argv[++ac]; 01487 } 01488 else if ( ! strncmp(argv[ac], "-ver",4) ) 01489 { 01490 RETURN( usage(PROG_NAME, ST_USE_VERSION) ); 01491 } 01492 else 01493 { 01494 fprintf(stderr,"invalid option <%s>\n",argv[ac]); 01495 RETURN( usage(PROG_NAME, ST_USE_SHORT) ); 01496 } 01497 } 01498 01499 RETURN(0); 01500 } |
|
|
|
Definition at line 916 of file SUMA_3dVol2Surf.c. References opts_t::debug, SUMA_CommonFields::DsetList, ENTRY, SUMA_CommonFields::InOut_Notify, SUMA_CommonFields::MemTrace, SUMA_SurfSpecFile::N_Groups, SUMA_SurfSpecFile::N_Surfs, RETURN, opts_t::snames, opts_t::spec_file, SUMA_Alloc_DisplayObject_Struct(), SUMA_Create_CommonFields(), SUMA_LoadSpec_eng(), SUMA_MAX_DISPLAYABLE_OBJECTS, SUMA_Read_SpecFile(), SUMA_ShowSpecStruct(), SUMA_spec_select_surfs(), SUMA_spec_set_map_refs(), SUMAg_N_DOv, opts_t::sv_file, and V2S_MAX_SURFS. Referenced by main().
00917 { 00918 int debug, rv; /* v3.5 [rickr] */ 00919 00920 ENTRY("read_surf_files"); 00921 00922 debug = (opts->debug > 2); 00923 00924 if ( debug ) 00925 fputs( "-- SUMA_Create_CommonFields()...\n", stderr ); 00926 00927 /* initialize common fields struct */ 00928 SUMAg_CF = SUMA_Create_CommonFields(); 00929 00930 if ( SUMAg_CF == NULL ) 00931 { 00932 fprintf( stderr, "** failed SUMA_Create_CommonFields(), exiting...\n" ); 00933 RETURN(-1); 00934 } 00935 00936 /* for SUMA type notifications */ 00937 if ( opts->debug > 3 ) 00938 { 00939 SUMAg_CF->MemTrace = 1; 00940 00941 if ( opts->debug > 4 ) 00942 SUMAg_CF->InOut_Notify = 1; 00943 } 00944 00945 if ( debug ) 00946 fputs( "-- SUMA_Alloc_DisplayObject_Struct()...\n", stderr ); 00947 00948 SUMAg_DOv = SUMA_Alloc_DisplayObject_Struct(SUMA_MAX_DISPLAYABLE_OBJECTS); 00949 00950 if ( debug ) /* can't SUMA_ShowSpecStruct() yet - v3.9 */ 00951 fputs( "-- SUMA_Read_SpecFile()...\n", stderr ); 00952 00953 if ( SUMA_Read_SpecFile( opts->spec_file, spec) == 0 ) 00954 { 00955 fprintf( stderr, "** failed SUMA_Read_SpecFile(), exiting...\n" ); 00956 RETURN(-1); 00957 } 00958 00959 rv = SUMA_spec_select_surfs(spec, opts->snames, V2S_MAX_SURFS, opts->debug); 00960 if ( rv < 1 ) 00961 { 00962 if ( rv == 0 ) 00963 fprintf(stderr,"** no named surfaces found in spec file\n"); 00964 RETURN(-1); 00965 } 00966 00967 if ( debug ) 00968 SUMA_ShowSpecStruct(spec, stderr, opts->debug > 2 ? 3 : 1); 00969 00970 if ( SUMA_spec_set_map_refs(spec, opts->debug) != 0 ) 00971 RETURN(-1); 00972 00973 /* make sure only group was read from spec file */ 00974 if ( spec->N_Groups != 1 ) 00975 { 00976 fprintf( stderr,"** error: N_Groups <%d> must be 1 in spec file <%s>\n", 00977 spec->N_Groups, opts->spec_file ); 00978 RETURN(-1); 00979 } 00980 00981 if ( debug ) 00982 fputs( "-- SUMA_LoadSpec_eng()...\n", stderr ); 00983 00984 /* actually load the surface(s) from the spec file */ 00985 if (SUMA_LoadSpec_eng(spec,SUMAg_DOv,&SUMAg_N_DOv,opts->sv_file,debug, 00986 SUMAg_CF->DsetList) == 0) /* DsetList 26 Mar 2004 [ziad] */ 00987 { 00988 fprintf( stderr, "** error: failed SUMA_LoadSpec_eng(), exiting...\n" ); 00989 RETURN(-1); 00990 } 00991 00992 if ( opts->debug > 1 ) 00993 fprintf(stderr, "++ %d surfaces loaded.\n", spec->N_Surfs ); 00994 00995 RETURN(0); 00996 } |
|
Definition at line 767 of file SUMA_3dVol2Surf.c. References check_map_func(), v2s_param_t::cmask, opts_t::debug, v2s_opts_t::debug, disp_v2s_opts_t(), opts_t::dnode, v2s_opts_t::dnode, E_SMAP_MEDIAN, E_SMAP_MIDPT, E_SMAP_MODE, E_SMAP_SEG_VALS, ENTRY, v2s_opts_t::f_index, opts_t::f_index_str, opts_t::f_p1_fr, v2s_opts_t::f_p1_fr, opts_t::f_p1_mm, v2s_opts_t::f_p1_mm, opts_t::f_pn_fr, v2s_opts_t::f_pn_fr, opts_t::f_pn_mm, v2s_opts_t::f_pn_mm, v2s_opts_t::f_steps, opts_t::f_steps, opts_t::first_node, v2s_opts_t::first_node, opts_t::gp_index, v2s_opts_t::gp_index, opts_t::last_node, v2s_opts_t::last_node, v2s_opts_t::map, opts_t::map_str, opts_t::no_head, v2s_opts_t::no_head, opts_t::norm_dir, v2s_opts_t::norm_dir, opts_t::norm_len, v2s_opts_t::norm_len, opts_t::oob, v2s_opts_t::oob, opts_t::oom, v2s_opts_t::oom, opts_t::outfile_1D, v2s_opts_t::outfile_1D, opts_t::outfile_niml, v2s_opts_t::outfile_niml, v2s_param_t::over_steps, p, RETURN, v2s_oob_t::show, opts_t::skip_cols, v2s_opts_t::skip_cols, opts_t::snames, opts_t::use_norms, v2s_opts_t::use_norms, V2S_INDEX_NODE, V2S_INDEX_VOXEL, V2S_M2_STEPS_DEFAULT, and v2s_vals_over_steps(). Referenced by main().
00768 { 00769 int nsurf = 1; 00770 00771 ENTRY("set_smap_opts"); 00772 00773 memset( sopt, 0, sizeof(*sopt) ); 00774 00775 if ( (sopt->map = check_map_func( opts->map_str )) == E_SMAP_INVALID ) 00776 RETURN(-1); 00777 00778 /* set defaults before checking map type */ 00779 00780 sopt->gp_index = opts->gp_index; 00781 sopt->debug = opts->debug; 00782 sopt->dnode = opts->dnode; 00783 sopt->no_head = opts->no_head; 00784 sopt->skip_cols = opts->skip_cols; 00785 00786 sopt->first_node = opts->first_node > 0 ? opts->first_node : 0; 00787 sopt->last_node = opts->last_node > 0 ? opts->last_node : 0; 00788 if ( sopt->first_node > sopt->last_node ) 00789 { 00790 fprintf(stderr, "** error: -first_node (%d) > -last_node (%d)\n", 00791 sopt->first_node, sopt->last_node); 00792 RETURN(1); 00793 } 00794 00795 sopt->use_norms = opts->use_norms; 00796 sopt->norm_len = opts->norm_len; 00797 sopt->norm_dir = opts->norm_dir; 00798 sopt->f_index = V2S_INDEX_VOXEL; /* default is "voxel" */ 00799 00800 if ( (opts->f_index_str != NULL) && 00801 (!strncmp(opts->f_index_str, "node", 4)) ) 00802 sopt->f_index = V2S_INDEX_NODE; 00803 00804 if ( opts->f_steps <= V2S_M2_STEPS_DEFAULT ) /* default is 2 */ 00805 sopt->f_steps = V2S_M2_STEPS_DEFAULT; 00806 else 00807 sopt->f_steps = opts->f_steps; 00808 00809 sopt->f_p1_fr = opts->f_p1_fr; /* copy fractions & distances */ 00810 sopt->f_pn_fr = opts->f_pn_fr; 00811 sopt->f_p1_mm = opts->f_p1_mm; 00812 sopt->f_pn_mm = opts->f_pn_mm; 00813 sopt->outfile_1D = opts->outfile_1D; 00814 sopt->outfile_niml = opts->outfile_niml; 00815 sopt->oob = opts->oob; /* out of bounds info */ 00816 sopt->oom = opts->oom; /* out of bounds info */ 00817 00818 if ( sopt->oom.show && !p->cmask ) 00819 { 00820 fprintf(stderr,"** '-cmask' option is required with '-oom_value'\n"); 00821 RETURN(1); 00822 } 00823 00824 /* great, now my switch is ineffective - save for later */ 00825 switch (sopt->map) 00826 { 00827 default: 00828 break; 00829 00830 case E_SMAP_AVE: 00831 case E_SMAP_COUNT: 00832 case E_SMAP_MAX: 00833 case E_SMAP_MAX_ABS: 00834 case E_SMAP_MIN: 00835 case E_SMAP_MASK2: 00836 case E_SMAP_SEG_VALS: 00837 case E_SMAP_MEDIAN: 00838 case E_SMAP_MODE: 00839 nsurf = 2; 00840 break; 00841 00842 case E_SMAP_MIDPT: /* continue to SMAP_MASK */ 00843 nsurf = 2; 00844 00845 case E_SMAP_MASK: 00846 if (sopt->f_steps != V2S_M2_STEPS_DEFAULT) 00847 { 00848 fprintf(stderr,"** -f_steps option not valid\n"); 00849 RETURN(-1); 00850 } 00851 00852 /* we will only use the first point in the computation */ 00853 sopt->f_steps = 1; 00854 break; 00855 } 00856 00857 if ( (nsurf == 2) && !opts->snames[1] && !opts->use_norms ) 00858 { 00859 fprintf(stderr, "** function '%s' requires 2 surfaces\n", 00860 gv2s_map_names[sopt->map]); 00861 RETURN(-1); 00862 } 00863 00864 p->over_steps = v2s_vals_over_steps(sopt->map); 00865 00866 if ( opts->debug > 0 ) 00867 disp_v2s_opts_t( "++ smap opts set :", sopt ); 00868 00869 RETURN(0); 00870 } |
|
Definition at line 576 of file SUMA_3dVol2Surf.c. References SUMA_SurfaceObject::Center, v2s_opts_t::debug, ENTRY, free, SUMA_ixyz::id, SUMA_surface::idcode, SUMA_surface::idcode_dset, SUMA_surface::idcode_ldp, SUMA_SurfaceObject::idcode_str, SUMA_surface::ixyz, SUMA_surface::label, SUMA_SurfaceObject::Label, SUMA_surface::label_ldp, SUMA_SurfaceObject::LocalDomainParent, malloc, SUMA_SurfaceObject::MaxDims, SUMA_SurfaceObject::MinDims, SUMA_SurfaceObject::N_Node, SUMA_surface::nall_ijk, SUMA_surface::nall_ixyz, SUMA_SurfaceObject::NodeList, SUMA_SurfaceObject::NodeNormList, SUMA_surface::norm, SUMA_surface::num_ijk, SUMA_surface::num_ixyz, p, RETURN, SUMA_surface::seq, SUMA_surface::seqbase, SUMA_surface::sorted, v2s_param_t::surf, SUMA_surface::type, UNIQ_idcode_fill(), v2s_opts_t::use_norms, V2S_MAX_SURFS, SUMA_surface::vn, SUMA_surface::vv, SUMA_ixyz::x, SUMA_surface::xbot, SUMA_surface::xcen, SUMA_surface::xtop, THD_fvec3::xyz, SUMA_ixyz::y, SUMA_surface::ybot, SUMA_surface::ycen, SUMA_surface::ytop, SUMA_ixyz::z, SUMA_surface::zbot, SUMA_surface::zcen, and SUMA_surface::ztop. Referenced by copy_surfaces().
00578 { 00579 SUMA_surface * sp; 00580 float * fp; 00581 int node; 00582 00583 ENTRY("suma2afni_surf"); 00584 00585 if ( !sopt || !p || !so || sindex < 0 || sindex >= V2S_MAX_SURFS ) 00586 { 00587 fprintf(stderr,"** s2as: bad params (%p,%p,%p,%d)\n",sopt,p,so,sindex); 00588 RETURN(-1); 00589 } 00590 00591 sp = p->surf + sindex; 00592 00593 sp->type = SUMA_SURFACE_TYPE; /* always (for a SUMA_surface) */ 00594 sp->num_ixyz = so->N_Node; /* number of nodes */ 00595 sp->nall_ixyz = so->N_Node; /* allocate later in this function */ 00596 sp->num_ijk = 0; /* no triangles */ 00597 sp->nall_ijk = 0; /* twice as many triangles as before */ 00598 00599 sp->seq = 1; /* surfaces are sequential */ 00600 sp->seqbase = 0; /* - from 0 */ 00601 sp->sorted = 1; /* - and therefore, a sorted lot */ 00602 00603 sp->ixyz = NULL; /* just for the moment ... */ 00604 sp->norm = NULL; 00605 00606 if ( !so->NodeList ) 00607 { 00608 fprintf(stderr,"** s2as: missing surface NodeList for '%s'\n", 00609 so->Label ? so->Label: "<no label>"); 00610 RETURN(1); 00611 } 00612 00613 if ( sopt->use_norms ) 00614 { 00615 if ( so->NodeNormList ) 00616 { 00617 sp->norm = (THD_fvec3 *)malloc(sp->num_ixyz * sizeof(THD_fvec3)); 00618 if ( !sp->norm ) 00619 { 00620 fprintf(stderr,"** s2as: cannot allocate %d THD_fvec3's\n", 00621 sp->num_ixyz); 00622 RETURN(1); 00623 } 00624 00625 if ( sopt->debug > 1 ) 00626 fprintf(stderr,"++ filling in norms for surf # %d (%d bytes)\n", 00627 sindex, (int)(sp->num_ixyz * sizeof(THD_fvec3))); 00628 00629 fp = so->NodeNormList; 00630 for ( node = 0; node < sp->num_ixyz; node++ ) 00631 { 00632 sp->norm[node].xyz[0] = *fp++; 00633 sp->norm[node].xyz[1] = *fp++; 00634 sp->norm[node].xyz[2] = *fp++; 00635 } 00636 } 00637 else 00638 { 00639 fprintf(stderr,"** missing normals for surface # %d, '%s'\n", 00640 sindex, so->Label ? so->Label: "<no label>"); 00641 } 00642 } 00643 00644 sp->ixyz = (SUMA_ixyz *)malloc(sp->num_ixyz * sizeof(SUMA_ixyz)); 00645 00646 if ( !sp->ixyz ) 00647 { 00648 fprintf(stderr,"** failed to allocate %d SUMA_ixyz\n",sp->num_ixyz); 00649 if (sp->norm) free(sp->norm); 00650 RETURN(1); 00651 } 00652 else if ( sopt->debug > 1 ) 00653 fprintf(stderr,"++ s2as: allocated %d SUMA_ixyz nodes (%d bytes)\n", 00654 sp->num_ixyz, (int)(sp->num_ixyz*sizeof(SUMA_ixyz))); 00655 00656 fp = so->NodeList; 00657 for ( node = 0; node < sp->num_ixyz; node++ ) 00658 { 00659 sp->ixyz[node].id = node; 00660 sp->ixyz[node].x = *fp++; 00661 sp->ixyz[node].y = *fp++; 00662 sp->ixyz[node].z = *fp++; 00663 } 00664 00665 sp->xbot = so->MinDims[0]; 00666 sp->ybot = so->MinDims[1]; 00667 sp->zbot = so->MinDims[2]; 00668 00669 sp->xtop = so->MaxDims[0]; 00670 sp->ytop = so->MaxDims[1]; 00671 sp->ztop = so->MaxDims[2]; 00672 00673 sp->xcen = so->Center[0]; 00674 sp->ycen = so->Center[1]; 00675 sp->zcen = so->Center[2]; 00676 00677 if (so->idcode_str) 00678 { 00679 strncpy(sp->idcode, so->idcode_str, 31); 00680 sp->idcode[31] = '\0'; 00681 } 00682 else 00683 UNIQ_idcode_fill(sp->idcode); 00684 00685 sp->idcode_ldp[0] = '\0'; /* maybe assign these ... */ 00686 sp->idcode_dset[0] = '\0'; 00687 00688 strncpy(sp->label, so->Label, 63); sp->label[63] = '\0'; 00689 if (so->LocalDomainParent && *so->LocalDomainParent) 00690 { 00691 strncpy(sp->label_ldp, so->LocalDomainParent, 63); 00692 sp->label[63] = '\0'; 00693 } 00694 else 00695 strcpy(sp->label_ldp, "no_LDP_label"); 00696 00697 sp->vv = NULL; /* no mappings, for now */ 00698 sp->vn = NULL; 00699 00700 RETURN(0); 00701 } |
|
Definition at line 2465 of file SUMA_3dVol2Surf.c. References SUMA_SurfaceObject::Center, ENTRY, SUMA_SurfaceObject::Label, SUMA_SurfaceObject::N_Node, SUMA_SurfaceObject::NodeList, and RETURN. Referenced by copy_surfaces().
02466 { 02467 double ss, sum = 0.0; 02468 float * fp; 02469 float c0, c1, c2; 02470 int node; 02471 02472 ENTRY("surf_ave_radius"); 02473 02474 if ( !so || !radius || so->N_Node <= 0 ) 02475 { 02476 fprintf(stderr, "** disp_sar, so, radius == %p,%p\n", so, radius ); 02477 RETURN(-1); 02478 } 02479 02480 c0 = so->Center[0]; /* for a little speed */ 02481 c1 = so->Center[1]; 02482 c2 = so->Center[2]; 02483 02484 fp = so->NodeList; 02485 for ( node = 0; node < so->N_Node; node++ ) 02486 { 02487 ss = (*fp - c0) * (*fp - c0); fp++; 02488 ss += (*fp - c1) * (*fp - c1); fp++; 02489 ss += (*fp - c2) * (*fp - c2); fp++; 02490 02491 sum += sqrt(ss); 02492 } 02493 02494 *radius = sum/so->N_Node; 02495 02496 if ( disp ) 02497 fprintf(stderr,"-- surf %s has average dist %f\n" 02498 " to center (%f, %f, %f)\n", 02499 so->Label, *radius, c0, c1, c2 ); 02500 02501 RETURN(0); 02502 } |
|
Definition at line 1824 of file SUMA_SurfMeasures.c.
01825 { 01826 int c; 01827 01828 ENTRY("usage"); 01829 01830 if ( use_type == ST_USE_SHORT ) 01831 { 01832 fprintf(stderr,"usage: %s [options] -spec SPEC_FILE -func FUNC_NAME\\\n" 01833 " -out_1D OUTFILE\n", prog); 01834 } 01835 else if ( use_type == ST_USE_LONG ) 01836 { 01837 printf( 01838 "\n" 01839 "%s - compute measures from the surface dataset(s)\n" 01840 "\n" 01841 " usage: %s [options] -spec SPEC_FILE -out_1D OUTFILE.1D\n" 01842 "\n" 01843 " This program is meant to read in a surface or surface pair,\n" 01844 " and to output and user-requested measures over the surfaces.\n" 01845 " The surfaces must be specified in the SPEC_FILE.\n" 01846 "\n" 01847 " ** Use the 'inspec' command for getting information about the\n" 01848 " surfaces in a spec file.\n" 01849 "\n" 01850 " The output will be a 1D format text file, with one column\n" 01851 " (or possibly 3) per user-specified measure function. Some\n" 01852 " functions require only 1 surface, some require 2.\n" 01853 "\n" 01854 " Current functions (applied with '-func') include:\n" 01855 "\n", 01856 prog, prog ); 01857 01858 /* display current list of measures */ 01859 for ( c = E_SM_INVALID + 1; c < E_SM_FINAL; c++ ) 01860 printf( " %-12s : %s\n", g_sm_names[c], g_sm_desc[c]); 01861 01862 printf( 01863 "\n" 01864 "------------------------------------------------------------\n" 01865 "\n" 01866 " examples:\n" 01867 "\n" 01868 " 1. For each node on the surface smoothwm in the spec file,\n" 01869 " fred.spec, output the node number (the default action),\n" 01870 " the xyz coordinates, and the area associated with the\n" 01871 " node (1/3 of the total area of triangles having that node\n" 01872 " as a vertex).\n" 01873 "\n" 01874 " %s \\\n" 01875 " -spec fred1.spec \\\n" 01876 " -sv fred_anat+orig \\\n" 01877 " -surf_A smoothwm \\\n" 01878 " -func coord_A \\\n" 01879 " -func n_area_A \\\n" 01880 " -out_1D fred1_areas.1D \n" 01881 "\n" 01882 " 2. For each node of the surface pair smoothwm and pial,\n" 01883 " display the:\n" 01884 " o node index\n" 01885 " o node's area from the first surface\n" 01886 " o node's area from the second surface\n" 01887 " o node's (approximate) resulting volume\n" 01888 " o thickness at that node (segment distance)\n" 01889 " o coordinates of the first segment node\n" 01890 " o coordinates of the second segment node\n" 01891 "\n" 01892 " Additionally, display total surface areas, minimum and\n" 01893 " maximum thicknesses, and the total volume for the\n" 01894 " cortical ribbon (the sum of node volumes).\n" 01895 "\n" 01896 " %s \\\n" 01897 " -spec fred2.spec \\\n" 01898 " -sv fred_anat+orig \\\n" 01899 " -surf_A smoothwm \\\n" 01900 " -surf_B pial \\\n" 01901 " -func n_area_A \\\n" 01902 " -func n_area_B \\\n" 01903 " -func node_vol \\\n" 01904 " -func thick \\\n" 01905 " -func coord_A \\\n" 01906 " -func coord_B \\\n" 01907 " -info_area \\\n" 01908 " -info_thick \\\n" 01909 " -info_vol \\\n" 01910 " -out_1D fred2_vol.1D \n" 01911 "\n" 01912 " 3. For each node of the surface pair, display the:\n" 01913 " o node index\n" 01914 " o angular diff between the first and second norms\n" 01915 " o angular diff between the segment and first norm\n" 01916 " o angular diff between the segment and second norm\n" 01917 " o the normal vectors for the first surface nodes\n" 01918 " o the normal vectors for the second surface nodes\n" 01919 " o angular diff between the segment and second norm\n" 01920 "\n" 01921 " %s \\\n" 01922 " -spec fred2.spec \\\n" 01923 " -surf_A smoothwm \\\n" 01924 " -surf_B pial \\\n" 01925 " -func ang_norms \\\n" 01926 " -func ang_ns_A \\\n" 01927 " -func ang_ns_B \\\n" 01928 " -func norm_A \\\n" 01929 " -func norm_B \\\n" 01930 " -out_1D fred2_norm_angles.1D \n" 01931 "\n" 01932 " 4. Similar to #3, but output extra debug info, and in\n" 01933 " particular, info regarding node 5000.\n" 01934 "\n" 01935 " %s \\\n" 01936 " -spec fred2.spec \\\n" 01937 " -sv fred_anat+orig \\\n" 01938 " -surf_A smoothwm \\\n" 01939 " -surf_B pial \\\n" 01940 " -func ang_norms \\\n" 01941 " -func ang_ns_A \\\n" 01942 " -func ang_ns_B \\\n" 01943 " -debug 2 \\\n" 01944 " -dnode 5000 \\\n" 01945 " -out_1D fred2_norm_angles.1D \n" 01946 "\n" 01947 " 5. For each node, output the volume, thickness and areas,\n" 01948 " but restrict the nodes to the list contained in column 0\n" 01949 " of file sdata.1D. Furthermore, restrict those nodes to\n" 01950 " the mask inferred by the given '-cmask' option.\n" 01951 "\n" 01952 " %s \\\n" 01953 " -spec fred2.spec \\\n" 01954 " -sv fred_anat+orig \\\n" 01955 " -surf_A smoothwm \\\n" 01956 " -surf_B pial \\\n" 01957 " -func node_vol \\\n" 01958 " -func thick \\\n" 01959 " -func n_area_A \\\n" 01960 " -func n_area_B \\\n" 01961 " -nodes_1D 'sdata.1D[0]' \\\n" 01962 " -cmask '-a sdata.1D[2] -expr step(a-1000)' \\\n" 01963 " -out_1D fred2_masked.1D \n" 01964 "\n" 01965 "------------------------------------------------------------\n" 01966 "\n" 01967 " REQUIRED COMMAND ARGUMENTS:\n" 01968 "\n" 01969 " -spec SPEC_FILE : SUMA spec file\n" 01970 "\n" 01971 " e.g. -spec fred2.spec\n" 01972 "\n" 01973 " The surface specification file contains a list of\n" 01974 " related surfaces. In order for a surface to be\n" 01975 " processed by this program, it must exist in the spec\n" 01976 " file.\n" 01977 "\n" 01978 " -surf_A SURF_NAME : surface name (in spec file)\n" 01979 " -surf_B SURF_NAME : surface name (in spec file)\n" 01980 "\n" 01981 " e.g. -surf_A smoothwm\n" 01982 " e.g. -surf_A lh.smoothwm\n" 01983 " e.g. -surf_B lh.pial\n" 01984 "\n" 01985 " This is used to specify which surface(s) will be used\n" 01986 " by the program. The 'A' and 'B' correspond to other\n" 01987 " program options (e.g. the 'A' in n_area_A).\n" 01988 "\n" 01989 " The '-surf_B' parameter is required only when the user\n" 01990 " wishes to input two surfaces.\n" 01991 "\n" 01992 " Any surface name provided must be unique in the spec\n" 01993 " file, and must match the name of the surface data file\n" 01994 " (e.g. lh.smoothwm.asc).\n" 01995 "\n" 01996 " -out_1D OUT_FILE.1D : 1D output filename\n" 01997 "\n" 01998 " e.g. -out_1D pickle_norm_info.1D\n" 01999 "\n" 02000 " This option is used to specify the name of the output\n" 02001 " file. The output file will be in the 1D ascii format,\n" 02002 " with 2 rows of comments for column headers, and 1 row\n" 02003 " for each node index.\n" 02004 "\n" 02005 " There will be 1 or 3 columns per '-func' option, with\n" 02006 " a default of 1 for \"nodes\".\n" 02007 "\n" 02008 "------------------------------------------------------------\n" 02009 "\n" 02010 " ALPHABETICAL LISTING OF OPTIONS:\n" 02011 "\n" 02012 " -cmask COMMAND : restrict nodes with a mask\n" 02013 "\n" 02014 " e.g. -cmask '-a sdata.1D[2] -expr step(a-1000)'\n" 02015 "\n" 02016 " This option will produce a mask to be applied to the\n" 02017 " list of surface nodes. The total mask size, including\n" 02018 " zero entries, must match the number of nodes. If a\n" 02019 " specific node list is provided via the '-nodes_1D'\n" 02020 " option, then the mask size should match the length of\n" 02021 " the provided node list.\n" 02022 " \n" 02023 " Consider the provided example using the file sdata.1D.\n" 02024 " If a surface has 100000 nodes (and no '-nodes_1D' option\n" 02025 " is used), then there must be 100000 values in column 2\n" 02026 " of the file sdata.1D.\n" 02027 "\n" 02028 " Alternately, if the '-nodes_1D' option is used, giving\n" 02029 " a list of 42 nodes, then the mask length should also be\n" 02030 " 42 (regardless of 0 entries).\n" 02031 "\n" 02032 " See '-nodes_1D' for more information.\n" 02033 "\n" 02034 " -debug LEVEL : display extra run-time info\n" 02035 "\n" 02036 " e.g. -debug 2\n" 02037 " default: -debug 0\n" 02038 "\n" 02039 " Valid debug levels are from 0 to 5.\n" 02040 "\n" 02041 " -dnode NODE : display extra info for node NODE\n" 02042 "\n" 02043 " e.g. -dnode 5000\n" 02044 "\n" 02045 " This option can be used to display extra information\n" 02046 " about node NODE during surface evaluation.\n" 02047 "\n" 02048 " -func FUNCTION : request output for FUNCTION\n" 02049 "\n" 02050 " e.g. -func thick\n" 02051 "\n" 02052 " This option is used to request output for the given\n" 02053 " FUNCTION (measure). Some measures produce one column\n" 02054 " of output (e.g. thick or ang_norms), and some produce\n" 02055 " three (e.g. coord_A). These options, in the order they\n" 02056 " are given, determine the structure of the output file.\n" 02057 "\n" 02058 " Current functions include:\n" 02059 "\n", 02060 prog, prog, prog, prog, prog ); 02061 02062 /* display current list of measures */ 02063 for ( c = E_SM_INVALID + 1; c < E_SM_FINAL; c++ ) 02064 printf( " %-12s : %s\n", g_sm_names[c], g_sm_desc[c]); 02065 02066 printf( 02067 "\n" 02068 " Note that the node volumes are approximations. Places\n" 02069 " where either normal points in the 'wrong' direction\n" 02070 " will be incorrect, as will be the parts of the surface\n" 02071 " that 'encompass' this region. Maybe we could refer\n" 02072 " to this as a mushroom effect...\n" 02073 "\n" 02074 " Basically, expect the total volume to be around 10%%\n" 02075 " too large.\n" 02076 "\n" 02077 " ** for more accuracy, try 'SurfPatch -vol' **\n" 02078 "\n" 02079 " -help : show this help menu\n" 02080 "\n" 02081 " -hist : display program revision history\n" 02082 "\n" 02083 " This option is used to provide a history of changes\n" 02084 " to the program, along with version numbers.\n" 02085 "\n" 02086 " NOTE: the following '-info_XXXX' options are used to display\n" 02087 " pieces of 'aggregate' information about the surface(s).\n" 02088 "\n" 02089 " -info_all : display all final info\n" 02090 "\n" 02091 " This is a short-cut to get all '-info_XXXX' options.\n" 02092 "\n" 02093 " -info_area : display info on surface area(s)\n" 02094 "\n" 02095 " Display the total area of each triangulated surface.\n" 02096 "\n" 02097 " -info_norms : display info about the normals\n" 02098 "\n" 02099 " For 1 or 2 surfaces, this will give (if possible) the\n" 02100 " average angular difference between:\n" 02101 "\n" 02102 " o the normals of the surfaces\n" 02103 " o the connecting segment and the first normal\n" 02104 " o the connecting segment and the second normal\n" 02105 "\n" 02106 " -info_thick : display min and max thickness\n" 02107 "\n" 02108 " For 2 surfaces, this is used to display the minimum and\n" 02109 " maximum distances between the surfaces, along each of\n" 02110 " the connecting segments.\n" 02111 "\n" 02112 " -info_vol : display info about the volume\n" 02113 "\n" 02114 " For 2 surfaces, display the total computed volume.\n" 02115 " Note that this node-wise volume computation is an\n" 02116 " approximation, and tends to run ~10 %% high.\n" 02117 "\n" 02118 " ** for more accuracy, try 'SurfPatch -vol' **\n" 02119 "\n" 02120 " -nodes_1D NODELIST.1D : request output for only these nodes\n" 02121 "\n" 02122 " e.g. -nodes_1D node_index_list.1D\n" 02123 " e.g. -nodes_1D sdata.1D'[0]'\n" 02124 "\n" 02125 " The NODELIST file should contain a list of node indices.\n" 02126 " Output from the program would then be restricted to the\n" 02127 " nodes in the list.\n" 02128 " \n" 02129 " For instance, suppose that the file BA_04.1D contains\n" 02130 " a list of surface nodes that are located in Broadman's\n" 02131 " Area 4. To get output from the nodes in that area, use:\n" 02132 " \n" 02133 " -nodes_1D BA_04.1D\n" 02134 " \n" 02135 " For another example, suppose that the file sdata.1D has\n" 02136 " node indices in column 0, and Broadman's Area indices in\n" 02137 " column 3. To restrict output to the nodes in Broadman's\n" 02138 " area 4, use the pair of options:\n" 02139 " \n" 02140 " -nodes_1D 'sdata.1D[0]' \\\n" 02141 " -cmask '-a sdata.1D[3] -expr (1-bool(a-4))' \n" 02142 "\n" 02143 " -sv SURF_VOLUME : specify an associated AFNI volume\n" 02144 "\n" 02145 " e.g. -sv fred_anat+orig\n" 02146 "\n" 02147 " If there is any need to know the orientation of the\n" 02148 " surface, a surface volume dataset may be provided.\n" 02149 "\n" 02150 " -ver : show version information\n" 02151 "\n" 02152 " Show version and compile date.\n" 02153 "\n" 02154 "------------------------------------------------------------\n" 02155 "\n" 02156 " Author: R. Reynolds - %s\n" 02157 "\n", 02158 VERSION ); 02159 } 02160 else if ( use_type == ST_USE_HIST ) 02161 { 02162 fputs (g_history, stdout); 02163 } 02164 else if ( use_type == ST_USE_VERSION ) 02165 { 02166 printf("%s: %s, compile date: %s\n", prog, VERSION, __DATE__); 02167 } 02168 else 02169 fprintf(stderr,"** error: usage - invalid use_type %d\n", use_type); 02170 02171 RETURN(-1); 02172 } |
|
Definition at line 1546 of file SUMA_3dVol2Surf.c. References v2s_param_t::cmask, opts_t::cmask_cmd, opts_t::debug, DSET_BRICK_TYPE, DSET_NVALS, DSET_NVOX, EDT_calcmask(), ENTRY, free, opts_t::gp_index, v2s_param_t::gpar, opts_t::gpar_file, ISVALID_DSET, malloc, v2s_param_t::nvox, p, RETURN, THD_countmask(), and THD_open_dataset(). Referenced by validate_options().
01547 { 01548 int ccount = 0; 01549 ENTRY("validate_datasets"); 01550 01551 p->gpar = THD_open_dataset( opts->gpar_file ); 01552 01553 if ( !ISVALID_DSET(p->gpar) ) 01554 { 01555 if ( opts->gpar_file == NULL ) 01556 fprintf( stderr, "** error: missing '-grid_parent DSET' option\n" ); 01557 else 01558 fprintf( stderr, "** error: invalid input dataset '%s'\n", 01559 opts->gpar_file); 01560 RETURN(-1); 01561 } 01562 else if ( DSET_BRICK_TYPE(p->gpar, 0) == MRI_complex ) 01563 { 01564 fprintf(stderr, 01565 "** failure: cannot deal with complex-valued dataset, '%s'\n", 01566 opts->gpar_file); 01567 RETURN(-1); 01568 } 01569 else if ( opts->gp_index >= DSET_NVALS(p->gpar) ) 01570 { 01571 fprintf(stderr,"** error: gp_index (%d) > max grid parent index (%d)\n", 01572 opts->gp_index, DSET_NVALS(p->gpar)-1); 01573 RETURN(-1); 01574 } 01575 01576 p->nvox = DSET_NVOX( p->gpar ); 01577 01578 /* -------------------------------------------------------------------- */ 01579 /* check for cmask - casually stolen from 3dmaskdump.c (thanks, Bob! :) */ 01580 01581 if ( opts->cmask_cmd != NULL ) 01582 { 01583 int ncmask, clen = strlen( opts->cmask_cmd ); 01584 char * cmd; 01585 01586 /* save original cmask command, as EDT_calcmask() is destructive */ 01587 cmd = (char *)malloc((clen + 1) * sizeof(char)); 01588 strcpy( cmd, opts->cmask_cmd ); 01589 01590 p->cmask = EDT_calcmask( cmd, &ncmask ); 01591 01592 free( cmd ); /* free EDT_calcmask() string */ 01593 01594 if ( p->cmask == NULL ) 01595 { 01596 fprintf( stderr, "** failure: cannot compute mask from option:\n" 01597 " -cmask '%s'\n", opts->cmask_cmd ); 01598 RETURN(-1); 01599 } 01600 if ( ncmask != p->nvox ) 01601 { 01602 fprintf( stderr, "** error: input and cmask datasets do not have " 01603 "the same dimensions\n" ); 01604 RETURN(-1); 01605 } 01606 if ( ( ccount = THD_countmask( ncmask, p->cmask ) ) <= 0 ) 01607 { 01608 fprintf( stderr, "** Warning! No voxels in computed cmask!\n" ); 01609 /* return -1; continue, and let the user deal with it... */ 01610 } 01611 } 01612 01613 if ( opts->debug > 0 ) 01614 { 01615 fprintf( stderr, "++ input dset has nvox = %d, nvals = %d", 01616 p->nvox, DSET_NVALS(p->gpar) ); 01617 if ( p->cmask == NULL ) 01618 fputc( '\n', stderr ); 01619 else 01620 fprintf( stderr, " (%d voxels in mask)\n", ccount ); 01621 } 01622 01623 RETURN(0); 01624 } |
|
Definition at line 1385 of file SUMA_3dVol2Surf.c. References check_map_func(), check_outfile(), v2s_param_t::cmask, opts_t::debug, disp_opts_t(), disp_v2s_param_t(), ENTRY, v2s_param_t::gpar, opts_t::map_str, opts_t::norm_dir, opts_t::norm_len, opts_t::outfile_1D, opts_t::outfile_niml, p, RETURN, opts_t::snames, opts_t::spec_file, opts_t::sv_file, usage(), opts_t::use_norms, V2S_USE_VERSION, and validate_datasets().
01386 { 01387 ENTRY("validate_options"); 01388 01389 memset( p, 0, sizeof(*p) ); 01390 p->gpar = NULL; 01391 p->cmask = NULL; 01392 01393 if ( opts->debug > 0 ) 01394 { 01395 usage( PROG_NAME, V2S_USE_VERSION ); 01396 disp_opts_t ( "++ opts read: ", opts ); 01397 } 01398 01399 if ( check_map_func( opts->map_str ) == E_SMAP_INVALID ) 01400 RETURN(-1); 01401 01402 if ( !opts->outfile_1D && !opts->outfile_niml ) 01403 { 01404 fprintf( stderr, "** missing '-out_1D OUTPUT_FILE' option\n" ); 01405 RETURN(-1); 01406 } 01407 01408 if ( opts->spec_file == NULL ) 01409 { 01410 fprintf( stderr, "** missing '-spec_file SPEC_FILE' option\n" ); 01411 RETURN(-1); 01412 } 01413 01414 if ( opts->sv_file == NULL ) 01415 { 01416 fprintf( stderr, "** missing '-sv SURF_VOL' option\n" ); 01417 RETURN(-1); 01418 } 01419 01420 if ( opts->snames[0] == NULL ) 01421 { 01422 fprintf(stderr,"** missing '-surf_A SURF_NAME' option\n"); 01423 RETURN(-1); 01424 } 01425 01426 if ( opts->use_norms ) 01427 { 01428 if ( opts->snames[1] ) 01429 { 01430 fprintf(stderr,"** no '-use_norms' option with 2 surfaces\n"); 01431 RETURN(-1); 01432 } 01433 } 01434 else if ( opts->norm_len != 1.0 || opts->norm_dir ) 01435 { 01436 fprintf(stderr,"** options for normals requires '-use_norms'\n"); 01437 RETURN(-1); 01438 } 01439 01440 if ( check_outfile( opts, p ) != 0 ) 01441 RETURN(-1); 01442 01443 if ( validate_datasets( opts, p ) != 0 ) 01444 RETURN(-1); 01445 01446 if ( opts->debug > 1 ) 01447 disp_v2s_param_t( "++ opts validated: ", p ); 01448 01449 RETURN(0); 01450 } |
|
Referenced by validate_options(). |
|
Definition at line 287 of file SUMA_3dVol2Surf.c. References v2s_opts_t::debug, disp_v2s_results(), ENTRY, free_v2s_results(), SUMA_surface::label, v2s_opts_t::map, v2s_opts_t::outfile_1D, v2s_opts_t::outfile_niml, p, RETURN, v2s_param_t::surf, v2s_write_outfile_1D(), v2s_write_outfile_niml(), and vol2surf().
00288 { 00289 v2s_results * sd; 00290 int rv = 0; 00291 ENTRY("write_output"); 00292 00293 if ( sopt == NULL || p == NULL ) 00294 { 00295 fprintf( stderr, "** v2s_wo - bad params (%p,%p)\n", sopt, p ); 00296 RETURN(-1); 00297 } 00298 00299 if ( sopt->map == E_SMAP_INVALID ) 00300 { 00301 fprintf(stderr,"** v2s wo: invalid map %d\n", sopt->map); 00302 RETURN(-1); 00303 } 00304 00305 sd = vol2surf(sopt, p); 00306 if ( !sd ) 00307 fprintf(stderr,"** vol2surf failed\n"); 00308 00309 if ( sd && sopt->debug > 1 ) disp_v2s_results("-- post vol2surf() : ",sd); 00310 00311 if ( sd && sopt->outfile_1D ) 00312 rv = v2s_write_outfile_1D(sopt, sd, p->surf[0].label); 00313 00314 if ( sd && !rv && sopt->outfile_niml ) 00315 rv = v2s_write_outfile_niml(sopt, sd, 1); /* request to free data */ 00316 00317 free_v2s_results( sd ); 00318 sd = NULL; 00319 00320 RETURN(rv); 00321 } |