casacore
Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::ImageStatistics< T > Class Template Reference

More...

#include <ImageStatistics.h>

Public Member Functions

 ImageStatistics (const ImageInterface< T > &image, LogIO &os, Bool showProgress=True, Bool forceDisk=False, Bool clone=True)
 Constructor takes the image and a LogIO object for logging. More...
 
 ImageStatistics (const ImageInterface< T > &image, Bool showProgress=True, Bool forceDisk=False, Bool clone=True)
 Constructor takes the image only. More...
 
 ImageStatistics (const ImageStatistics< T > &other)
 Copy constructor. More...
 
virtual ~ImageStatistics ()
 Destructor. More...
 
ImageStatistics< T > & operator= (const ImageStatistics< T > &other)
 Assignment operator. More...
 
Bool setNewImage (const ImageInterface< T > &image, Bool clone=True)
 Set a new ImageInterface object. More...
 
void setPrecision (Int precision)
 
void setBlc (const IPosition &blc)
 
IPosition getBlc () const
 
Int getPrecision () const
 
void showRobust (const Bool show)
 list robust statistics? Should be called before display() More...
 
void recordMessages (const Bool rm)
 
vector< StringgetMessages ()
 
void clearMessages ()
 
void setListStats (Bool b)
 
- Public Member Functions inherited from casacore::LatticeStatistics< T >
 LatticeStatistics (const MaskedLattice< T > &lattice, LogIO &os, Bool showProgress=True, Bool forceDisk=False, Bool clone=True)
 Constructor takes the lattice and a LogIO object for logging. More...
 
 LatticeStatistics (const MaskedLattice< T > &lattice, Bool showProgress=True, Bool forceDisk=False, Bool clone=True)
 Constructor takes the lattice only. More...
 
 LatticeStatistics (const LatticeStatistics< T > &other)
 Copy constructor. More...
 
virtual ~LatticeStatistics ()
 Destructor. More...
 
LatticeStatistics< T > & operator= (const LatticeStatistics< T > &other)
 Assignment operator. More...
 
Bool setAxes (const Vector< Int > &cursorAxes)
 Set the cursor axes (0 relative). More...
 
Bool setInExCludeRange (const Vector< T > &include, const Vector< T > &exclude, Bool setMinMaxToInclude=False)
 You may specify a pixel intensity range as either one for which all pixels in that range are included or one for which all pixels in that range are excluded. More...
 
Bool setList (const Bool &doList)
 This function allows you to control whether the statistics are written to the output stream if you are also making a plot. More...
 
Bool display ()
 Display the statistics by listing and/or plotting them. More...
 
Bool getLayerStats (String &stats, Double area, Int zAxis=-1, Int zLayer=-1, Int hAxis=-1, Int hLayer=-1)
 
Bool getLayerStats (stat_list &stats, Double area, Int zAxis=-1, Int zLayer=-1, Int hAxis=-1, Int hLayer=-1)
 
Vector< IntdisplayAxes () const
 Return the display axes. More...
 
Bool getStatistic (Array< AccumType > &stat, LatticeStatsBase::StatisticsTypes type, Bool dropDeg=True)
 Recover the desired Statistic into an array. More...
 
Bool getConvertedStatistic (Array< T > &stat, LatticeStatsBase::StatisticsTypes type, Bool dropDeg=True)
 
Bool getMinMaxPos (IPosition &minPos, IPosition &maxPos)
 Recover position of min and max. More...
 
Bool getStats (Vector< AccumType > &, const IPosition &pos, const Bool posInLattice=False)
 This function gets a vector containing all the statistics for a given location. More...
 
void resetError ()
 Reset argument error condition. More...
 
Bool getFullMinMax (T &dataMin, T &dataMax)
 Get full lattice min and max only. More...
 
String errorMessage () const
 Recover last error message. More...
 
Bool setNewLattice (const MaskedLattice< T > &lattice, Bool clone=True)
 Set a new MaskedLattice object. More...
 
Bool hasLogger () const
 Did we construct with a logger ? More...
 
Bool configureBiweight (Int maxIter, Double c)
 The configure methods return True if reconfiguration is actually necessary (ie if the underlying storage lattice needs to be recomputed). More...
 
