Doxygen Source Code Documentation
3destpdf.c File Reference
#include "mrilib.h"#include "estpdf3.c"Go to the source code of this file.
Defines | |
| #define | PROGRAM_NAME "3destpdf" |
| #define | PROGRAM_AUTHOR "B. D. Ward" |
| #define | PROGRAM_DATE "20 January 2000" |
| #define | MAX_STRING_LENGTH 80 |
| #define | MTEST(ptr) |
Functions | |
| void | estPDF_error (char *message) |
| void | display_help_menu () |
| void | get_options (int argc, char **argv) |
| void | initialize_program (int argc, char **argv) |
| int | main (int argc, char **argv) |
Variables | |
| char * | anat_filename = NULL |
| THD_3dim_dataset * | anat |
| float | min_val_float |
| float | max_val_float |
| Boolean | quiet = FALSE |
Define Documentation
|
|
Definition at line 46 of file 3destpdf.c. Referenced by get_options(). |
|
|
|
Definition at line 20 of file 3destpdf.c. Referenced by main(). |
|
|
Definition at line 21 of file 3destpdf.c. Referenced by main(). |
|
|
Definition at line 19 of file 3destpdf.c. Referenced by estPDF_error(), and main(). |
Function Documentation
|
|
Definition at line 82 of file 3destpdf.c.
00083 {
00084 printf
00085 (
00086 "This program estimates the PDF for a dataset.\n\n"
00087 "Usage: \n"
00088 "3destpdf \n"
00089 "-anat filename Filename of anat dataset to be segmented \n"
00090 );
00091
00092 exit(0);
00093 }
|
|
|
Definition at line 53 of file 3destpdf.c. References PROGRAM_NAME. Referenced by get_options(), and initialize_program().
00054 {
00055 fprintf (stderr, "\n");
00056 fprintf (stderr, "%s Error: %s \n", PROGRAM_NAME, message);
00057 exit(1);
00058 }
|
|
||||||||||||
|
Definition at line 102 of file 3destpdf.c. References anat_filename, argc, THD_3dim_dataset::dblk, display_help_menu(), DSET_ARRAY, estPDF_error(), ISVALID_3DIM_DATASET, malloc, MAX_STRING_LENGTH, MTEST, THD_load_datablock(), and THD_open_one_dataset().
00107 {
00108 int nopt = 1; /* input option argument counter */
00109 int ival, index; /* integer input */
00110 float fval; /* float input */
00111 char message[MAX_STRING_LENGTH]; /* error message */
00112
00113
00114 /*----- does user request help menu? -----*/
00115 if (argc < 2 || strncmp(argv[1], "-help", 5) == 0) display_help_menu();
00116
00117
00118 /*----- main loop over input options -----*/
00119 while (nopt < argc )
00120 {
00121
00122 /*----- -anat filename -----*/
00123 if (strncmp(argv[nopt], "-anat", 5) == 0)
00124 {
00125 nopt++;
00126 if (nopt >= argc) estPDF_error ("need argument after -anat ");
00127 anat_filename = malloc (sizeof(char) * MAX_STRING_LENGTH);
00128 MTEST (anat_filename);
00129 strcpy (anat_filename, argv[nopt]);
00130
00131 anat = THD_open_one_dataset (anat_filename);
00132 if (!ISVALID_3DIM_DATASET (anat))
00133 {
00134 sprintf (message, "Can't open dataset: %s\n", anat_filename);
00135 estPDF_error (message);
00136 }
00137 THD_load_datablock (anat->dblk);
00138 if (DSET_ARRAY(anat,0) == NULL)
00139 {
00140 sprintf (message, "Can't access data: %s\n", anat_filename);
00141 estPDF_error (message);
00142 }
00143
00144 nopt++;
00145 continue;
00146 }
00147
00148
00149 /*----- unknown command -----*/
00150 sprintf(message,"Unrecognized command line option: %s\n", argv[nopt]);
00151 estPDF_error (message);
00152
00153 }
00154
00155
00156 }
|
|
||||||||||||
|
Definition at line 165 of file 3destpdf.c. References anat_filename, argc, DSET_BRICK_ARRAY, DSET_NX, DSET_NY, DSET_NZ, estPDF_error(), estpdf_short(), get_options(), malloc, max_val_float, min_val_float, MTEST, nz, and quiet.
00170 {
00171 float parameters [DIMENSION]; /* parameters for PDF estimation */
00172 Boolean ok = TRUE; /* flag for successful PDF estimation */
00173
00174 int nx, ny, nz, nxy, nxyz, ixyz; /* voxel counters */
00175 int n; /* histogram bin index */
00176 short * sfim = NULL; /* pointer to anat data */
00177 short * rfim = NULL; /* truncated data */
00178 int icount;
00179 int lower_cutoff = 25;
00180
00181 /*----- Get operator inputs -----*/
00182 get_options (argc, argv);
00183
00184
00185 /*----- Initialize local variables -----*/
00186 if (anat == NULL) estPDF_error ("Unable to read anat dataset");
00187 nx = DSET_NX(anat); ny = DSET_NY(anat); nz = DSET_NZ(anat);
00188 nxy = nx*ny; nxyz = nxy*nz;
00189 sfim = (short *) DSET_BRICK_ARRAY(anat,0) ;
00190 if (sfim == NULL) estPDF_error ("Unable to read anat dataset");
00191 rfim = (short *) malloc (sizeof(short) * nxyz); MTEST (rfim);
00192
00193
00194 /*----- Just use voxels whose intensity is above the lower cutoff -----*/
00195 icount = 0;
00196 for (ixyz = 0; ixyz < nxyz; ixyz++)
00197 if (sfim[ixyz] > lower_cutoff)
00198 {
00199 rfim[icount] = sfim[ixyz];
00200 icount++;
00201 }
00202 printf ("%d voxels above lower cutoff = %d \n", icount, lower_cutoff);
00203
00204
00205 /*----- Get PDF estimate and set voxel intensity limits -----*/
00206 estpdf_short (icount, rfim, parameters);
00207 min_val_float = parameters[4] - 2.0*parameters[5];
00208 max_val_float = parameters[7] + 2.0*parameters[8];
00209
00210
00211 if (! quiet)
00212 {
00213 printf ("\n");
00214 printf ("Control inputs: \n");
00215 printf ("anat filename = %s \n", anat_filename);
00216 printf ("min value = %f \n", min_val_float);
00217 printf ("max value = %f \n", max_val_float);
00218 }
00219
00220
00221 }
|
|
||||||||||||
|
Definition at line 230 of file 3destpdf.c. References argc, initialize_program(), PROGRAM_AUTHOR, PROGRAM_DATE, and PROGRAM_NAME.
00235 {
00236
00237 /*----- Identify software -----*/
00238 printf ("\n\n");
00239 printf ("Program: %s \n", PROGRAM_NAME);
00240 printf ("Author: %s \n", PROGRAM_AUTHOR);
00241 printf ("Date: %s \n", PROGRAM_DATE);
00242 printf ("\n");
00243
00244
00245 /*----- Program initialization -----*/
00246 initialize_program (argc, argv);
00247
00248
00249
00250 }
|
Variable Documentation
|
|
Definition at line 39 of file 3destpdf.c. |
|
|
Definition at line 37 of file 3destpdf.c. Referenced by get_options(), and initialize_program(). |
|
|
Definition at line 42 of file 3destpdf.c. Referenced by initialize_program(). |
|
|
Definition at line 41 of file 3destpdf.c. Referenced by initialize_program(). |
|
|
Definition at line 44 of file 3destpdf.c. Referenced by initialize_program(). |