Doxygen Source Code Documentation
plug_copy.c File Reference
#include "afni.h"Go to the source code of this file.
Defines | |
| #define | NFILL 3 |
| #define | NDTYPE 4 |
Functions | |
| char * | COPY_main (PLUGIN_interface *) |
| DEFINE_PLUGIN_PROTOTYPE PLUGIN_interface * | PLUGIN_init (int ncall) |
Variables | |
| char | helpstring [] |
| char * | fill_options [NFILL] = { "Data [All]" , "Zero [All]" , "Zero [One]" } |
| char * | dtype_options [NDTYPE] |
| int | dtype_kinds [NDTYPE] |
Define Documentation
|
|
Definition at line 43 of file plug_copy.c. Referenced by COPY_main(), and PLUGIN_init(). |
|
|
Definition at line 40 of file plug_copy.c. Referenced by COPY_main(), and PLUGIN_init(). |
Function Documentation
|
|
Definition at line 107 of file plug_copy.c. References ADN_datum_all, ADN_func_type, ADN_label1, ADN_none, ADN_ntt, ADN_nvals, ADN_prefix, ADN_type, DSET_BRICK_ARRAY, DSET_BRICK_BYTES, DSET_BRICK_TYPE, DSET_delete, DSET_NVALS, DSET_unload, dtype_kinds, dtype_options, EDIT_BRICK_FACTOR, EDIT_dset_items(), EDIT_empty_copy(), EDIT_substitute_brick(), fill_options, free, FUNC_FIM_TYPE, HEAD_ANAT_TYPE, HEAD_FUNC_TYPE, ISFUNCTYPE, LAST_FUNC_TYPE, malloc, NDTYPE, NFILL, NUM_DSET_TYPES, PLUTO_add_dset(), PLUTO_commandstring(), PLUTO_copy_dset(), PLUTO_find_dset(), PLUTO_prefix_ok(), PLUTO_string_index(), THD_delete_3dim_dataset(), tross_Append_History(), tross_Copy_History(), and THD_3dim_dataset::type. Referenced by PLUGIN_init().
00108 {
00109 char * tag , * new_prefix , * cpt ;
00110 MCW_idcode * idc ;
00111 THD_3dim_dataset * dset , * new_dset ;
00112 int ival , zfill=0 , ftyp=-1 , dtyp=-1, type_index=-1, data_type=-1 ;
00113
00114 /*--------------------------------------------------------------------*/
00115 /*----- Check inputs from AFNI to see if they are reasonable-ish -----*/
00116
00117 if( plint == NULL )
00118 return "**********************\n"
00119 "COPY_main: NULL input\n"
00120 "**********************" ;
00121
00122 PLUTO_next_option(plint) ;
00123 idc = PLUTO_get_idcode(plint) ;
00124 dset = PLUTO_find_dset(idc) ;
00125 if( dset == NULL )
00126 return "*****************************\n"
00127 "COPY_main: bad input dataset\n"
00128 "*****************************" ;
00129
00130 dtyp = dset->type ;
00131
00132 PLUTO_next_option(plint) ;
00133 new_prefix = PLUTO_get_string(plint) ;
00134 if( ! PLUTO_prefix_ok(new_prefix) )
00135 return "**********************\n"
00136 "COPY_main: bad prefix\n"
00137 "**********************" ;
00138
00139 tag = PLUTO_get_optiontag(plint) ;
00140 while( tag != NULL ){
00141
00142 if( strcmp(tag,"Data Fill") == 0 ){
00143 cpt = PLUTO_get_string(plint) ;
00144 if( cpt != NULL )
00145 zfill = PLUTO_string_index( cpt , NFILL , fill_options ) ;
00146 }
00147
00148 else if( strcmp(tag,"Dataset") == 0 ){
00149 cpt = PLUTO_get_string(plint) ;
00150 ftyp = PLUTO_string_index( cpt , NUM_DSET_TYPES,DSET_prefixstr ) ;
00151 if( ftyp >= 0 ){
00152 if( ftyp <= LAST_FUNC_TYPE ){
00153 dtyp = HEAD_FUNC_TYPE ;
00154 } else {
00155 ftyp -= (LAST_FUNC_TYPE+1) ; /* 14 Jul 1998 */
00156 dtyp = HEAD_ANAT_TYPE ;
00157 }
00158 }
00159 }
00160
00161 else if( strcmp(tag, "Datum") == 0 ){
00162 cpt = PLUTO_get_string(plint) ;
00163 type_index = PLUTO_string_index( cpt, NDTYPE, dtype_options ) ;
00164 if ( (type_index >= 0) && (type_index < NDTYPE) )
00165 data_type = dtype_kinds[type_index] ;
00166 }
00167
00168 tag = PLUTO_get_optiontag(plint) ;
00169 }
00170
00171 /*------------------------------------------------------*/
00172 /*---------- At this point, the inputs are OK ----------*/
00173
00174 /*-- make a new dataset --*/
00175
00176 if( zfill == 0 ){
00177 new_dset = PLUTO_copy_dset( dset , new_prefix ) ;
00178 } else {
00179 new_dset = EDIT_empty_copy( dset ) ;
00180
00181 if( ISFUNCTYPE(dtyp) && ( zfill == 2 ) )
00182 ftyp = FUNC_FIM_TYPE ; /* 14 Jul 1998 */
00183 }
00184
00185 if( new_dset == NULL )
00186 return "****************************************\n"
00187 "COPY_main: failed to copy input dataset\n"
00188 "****************************************" ;
00189
00190 DSET_unload( dset ) ; /* unload old one from memory */
00191
00192 /*--- modify dataset, if desired ---*/
00193
00194 if( ftyp >= 0 ) EDIT_dset_items( new_dset ,
00195 ADN_type , dtyp ,
00196 ADN_func_type , ftyp ,
00197 ADN_none ) ;
00198
00199 /*--- change type of data stored ---*/
00200
00201 if ( (data_type >= 0) )
00202 {
00203 if ( zfill )
00204 EDIT_dset_items( new_dset ,
00205 ADN_datum_all, data_type,
00206 ADN_none ) ;
00207 else{
00208 DSET_delete(new_dset) ;
00209
00210 return "****************************************************\n"
00211 "COPY_main: Cannot change type of non-zeroed dataset\n"
00212 "****************************************************" ;
00213 }
00214 }
00215
00216 /* if 'Zero [All]' or 'Zero [One]' */
00217
00218 if( zfill ) {
00219 int ityp , nbytes , nvals , ival ;
00220 void * new_brick , * bp ;
00221
00222 EDIT_dset_items( new_dset ,
00223 ADN_prefix , new_prefix ,
00224 ADN_label1 , new_prefix ,
00225 ADN_none ) ;
00226
00227 if ( zfill == 2 ) { /* for 'Zero [One]' case - just make one brick */
00228 EDIT_dset_items( new_dset ,
00229 ADN_nvals , 1 ,
00230 ADN_ntt , 0 ,
00231 ADN_none ) ;
00232 }
00233
00234 nvals = DSET_NVALS(new_dset) ;
00235
00236 for ( ival = 0 ; ival < nvals ; ival++) /* get memory for bricks */
00237 { /* and zero fill */
00238 ityp = DSET_BRICK_TYPE(new_dset,ival) ;
00239 nbytes = DSET_BRICK_BYTES(new_dset,ival) ; /* how much data */
00240 new_brick = malloc( nbytes ) ;
00241 EDIT_substitute_brick( new_dset , ival , ityp , new_brick ) ;
00242
00243 bp = DSET_BRICK_ARRAY(new_dset,ival) ; /* brick pointer */
00244 EDIT_BRICK_FACTOR(new_dset,ival,0.0) ; /* brick factor */
00245 memset( bp , 0 , nbytes ) ;
00246 }
00247 }
00248
00249 { char *his ;
00250 tross_Copy_History( dset , new_dset ) ;
00251 his = PLUTO_commandstring( plint ) ;
00252 tross_Append_History( new_dset , his ) ; free(his) ;
00253 }
00254
00255 ival = PLUTO_add_dset( plint , new_dset , DSET_ACTION_MAKE_CURRENT ) ;
00256
00257 if( ival ){
00258 THD_delete_3dim_dataset( new_dset , False ) ;
00259 return "**********************************************\n"
00260 "COPY_main: failure to add new dataset to AFNI\n"
00261 "**********************************************" ;
00262 }
00263
00264 /*-- done successfully!!! --*/
00265
00266 return NULL ;
00267 }
|
|
|
Definition at line 56 of file plug_copy.c. References ANAT_ALL_MASK, COPY_main(), dtype_options, fill_options, FUNC_ALL_MASK, helpstring, NDTYPE, NFILL, NUM_DSET_TYPES, PLUTO_add_hint(), PLUTO_set_runlabels(), and PLUTO_set_sequence().
00057 {
00058 PLUGIN_interface * plint ;
00059
00060 if( ncall > 0 ) return NULL ; /* only one interface */
00061
00062 /*-- set titles and call point --*/
00063
00064 plint = PLUTO_new_interface( "Dataset Copy" , "Make a Copy of a Dataset" , helpstring ,
00065 PLUGIN_CALL_VIA_MENU , COPY_main ) ;
00066
00067 PLUTO_add_hint( plint , "Make a Copy of a Dataset" ) ;
00068
00069 PLUTO_set_sequence( plint , "A:newdset:copy" ) ;
00070
00071 PLUTO_set_runlabels( plint , "Copy+Keep" , "Copy+Close" ) ; /* 04 Nov 2003 */
00072
00073 /*-- first line of input: Dataset --*/
00074
00075 PLUTO_add_option( plint , "Input" , "Input" , TRUE ) ;
00076 PLUTO_add_dataset(plint , "Dataset" ,
00077 ANAT_ALL_MASK , FUNC_ALL_MASK ,
00078 DIMEN_ALL_MASK | BRICK_ALLTYPE_MASK ) ;
00079
00080 /*-- second line of input: Prefix for output dataset --*/
00081
00082 PLUTO_add_option( plint , "Output" , "Output" , TRUE ) ;
00083 PLUTO_add_string( plint , "Prefix" , 0,NULL , 19 ) ;
00084
00085 /*-- third line of input: Fill option --*/
00086
00087 PLUTO_add_option( plint , "Data Fill" , "Data Fill" , FALSE ) ;
00088 PLUTO_add_string( plint , "Method" , NFILL,fill_options , 0 ) ;
00089
00090 /*-- fourth line of input: Type option --*/
00091
00092 PLUTO_add_option( plint , "Dataset" , "Dataset" , FALSE ) ;
00093 PLUTO_add_string( plint , "Type" , NUM_DSET_TYPES,DSET_prefixstr , 0 ) ;
00094
00095 /*-- fifth line of input: Datum option --*/
00096
00097 PLUTO_add_option( plint , "Datum" , "Datum" , FALSE ) ;
00098 PLUTO_add_string( plint , "Datum" , NDTYPE,dtype_options, 2 ) ;
00099
00100 return plint ;
00101 }
|
Variable Documentation
|
|
Initial value: {
MRI_byte , MRI_short , MRI_float , MRI_complex }Definition at line 46 of file plug_copy.c. Referenced by COPY_main(). |
|
|
Initial value: {
"byte" , "short" , "float" , "complex" }Definition at line 44 of file plug_copy.c. Referenced by COPY_main(), and PLUGIN_init(). |
|
|
Definition at line 41 of file plug_copy.c. Referenced by COPY_main(), and PLUGIN_init(). |
|
|
Initial value: " Purpose: Creating a copy of a dataset.\n" " Inputs:\n" " Dataset = A dataset in the current session that exists in memory\n" " (not warp-on-demand).\n" " Prefix = Filename prefix to be used for the output dataset.\n" " Fill = How to fill voxel data in new dataset:\n" " Data [All] = copy all sub-bricks from input\n" " Zero [All] = fill all sub-bricks with zero\n" " Zero [One] = make new dataset have only 1 sub-brick,\n" " and fill with zero -- this is useful for\n" " creating mask datasets using the\n" " 'Draw Dataset' plugin.\n" " Type = Lets you change the 'type' of the output dataset, for\n" " example from anat to func.\n" " Datum = Lets you set the data type of the new brick. This will\n" " only work when using \"Zero [All]\" or \"Zero [One]\"\n" " Fill modes.\n" "Author -- RWCox" Definition at line 19 of file plug_copy.c. Referenced by PLUGIN_init(). |