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_maxima.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 /*----------------------------------------------------------------------
00008  *
00009  *  plug_maxima.h
00010  *
00011  *----------------------------------------------------------------------
00012 */
00013 
00014 
00015 /*  AFNI stuff  */
00016 /*--------------------  defines    ----------------------------------------*/
00017 
00018 #define R_MAX_AFNI_DSETS          3
00019 #define R_MESSAGE_L             256
00020 #define R_FILE_L                128
00021 
00022 #define rWARNING( string ) fprintf( stderr, "\033[1m%s\033[0m\n", string )
00023 #define rERROR(   string ) fprintf( stderr, "\007\033[2m%s\033[0m\n", string )
00024 
00025 
00026 /*--------------------  typedefs   ----------------------------------------*/
00027 
00028 typedef struct
00029 {
00030     /* set before reading afni info */
00031     int                 must_be_short;               /* must input be short   */
00032     int                 want_floats;                 /* create fimage ?       */
00033     int                 subs_must_equal;             /* require same number   */
00034     int                 max_subs;                    /* max number of subs    */
00035 
00036     /* basic afni stuff */
00037     THD_3dim_dataset  * dset    [ R_MAX_AFNI_DSETS ];
00038     short             * simage  [ R_MAX_AFNI_DSETS ];
00039     float               factor  [ R_MAX_AFNI_DSETS ];
00040     int                 subs    [ R_MAX_AFNI_DSETS ]; /* number of subbricks  */
00041     int                 sub_brick;                    /* user chosen index    */
00042 
00043     int                 nx, ny, nz, nvox;
00044 
00045     /* other */
00046     float             * fimage  [ R_MAX_AFNI_DSETS ]; /* shorts with factor   */
00047 
00048     u_short             max_u_short;                  /* no factor considered */
00049     int                 num_dsets;                    /* number read in       */
00050 } r_afni_s;
00051 
00052 
00053 /*--------------------  globals    ----------------------------------------*/
00054 
00055 extern char grMessage [ R_MESSAGE_L ];          /* global message string */
00056 
00057 
00058 
00059 
00060 /*-- maxima stuff ---*/
00061 
00062 
00063 #define MAX_MASK_FILL_VAL       1
00064 
00065 #define MAX_SORT_N_REMOVE_STYLE 1
00066 #define MAX_WEIGHTED_AVE_STYLE  2
00067 #define MAX_MAX_STYLE           2
00068 
00069 typedef struct
00070 {
00071     int   * plist;
00072     int     used;
00073     int     M;
00074 } point_list_s;
00075 
00076 
00077 typedef struct
00078 {
00079     THD_3dim_dataset  * dset;                   /* input dset                 */
00080     short             * sdata;                  /* short data from dset       */
00081     short             * result;                 /* requires own M             */
00082     int                 nx, ny, nz, nxy, nvox;
00083 
00084     point_list_s        P;                      /* point list in result       */
00085 
00086     int                 extrema_count;          /* number of extrema          */
00087 
00088     int                 data_type;              /* MRI_short, etc             */
00089     int                 adn_type;               /* HEAD_ANAT/FUNC             */
00090     int                 func_type;              /* FUNC_FIM_TYPE?             */
00091 
00092     char                outfile[ R_FILE_L ];    /* output prefix              */
00093     int                 sval_style;             /* sphere vals: 1, 1toN, Nto1 */
00094 
00095     float               cutoff;                 /* acceptable value cutoff    */
00096     float               min_dist;               /* distance between extrema   */
00097     float               out_rad;                /* mask radius around extrema */
00098 
00099     int                 negatives;              /* find negative extrema      */
00100     int                 ngbr_style;             /* what to do with neighbors  */
00101     int                 overwrite;              /* do we allow overwrite      */
00102     int                 quiet;                  /* no text output of results  */
00103     int                 true_max;               /* no neighbor equality       */
00104     int                 dicom_coords;           /* no neighbor equality       */
00105     int                 debug;                  /* debug level                */
00106 } maxima_s;
00107 
00108 
00109 static int      add_point_to_list  ( point_list_s *, int );
00110 static int      apply_fill_radius  ( maxima_s * );
00111 static int      apply_min_dist     ( maxima_s * );
00112 static int      clear_around_point ( int, maxima_s *, point_list_s * );
00113 static int      create_point_list  ( maxima_s * );
00114 static int      display_coords     ( r_afni_s *, maxima_s * );
00115 static int      find_local_maxima  ( maxima_s * );
00116 static void     free_memory        ( r_afni_s *, maxima_s * );
00117 static int      init_maxima_s      ( maxima_s *, r_afni_s *, char * );
00118 static int      init_afni_s        ( r_afni_s * );
00119 static char *   process_args       ( r_afni_s *, maxima_s *,PLUGIN_interface *);
00120 static int      process_data       ( maxima_s * );
00121 static int      radial_fill        ( int, int, int, maxima_s *, int );
00122 static int      weighted_index     ( point_list_s *, maxima_s * );
00123 static int      write_results      ( r_afni_s *, maxima_s *,PLUGIN_interface *);
00124 
00125 static void     show_point_list_s  ( char * mesg, point_list_s *, int );
00126 static void     show_maxima_s      ( char * mesg, maxima_s * );
00127 
00128 int             point_comp_neg     ( const void *, const void * );
00129 int             point_comp_pos     ( const void *, const void * );
00130 
00131 
00132 int r_set_afni_s_from_dset( r_afni_s *, THD_3dim_dataset * );
00133 u_short r_get_max_u_short( ushort *, int );
00134 
00135 
00136 /* global var for comparison function use */
00137 static short *  gr_orig_data = NULL;
00138 static float    gr_fac = 1.0;
00139 
00140 
 

Powered by Plone

This site conforms to the following standards: