Doxygen Source Code Documentation
vol2surf.h File Reference
Go to the source code of this file.
Define Documentation
| 
 | 
| 
 Definition at line 28 of file vol2surf.h. Referenced by check_SUMA_surface(), and validate_v2s_inputs(). | 
| 
 | 
| 
 Definition at line 27 of file vol2surf.h. | 
| 
 | 
| 
 Definition at line 15 of file vol2surf.h. Referenced by directed_dist(). | 
| 
 | 
| 
 Definition at line 7 of file vol2surf.h. Referenced by set_smap_opts(). | 
| 
 | 
| 
 Definition at line 6 of file vol2surf.h. Referenced by segment_imarr(), and set_smap_opts(). | 
| 
 | 
| 
 Definition at line 4 of file vol2surf.h. Referenced by copy_surfaces(), init_options(), read_surf_files(), and suma2afni_surf(). | 
| 
 | 
| 
 Definition at line 11 of file vol2surf.h. Referenced by get_surf_data(), and PV2S_process_args(). | 
| 
 | 
| 
 Definition at line 12 of file vol2surf.h. Referenced by init_options(), and PV2S_process_args(). | 
| 
 | 
| 
 Definition at line 13 of file vol2surf.h. Referenced by get_surf_data(), init_options(), and PV2S_process_args(). | 
| 
 | 
| 
 Definition at line 25 of file vol2surf.h. Referenced by fill_sopt_default(), init_options(), and PV2S_process_args(). | 
| 
 | 
| 
 Definition at line 20 of file vol2surf.h. Referenced by alloc_output_mem(), and init_options(). | 
| 
 | 
| 
 Definition at line 21 of file vol2surf.h. Referenced by alloc_output_mem(), and init_options(). | 
| 
 | 
| 
 Definition at line 22 of file vol2surf.h. Referenced by alloc_output_mem(), and init_options(). | 
| 
 | 
| 
 Definition at line 18 of file vol2surf.h. Referenced by alloc_output_mem(), fill_sopt_default(), init_options(), and PV2S_process_args(). | 
| 
 | 
| 
 Definition at line 17 of file vol2surf.h. | 
| 
 | 
| 
 Definition at line 23 of file vol2surf.h. Referenced by alloc_output_mem(), and init_options(). | 
| 
 | 
| 
 Definition at line 24 of file vol2surf.h. Referenced by alloc_output_mem(), and init_options(). | 
| 
 | 
| 
 Definition at line 19 of file vol2surf.h. Referenced by alloc_output_mem(), and init_options(). | 
| 
 | 
| 
 Definition at line 9 of file vol2surf.h. Referenced by PV2S_process_args(), and validate_v2s_inputs(). | 
Enumeration Type Documentation
| 
 | 
| 
 
 Definition at line 31 of file vol2surf.h. Referenced by v2s_map_type(). 
 00032 {
00033     E_SMAP_INVALID = 0,                 /* do not change INVALID (from 0) */
00034     E_SMAP_MASK,    E_SMAP_MIDPT,
00035     E_SMAP_MASK2,
00036     E_SMAP_AVE,     E_SMAP_COUNT,
00037     E_SMAP_MIN,     E_SMAP_MAX,
00038     E_SMAP_MAX_ABS, E_SMAP_SEG_VALS,
00039     /* sorted ones: */
00040     E_SMAP_MEDIAN,  E_SMAP_MODE,
00041     E_SMAP_FINAL                        /* leave FINAL at the end */
00042 } v2s_map_nums;
 | 
