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
00003
00004
00005
00006
00007
00008
00009 #define USENOOP 0
00010 #define USEFULL 1
00011 #define USEOTHER 2
00012
00013
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
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
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
00050 int must_be_short;
00051 int want_floats;
00052 int subs_must_equal;
00053 int max_subs;
00054
00055
00056 THD_3dim_dataset * dset [ R_MAX_AFNI_DSETS ];
00057 short ** simage [ R_MAX_AFNI_DSETS ];
00058 float * factor [ R_MAX_AFNI_DSETS ];
00059 int subs [ R_MAX_AFNI_DSETS ];
00060
00061 int nx, ny, nz, nvox;
00062
00063
00064 float * fimage [ R_MAX_AFNI_DSETS ];
00065
00066 u_short max_u_short;
00067 int num_dsets;
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;
00084
00085 float min, max;
00086 int use_min;
00087 int use_max;
00088 int use_tails;
00089
00090 int num_bins;
00091
00092 char * comment;
00093 int use_comment;
00094
00095 int slice_number;
00096 int use_LPI;
00097
00098 char * outfile;
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
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152