Bool configureClassical ()
 configure object to use Classical Statistics The time, t_x, it takes to compute classical statistics using algorithm x, can be modeled by t_x = n_sets*(a_x + b_x*n_el) where n_sets is the number of independent sets of data to compute stats on, each containing n_el number of elements. More...
 
Bool configureClassical (Double aOld, Double bOld, Double aNew, Double bNew)
 
Bool configureFitToHalf (FitToHalfStatisticsData::CENTER centerType=FitToHalfStatisticsData::CMEAN, FitToHalfStatisticsData::USE_DATA useData=FitToHalfStatisticsData::LE_CENTER, AccumType centerValue=0)
 configure to use fit to half algorithm. More...
 
Bool configureHingesFences (Double f)
 configure to use hinges-fences algorithm More...
 
Bool configureChauvenet (Double zscore=-1, Int maxIterations=-1)
 configure to use Chauvenet's criterion More...
 
void forceUseStatsFrameworkUsingDataProviders ()
 The force* methods are really only for testing. More...
 
void forceUseStatsFrameworkUsingArrays ()
 
void forceUseOldTiledApplyMethod ()
 
void forceAllowCodeDecideWhichAlgortihmToUse ()
 
std::map< String, uIntgetChauvenetNiter () const
 get number of iterations associated with Chauvenet criterion algorithm More...
 
void setComputeQuantiles (Bool b)
 should quantile-like stats (median, quartiles, medabsdevmed) be computed? When the stats framework is used, It is better to set this before computing any statistics, to avoid unnecessary duplicate creations of the stats algorithm objects. More...
 

Protected Types

typedef NumericTraits< T >::PrecisionType AccumType
 

Protected Member Functions

virtual Bool _canDoFlux () const
 Virtual Functions. More...
 
- Protected Member Functions inherited from casacore::LatticeStatistics< T >
virtual Bool listLayerStats (const Matrix< AccumType > &ord, ostringstream &rslt, Int zLayer)
 
IPosition locInLattice (const IPosition &storagePosition, Bool relativeToParent=True) const
 Given a location in the storage lattice, convert those locations on the
non-statistics axis (the last one) and optionally account for the lattice subsectioning. More...
 
void setStream (ostream &os, Int oPrec)
 Non-virtual functions. More...
 
IPosition _storageLatticeShape () const
 get the storage lattice shape More...
 
void _latticePosToStoragePos (IPosition &storagePos, const IPosition &latticePos)
 convert a position in the input lattice to the corresponding position in the stats storage lattice. More...
 
StatisticsData::ALGORITHM _getAlgorithm () const
 

Private Member Functions

virtual void getLabels (String &higherOrder, String &xAxis, const IPosition &dPos) const
 Virtual functions. More...
 
virtual Bool _getBeamArea (Array< Double > &beamArea, String &msg) const
 Get beam area in pixels if possible. More...
 
virtual void listMinMax (ostringstream &osMin, ostringstream &osMax, Int oWidth, DataType type)
 List min and max with world coordinates. More...
 
virtual Bool listStats (Bool hasBeam, const IPosition &dPos, const Matrix< AccumType > &ord)
 List the statistics. More...
 
virtual void displayStats (AccumType nPts, AccumType sum, AccumType median, AccumType medAbsDevMed, AccumType quartile, AccumType sumSq, AccumType mean, AccumType var, AccumType rms, AccumType sigma, AccumType dMin, AccumType dMax, AccumType q1, AccumType q3)
 
Quantum< AccumType_flux (Bool &isFluxDensity, AccumType sum, Double beamAreaInPixels) const
 If isFluxDensity is False, then the computed value is a flux (ie flux density integrated over a spectral extent) More...
 
Bool _computeFlux (Array< AccumType > &flux, const Array< AccumType > &npts, const Array< AccumType > &sum)
 
Bool _computeFlux (Quantum< AccumType > &flux, AccumType sum, const IPosition &pos, Bool posInLattice)
 

Private Attributes

LogIO os_p
 Data. More...
 
const ImageInterface< T > * pInImage_p
 
std::shared_ptr< const ImageInterface< T > > _inImPtrMgr
 
IPosition blc_
 
Int precision_
 
Bool _showRobust
 
Bool _recordMessages
 
Bool _listStats
 
