Doxygen Source Code Documentation
plug_second_dataset.c File Reference
#include "afni.h"Go to the source code of this file.
Defines | |
| #define | DSET2_VERSION "Version 1.1 <October, 2002>" |
Functions | |
| char * | DSET2_main (PLUGIN_interface *) |
| void | DSET2_func (int num, double to, double dt, float *vec) |
| void | DSET2_dset_recv (int why, int np, int *ijk, void *aux) |
| void | DSET2_func_init (void) |
| DEFINE_PLUGIN_PROTOTYPE PLUGIN_interface * | PLUGIN_init (int ncall) |
Variables | |
| char | helpstring [] |
| THD_3dim_dataset * | dset = NULL |
| MCW_idcode | g_id |
| int | g_dset_recv = -1 |
| int | justify = 0 |
| int | fill = 0 |
| char * | lr [2] = { "Left" , "Right" } |
| char * | ez [2] = { "Extend" , "Zero" } |
| PLUGIN_interface * | plint = NULL |
Define Documentation
|
|
Definition at line 13 of file plug_second_dataset.c. |
Function Documentation
|
||||||||||||||||||||
|
Definition at line 168 of file plug_second_dataset.c. References AFNI_receive_control(), ENTRY, EVERYTHING_SHUTDOWN, g_dset_recv, ISVALID_DSET, ISZERO_IDCODE, MCW_TIMER_KILL, MCW_USER_KILL, plint, PLUTO_find_dset(), PLUTO_popup_worker(), RECEIVE_ALTERATION, RECEIVE_DSETCHANGE, and ZERO_IDCODE. Referenced by DSET2_main().
00169 {
00170 PLUGIN_interface * plint = (PLUGIN_interface *)aux;
00171
00172 ENTRY( "DSET2_dset_recv" );
00173
00174 switch ( why )
00175 {
00176 default:
00177 {
00178 fprintf( stderr, "warning: DSET2_dset_recv() called with invalid "
00179 "why code, %d\n", why );
00180 EXRETURN;
00181 }
00182
00183 case RECEIVE_ALTERATION: /* may take effect before DSETCHANGE */
00184 case RECEIVE_DSETCHANGE:
00185 {
00186 /* update global dset with idcode */
00187 if ( ! ISZERO_IDCODE( g_id ) )
00188 {
00189 dset = PLUTO_find_dset( &g_id );
00190
00191 if( !ISVALID_DSET(dset) ) /* dset has disappeared */
00192 {
00193 ZERO_IDCODE( g_id );
00194 dset = NULL;
00195 }
00196 }
00197 else
00198 dset = NULL;
00199
00200 if ( dset == NULL ) /* shutdown messaging, must re-run plugin */
00201 {
00202 AFNI_receive_control( plint->im3d, g_dset_recv,
00203 EVERYTHING_SHUTDOWN, NULL );
00204 g_dset_recv = -1;
00205 PLUTO_popup_worker( plint,
00206 "Warning: plugin 'Dataset#2'\n"
00207 "has lost its dataset link.\n"
00208 "To plot a 1-D overlay, please\n"
00209 "re-run the plugin.",
00210 MCW_USER_KILL | MCW_TIMER_KILL ) ;
00211 }
00212 }
00213 }
00214
00215 EXRETURN;
00216 }
|
|
||||||||||||||||||||
|
Definition at line 220 of file plug_second_dataset.c. References AFNI_needs_dset_ijk(), DSET_load, dt, ENTRY, fill, ISVALID_DSET, justify, MRI_FLOAT_PTR, mri_free(), MRI_IMAGE::nx, THD_extract_series(), and vec. Referenced by PLUGIN_init().
00221 {
00222 int ii , ijk , jj ;
00223 MRI_IMAGE * tsim ;
00224 float val ;
00225
00226 ENTRY("DSET2_func") ;
00227
00228 if( !ISVALID_DSET(dset) ) EXRETURN ; /* nothing to do */
00229
00230 DSET_load(dset) ; /* if needed */
00231
00232 ijk = AFNI_needs_dset_ijk() ; /* voxel index from AFNI */
00233
00234 tsim = THD_extract_series( ijk , dset , 0 ) ; /* get data */
00235
00236 if( tsim == NULL ) EXRETURN ; /* bad news */
00237
00238 if( tsim->nx == num ){ /* exact fit */
00239
00240 memcpy(vec,MRI_FLOAT_PTR(tsim),sizeof(float)*num) ; /* copy data */
00241
00242 } else if( tsim->nx < num ){ /* too little data */
00243
00244 if( justify == 0 ){ /* left justify */
00245 memcpy(vec,MRI_FLOAT_PTR(tsim),sizeof(float)*tsim->nx) ;
00246
00247 val = (fill == 0) ? vec[tsim->nx-1] /* extend fill */
00248 : 0.0 ; /* zero fill */
00249
00250 for( ii=tsim->nx ; ii < num ; ii++ ) vec[ii] = val ;
00251
00252 } else { /* right justify */
00253 jj = num - tsim->nx ;
00254 memcpy(vec+jj,MRI_FLOAT_PTR(tsim),sizeof(float)*tsim->nx) ;
00255
00256 val = (fill == 0) ? vec[jj] /* extend fill */
00257 : 0.0 ; /* zero fill */
00258
00259 for( ii=0 ; ii < jj ; ii++ ) vec[ii] = val ;
00260 }
00261
00262 } else { /* too much data */
00263
00264 if( justify == 0 ){ /* left justify */
00265 memcpy(vec,MRI_FLOAT_PTR(tsim),sizeof(float)*num) ;
00266 } else {
00267 jj = tsim->nx - num ;
00268 memcpy(vec,MRI_FLOAT_PTR(tsim)+jj,sizeof(float)*num) ;
00269 }
00270 }
00271
00272 mri_free(tsim) ; /* toss the trash */
00273 EXRETURN ;
00274 }
|
|
|
Definition at line 77 of file plug_second_dataset.c. References plint, and PLUG_startup_plugin_CB(). Referenced by PLUGIN_init().
00078 {
00079 PLUG_startup_plugin_CB( NULL , (XtPointer)plint , NULL ) ;
00080 }
|
|
|
Definition at line 123 of file plug_second_dataset.c. References AFNI_receive_init(), DSET2_dset_recv(), ENTRY, ez, fill, g_dset_recv, justify, lr, plint, PLUTO_find_dset(), RECEIVE_DSETCHANGE_MASK, and RETURN. Referenced by PLUGIN_init().
00124 {
00125 MCW_idcode * idc ;
00126 char * str ;
00127
00128 ENTRY("DSET2_main") ;
00129
00130 if( plint == NULL )
00131 RETURN("***********************\n"
00132 "DSET2_main: NULL input\n"
00133 "***********************") ;
00134
00135 PLUTO_next_option(plint) ;
00136 idc = PLUTO_get_idcode(plint) ;
00137 dset = PLUTO_find_dset(idc) ;
00138 if( dset == NULL )
00139 RETURN("******************************\n"
00140 "DSET2_main: bad input dataset\n"
00141 "******************************") ;
00142
00143 g_id = *idc ; /* make a copy of the MCW_idcode */
00144
00145 PLUTO_next_option(plint) ;
00146 str = PLUTO_get_string(plint) ;
00147 justify = (strcmp(str,lr[0]) != 0) ;
00148
00149 PLUTO_next_option(plint) ;
00150 str = PLUTO_get_string(plint) ;
00151 fill = (strcmp(str,ez[0]) != 0) ;
00152
00153 if ( g_dset_recv < 0 ) /* only initialize once */
00154 g_dset_recv = AFNI_receive_init( plint->im3d, RECEIVE_DSETCHANGE_MASK,
00155 DSET2_dset_recv, (void *)plint ,
00156 "DSET2_dset_recv" ) ;
00157
00158 if ( g_dset_recv < 0 )
00159 RETURN("*************************************\n"
00160 "DSET2_main: failed AFNI_receive_init\n"
00161 "*************************************") ;
00162
00163 RETURN(NULL) ;
00164 }
|
|
|
Definition at line 85 of file plug_second_dataset.c. References AFNI_register_nD_func_init(), AFNI_register_nD_function(), ANAT_ALL_MASK, DSET2_func(), DSET2_func_init(), DSET2_main(), ENTRY, ez, fill, FUNC_ALL_MASK, generic_func, helpstring, justify, lr, NEEDS_DSET_INDEX, plint, PLUTO_add_hint(), PLUTO_set_runlabels(), PLUTO_set_sequence(), and RETURN.
00086 {
00087
00088 ENTRY("PLUGIN_init - Dataset#2") ;
00089
00090 if( ncall > 0 ) RETURN( NULL ) ; /* only one interface */
00091
00092 AFNI_register_nD_function ( 1 , "Dataset#2" , (generic_func *)DSET2_func ,
00093 NEEDS_DSET_INDEX ) ;
00094 AFNI_register_nD_func_init( 1 , (generic_func *)DSET2_func_init ) ; /* 21 Jul 2003 */
00095
00096 plint = PLUTO_new_interface( "Dataset#2" , "Controls 1D function Dataset#2" , helpstring ,
00097 PLUGIN_CALL_VIA_MENU , DSET2_main ) ;
00098
00099 PLUTO_add_hint( plint , "Controls 1D function Dataset#2" ) ;
00100
00101 PLUTO_set_runlabels( plint , "Set+Keep" , "Set+Close" ) ; /* 04 Nov 2003 */
00102
00103 PLUTO_set_sequence( plint , "A:funcs:dataset#2" ) ;
00104
00105 PLUTO_add_option( plint , "Input" , "Input" , TRUE ) ;
00106 PLUTO_add_dataset(plint , "Dataset" ,
00107 ANAT_ALL_MASK , FUNC_ALL_MASK ,
00108 DIMEN_4D_MASK | BRICK_ALLREAL_MASK ) ;
00109
00110 PLUTO_add_option( plint , "Where" , "Where" , TRUE ) ;
00111 PLUTO_add_string( plint, "Justify", 2, lr, justify ) ;
00112
00113 PLUTO_add_option( plint , "How" , "How" , TRUE ) ;
00114 PLUTO_add_string( plint, "Fill", 2, ez, fill ) ;
00115
00116 RETURN( plint ) ;
00117 }
|
Variable Documentation
|
|
Definition at line 62 of file plug_second_dataset.c. |
|
|
Definition at line 73 of file plug_second_dataset.c. Referenced by DSET2_main(), and PLUGIN_init(). |
|
|
Definition at line 66 of file plug_second_dataset.c. Referenced by DSET2_func(), DSET2_main(), and PLUGIN_init(). |
|
|
Definition at line 64 of file plug_second_dataset.c. Referenced by DSET2_dset_recv(), and DSET2_main(). |
|
|
Definition at line 63 of file plug_second_dataset.c. |
|
|
Initial value: " Purpose: Control the 'Dataset#2' 1D timeseries function\n" "\n" " Dataset = a 3D+time dataset from which to extract data\n" "\n" " Justify = Left means to put timeseries data at start of output array\n" " Right means to put timeseries data at end of output array\n" "\n" " Fill = Extend means to copy the last value\n" " Zero means to fill with zeros\n" "\n" " Justify and Fill are only used when the number of points in the input\n" " dataset doesn't match the number of points in the timeseries being replaced.\n" " Let M = length of dataset, N = length of timeseries,\n" " ts[] = timeseries array, ds[] = dataset array.\n" "\n" " Case: M < N (too little data to fill timeseries)\n" " Left: ts[i] = ds[i] i=0..M-1 Data goes to left\n" " = ds[M-1] i=M..N-1 if Extend edge of timeseries\n" " = 0.0 i=M..N-1 if Zero\n" " Right: ts[i] = ds[0] i=0..J-1 if Extend (with J=N-M) Data goes to right\n" " = 0.0 i=0..J-1 if Zero edge of timeseries\n" " = ds[i-J] i=J..N-1\n" " Case: M > N (too much data for timeseries)\n" " Left: ts[i] = ds[i] i=0..N-1 Left data to ts[]\n" " Right: ts[i] = ds[i+J] i=0..N-1 (with J=M-N) Right data to ts[]\n" "\n" " -- RWCox - 18 May 2000\n" Definition at line 32 of file plug_second_dataset.c. Referenced by PLUGIN_init(). |
|
|
Definition at line 65 of file plug_second_dataset.c. Referenced by DSET2_func(), DSET2_main(), and PLUGIN_init(). |
|
|
Definition at line 72 of file plug_second_dataset.c. Referenced by DSET2_main(), and PLUGIN_init(). |
|
|
Definition at line 75 of file plug_second_dataset.c. Referenced by DSET2_dset_recv(), DSET2_func_init(), DSET2_main(), and PLUGIN_init(). |