30 #include "../common/WAssert.h"
31 #include "../common/WLimits.h"
32 #include "WDataSetTimeSeries.h"
38 std::vector< float > times )
41 WAssert( !datasets.empty(),
"" );
42 WAssert( datasets.size() == times.size(),
"" );
43 std::vector< boost::shared_ptr< WDataSetScalar const > >::iterator dit;
44 std::vector< float >::iterator tit;
45 boost::shared_ptr< WGridRegular3D > g = boost::dynamic_pointer_cast<
WGridRegular3D >( datasets.front()->getGrid() );
47 dataType d = datasets.front()->getValueSet()->getDataType();
50 for( dit = datasets.begin(), tit = times.begin(); dit != datasets.end() && tit != times.end(); ++dit, ++tit )
53 WAssert( g == boost::dynamic_pointer_cast< WGridRegular3D >( ( *dit )->getGrid() ),
"" );
55 WAssert( d == ( *dit )->getValueSet()->getDataType(),
"" );
56 WAssert( ( *dit )->getValueSet()->dimension() == 1,
"" );
57 WAssert( ( *dit )->getValueSet()->order() == 0,
"" );
69 for( std::size_t k = 1; k <
m_dataSets.size(); ++k )
73 throw WException( std::string(
"There are multiple time slices at the same point in time!" ) );
84 return std::string(
"WDataSetTimeSeries" );
89 return std::string(
"A time series." );
105 return f !=
m_dataSets.end() && f->second == time;
117 return time - lb <= ub - time ? lb : ub;
123 if( f !=
m_dataSets.end() && f->second == time )
127 return boost::shared_ptr< WDataSetScalar const >();
135 return boost::shared_ptr< WDataSetScalar const >();
139 if( lb == time || ub == time )
145 boost::shared_ptr< WValueSetBase > vs;
146 switch(
m_dataSets.front().first->getValueSet()->getDataType() )
149 vs = calcInterpolatedValueSet< uint8_t >( lb, ub, time );
152 vs = calcInterpolatedValueSet< int8_t >( lb, ub, time );
155 vs = calcInterpolatedValueSet< uint16_t >( lb, ub, time );
158 vs = calcInterpolatedValueSet< int16_t >( lb, ub, time );
161 vs = calcInterpolatedValueSet< uint32_t >( lb, ub, time );
163 case W_DT_SIGNED_INT:
164 vs = calcInterpolatedValueSet< int32_t >( lb, ub, time );
167 vs = calcInterpolatedValueSet< uint64_t >( lb, ub, time );
170 vs = calcInterpolatedValueSet< int64_t >( lb, ub, time );
173 vs = calcInterpolatedValueSet< float >( lb, ub, time );
176 vs = calcInterpolatedValueSet< double >( lb, ub, time );
179 throw WException( std::string(
"Unsupported datatype in WDataSetTimeSeries::calcDataSetAtTime()" ) );
183 ds->setFilename( name );
189 return t0.second < t1.second;
194 return t0 < t1.second;
199 return t0.second < t1;
205 float t = -std::numeric_limits< float >::infinity();
206 if( f !=
m_dataSets.end() && f->second == time )
221 float t = std::numeric_limits< float >::infinity();
double m_maxValue
the largest value
A grid that has parallelepiped cells which all have the same proportion.
std::string const getName() const
Returns a name.
std::pair< boost::shared_ptr< WDataSetScalar const >, float > TimeSlice
a time slice
double m_minValue
the smallest value
float getUBTimeSlice(float time) const
Find the smallest time slice position that is larger than time, or return inf, if there is no such ti...
static boost::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
virtual ~WDataSetTimeSeries()
Destructor.
float getLBTimeSlice(float time) const
Find the largest time slice position that is smaller than or equal to time, or return -inf...
std::string const getDescription() const
Returns a description.
boost::shared_ptr< WDataSetScalar const > getDataSetPtrAtTimeSlice(float time) const
Get a pointer to the dataset at a given time or a NULL-pointer, if there was no dataset given for tha...
double getMaxValue()
Get the largest value in all datasets.
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
double getMinValue()
Get the smallest value in all datasets.
bool operator()(TimeSlice const &t0, TimeSlice const &t1)
Compares the time of two time slices.
float findNearestTimeSlice(float time) const
Find the nearest time slice for a given time.
dataType
Data types and number values taken from the nifti1.h, at this point it's unknown if it makes sense to...
A compare functor for time slices.
bool isNaN(T value)
Determines if a number is considered as NaN (aka Not a Number) or not.
WDataSetTimeSeries()
Standard constructor.
bool isTimeSlice(float time) const
Check if there exists a predefined dataset at the given point in time, i.e.
std::vector< TimeSlice > m_dataSets
the datasets that compose the time series
This data set type contains scalars as values.
float getMaxTime() const
Get the last point of time in the time series.
boost::shared_ptr< WDataSetScalar const > calcDataSetAtTime(float time, std::string const &name) const
Calculates a new dataset with values interpolated between the two nearest time slices.
float getMinTime() const
Get the first point of time in the time series.