vector< String_messages
 

Additional Inherited Members

- Public Types inherited from casacore::LatticeStatistics< T >
typedef NumericTraits< T >::PrecisionType AccumType
 
typedef std::pair< String, Stringstat_element
 
typedef std::list< stat_elementstat_list
 
- Public Types inherited from casacore::LatticeStatsBase
enum  StatisticsTypes {
  NPTS ,
  SUM ,
  SUMSQ ,
  MEDIAN ,
  MEDABSDEVMED ,
  QUARTILE ,
  Q1 ,
  Q3 ,
  MIN ,
  MAX ,
  MEAN ,
  VARIANCE ,
  SIGMA ,
  RMS ,
  FLUX ,
  NSTATS ,
  NACCUM
}
 This enum StatisticTypes is provided for use with the LatticeStatistics<T>::setPlotting function. More...
 
- Static Public Member Functions inherited from casacore::LatticeStatsBase
static Vector< InttoStatisticTypes (const String &statistics, const std::regex &delimiter)
 Helper function to convert a String containing a list of desired statistics to the correct Vector<Int> required for the LatticeStatistics<T>::setPlotting function. More...
 
static Vector< InttoStatisticTypes (const Vector< String > &statistics)
 
static String toStatisticName (StatisticsTypes type)
 Convert type to string. More...
 
static String toStatisticName (Int type)
 
static Int toStatisticType (const String &statistic)
 Returns -1 if the statistic string is not valid. More...
 
static Bool setNxy (Vector< Int > &nxy, ostream &os)
 Check and fill in defaults for a Vector<Int> containing the number of subplots in x and y to be put on a plot. More...
 
static void setStorageImageShape (IPosition &storeImageShape, const Bool &last, const Int &axisSize, const Vector< Int > &displayAxes, const IPosition &shape)
 A storage image is used to accumulate information as a function of the display axes as an image is iterated through. More...
 
static void stretchMinMax (Float &min, Float &max)
 Stretch a range by 10%. More...
 
static std::set< DoublequartileFracs ()
 
- Protected Attributes inherited from casacore::LatticeStatistics< T >
LogIO os_p
 
Vector< IntcursorAxes_p
 
Vector< IntdisplayAxes_p
 
Bool goodParameterStatus_p
 
Bool haveLogger_p
 
Bool fixedMinMax_p
 
Bool doRobust_p
 doRobust means that when the storage lattice is generated, the robust statistics are generated as well More...
 
Bool doList_p
 
IPosition minPos_p
 
IPosition maxPos_p
 
IPosition blcParent_p
 
String error_p
 

Detailed Description

template<class T>
class casacore::ImageStatistics< T >

Displays various statistics from an image.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Etymology

This is a class designed to display and retrieve statistics from images

Synopsis

This class enable you to display and/or retrieve statistics evaluated over specified regions from an image. The dimension of the region is arbitrary, but the size of each dimension is always the size of the corresponding image axis. The statistics are displayed as a function of location of the axes not used to evaluate the statistics over. The axes which you evaluate the statistics over are called the cursor axes, the others are called the display axes.

This class is derived from the class LatticeStatistics which does all the work. This class only adds some extra capability in terms of logging world (rather than pixel) coordinates and computing the synthesized beam area, if there is one. There are just a few virtual functions for you to over-ride. These are rather specialized, they are not part of a general polymorphic interface, just a way to separate the Lattice and Image functionality out.

See LatticeStatistics for details and examples.

Motivation

The generation of statistical information from an image is a basic and necessary capability.

To Do

Definition at line 99 of file ImageStatistics.h.

Member Typedef Documentation

◆ AccumType

template<class T >
typedef NumericTraits<T>::PrecisionType casacore::ImageStatistics< T >::AccumType
protected

Definition at line 173 of file ImageStatistics.h.

Constructor & Destructor Documentation

◆ ImageStatistics() [1/3]

template<class T >
casacore::ImageStatistics< T >::ImageStatistics ( const ImageInterface< T > &  image,
LogIO os,
Bool  showProgress = True,
Bool  forceDisk = False,
Bool  clone = True 
)

Constructor takes the image and a LogIO object for logging.

