22 #include <boost/numeric/conversion/converter.hpp>
26 , m_BaselineValue( 0 )
40 return m_BaselineValue;
50 return this->GetXMin();
55 return this->GetXMax();
65 return ( m_StartValue + this->GetRange() );
70 return m_HistogramVector.size();
80 MITK_INFO <<
"Histogram - Maximum " << this->GetYMax() <<
" Minimum " << this->GetYMin() <<
" Range " << this->GetRange();
82 for(
unsigned int index( 0 ); index < m_HistogramVector.size(); index++ )
84 MITK_INFO <<
" Bin: " << index <<
" Value: " << m_HistogramVector[ index ];
101 m_HistogramVector.clear();
111 if (networkSource==
nullptr)
116 ComputeFromConnectomicsNetwork( networkSource );
123 typedef boost::numeric::converter<int,double> Double2Int ;
133 if( ( start < 0.0 ) ||
141 if( std::abs( end - start ) <= 1.0 )
144 unsigned int index( 0 );
148 double temp = ( start + end ) / 2.0;
149 index = Double2Int::convert( temp );
151 catch ( boost::numeric::positive_overflow
const& )
156 if( index < m_HistogramVector.size() )
158 result = m_HistogramVector[ index ];
163 index <<
" on vector sized: " << m_HistogramVector.size();
169 unsigned int indexStart( 0 ), indexEnd( 0 );
173 indexStart = Double2Int::convert( start );
174 indexEnd = Double2Int::convert( end );
176 catch ( boost::numeric::positive_overflow
const& )
181 if( ( indexStart < m_HistogramVector.size() ) &&
182 ( indexEnd < m_HistogramVector.size() ) )
188 double startPercentage = 1.0 - start + indexStart;
189 double endPercentage = end - indexEnd;
191 result += startPercentage * m_HistogramVector[ indexStart ];
192 result += endPercentage * m_HistogramVector[ indexEnd ];
195 for(
unsigned int tempIndex = indexStart + 1; tempIndex < indexEnd; tempIndex++ )
197 result += m_HistogramVector[ tempIndex ];
203 indexEnd <<
" on vector sized: " << m_HistogramVector.size();
208 result = result / GetYMax();
214 for (
unsigned int index( 0 ); index < m_HistogramVector.size(); index++ )
216 if( m_HistogramVector[ index ] > m_TopValue )
218 m_TopValue = m_HistogramVector[ index ];
225 return m_HistogramVector;
ConnectomicsHistogramBase()
virtual double GetYMin() const
Returns the minimal y=f(x) value of the histogram.
Base of all data objects.
virtual bool IsValid() const
Returns whether the histogram can be considered valid.
virtual double GetYMax() const
Returns the maximum y=f(x) value of the histogram.
virtual ~ConnectomicsHistogramBase()
static const char * CONNECTOMICS_ERROR_BEYOND_SCOPE
virtual int GetRange() const
Returns the range of the histogram.
virtual std::vector< double > GetHistogramVector()
Get the double vector.
static const char * CONNECTOMICS_ERROR_OUTSIDE_INTEGER_RANGE
virtual void ComputeFromBaseData(BaseData *source) override
Creates a new histogram from the source.
virtual double GetXMax() const
Returns the maximum x value of the histogram.
virtual std::string GetSubject() const
Returns the subject of the histogram as a string.
virtual double GetXMin() const
Returns the minimal x value of the histogram.
virtual double GetMin() const override
Legacy method, do no use.
virtual double GetMax() const override
Legacy method, do no use.
virtual float GetRelativeBin(double start, double end) const override
Get bin height for the bin between start and end.
static const char * CONNECTOMICS_ERROR_PASSED_NEGATIVE_INDEX_TO_HISTOGRAM
static const char * CONNECTOMICS_ERROR_TRIED_TO_ACCESS_INVALID_HISTOGRAM
virtual void PrintToConsole() const
Print values to console.
virtual void SetSubject(std::string)
Set the subject of the histogram as a string.
Connectomics Network Class.
virtual void UpdateYMax()
Update the Y maximum to the maximal value in the histogram.