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_3ddup.c

Go to the documentation of this file.
00001 #include "afni.h"
00002 
00003 #ifndef ALLOW_PLUGINS
00004 #  error "Plugins not properly set up -- see machdep.h"
00005 #endif
00006 
00007 /*****************************************************************************
00008    Like 3ddup, but as a plugin.  RWCox - 06 Aug 2003.
00009 ******************************************************************************/
00010    
00011 static char helpstring[] =
00012   " Purpose: Make a 'warp-on-demand' duplicated of a dataset.\n"
00013   "\n"
00014   " Inputs:\n"
00015   "  Dataset = A dataset in the current session (not warp-on-demand itself).\n"
00016   "  Prefix  = Name for the new dataset.\n"
00017   "\n"
00018   " Note: output dataset will be in the AFNI .HEAD format.\n"
00019   "\n"
00020   " RWCox - 06 Aug 2003 - cf. 3ddup."
00021 ;
00022 
00023 static char * DUP_main( PLUGIN_interface *plint ) ;
00024 
00025 /***********************************************************************
00026    Set up the interface to the user
00027 ************************************************************************/
00028 
00029 DEFINE_PLUGIN_PROTOTYPE
00030 
00031 PLUGIN_interface * PLUGIN_init( int ncall )
00032 {
00033    PLUGIN_interface * plint ;
00034 
00035    if( ncall > 0 ) return NULL ;  /* only one interface */
00036 
00037    /*-- set titles and call point --*/
00038 
00039    plint = PLUTO_new_interface( "Dataset Dup" , "Warp-on-Demand duplicate" , helpstring ,
00040                                  PLUGIN_CALL_VIA_MENU , DUP_main  ) ;
00041 
00042    PLUTO_add_hint( plint , "Warp-on-Demand duplicate" ) ;
00043 
00044    /*-- first line of input: Dataset --*/
00045 
00046    PLUTO_add_option( plint , "Input" , "Input" , TRUE ) ;
00047    PLUTO_add_dataset(plint , "Dataset" ,
00048                                     ANAT_ALL_MASK , FUNC_ALL_MASK ,
00049                                     DIMEN_ALL_MASK | BRICK_ALLTYPE_MASK ) ;
00050 
00051    /*-- second line of input: Prefix for output dataset --*/
00052 
00053    PLUTO_add_option( plint , "Output" , "Output" , TRUE ) ;
00054    PLUTO_add_string( plint , "Prefix" , 0,NULL , 19 ) ;
00055 
00056    return plint ;
00057 }
00058 
00059 /*----------------------------------------------------------------------------*/
00060 
00061 static char * DUP_main( PLUGIN_interface *plint )
00062 {
00063    THD_3dim_dataset *dset_in , *dset_out ;
00064    THD_warp *warp , *twarp ;
00065    MCW_idcode *idc ;
00066    char *new_prefix ;
00067 
00068    if( plint == NULL ) return " \nDUP_main: NULL input!\n" ;
00069 
00070    PLUTO_next_option(plint) ;
00071    idc     = PLUTO_get_idcode(plint) ;
00072    dset_in = PLUTO_find_dset(idc) ;
00073    if( dset_in == NULL )
00074      return "****************************\n"
00075             "DUP_main:  bad input dataset\n"
00076             "****************************"  ;
00077    if( !DSET_ONDISK(dset_in) )
00078      return "********************************\n"
00079             "DUP_main:  illegal input dataset\n"
00080             "********************************"  ;
00081 
00082    PLUTO_next_option(plint) ;
00083    new_prefix = PLUTO_get_string(plint) ;
00084    if( ! PLUTO_prefix_ok(new_prefix) )
00085      return "*********************\n"
00086             "DUP_main:  bad prefix\n"
00087             "*********************"  ;
00088 
00089    /*** copy header info ***/
00090 
00091    dset_out = EDIT_empty_copy( dset_in ) ;
00092    if( !ISVALID_3DIM_DATASET(dset_out) )
00093      return "****************************\n"
00094             "DUP_main:  can't duplicate?!\n"
00095             "****************************"  ;
00096 
00097    EDIT_dset_items( dset_out , ADN_prefix,new_prefix , ADN_none ) ;
00098 
00099    tross_Copy_History( dset_in , dset_out ) ;
00100    tross_Append_History( dset_out , "Warp-on-Demand duplicate from plug_3ddup." ) ;
00101 
00102    warp = myXtNew(THD_warp) ; *warp = IDENTITY_WARP ;
00103 
00104    EDIT_dset_items( dset_out ,
00105                       ADN_warp        , warp    ,
00106                       ADN_warp_parent , dset_in ,
00107                     ADN_none ) ;
00108 
00109    /*** done! ***/
00110 
00111    THD_write_3dim_dataset( NULL , NULL , dset_out , False ) ;
00112    PLUTO_add_dset( plint , dset_out , DSET_ACTION_MAKE_CURRENT ) ;
00113 
00114    return NULL ;
00115 }
 

Powered by Plone

This site conforms to the following standards: