Doxygen Source Code Documentation
plug_roiplot.c File Reference
#include "afni.h"
Go to the source code of this file.
Defines | |
#define | MAX_NC 7 |
Functions | |
void | ROIPLOT_tsgraph_draw (void) |
void | ROIPLOT_tsgraph_mtdkill (MEM_topshell_data *mp) |
char * | ROIPLOT_main (PLUGIN_interface *) |
DEFINE_PLUGIN_PROTOTYPE PLUGIN_interface * | PLUGIN_init (int ncall) |
Variables | |
int | tsgraph_num = 0 |
MEM_topshell_data * | tsgraph_mtd = NULL |
char | helpstring [] |
Define Documentation
|
|
Function Documentation
|
Definition at line 58 of file plug_roiplot.c. References ANAT_ALL_MASK, FUNC_ALL_MASK, helpstring, PLUTO_add_hint(), PLUTO_set_runlabels(), PLUTO_set_sequence(), and ROIPLOT_main().
00059 { 00060 PLUGIN_interface * plint ; 00061 00062 if( ncall > 0 ) return NULL ; /* only one interface */ 00063 00064 /*-- set titles and call point --*/ 00065 00066 plint = PLUTO_new_interface( "ROI Plot" , "Plot Average Timeseries over ROI" , 00067 helpstring , 00068 PLUGIN_CALL_VIA_MENU , ROIPLOT_main ) ; 00069 00070 PLUTO_short_choose(plint) ; 00071 PLUTO_short_number(plint) ; 00072 00073 PLUTO_add_hint( plint , "Plot Average Timeseries over ROI" ) ; 00074 00075 PLUTO_set_sequence( plint , "A:afniinfo:dset" ) ; 00076 00077 PLUTO_set_runlabels( plint , "Plot+Keep" , "Plot+Close" ) ; /* 04 Nov 2003 */ 00078 00079 /*-- first line of input --*/ 00080 00081 PLUTO_add_option( plint , "Source" , "Source" , TRUE ) ; 00082 PLUTO_add_dataset(plint , "Timeseries" , 00083 ANAT_ALL_MASK , FUNC_ALL_MASK , 00084 DIMEN_4D_MASK | BRICK_ALLREAL_MASK ) ; 00085 00086 PLUTO_add_number( plint , "Start" , 0,99999,0 , 0 ,1 ) ; 00087 PLUTO_add_number( plint , "Stop" , 0,99999,0 , 99999,1 ) ; 00088 00089 /*-- second line of input --*/ 00090 00091 PLUTO_add_option( plint , "Cluster" , "Cluster" , FALSE ) ; 00092 PLUTO_add_dataset( plint , "From" , 00093 ANAT_ALL_MASK , FUNC_ALL_MASK , 00094 DIMEN_ALL_MASK | BRICK_ALLREAL_MASK ) ; 00095 PLUTO_add_number( plint , "Index" , 0,99999,0 , 0,1 ) ; 00096 PLUTO_add_number( plint , "Thresh", 0,9999 ,1 , 1,1 ) ; 00097 PLUTO_add_number( plint , "rmm" , 0,99 ,1 , 11,1 ) ; 00098 PLUTO_add_number( plint , "vmul" , 0,9999,-1 , 20,1 ) ; 00099 00100 /*-- third line of input --*/ 00101 00102 PLUTO_add_option( plint , "Values" , "Values" , FALSE ) ; 00103 PLUTO_add_dataset( plint , "From" , 00104 ANAT_ALL_MASK , FUNC_ALL_MASK , 00105 DIMEN_ALL_MASK | BRICK_ALLREAL_MASK ) ; 00106 PLUTO_add_number( plint , "Index" , 0,99999,0 , 0,1 ) ; 00107 PLUTO_add_number( plint , "Min" , 0,99999,0 , 0 ,1 ) ; 00108 PLUTO_add_number( plint , "Max" , 0,99999,0 , 99999,1 ) ; 00109 00110 return plint ; 00111 } |
|
Definition at line 117 of file plug_roiplot.c. References ADDTO_CLARR, MCW_cluster_array::clar, THD_3dim_dataset::daxes, DESTROY_CLARR, DSET_ARRAY, DSET_BRICK_FACTOR, DSET_BRICK_TYPE, DSET_load, DSET_NVALS, DSET_NVOX, EDIT_coerce_scale_type(), free, MCW_cluster::i, INIT_CLARR, MCW_cluster::j, MCW_cluster::k, malloc, MCW_find_clusters(), memplot_to_topshell(), mp, MRI_FLOAT_PTR, mri_free(), nc, MCW_cluster_array::num_clu, MCW_cluster::num_pt, MRI_IMAGE::nx, THD_dataxes::nxx, MRI_IMAGE::ny, THD_dataxes::nyy, nz, THD_dataxes::nzz, plot_ts_mem(), PLUTO_find_dset(), SORT_CLARR, THD_average_timeseries(), thr, THD_dataxes::xxdel, THD_dataxes::yydel, and THD_dataxes::zzdel. Referenced by PLUGIN_init().
00118 { 00119 MCW_idcode *idc ; 00120 THD_3dim_dataset *input_dset , *mask_dset ; 00121 int iv_start,iv_stop , nvox , iv_mask ; 00122 float thr,rmm,vmul , dx,dy,dz ; 00123 int val_min , val_max , nx,ny,nz , ii,jj , nt,nc ; 00124 char *tag ; 00125 MCW_cluster_array *clustar ; 00126 MRI_IMAGE *flim ; 00127 float *flar , **yar , *xar , xcm,ycm,zcm ; 00128 char **nam_yyy ; 00129 MEM_plotdata * mp ; 00130 00131 #define MAX_NC 7 00132 00133 /*--------------------------------------------------------------------*/ 00134 /*----- Check inputs from AFNI to see if they are reasonable-ish -----*/ 00135 00136 if( plint == NULL ) 00137 return "*************************\n" 00138 "ROIPLOT_main: NULL input\n" 00139 "*************************" ; 00140 00141 /*-- read 1st line --*/ 00142 00143 PLUTO_next_option(plint) ; 00144 idc = PLUTO_get_idcode(plint) ; 00145 input_dset = PLUTO_find_dset(idc) ; 00146 if( input_dset == NULL ) 00147 return "*********************************\n" 00148 "ROIPLOT_main: bad Source dataset\n" 00149 "*********************************" ; 00150 00151 iv_start = (int) PLUTO_get_number(plint) ; 00152 iv_stop = (int) PLUTO_get_number(plint) ; 00153 if( iv_stop >= DSET_NVALS(input_dset) ) iv_stop = DSET_NVALS(input_dset)-1 ; 00154 if( iv_start >= iv_stop ) 00155 return "***********************************\n" 00156 "ROIPLOT_main: bad Start/Stop range\n" 00157 "***********************************" ; 00158 DSET_load(input_dset) ; 00159 if( DSET_ARRAY(input_dset,iv_stop) == NULL ) 00160 return "****************************************\n" 00161 "ROIPLOT_main: can't load Source dataset\n" 00162 "****************************************" ; 00163 00164 nx = input_dset->daxes->nxx ; dx = fabs(input_dset->daxes->xxdel) ; 00165 ny = input_dset->daxes->nyy ; dy = fabs(input_dset->daxes->yydel) ; 00166 nz = input_dset->daxes->nzz ; dz = fabs(input_dset->daxes->zzdel) ; 00167 nvox = nx*ny*nz ; 00168 00169 /*-- read next lines --*/ 00170 00171 tag = PLUTO_get_optiontag(plint) ; 00172 if( tag == NULL ) 00173 return "***********************************" 00174 "ROIPLOT_main: no ROI selection made\n" 00175 "***********************************" ; 00176 00177 /*--------------------------------------*/ 00178 00179 if( strcmp(tag,"Cluster") == 0 ){ 00180 float *vfim ; 00181 MCW_cluster_array *clbig ; 00182 MCW_cluster *cl ; 00183 int ptmin ; 00184 00185 idc = PLUTO_get_idcode(plint) ; 00186 mask_dset = PLUTO_find_dset(idc) ; 00187 if( mask_dset == NULL ) 00188 return "**********************************\n" 00189 "ROIPLOT_main: bad Cluster dataset\n" 00190 "**********************************" ; 00191 if( DSET_NVOX(mask_dset) != nvox ) 00192 return "******************************************************\n" 00193 "ROIPLOT_main: Source and Cluster datasets don't match\n" 00194 "******************************************************" ; 00195 iv_mask = (int) PLUTO_get_number(plint) ; 00196 if( iv_mask >= DSET_NVALS(mask_dset) ) 00197 return "********************************\n" 00198 "ROIPLOT_main: bad Cluster index\n" 00199 "*********************************" ; 00200 DSET_load(mask_dset) ; 00201 if( DSET_ARRAY(mask_dset,iv_mask) == NULL ) 00202 return "*****************************************\n" 00203 "ROIPLOT_main: can't load Cluster dataset\n" 00204 "*****************************************\n" ; 00205 00206 thr = PLUTO_get_number(plint) ; 00207 rmm = PLUTO_get_number(plint) ; 00208 vmul = PLUTO_get_number(plint) ; 00209 00210 vfim = (float *) malloc(sizeof(float)*nx*ny*nz) ; 00211 EDIT_coerce_scale_type( nvox , 00212 DSET_BRICK_FACTOR(mask_dset,iv_mask) , 00213 DSET_BRICK_TYPE(mask_dset,iv_mask) , 00214 DSET_ARRAY(mask_dset,iv_mask) , 00215 MRI_float , vfim ) ; 00216 if( thr > 0.0 ){ 00217 for( ii=0 ; ii < nvox ; ii++ ) 00218 if( fabs(vfim[ii]) < thr ) vfim[ii] = 0.0 ; 00219 } 00220 00221 clustar = MCW_find_clusters( nx,ny,nz , dx,dy,dz , 00222 MRI_float , vfim , rmm ) ; 00223 free(vfim) ; 00224 00225 if( clustar == NULL ) 00226 return "********************************\n" 00227 "ROIPLOT_main: no Clusters found\n" 00228 "********************************\n" ; 00229 00230 /* edit for volume */ 00231 00232 ptmin = (int) (vmul / (dx*dy*dz) + 0.99) ; 00233 INIT_CLARR(clbig) ; 00234 for( ii=0 ; ii < clustar->num_clu ; ii++ ){ 00235 cl = clustar->clar[ii] ; 00236 if( cl != NULL && cl->num_pt >= ptmin ){ /* big enough */ 00237 ADDTO_CLARR(clbig,cl) ; /* copy pointer */ 00238 clustar->clar[ii] = NULL ; /* null out original */ 00239 } 00240 } 00241 DESTROY_CLARR(clustar) ; 00242 clustar = clbig ; 00243 if( clustar == NULL || clustar->num_clu == 0 ){ 00244 printf("** NO CLUSTERS FOUND ***\n") ; 00245 if( clustar != NULL ) DESTROY_CLARR(clustar) ; 00246 return "********************************\n" 00247 "ROIPLOT_main: no Clusters found\n" 00248 "********************************\n" ; 00249 } 00250 SORT_CLARR(clustar) ; 00251 00252 /*--------------------------------------*/ 00253 00254 } else if( strcmp(tag,"Values") == 0 ){ 00255 idc = PLUTO_get_idcode(plint) ; 00256 mask_dset = PLUTO_find_dset(idc) ; 00257 if( mask_dset == NULL ) 00258 return "*********************************\n" 00259 "ROIPLOT_main: bad Values dataset\n" 00260 "*********************************" ; 00261 if( DSET_NVOX(mask_dset) != nvox ) 00262 return "*****************************************************\n" 00263 "ROIPLOT_main: Source and Values datasets don't match\n" 00264 "*****************************************************" ; 00265 iv_mask = (int) PLUTO_get_number(plint) ; 00266 if( iv_mask >= DSET_NVALS(mask_dset) ) 00267 return "*******************************\n" 00268 "ROIPLOT_main: bad Values index\n" 00269 "********************************" ; 00270 DSET_load(mask_dset) ; 00271 if( DSET_ARRAY(mask_dset,iv_mask) == NULL ) 00272 return "****************************************\n" 00273 "ROIPLOT_main: can't load Values dataset\n" 00274 "****************************************\n" ; 00275 00276 val_min = (int) PLUTO_get_number(plint) ; 00277 val_max = (int) PLUTO_get_number(plint) ; 00278 if( val_max < val_min ) val_max = val_min ; 00279 00280 /* must build cluster here */ 00281 00282 return "****************************************\n" 00283 "ROIPLOT_main: Values NOT IMPLEMENT YET!\n" 00284 "****************************************\n" ; 00285 00286 } else { 00287 return "*******************************\n" 00288 "ROIPLOT_main: no ROI selection?\n" 00289 "********************************" ; 00290 } 00291 00292 /* check for too many options */ 00293 00294 tag = PLUTO_get_optiontag(plint) ; 00295 if( tag != NULL ) 00296 PLUTO_popup_transient(plint,"\n" 00297 "+++++++ WARNING ++++++++\n" 00298 " Using Cluster option;\n" 00299 " Ignoring Values option\n" ) ; 00300 00301 /* extract average time series */ 00302 00303 flim = THD_average_timeseries( clustar , input_dset ) ; 00304 00305 if( flim == NULL ){ 00306 DESTROY_CLARR(clustar) ; 00307 return "***********************************************\n" 00308 "ROIPLOT_main: Can't extract average timeseries\n" 00309 "***********************************************\n" ; 00310 } 00311 00312 nc = flim->ny ; if( nc > MAX_NC ) nc = MAX_NC ; 00313 nt = flim->nx ; 00314 flar = MRI_FLOAT_PTR(flim) ; 00315 yar = (float **) malloc(sizeof(float *)*nc) ; 00316 for( ii=0 ; ii < nc ; ii++ ) yar[ii] = flar + (ii*nt+iv_start) ; 00317 xar = (float *) malloc(sizeof(float)*nt) ; 00318 for( ii=0 ; ii < nt ; ii++ ) xar[ii] = ii ; 00319 nam_yyy = (char **) malloc(sizeof(char *)*nc) ; 00320 for( ii=0 ; ii < nc ; ii++ ){ 00321 xcm = ycm = zcm = 0.0 ; 00322 for( jj=0 ; jj < clustar->clar[ii]->num_pt ; jj++ ){ 00323 xcm += clustar->clar[ii]->i[ii] ; 00324 ycm += clustar->clar[ii]->j[ii] ; 00325 zcm += clustar->clar[ii]->k[ii] ; 00326 } 00327 xcm /= clustar->clar[ii]->num_pt ; 00328 ycm /= clustar->clar[ii]->num_pt ; 00329 zcm /= clustar->clar[ii]->num_pt ; 00330 nam_yyy[ii] = malloc(256) ; 00331 sprintf(nam_yyy[ii],"%d voxels\n" 00332 "_{ijk: %d %d %d}" , 00333 clustar->clar[ii]->num_pt , 00334 (int)(xcm+0.499) , (int)(ycm+0.499) , (int)(zcm+0.499) ) ; 00335 } 00336 DESTROY_CLARR(clustar); 00337 00338 mp = plot_ts_mem( iv_stop-iv_start+1 , xar+iv_start , 00339 nc,TSP_SEPARATE_YBOX,yar , 00340 NULL,NULL,NULL,nam_yyy ) ; 00341 00342 for( ii=0 ; ii < nc ; ii++ ) free(nam_yyy[ii]) ; 00343 free(nam_yyy); 00344 free(xar); free(yar); mri_free(flim); 00345 00346 if( mp == NULL ) 00347 return "******************************************\n" 00348 "ROIPLOT_main: Can't create in-memory plot\n" 00349 "******************************************\n" ; 00350 00351 memplot_to_topshell( plint->im3d->dc->display , mp , NULL ) ; 00352 00353 return NULL ; 00354 } |
|
|
|
|
Variable Documentation
|
Initial value: " Purpose: Plot averages over ROIs.\n" "\n" " INPUTS\n" " ------\n" " Source: Defines where the data to be averaged over the ROIs comes from.\n" " Dataset = Where to get time series values from\n" " Start = 1st sub-brick index to extract\n" " Stop = Last sub-brick index to extract\n" "\n" " Two methods are available to define the ROIs from which dataset values\n" " will be extracted. Only one of these can be used at a time:\n" "\n" " Cluster: Clusters of contiguous voxels are extracted (as in 3dclust),\n" " -------- and these are used for the ROIs.\n" " From = Dataset to define the clusters in\n" " Index = Sub-brick index to define the clusters in\n" " Thresh = Minimum value to accept in the sub-brick\n" " rmm }= Clustering radius and\n" " vmul }= minimum cluster volume\n" "\n" " Values: ROIs are defined by common values stored in a dataset, as\n" " ------- might be generated by the 'Draw Dataset' plugin.\n" " From = Dataset to define the ROIs\n" " Index = Sub-brick index to define the ROIs\n" " Min }= Range of values to\n" " Max }= use for the ROIS\n" " *** N.B.: Values selection is NOT YET IMPLEMENTED ***\n" "\n" " Author -- RW Cox - April 2002" Definition at line 19 of file plug_roiplot.c. Referenced by PLUGIN_init(). |
|
Definition at line 12 of file plug_roiplot.c. |
|
Definition at line 11 of file plug_roiplot.c. |