Function Documentation
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 183 of file vol2surf.c. References check_SUMA_surface(), v2s_param_t::cmask, v2s_opts_t::debug, disp_v2s_opts_t(), v2s_opts_t::dnode, DSET_NVOX, ENTRY, v2s_opts_t::f_steps, fill_sopt_default(), v2s_opts_t::gp_index, v2s_param_t::gpar, SUMA_surface::label, v2s_opts_t::map, v2s_param_t::nsurf, v2s_param_t::nvox, v2s_opts_t::outfile_1D, v2s_opts_t::outfile_niml, v2s_param_t::over_steps, RETURN, v2s_plugin_opts::sopt, v2s_param_t::surf, THD_is_file(), v2s_opts_t::use_norms, v2s_vals_over_steps(), v2s_write_outfile_1D(), v2s_write_outfile_niml(), and vol2surf(). Referenced by AFNI_vol2surf_func_overlay(). 
 00186 {
00187     static v2s_param_t   P;
00188     v2s_opts_t         * sopt, sopt_def;
00189     v2s_results        * res;
00190 
00191 ENTRY("afni_vol2surf");
00192 
00193     if ( !gpar )                 RETURN(NULL);
00194 
00195     if (       check_SUMA_surface(sA) ) RETURN(NULL);
00196     if ( sB && check_SUMA_surface(sB) ) RETURN(NULL);
00197 
00198     if ( use_defaults )
00199     {
00200         sopt = &sopt_def;
00201         fill_sopt_default(sopt, sB ? 2 : 1);  /* 1 or 2 surfaces */
00202 
00203         /* but apply any debug options */
00204         sopt->debug = gv2s_plug_opts.sopt.debug;
00205         sopt->dnode = gv2s_plug_opts.sopt.dnode;
00206     }
00207     else 
00208         sopt = &gv2s_plug_opts.sopt;
00209 
00210     sopt->gp_index = gp_index;
00211 
00212     /* now fill the param struct based on the inputs */
00213     memset(&P, 0, sizeof(P));
00214     P.gpar         = gpar;
00215     P.cmask        = mask;
00216     P.nvox         = DSET_NVOX(gpar);
00217     P.over_steps   = v2s_vals_over_steps(sopt->map);
00218     P.nsurf        = sB ? 2 : 1;
00219     P.surf[0]      = *sA;
00220 
00221     /* verify steps, in case the user has not selected 2 surfaces */
00222     if ( P.nsurf == 1 && ! sopt->use_norms )
00223         sopt->f_steps = 1;
00224 
00225     if ( sB ) P.surf[1] = *sB;
00226 
00227     if ( gv2s_plug_opts.sopt.debug > 1 )
00228         disp_v2s_opts_t("   surf options: ", sopt);
00229 
00230     /* fire it up */
00231 
00232     res = vol2surf(sopt, &P);
00233 
00234     /* if the user wants output files, here they are (don't error check) */
00235     if (res && sopt->outfile_1D )
00236     {
00237         if ( THD_is_file(sopt->outfile_1D) )
00238             fprintf(stderr,"** over-writing 1D output file '%s'\n",
00239                     sopt->outfile_1D);
00240         v2s_write_outfile_1D(sopt, res, P.surf[0].label);
00241     }
00242 
00243     if (res && sopt->outfile_niml )
00244     {
00245         if ( THD_is_file(sopt->outfile_niml) )
00246             fprintf(stderr,"** over-writing niml output file '%s'\n",
00247                     sopt->outfile_niml);
00248         v2s_write_outfile_niml(sopt, res, 0);
00249     }
00250 
00251     RETURN(res);
00252 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 1726 of file vol2surf.c. References ENTRY, MRI_IMARR::imarr, MRI_FLOAT_PTR, MRI_IMARR::nall, MRI_IMARR::num, MRI_IMAGE::nx, and RETURN. Referenced by set_surf_results(). 
 01727 {
01728     float * fp;
01729     int     cr, cc;
01730 
01731 ENTRY("disp_mri_imarr");
01732 
01733     if ( info )
01734         fputs( info, stderr );
01735 
01736     if ( dp == NULL )
01737     {
01738         fprintf(stderr, "disp_mri_imarr: dp == NULL\n");
01739         RETURN(-1);
01740     }
01741 
01742     fprintf(stderr,
01743             "mri_imarr struct at %p :\n"
01744             "    num, nall = %d, %d\n",
01745             dp, dp->num, dp->nall );
01746 
01747     for ( cr = 0; cr < dp->num; cr++ )
01748     {
01749         fp = MRI_FLOAT_PTR(dp->imarr[cr]);
01750         fprintf(stderr, "    %3d: ", cr);
01751         for ( cc = 0; cc < dp->imarr[cr]->nx; cc++, fp++ )
01752             fprintf(stderr, "%f  ", *fp );
01753         fputc( '\n', stderr );
01754     }
01755 
01756     RETURN(0);
01757 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 1566 of file vol2surf.c. References v2s_opts_t::debug, v2s_opts_t::dnode, ENTRY, v2s_opts_t::f_index, v2s_opts_t::f_p1_fr, v2s_opts_t::f_p1_mm, v2s_opts_t::f_pn_fr, v2s_opts_t::f_pn_mm, v2s_opts_t::f_steps, v2s_opts_t::first_node, v2s_opts_t::gp_index, v2s_opts_t::last_node, v2s_opts_t::map, v2s_opts_t::no_head, v2s_opts_t::norm_dir, v2s_opts_t::norm_len, v2s_opts_t::outfile_1D, v2s_opts_t::outfile_niml, RETURN, v2s_opts_t::skip_cols, and v2s_opts_t::use_norms. Referenced by afni_vol2surf(), PV2S_process_args(), and set_smap_opts(). 
 01567 {
01568 ENTRY("disp_v2s_opts_t");
01569 
01570     if ( info )
01571         fputs( info, stderr );
01572 
01573     if ( sopt == NULL )
01574     {
01575         fprintf(stderr, "disp_v2s_opts_t: sopt == NULL\n");
01576         RETURN(-1);
01577     }
01578 
01579     fprintf(stderr,
01580             "v2s_opts_t struct at %p  :\n"
01581             "    map, gp_index         = %d, %d\n"
01582             "    debug, dnode          = %d, %d\n"
01583             "    no_head, skip_cols    = %d, %d\n"
01584             "    first_node, last_node = %d, %d\n"
01585             "    use_norms, norm_len   = %d, %f\n"
01586             "    norm_dir              = %d\n"
01587             "    f_index, f_steps      = %d, %d\n"
01588             "    f_p1_fr, f_pn_fr      = %f, %f\n"
01589             "    f_p1_mm, f_pn_mm      = %f, %f\n"
01590             "    outfile_1D            = %s\n"
01591             "    outfile_niml          = %s\n"
01592             , sopt,
01593             sopt->map, sopt->gp_index, sopt->debug, sopt->dnode,
01594             sopt->no_head, sopt->skip_cols,
01595             sopt->first_node, sopt->last_node,
01596             sopt->use_norms, sopt->norm_len, sopt->norm_dir,
01597             sopt->f_index, sopt->f_steps,
01598             sopt->f_p1_fr, sopt->f_pn_fr, sopt->f_p1_mm, sopt->f_pn_mm,
01599             CHECK_NULL_STR(sopt->outfile_1D),
01600             CHECK_NULL_STR(sopt->outfile_niml)
01601             );
01602 
01603     RETURN(0);
01604 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 1534 of file vol2surf.c. References v2s_param_t::cmask, ENTRY, v2s_param_t::gpar, ISVALID_DSET, v2s_param_t::nsurf, v2s_param_t::nvox, v2s_param_t::over_steps, p, and RETURN. Referenced by validate_options(), and vol2surf(). 
 01535 {
01536 ENTRY("disp_v2s_param_t");
01537 
01538     if ( info )
01539         fputs( info, stderr );
01540 
01541     if ( p == NULL )
01542     {
01543         fprintf(stderr, "disp_v2s_param_t: p == NULL\n" );
01544         RETURN(-1);
01545     }
01546 
01547     fprintf(stderr,
01548             "v2s_param_t struct at     %p :\n"
01549             "    gpar  : vcheck      = %p : %s\n"
01550             "    cmask               = %p\n"
01551             "    nvox, over_steps    = %d, %d\n"
01552             "    nsurf               = %d\n"
01553             , p,
01554             p->gpar, ISVALID_DSET(p->gpar) ? "valid" : "invalid",
01555             p->cmask, p->nvox, p->over_steps, p->nsurf
01556             );
01557 
01558     RETURN(0);
01559 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 1825 of file vol2surf.c. References ENTRY, v2s_plugin_opts::ready, RETURN, v2s_plugin_opts::s0A, v2s_plugin_opts::s0B, v2s_plugin_opts::s1A, v2s_plugin_opts::s1B, v2s_plugin_opts::use0, and v2s_plugin_opts::use1. Referenced by PV2S_process_args(). 
 01826 {
01827 ENTRY("disp_v2s_plugin_opts");
01828 
01829     if ( mesg ) fputs( mesg, stderr );
01830 
01831     fprintf(stderr, "v2s_plugin_opts @ %p\n"
01832                     "    ready      = %d\n"
01833                     "    use0, use1 = %d, %d\n"
01834                     "    s0A, s0B   = %d, %d\n"
01835                     "    s1A, s1B   = %d, %d\n",
01836                     d, d->ready, d->use0, d->use1,
01837                     d->s0A, d->s0B, d->s1A, d->s1B );
01838     RETURN(0);
01839 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 1802 of file vol2surf.c. References ENTRY, v2s_results::i, v2s_results::j, v2s_results::k, v2s_results::max_vals, v2s_results::memory, v2s_results::nalloc, v2s_results::nodes, v2s_results::nused, v2s_results::nvals, RETURN, v2s_results::vals, and v2s_results::volind. Referenced by vol2surf(), and write_output(). 
 01803 {
01804 ENTRY("disp_v2s_results");
01805 
01806     if ( mesg ) fputs( mesg, stderr );
01807 
01808     fprintf(stderr, "v2s_results @ %p\n"
01809                     "    nalloc, nused    = %d, %d\n"
01810                     "    max_vals, memory = %d, %d\n"
01811                     "    nodes, volind    = %p, %p\n"
01812                     "    i, j, k          = %p, %p, %p\n"
01813                     "    nvals, vals      = %p, %p\n",
01814                     d, d->nalloc, d->nused, d->max_vals, d->memory,
01815                     d->nodes, d->volind, d->i, d->j, d->k, d->nvals, d->vals);
01816 
01817     RETURN(0);
01818 }
 | 
| 
 | 
| 
 Definition at line 1846 of file vol2surf.c. References c, ENTRY, free, v2s_results::i, v2s_results::j, v2s_results::k, v2s_results::max_vals, v2s_results::nodes, v2s_results::nvals, RETURN, v2s_results::vals, and v2s_results::volind. Referenced by AFNI_vol2surf_func_overlay(), alloc_output_mem(), vol2surf(), and write_output(). 
 01847 {
01848     int c;
01849                                                                                 
01850 ENTRY("free_v2s_results");
01851 
01852     if( ! sd ) RETURN(0);
01853                                                                                 
01854     if (sd->nodes)  { free(sd->nodes);   sd->nodes  = NULL; }
01855     if (sd->volind) { free(sd->volind);  sd->volind = NULL; }
01856     if (sd->i)      { free(sd->i);       sd->i      = NULL; }
01857     if (sd->j)      { free(sd->j);       sd->j      = NULL; }
01858     if (sd->k)      { free(sd->k);       sd->k      = NULL; }
01859     if (sd->nvals)  { free(sd->nvals);   sd->nvals  = NULL; }
01860                                                                                 
01861     if (sd->vals)
01862     {
01863         for ( c = 0; c < sd->max_vals; c++ )
01864             if ( sd->vals[c] ) { free(sd->vals[c]);  sd->vals[c] = NULL; }
01865                                                                                 
01866         free(sd->vals);
01867         sd->vals = NULL;
01868     }
01869 
01870     free(sd);
01871                                                                                 
01872     RETURN(0);
01873 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 2057 of file vol2surf.c. References BYTEIZE, c, calloc, DSET_ARRAY, DSET_BRICK_FACTOR, DSET_BRICK_TYPE, DSET_NVALS, DSET_NVOX, ENTRY, free, ISVALID_DSET, MRI_type_name, RETURN, SHORTIZE, and thr. Referenced by AFNI_vol2surf_func_overlay(). 
 02059 {
02060     float   factor;
02061     byte  * tmask;
02062     int     nvox, type, c, size = 0;
02063 
02064 ENTRY("thd_mask_from_brick");
02065 
02066     if ( mask ) *mask = NULL;   /* to be sure */
02067 
02068     if ( !ISVALID_DSET(dset) || ! mask || volume < 0 )
02069         RETURN(-1);
02070 
02071     if ( volume >= DSET_NVALS(dset) )
02072     {
02073         fprintf(stderr,"** tmfb: sub-brick %d out-of-range\n", volume);
02074         RETURN(-1);
02075     }
02076 
02077     nvox = DSET_NVOX(dset);
02078     type = DSET_BRICK_TYPE(dset, volume);
02079 
02080     if ( type != MRI_byte && type != MRI_short &&
02081          type != MRI_int && type != MRI_float )
02082     {
02083         fprintf(stderr,"** tmfb: invalid dataset type %s, sorry...\n",
02084                 MRI_type_name[type]);
02085         RETURN(-1);
02086     }
02087 
02088     tmask = (byte *)calloc(nvox, sizeof(byte));
02089     if ( ! tmask )
02090     {
02091         fprintf(stderr,"** tmfb: failed to allocate mask of %d bytes\n", nvox);
02092         RETURN(-1);
02093     }
02094 
02095     factor = DSET_BRICK_FACTOR(dset, volume);
02096 
02097     /* cheat: adjust threshold, not data */
02098     if ( factor != 0.0 ) thresh /= factor;
02099 
02100     switch( DSET_BRICK_TYPE(dset, volume) )
02101     {
02102         case MRI_byte:
02103         {
02104             byte * dp  = DSET_ARRAY(dset, volume);
02105             byte   thr = BYTEIZE(thresh + 0.99999);  /* ceiling */
02106             for ( c = 0; c < nvox; c++ )
02107                 if ( dp[c] != 0 && ( dp[c] >= thr ) )
02108                 {
02109                     size++;
02110                     tmask[c] = 1;
02111                 }
02112         }
02113             break;
02114 
02115         case MRI_short:
02116         {
02117             short * dp  = DSET_ARRAY(dset, volume);
02118             short   thr = SHORTIZE(thresh + 0.99999);  /* ceiling */
02119             for ( c = 0; c < nvox; c++, dp++ )
02120                 if ( *dp != 0 && ( *dp >= thr || (absolute && *dp <= -thr) ) )
02121                 {
02122                     size++;
02123                     tmask[c] = 1;
02124                 }
02125         }
02126             break;
02127 
02128         case MRI_int:
02129         {
02130             int * dp  = DSET_ARRAY(dset, volume);
02131             int   thr = (int)(thresh + 0.99999);  /* ceiling */
02132             for ( c = 0; c < nvox; c++, dp++ )
02133                 if ( *dp != 0 && ( *dp >= thr || (absolute && *dp <= -thr) ) )
02134                 {
02135                     size++;
02136                     tmask[c] = 1;
02137                 }
02138         }
02139             break;
02140 
02141         case MRI_float:
02142         {
02143             float * dp = DSET_ARRAY(dset, volume);
02144             for ( c = 0; c < nvox; c++, dp++ )
02145                 if (*dp != 0 && (*dp >= thresh || (absolute && *dp <= -thresh)))
02146                 {
02147                     size++;
02148                     tmask[c] = 1;
02149                 }
02150         }
02151             break;
02152 
02153         default:                /* let's be sure */
02154         {
02155             fprintf(stderr,"** tmfb: invalid dataset type, sorry...\n");
02156             free(tmask);
02157         }
02158             break;
02159     }
02160 
02161     *mask = tmask;
02162 
02163     RETURN(size);
02164 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 2173 of file vol2surf.c. References E_SMAP_SEG_VALS, ENTRY, and RETURN. Referenced by PV2S_process_args(). 
 02174 {
02175 ENTRY("v2s_good_map_index");
02176 
02177     if ( map <= E_SMAP_INVALID || map >= E_SMAP_FINAL )
02178         RETURN(0);
02179 
02180     /* these have not (yet? do we care?) been implemented */
02181     if ( map == E_SMAP_MASK2 || map == E_SMAP_COUNT )
02182         RETURN(0);
02183 
02184     if ( from_afni && map == E_SMAP_SEG_VALS )
02185         RETURN(0);
02186 
02187     RETURN(1);
02188 }
 | 
| 
 | 
| 
 Definition at line 2021 of file vol2surf.c. References ENTRY, gv2s_map_names, RETURN, and v2s_map_nums. Referenced by check_map_func(), and validate_v2s_inputs(). 
 02022 {
02023     v2s_map_nums map;
02024                                                                                 
02025 ENTRY("v2s_map_type");
02026                                                                                 
02027     if ( map_str == NULL )
02028     {
02029         fprintf( stderr, "** v2s_map_type: missing map_str parameter\n" );
02030         RETURN((int)E_SMAP_INVALID);
02031     }
02032                                                                                 
02033     if ( sizeof(gv2s_map_names) / sizeof(char *) != (int)E_SMAP_FINAL )
02034     {
02035         fprintf( stderr, "** error:  gv2s_map_names/v2s_map_num mis-match\n");
02036         RETURN((int)E_SMAP_INVALID);
02037     }
02038                                                                                 
02039     /* not ready for E_SMAP_COUNT yet (until someone wants it) */
02040     if ( !strcmp( map_str, gv2s_map_names[E_SMAP_COUNT] ) )
02041         RETURN((int)E_SMAP_INVALID);
02042                                                                                 
02043     for ( map = E_SMAP_INVALID; map < E_SMAP_FINAL; map++ )
02044         if ( !strcmp( map_str, gv2s_map_names[map] ) )
02045             RETURN((int)map);
02046 
02047     RETURN((int)E_SMAP_INVALID);
02048 }
 | 
| 
 | 
| 
 Definition at line 2005 of file vol2surf.c. References E_SMAP_SEG_VALS. Referenced by afni_vol2surf(), and set_smap_opts(). 
 02006 {
02007     if ( map == E_SMAP_SEG_VALS )
02008         return 1;
02009 
02010     return 0;
02011 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 2231 of file vol2surf.c. References c, ENTRY, gv2s_map_names, v2s_results::i, v2s_results::j, v2s_results::k, v2s_opts_t::map, v2s_results::max_vals, MV_format_fval(), v2s_opts_t::no_head, v2s_results::nodes, v2s_results::nused, v2s_results::nvals, v2s_opts_t::outfile_1D, print_header(), RETURN, v2s_results::vals, and v2s_results::volind. Referenced by afni_vol2surf(), and write_output(). 
 02232 {
02233     FILE        * fp;
02234     int           c, c2;
02235 ENTRY("v2s_write_outfile_1D");
02236 
02237     fp = fopen( sopt->outfile_1D, "w" );
02238     if ( fp == NULL )
02239     {
02240         fprintf( stderr, "** failure to open '%s' for writing\n",
02241                  sopt->outfile_1D );
02242         RETURN(-1);
02243     }
02244 
02245     if ( ! sopt->no_head )
02246         print_header(fp, label, gv2s_map_names[sopt->map], sd);
02247 
02248     for ( c = 0; c < sd->nused; c++ )
02249     {
02250         /* keep old spacing */
02251         fputc(' ', fp);
02252         if ( sd->nodes  ) fprintf(fp, " %8d", sd->nodes[c]);
02253         if ( sd->volind ) fprintf(fp, "   %8d ", sd->volind[c]);
02254         if ( sd->i      ) fprintf(fp, "  %3d", sd->i[c]);
02255         if ( sd->j      ) fprintf(fp, "  %3d", sd->j[c]);
02256         if ( sd->k      ) fprintf(fp, "  %3d", sd->k[c]);
02257         if ( sd->nvals  ) fprintf(fp, "     %3d", sd->nvals[c]);
02258 
02259         for ( c2 = 0; c2 < sd->max_vals; c2++ )
02260             fprintf(fp, "  %10s", MV_format_fval(sd->vals[c2][c]));
02261         fputc('\n', fp);
02262     }
02263 
02264     fclose(fp);
02265 
02266     RETURN(0);
02267 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 2275 of file vol2surf.c. References c, calloc, ENTRY, free, v2s_results::max_vals, NI_add_column(), NI_BINARY_MODE, NI_FLOAT, NI_free_element(), NI_INT, NI_new_data_element(), NI_stream_close(), NI_stream_open(), NI_write_element(), v2s_results::nodes, v2s_results::nused, v2s_opts_t::outfile_niml, RETURN, and v2s_results::vals. Referenced by afni_vol2surf(), and write_output(). 
 02275                                                                                 {
02276     static char   v2s_name[] = "3dVol2Surf_dataset";
02277     NI_element  * nel = NULL;
02278     NI_stream     ns;
02279     char        * ni_name;
02280     int           c;
02281 
02282 ENTRY("v2s_write_outfile_niml");
02283 
02284     if ( !sopt->outfile_niml ) RETURN(0);
02285 
02286     nel = NI_new_data_element( v2s_name, sd->nused );
02287     if ( !nel )
02288     {
02289         fprintf(stderr,"** file NI_new_data_element, n = '%s', len = %d\n",
02290                 v2s_name, sd->nused);
02291         RETURN(1);
02292     }
02293 
02294     ni_name = (char *)calloc(strlen(sopt->outfile_niml)+6, sizeof(char));
02295     if ( !ni_name ) { fprintf(stderr,"** ni_name failed\n"); RETURN(1); }
02296     sprintf(ni_name, "file:%s", sopt->outfile_niml);
02297 
02298     ns = NI_stream_open(ni_name, "w");
02299 
02300     NI_add_column(nel,NI_INT,sd->nodes);
02301 
02302     for ( c = 0; c < sd->max_vals; c++ )
02303     {
02304         NI_add_column(nel, NI_FLOAT, sd->vals[c]);
02305         if ( free_vals ) { free(sd->vals[c]); sd->vals[c] = NULL; }
02306     }
02307     if ( free_vals ) { free(sd->vals); sd->vals = NULL; }
02308 
02309     if ( NI_write_element(ns, nel, NI_BINARY_MODE) < 0 )
02310     {
02311         fprintf(stderr,"** NI_write_element failed for: '%s'\n", ni_name);
02312         RETURN(1);
02313     }
02314 
02315     NI_free_element( nel );
02316     NI_stream_close( ns );
02317     free(ni_name);
02318 
02319     RETURN(0);
02320 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 267 of file vol2surf.c. References alloc_output_mem(), compact_results(), v2s_opts_t::debug, disp_v2s_param_t(), disp_v2s_results(), dump_surf_3dt(), ENTRY, free_v2s_results(), v2s_opts_t::map, p, RETURN, and validate_v2s_inputs(). Referenced by afni_vol2surf(), and write_output(). 
 00268 {
00269     v2s_results * sd;
00270     int           rv;
00271 ENTRY("vol2surf");
00272 
00273     if ( sopt == NULL || p == NULL )
00274     {
00275         fprintf( stderr, "** smd_wo - bad params (%p,%p)\n", sopt, p );
00276         RETURN(NULL);
00277     }
00278 
00279     if ( validate_v2s_inputs(sopt, p) )
00280         RETURN(NULL);
00281 
00282     if ( sopt->map == E_SMAP_INVALID )
00283     {
00284         fprintf(stderr,"** v2s wo: invalid map %d\n", sopt->map);
00285         RETURN(NULL);
00286     }
00287 
00288     sd = alloc_output_mem( sopt, p );
00289     if ( !sd ) RETURN(NULL);
00290 
00291     if ( sopt->debug > 1 ) disp_v2s_param_t( "-d post alloc_output_mem : ", p );
00292 
00293     rv = dump_surf_3dt( sopt, p, sd );
00294 
00295     if ( compact_results(sd, sopt->debug) )
00296     {
00297         free_v2s_results(sd);           /* free whatever didn't get burned */
00298         RETURN(NULL);
00299     }
00300 
00301     if ( sopt->debug > 1 ) disp_v2s_results( "-d post surf creation : ", sd);
00302 
00303     RETURN(sd);
00304 }
 | 
Variable Documentation
| 
 | 
| 
 Definition at line 138 of file vol2surf.h. | 
| 
 | 
| 
 Definition at line 137 of file vol2surf.h. Referenced by v2s_map_type(), v2s_write_outfile_1D(), and validate_v2s_inputs(). | 
| 
 | 
| 
 Definition at line 136 of file vol2surf.h. | 
 
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
 
 
 
 
       
	   
	   
	   
	  