You can specify whether you want to see progress meters or not. You can force the storage image to be disk based, otherwise the decision for core or disk is taken for you. If clone is True, the input image will be cloned, so the caller can make changes to the input image, but the statistics will reflect the image as it was at construction. If False, a reference to the input image is used, and so the caller shouldn't make changes to the input image between construction and calling statistics computation methods, unless it calls setNewImage() to update the changed image. Obviously, cloning the image impacts performance and memory usage.

◆ ImageStatistics() [2/3]

template<class T >
casacore::ImageStatistics< T >::ImageStatistics ( const ImageInterface< T > &  image,
Bool  showProgress = True,
Bool  forceDisk = False,
Bool  clone = True 
)

Constructor takes the image only.

In the absence of a logger you get no messages. This includes error messages and potential listing of the statistics. You can specify whether you want to see progress meters or not. You can force the storage image to be disk based, otherwise the decision for core or disk is taken for you.

◆ ImageStatistics() [3/3]

template<class T >
casacore::ImageStatistics< T >::ImageStatistics ( const ImageStatistics< T > &  other)

Copy constructor.

Copy semantics are followed. Therefore any storage image that has already been created for other is copied to *this

◆ ~ImageStatistics()

template<class T >
virtual casacore::ImageStatistics< T >::~ImageStatistics ( )
virtual

Destructor.

Member Function Documentation

◆ _canDoFlux()

template<class T >
virtual Bool casacore::ImageStatistics< T >::_canDoFlux ( ) const
protectedvirtual

Virtual Functions.

See implementation to figure it all out !

FIXME The indirect dependence of this class on ImageInterface related issues (eg flux density) breaks encapsulation. All the ImageInterface related code should be encapsulated in ImageStatistics. Unfortunately, that requires significantly more time than I have atm. A return value of False means that the object in question cannot compute flux density values. The default implementation returns False.

Reimplemented from casacore::LatticeStatistics< T >.

◆ _computeFlux() [1/2]

template<class T >
Bool casacore::ImageStatistics< T >::_computeFlux ( Array< AccumType > &  flux,
const Array< AccumType > &  npts,
const Array< AccumType > &  sum 
)
privatevirtual

Reimplemented from casacore::LatticeStatistics< T >.

◆ _computeFlux() [2/2]

template<class T >
Bool casacore::ImageStatistics< T >::_computeFlux ( Quantum< AccumType > &  flux,
AccumType  sum,
const IPosition pos,
Bool  posInLattice 
)
privatevirtual

Reimplemented from casacore::LatticeStatistics< T >.

◆ _flux()

template<class T >
Quantum<AccumType> casacore::ImageStatistics< T >::_flux ( Bool isFluxDensity,
AccumType  sum,
Double  beamAreaInPixels 
) const
privatevirtual

If isFluxDensity is False, then the computed value is a flux (ie flux density integrated over a spectral extent)

Reimplemented from casacore::LatticeStatistics< T >.

◆ _getBeamArea()

template<class T >
virtual Bool casacore::ImageStatistics< T >::_getBeamArea ( Array< Double > &  beamArea,
String msg 
) const
privatevirtual

Get beam area in pixels if possible.

Return False if the beam area could not be calculated.

◆ clearMessages()

template<class T >
void casacore::ImageStatistics< T >::clearMessages ( )
inline

Definition at line 168 of file ImageStatistics.h.

References casacore::ImageStatistics< T >::_messages.

◆ displayStats()

template<class T >
virtual void casacore::ImageStatistics< T >::displayStats ( AccumType  nPts,
AccumType  sum,
AccumType  median,
AccumType  medAbsDevMed,
AccumType  quartile,
AccumType  sumSq,
AccumType  mean,
AccumType  var,
AccumType  rms,
AccumType  sigma,
AccumType  dMin,
AccumType  dMax,
AccumType  q1,
AccumType  q3 
)
privatevirtual

Reimplemented from casacore::LatticeStatistics< T >.

◆ getBlc()

template<class T >
IPosition casacore::ImageStatistics< T >::getBlc ( ) const

◆ getLabels()

template<class T >
virtual void casacore::ImageStatistics< T >::getLabels ( String higherOrder,
String xAxis,
const IPosition dPos 
) const
privatevirtual

Virtual functions.

See LatticeStatistics for more information about these, or see the implementation.

