Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

plug_maskcalc.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006    
00007 /*       usage types            */
00008 
00009 #define  USENOOP        0
00010 #define  USEFULL        1
00011 #define  USEOTHER       2
00012 
00013 /*       operation values       */
00014 
00015 #define  NO_OP                  0
00016 #define  STAT_OP                1
00017 #define  BI_STAT_OP             2
00018 #define  HIST_OP                10
00019 #define  CORR_OP                20
00020 #define  POINTS_OP              25
00021 #define  SLICE_VALS_OP          27
00022 #define  UTEST_OP               30
00023 #define  UTEST1_OP              40
00024 
00025 /*       operation strings      */
00026 
00027 #define  STAT_ST        "stats"
00028 #define  BI_STAT_ST     "bi_stats"
00029 #define  HIST_ST        "hist"
00030 #define  CORR_ST        "correlate"
00031 #define  POINTS_ST      "points"
00032 #define  SLICE_VALS_ST  "slice_vals"
00033 #define  UTEST_ST       "u_test"
00034 #define  UTEST1_ST      "u_test_1m"
00035 
00036 
00037 /*       general definitions    */
00038 
00039 #define  MAX_INPUTS             3
00040 #define  MAX_SUB_BRICKS         2000
00041 
00042 #define  R_MAX_AFNI_DSETS       3
00043 #define  R_FILE_L               128
00044 #define  R_MESSAGE_L            1024
00045 #define  R_MAX_BINS             10000
00046 
00047 typedef struct
00048 {
00049     /* set before reading afni info */
00050     int                 must_be_short;               /* must input be short   */
00051     int                 want_floats;                 /* create fimage ?       */
00052     int                 subs_must_equal;             /* require same number   */
00053     int                 max_subs;                    /* max number of subs    */
00054 
00055     /* basic afni stuff */
00056     THD_3dim_dataset  * dset    [ R_MAX_AFNI_DSETS ];
00057     short            ** simage  [ R_MAX_AFNI_DSETS ]; /* must allocate        */
00058     float             * factor  [ R_MAX_AFNI_DSETS ]; /* must allocate        */
00059     int                 subs    [ R_MAX_AFNI_DSETS ]; /* number of subbricks  */
00060 
00061     int                 nx, ny, nz, nvox;
00062 
00063     /* other */
00064     float             * fimage  [ R_MAX_AFNI_DSETS ]; /* shorts with factor   */
00065 
00066     u_short             max_u_short;                  /* no factor considered */
00067     int                 num_dsets;                    /* number read in       */
00068 } r_afni_s;
00069 
00070 
00071 typedef enum operation_enum
00072         { no_op, hist_op, stats_op, last_op } op_enum;
00073 
00074 static char * gr_op_strings[] =
00075         { "hist", "stats" };
00076 static int    gr_num_ops      = 2;
00077 static char * gr_yn_strings[] = { "y", "n" };
00078 static int    gr_num_yn_strings = 2;
00079 
00080 
00081 typedef struct
00082 {
00083     op_enum     operation;      /* which function to execute    */
00084 
00085     float       min, max;       /* restrictions on data values  */
00086     int         use_min;
00087     int         use_max;
00088     int         use_tails;
00089 
00090     int         num_bins;       /* number of bins for histogram */
00091 
00092     char      * comment;        /* comment to print for point display */
00093     int         use_comment;
00094 
00095     int         slice_number;   /* slice number to print out    */
00096     int         use_LPI;        /* boolean                      */
00097 
00098     char      * outfile;        /* memory is on the afni side   */
00099     FILE      * outfp;
00100 } mask_opt_s;
00101 
00102 
00103 /*----------------------------------------------------------------------*/
00104 
00105 static  int     check_usage             ( int, char **, mask_opt_s * );
00106 static  int     file_exists             ( char *, char * );
00107 static  char *  fill_afni_struct        ( r_afni_s * );
00108 static  FILE *  open_file               ( char *, char * );
00109 static  void    print_stats_header      ( FILE * );
00110 static  void    print_empty_stats       ( FILE * );
00111 static  char *  process                 ( r_afni_s *, mask_opt_s * );
00112 static  char *  process_args            ( r_afni_s *, mask_opt_s *,
00113                                           PLUGIN_interface * );
00114 static  u_short r_get_max_u_short       ( u_short *, int );
00115 static  int     read_dataset            ( char *, int );
00116 static  void    usage                   ( char *, char *, int, mask_opt_s * );
00117 
00118 static  int     op_type                 ( char * );
00119 
00120 static  int     assign_afni_floats      ( r_afni_s * );
00121 static  void    assign_min_max          ( float *, long, float *, float * );
00122 static  char *  calc_hist               ( r_afni_s *, mask_opt_s * );
00123 static  char *  calc_stats              ( r_afni_s *, mask_opt_s * );
00124 
00125 static  void    do_stats                ( r_afni_s *, float *, long, float,
00126                                           float, int, FILE *, long *, float *,
00127                                           float * );
00128 static  void    do_bi_stats             ( r_afni_s *, mask_opt_s * );
00129 
00130 static  long    get_mask_size           ( r_afni_s *, int, int );
00131 static  long    mask_all_shorts_to_float( r_afni_s *, int, int, float * );
00132 static  long    mask_shorts_to_float    ( r_afni_s *, float *, int, int, int );
00133 static  long    mask_shorts_to_short    ( r_afni_s *, short *, int, int, int );
00134 static  int     num_places              ( float, int );
00135         int     short_test              ( const void *, const void * );
00136 
00137 
00138 
00139 /*----------------------------------------------------------------------
00140 
00141 Adding a new function to maskcalc:
00142 
00143 - define function_OP, func_ST, USEfunc
00144 - add F_OP to read_args( )      ( check subbricks in read_dataset )
00145 - add F_OP to check_usage ( )
00146 - add F_ST usage to usage( )    ( and add to USEFULL )
00147 - add F_OP to op_type( )
00148 - add F_OP to process( )
00149 - write new function and prototype
00150 
00151   ----------------------------------------------------------------------
00152 */
 

Powered by Plone

This site conforms to the following standards: