Doxygen Source Code Documentation
SUMA_SampBias.c File Reference
#include "SUMA_suma.h"Go to the source code of this file.
Data Structures | |
| struct | SUMA_KUBATEST_OPTIONS |
Defines | |
| #define | SURFPATCH_MAX_SURF 1 |
Functions | |
| void | usage_SUMA_SampBias () |
| SUMA_KUBATEST_OPTIONS * | SUMA_SampBias_ParseInput (char *argv[], int argc, SUMA_KUBATEST_OPTIONS *Opt) |
| parse the arguments for SurfSmooth program | |
| void | calcWithOffsets (SUMA_SurfaceObject *SO, SUMA_KUBATEST_OPTIONS *Opt) |
Variables | |
| SUMA_CommonFields * | SUMAg_CF |
| SUMA_DO * | SUMAg_DOv |
| SUMA_SurfaceViewer * | SUMAg_SVv |
| int | SUMAg_N_SVv |
| int | SUMAg_N_DOv |
| SUMA_Boolean | LocalHead = NOPE |
Define Documentation
|
|
Maximum number of input surfaces Definition at line 7 of file SUMA_SampBias.c. Referenced by SUMA_SampBias_ParseInput(). |
Function Documentation
|
||||||||||||
|
Definition at line 220 of file SUMA_SampBias.c. References SUMA_KUBATEST_OPTIONS::dlimit, SUMA_KUBATEST_OPTIONS::histnote, i, SUMA_GET_OFFSET_STRUCT::LayerVect, SUMA_SurfaceObject::N_Node, SUMA_GET_OFFSET_STRUCT::N_Nodes, SUMA_SurfaceObject::NodeList, SUMA_GET_OFFSET_STRUCT::OffVect, SUMA_KUBATEST_OPTIONS::outfile, SUMA_KUBATEST_OPTIONS::plimit, r, SUMA_Boolean, SUMA_ENTRY, SUMA_etime(), SUMA_Free_getoffsets(), SUMA_getoffsets2(), SUMA_Initialize_getoffsets(), SUMA_Recycle_getoffsets(), SUMA_RETURNe, write(), x2, y1, and z1.
00221 {
00222 static char FuncName[]={"calcWithOffsets"};
00223 /* initialize OffS */
00224 SUMA_GET_OFFSET_STRUCT *OffS = SUMA_Initialize_getoffsets (SO->N_Node);
00225 struct timeval start_time, start_time_all;
00226 float etime_GetOffset, etime_GetOffset_all;
00227 int i = 0;
00228 FILE* outFile = NULL;
00229 SUMA_Boolean write = YUP;
00230
00231 SUMA_ENTRY;
00232
00233 outFile = fopen(Opt->outfile, "w");
00234 fprintf(outFile, "#Col. 0 Node index\n"
00235 "#Col. 1 Node for which the ratio in 4 is the largest. (Companion of Node in Col.0)\n"
00236 "#Col. 2 distance in 3D\n"
00237 "#Col. 3 shortest surface path\n"
00238 "#Col. 4 Ratio of path/distance\n");
00239 if (Opt->histnote) {
00240 fprintf(outFile, "#History:%s\n", Opt->histnote);
00241 }
00242
00243 SUMA_etime(&start_time_all,0);
00244 for (i=0; i < SO->N_Node; ++i)
00245 /* i=45552; */
00246 {
00247 float pathD = 0;/*shortest distance along surface to node ii*/
00248 float geomD = 0;/*geometric distance to node ii*/
00249 float ratio = 1;
00250 int j = 0;
00251 int ii = 0;
00252
00253 /* show me the offset from node 0 */
00254 if (LocalHead) fprintf(SUMA_STDERR,"%s: Calculating offsets from node %d\n",FuncName, i);
00255 if (i == 0) {
00256 SUMA_etime(&start_time,0);
00257 }
00258 SUMA_getoffsets2 (i, SO, Opt->plimit, OffS, NULL, 0);
00259 if (i == 99) {
00260 etime_GetOffset = SUMA_etime(&start_time,1);
00261 fprintf(SUMA_STDERR, "%s: Search to %f mm took %f seconds for %d nodes.\n"
00262 "Projected completion time: %f minutes\n",
00263 FuncName, Opt->plimit, etime_GetOffset, i+1,
00264 etime_GetOffset * SO->N_Node / 60.0 / (i+1));
00265 }
00266 /*find smallest ratio*/
00267 for (j=0; j < OffS->N_Nodes; j++)
00268 {
00269 if( i!=j && OffS->LayerVect[j] >= 0)
00270 {
00271 float x1 = SO->NodeList[i*3+0];
00272 float x2 = SO->NodeList[j*3+0];
00273 float y1 = SO->NodeList[i*3+1];
00274 float y2 = SO->NodeList[j*3+1];
00275 float z1 = SO->NodeList[i*3+2];
00276 float z2 = SO->NodeList[j*3+2];
00277 float dx = x1 - x2;
00278 float dy = y1 - y2;
00279 float dz = z1 - z2;
00280 float d1 = OffS->OffVect[j];
00281 float d2 = sqrt(dx*dx + dy*dy + dz*dz);
00282 float r = d1 / d2;
00283 /*printf("i=%i j=%i offvect=%f dist=%f r=%f layervect=%i\n", i,j,d1,d2,r, OffS->LayerVect[j]); */
00284 if ( d2 < Opt->dlimit && d1 < Opt->plimit && r > ratio )
00285 {
00286 ratio = r;
00287 ii = j;
00288 pathD = d1;
00289 geomD = d2;
00290 }
00291 }
00292 }
00293 if (write)
00294 fprintf(outFile, "%i\t%i\t%f\t%f\t%f\n", i, ii, geomD, pathD, ratio);
00295
00296 if (LocalHead)
00297 fprintf(SUMA_STDERR,"%s: Recycling OffS\n", FuncName);
00298 SUMA_Recycle_getoffsets (OffS);
00299 if (LocalHead)
00300 fprintf(SUMA_STDERR,"%s: Done.\n", FuncName);
00301 }
00302 if (write)
00303 fclose(outFile);
00304
00305 etime_GetOffset_all = SUMA_etime(&start_time_all,1);
00306 fprintf(SUMA_STDERR, "%s: Done.\nSearch to %f mm took %f minutes for %d nodes.\n" ,
00307 FuncName, Opt->plimit, etime_GetOffset_all / 60.0 , SO->N_Node);
00308 SUMA_Free_getoffsets(OffS);
00309 SUMA_RETURNe;
00310 }
|
|
||||||||||||||||
|
parse the arguments for SurfSmooth program
Definition at line 81 of file SUMA_SampBias.c. References argc, SUMA_KUBATEST_OPTIONS::dlimit, SUMA_KUBATEST_OPTIONS::histnote, i, ind, SUMA_KUBATEST_OPTIONS::iType, LocalHead, SUMA_KUBATEST_OPTIONS::N_surf, SUMA_KUBATEST_OPTIONS::outfile, SUMA_KUBATEST_OPTIONS::plimit, SUMA_KUBATEST_OPTIONS::spec_file, SUMA_Boolean, SUMA_ENTRY, SUMA_filexists(), SUMA_FT_NOT_SPECIFIED, SUMA_HistString(), SUMA_RETURN, SUMA_SKIP_COMMON_OPTIONS, SUMA_SL_Err, SUMA_KUBATEST_OPTIONS::surf_names, SURFPATCH_MAX_SURF, SUMA_KUBATEST_OPTIONS::sv_name, and usage_SUMA_SampBias().
00082 {
00083 static char FuncName[]={"SUMA_SampBias_ParseInput"};
00084 int kar, i, ind;
00085 char *outprefix;
00086 SUMA_Boolean brk = NOPE;
00087 SUMA_Boolean LocalHead = NOPE;
00088
00089 SUMA_ENTRY;
00090
00091
00092 kar = 1;
00093 Opt->iType = SUMA_FT_NOT_SPECIFIED;
00094 Opt->sv_name = NULL;
00095 Opt->spec_file = NULL;
00096 Opt->N_surf = -1;
00097 for (i=0; i<SURFPATCH_MAX_SURF; ++i)
00098 Opt->surf_names[i] = NULL;
00099 brk = NOPE;
00100 Opt->plimit = 50;
00101 Opt->dlimit = 1000;
00102 Opt->outfile = NULL;
00103
00104 while (kar < argc)
00105 { /* loop accross command ine options */
00106 /*fprintf(stdout, "%s verbose: Parsing command line...\n", FuncName);*/
00107 if (strcmp(argv[kar], "-h") == 0 || strcmp(argv[kar], "-help") == 0)
00108 {
00109 usage_SUMA_SampBias();
00110 exit (0);
00111 }
00112
00113 SUMA_SKIP_COMMON_OPTIONS(brk, kar);
00114
00115 if (!brk && (strcmp(argv[kar], "-spec") == 0))
00116 {
00117 kar ++;
00118 if (kar >= argc)
00119 {
00120 fprintf (SUMA_STDERR, "need argument after -spec \n");
00121 exit (1);
00122 }
00123 Opt->spec_file = argv[kar];
00124 brk = YUP;
00125 }
00126 if (!brk && (strcmp(argv[kar], "-surf") == 0))
00127 {
00128 if (kar + 1>= argc)
00129 {
00130 fprintf (SUMA_STDERR, "need argument after -surf SURF_NAME \n");
00131 exit (1);
00132 }
00133 /*ind = argv[kar][6] - 'A';
00134 if (ind < 0 || ind >= SURFPATCH_MAX_SURF)
00135 {
00136 fprintf (SUMA_STDERR, "you can use only one surface\n");
00137 exit (1);
00138 }
00139 */
00140 kar ++;
00141 Opt->surf_names[0] = argv[kar];
00142 Opt->N_surf = 1;
00143 brk = YUP;
00144 }
00145
00146 if (!brk && (strcmp(argv[kar], "-plimit") == 0))
00147 {
00148 kar++;
00149 if (kar >= argc)
00150 {
00151 fprintf (SUMA_STDERR, "need argument after -plimit \n");
00152 exit (1);
00153 }
00154 Opt->plimit = atof(argv[kar]);
00155 brk = YUP;
00156 }
00157
00158 if (!brk && (strcmp(argv[kar], "-dlimit") == 0))
00159 {
00160 kar++;
00161 if (kar >= argc)
00162 {
00163 fprintf (SUMA_STDERR, "need argument after -dlimit \n");
00164 exit (1);
00165 }
00166 Opt->dlimit = atof(argv[kar]);
00167 brk = YUP;
00168 }
00169
00170 if (!brk && (strcmp(argv[kar], "-out") == 0))
00171 {
00172 kar++;
00173 if (kar >= argc)
00174 {
00175 fprintf (SUMA_STDERR, "need argument after -out \n");
00176 exit (1);
00177 }
00178 Opt->outfile = argv[kar];
00179 brk = YUP;
00180 }
00181
00182 if (!brk)
00183 {
00184 fprintf (SUMA_STDERR,"Error %s:\nOption %s not understood. Try -help for usage\n", FuncName, argv[kar]);
00185 exit (1);
00186 } else
00187 {
00188 brk = NOPE;
00189 kar ++;
00190 }
00191 }
00192
00193 /* sanity checks */
00194 if (Opt->N_surf != 1)
00195 {
00196 SUMA_SL_Err("No surface specified.");
00197 exit(1);
00198 }
00199 if (Opt->spec_file == NULL)
00200 {
00201 SUMA_SL_Err("No spec file specified.");
00202 exit(1);
00203 }
00204 if (Opt->outfile == NULL)
00205 {
00206 SUMA_SL_Err("No outfile specified.");
00207 exit(1);
00208 }
00209 else if (SUMA_filexists(Opt->outfile))
00210 {
00211 SUMA_SL_Err("that outfile already exists");
00212 exit(1);
00213 }
00214
00215 Opt->histnote = SUMA_HistString (NULL, argc, argv, NULL);
00216
00217 SUMA_RETURN (Opt);
00218 }
|
|
|
Definition at line 32 of file SUMA_SampBias.c. References SUMA_free, SUMA_help_basics(), and SUMA_New_Additions(). Referenced by SUMA_SampBias_ParseInput().
00033 {
00034 static char FuncName[]={"usage_SUMA_SampBias"};
00035 char * s = NULL;
00036 s = SUMA_help_basics();
00037 printf ( "\nUsage:\n"
00038 " SampBias -spec SPECFILE -surf SURFNAME -plimit limit -dlimit limit -out FILE\n"
00039 "\n"
00040 " Mandatory parameters:\n"
00041 " -spec SpecFile: Spec file containing input surfaces.\n"
00042 " -surf SURFNAME: Name of input surface \n"
00043 " -plimit limit: maximum length of path along surface in mm.\n"
00044 " default is 50 mm\n"
00045 " -dlimit limit: maximum length of euclidean distance in mm.\n"
00046 " default is 1000 mm\n"
00047 " -out FILE: output dataset\n"
00048 "\n"
00049 "\n"
00050 "%s"
00051 "\n",s); SUMA_free(s); s = NULL;
00052 s = SUMA_New_Additions(0, 1); printf("%s\n", s);SUMA_free(s); s = NULL;
00053 printf(" blame Ziad S. Saad SSCC/NIMH/NIH ziad@nih.gov \n");
00054 exit (0);
00055 }
|
Variable Documentation
|
|
|
Global pointer to structure containing info common to all viewers Definition at line 23 of file SUMA_SampBias.c. |
|
|
Global pointer to Displayable Object structure vector Definition at line 24 of file SUMA_SampBias.c. |
|
|
Number of DOs stored in DOv Definition at line 27 of file SUMA_SampBias.c. |
|
|
Number of SVs stored in SVv Definition at line 26 of file SUMA_SampBias.c. |
|
|
Global pointer to the vector containing the various Surface Viewer Structures Definition at line 25 of file SUMA_SampBias.c. |