Get label for higher order axes

◆ getMessages()

template<class T >
vector<String> casacore::ImageStatistics< T >::getMessages ( )
inline

Definition at line 166 of file ImageStatistics.h.

References casacore::ImageStatistics< T >::_messages.

◆ getPrecision()

template<class T >
Int casacore::ImageStatistics< T >::getPrecision ( ) const

◆ listMinMax()

template<class T >
virtual void casacore::ImageStatistics< T >::listMinMax ( ostringstream &  osMin,
ostringstream &  osMax,
Int  oWidth,
DataType  type 
)
privatevirtual

List min and max with world coordinates.

Reimplemented from casacore::LatticeStatistics< T >.

◆ listStats()

template<class T >
virtual Bool casacore::ImageStatistics< T >::listStats ( Bool  hasBeam,
const IPosition dPos,
const Matrix< AccumType > &  ord 
)
privatevirtual

List the statistics.

Reimplemented from casacore::LatticeStatistics< T >.

◆ operator=()

template<class T >
ImageStatistics<T>& casacore::ImageStatistics< T >::operator= ( const ImageStatistics< T > &  other)

Assignment operator.

Deletes any storage image associated with the object being assigned to and copies any storage image that has already been created for "other".

◆ recordMessages()

template<class T >
void casacore::ImageStatistics< T >::recordMessages ( const Bool  rm)
inline

◆ setBlc()

template<class T >
void casacore::ImageStatistics< T >::setBlc ( const IPosition blc)

◆ setListStats()

template<class T >
void casacore::ImageStatistics< T >::setListStats ( Bool  b)
inline

Definition at line 170 of file ImageStatistics.h.

References casacore::ImageStatistics< T >::_listStats.

◆ setNewImage()

template<class T >
Bool casacore::ImageStatistics< T >::setNewImage ( const ImageInterface< T > &  image,
Bool  clone = True 
)

Set a new ImageInterface object.

A return value of False indicates the image had an invalid type or that the internal state of the class is bad. If clone is True, the input image will be cloned, so the caller can make changes to the input image, but the statistics will reflect the image as it was at construction. If False, a reference to the input image is used, and so the caller shouldn't make changes to the input image between construction and calling statistics computation methods, unless it calls setNewImage() to update the changed image. Obviously, cloning the image impacts performance and memory usage.

◆ setPrecision()

template<class T >
void casacore::ImageStatistics< T >::setPrecision ( Int  precision)

◆ showRobust()

template<class T >
void casacore::ImageStatistics< T >::showRobust ( const Bool  show)

list robust statistics? Should be called before display()

Member Data Documentation

◆ _inImPtrMgr

template<class T >
std::shared_ptr<const ImageInterface<T> > casacore::ImageStatistics< T >::_inImPtrMgr
private

Definition at line 182 of file ImageStatistics.h.

◆ _listStats

template<class T >
Bool casacore::ImageStatistics< T >::_listStats
private

Definition at line 185 of file ImageStatistics.h.

Referenced by casacore::ImageStatistics< T >::setListStats().

◆ _messages

template<class T >
vector<String> casacore::ImageStatistics< T >::_messages
mutableprivate

◆ _recordMessages

template<class T >
Bool casacore::ImageStatistics< T >::_recordMessages
private

Definition at line 185 of file ImageStatistics.h.

Referenced by casacore::ImageStatistics< T >::recordMessages().

◆ _showRobust

template<class T >
Bool casacore::ImageStatistics< T >::_showRobust
private

Definition at line 185 of file ImageStatistics.h.

◆ blc_

template<class T >
IPosition casacore::ImageStatistics< T >::blc_
private

Definition at line 183 of file ImageStatistics.h.

◆ os_p

template<class T >
LogIO casacore::ImageStatistics< T >::os_p
private

Data.

Definition at line 180 of file ImageStatistics.h.

◆ pInImage_p

template<class T >
const ImageInterface<T>* casacore::ImageStatistics< T >::pInImage_p
private

Definition at line 181 of file ImageStatistics.h.

◆ precision_

template<class T >
Int casacore::ImageStatistics< T >::precision_
private

Definition at line 184 of file ImageStatistics.h.


The documentation for this class was generated from the following file: