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

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 #include "afni.h"
00008 
00009 #ifndef ALLOW_PLUGINS
00010 #  error "Plugins not properly set up -- see machdep.h"
00011 #endif
00012 
00013 /***********************************************************************
00014   Plugin to switch the .BRIK compression mode
00015 ************************************************************************/
00016 
00017 /*--------------------- string to 'help' the user --------------------*/
00018 
00019 static char helpstring[] =
00020   "Purpose: control the way AFNI compresses datasets.\n"
00021   "\n"
00022   "The input 'Mode' specifies how dataset .BRIK files will be\n"
00023   "compress when written to disk.  The options are\n"
00024   "\n"
00025   "  NONE     = no compression\n"
00026   "  GZIP     = use program 'gzip'\n"
00027   "  BZIP2    = use program 'bzip2'    [very slow; most compression]\n"
00028   "  COMPRESS = use program 'compress'\n"
00029   "\n"
00030   "Compressed datasets will save disk space.  The principal cost is\n"
00031   "the CPU time it takes to read and write compressed files."
00032   "\n"
00033   "After you make your choice, you must press one of the\n"
00034   "'Set' buttons for the plugin to send its data to AFNI.\n"
00035   "Author -- RW Cox"
00036 ;
00037 
00038 /*--------------------- strings for output format --------------------*/
00039 
00040 static char * comp_strings[] = {
00041  "NONE" , "GZIP" , "BZIP2" , "COMPRESS"
00042 } ;
00043 
00044 #define NUM_COMP_STRINGS (sizeof(comp_strings)/sizeof(char *))
00045 
00046 /*----------------- prototypes for internal routines -----------------*/
00047 
00048 static char * COMP_main( PLUGIN_interface * ) ;  /* the entry point */
00049 
00050 /***********************************************************************
00051    Set up the interface to the user:
00052     1) Create a new interface using "PLUTO_new_interface";
00053 
00054     2) For each line of inputs, create the line with "PLUTO_add_option"
00055          (this line of inputs can be optional or mandatory);
00056 
00057     3) For each item on the line, create the item with
00058         "PLUTO_add_dataset" for a dataset chooser,
00059         "PLUTO_add_string"  for a string chooser,
00060         "PLUTO_add_number"  for a number chooser.
00061 ************************************************************************/
00062 
00063 
00064 DEFINE_PLUGIN_PROTOTYPE
00065 
00066 PLUGIN_interface * PLUGIN_init( int ncall )
00067 {
00068    PLUGIN_interface * plint ;     /* will be the output of this routine */
00069    int meth ;
00070 
00071    if( ncall > 0 ) return NULL ;  /* only one interface */
00072 
00073    /*---------------- set titles and call point ----------------*/
00074 
00075    plint = PLUTO_new_interface( "BRIK Compressor" ,
00076                                 "Control .BRIK compression" ,
00077                                 helpstring ,
00078                                 PLUGIN_CALL_VIA_MENU , COMP_main  ) ;
00079 
00080    PLUTO_add_hint( plint , "Control .BRIK compression" ) ;
00081 
00082    PLUTO_set_sequence( plint , "A:afnicontrol:dset" ) ;
00083 
00084    PLUTO_set_runlabels( plint , "Set+Keep" , "Set+Close" ) ;  /* 04 Nov 2003 */
00085 
00086    /*---------- 2nd line: other inputs ----------*/
00087 
00088    PLUTO_add_option( plint ,
00089                      "Input" ,  /* label at left of input line */
00090                      "Input" ,  /* tag to return to plugin */
00091                      TRUE       /* is this mandatory? */
00092                    ) ;
00093 
00094    meth = THD_get_write_compression()+1 ;
00095    if( meth < 0 || meth >= NUM_COMP_STRINGS ) meth = 0 ;
00096 
00097    PLUTO_add_string( plint ,
00098                      "Mode" ,          /* label next to chooser button */
00099                      NUM_COMP_STRINGS , /* number of strings to choose among */
00100                      comp_strings ,     /* list of strings to choose among */
00101                      meth               /* index of default string */
00102                    ) ;
00103 
00104    /*--------- done with interface setup ---------*/
00105 
00106    return plint ;
00107 }
00108 
00109 /***************************************************************************
00110   Main routine for this plugin (will be called from AFNI).
00111   If the return string is not NULL, some error transpired, and
00112   AFNI will popup the return string in a message box.
00113 ****************************************************************************/
00114 
00115 static char * COMP_main( PLUGIN_interface * plint )
00116 {
00117    char * str ;
00118    int meth ;
00119 
00120    PLUTO_next_option(plint) ;
00121 
00122    str  = PLUTO_get_string(plint) ;
00123    meth = PLUTO_string_index(str,NUM_COMP_STRINGS,comp_strings) - 1 ;
00124    if( meth < 0 || meth > COMPRESS_LASTCODE ) meth = COMPRESS_NONE ;
00125    THD_set_write_compression(meth) ;
00126    return NULL ;
00127 }
 

Powered by Plone

This site conforms to the following standards: