Imstat

From CASA Guides
Revision as of 20:43, 16 March 2012 by Conversion script (talk) (moved Imstat to imstat: Converting page titles to lowercase)
Jump to navigationJump to search
Help on imstat task:

Displays statistical information from an image or image region

     Many parameters are determined from the specified region of an image.
     For this version, the region can be specified by a set of rectangular
     pixel coordinates, the channel ranges and the Stokes.

     For directed output, run as 
                    myoutput = imstat()
   

        Keyword arguments:
        imagename -- Name of input image
                Default: none; Example: imagename='ngc5921_task.im'
        region -- File path to an ImageRegion file or name.
                Use the viewer, then region manager to select regions of
                   the image to process.  Similar to box, but graphical
                Or the name of a region stored with the image, 
                      use rg.namesintable()
                to retrieve the list of names.
                Default: none
                Example: region='myimage.im.rgn'
                         region='region1'
        box --  A box region on the directional plane
                Only pixel values acceptable at this time.
                Default: none (whole 2-D plane); 
                  Example: box='10,10,50,50'
                      box = '10,10,30,30,35,35,50,50' (two boxes)
        chans -- channel numbers
                Range of channel numbers to include in statistics
                  All spectral windows are included
                Default:''= all;  Example: chans='3~20'    
        stokes -- Stokes parameters to analyze.
                Default: none (all); Example: stokes='IQUV';  
                                     Example:stokes='I,Q'
                Options: 'I','Q','U','V','RR','RL','LR','LL','XX','YX','XY','YY', ...

      General procedure:

         1.  Specify inputs, then

         2.  myoutput = imstat()
               or specify inputs directly in calling sequence to task
             myoutput = imstat(imagename='image.im', etc)

         3.  myoutput['KEYS'] will contain the result associated with any
              of the keys given below
        
        KEYS CURRENTLY AVAILABLE
        blc          - absolute PIXEL coordinate of the bottom left corner of 
                       the bounding box surrounding the selected region
        blcf         - Same as blc, but uses WORLD coordinates instead of pixels
        trc          - the absolute PIXEL coordinate of the top right corner 
                       of the bounding box surrounding the selected region
        trcf         - Same as trc, but uses WORLD coordinates instead of pixels
        flux         - the integrated flux density if the beam is defined and 
                       the if brightness units are $Jy/beam$
        npts         - the number of unmasked points used
        max          - the maximum pixel value
        min          - minimum pixel value
        maxpos       - absolute PIXEL coordinate of maximum pixel value
        maxposf      - Same as maxpos, but uses WORLD coordinates instead of pixels
        minpos       - absolute pixel coordinate of minimum pixel value
        minposf      - Same as minpos, but uses WORLD coordinates instead of pixels
        sum          - the sum of the pixel values: $\sum I_i$
        sumsq        - the sum of the squares of the pixel values: $\sum I_i^2$
        mean         - the mean of pixel values: 
                       ar{I} = \sum I_i / n$
        sigma        - the standard deviation about the mean: 
                       $\sigma^2 = (\sum I_i -ar{I})^2 / (n-1)$
        rms          - the root mean square: 
                       $\sqrt {\sum I_i^2 / n}$
        median       - the median pixel value (if robust=T)
        medabsdevmed - the median of the absolute deviations from the 
                       median (if robust=T)    
        quartile     - the inter-quartile range (if robust=T). Find the points 
                       which are 25% largest and 75% largest (the median is 
                       50% largest), find their difference and divide that 
                       difference by 2.

        Additional Examples
        # Selected two box region
        # box 1, bottom-left coord is 2,3 and top-right coord is 14,15
        # box 2, bottom-left coord is 30,31 and top-right coord is 42,43
        imstat( 'myImage', box='2,3,14,15;30,31,42,43' )

        # Select the same two box regions but only channels 4 and 5
        imstat( 'myImage', box='2,3,14,15;30,31,42,43', chan='4~5' )

        # Select all channels greater the 20 as well as channel 0.
        # Then the mean and standard deviation are printed
        results = imstat( 'myImage', chans='>20;0' )
        print "Mean is: ", results['mean'], "  s.d. ", results['sigma']
        max          - the maximum pixel value
        min          - minimum pixel value
        maxpos       - absolute PIXEL coordinate of maximum pixel value
        maxposf      - Same as maxpos, but uses WORLD coordinates instead of pixels
        minpos       - absolute pixel coordinate of minimum pixel value
        minposf      - Same as minpos, but uses WORLD coordinates instead of pixels
        sum          - the sum of the pixel values: $\sum I_i$
        sumsq        - the sum of the squares of the pixel values: $\sum I_i^2$
        mean         - the mean of pixel values: 
                       ar{I} = \sum I_i / n$
        sigma        - the standard deviation about the mean: 
                       $\sigma^2 = (\sum I_i -ar{I})^2 / (n-1)$
        rms          - the root mean square: 
                       $\sqrt {\sum I_i^2 / n}$
        median       - the median pixel value (if robust=T)
        medabsdevmed - the median of the absolute deviations from the 
                       median (if robust=T)    
        quartile     - the inter-quartile range (if robust=T). Find the points 
                       which are 25% largest and 75% largest (the median is 
                       50% largest), find their difference and divide that 
                       difference by 2.

        Additional Examples
        # Selected two box region
        # box 1, bottom-left coord is 2,3 and top-right coord is 14,15
        # box 2, bottom-left coord is 30,31 and top-right coord is 42,43
        imstat( 'myImage', box='2,3,14,15;30,31,42,43' )

        # Select the same two box regions but only channels 4 and 5
        imstat( 'myImage', box='2,3,14,15;30,31,42,43', chan='4~5' )

        # Select all channels greater the 20 as well as channel 0.
        # Then the mean and standard deviation are printed
        results = imstat( 'myImage', chans='>20;0' )
        print "Mean is: ", results['mean'], "  s.d. ", results['sigma']

        # Find statistical information for the Q stokes value only
        # then the I stokes values only, and printing out the statistical
        # values that we are interested in.
        s1 = imstat( 'myimage', stokes='Q' )
        s2 = imstat( 'myimage', stokes='I' )
        print "       |  MIN  |   MAX  | MEAN"
        print "  Q    | ",s1['min'][0],"  |  ",s1['max'][0],"  |  ",,"  |  ",s1['mean'][0]
        print "  I    | ",s2['min'][0],"  |  ",s2['max'][0],"  |  ",,"  |  ",s2['mean'][0]