28 #include "WDataSetScalar.h"
30 #include "WDataSetSegmentation.h"
36 boost::shared_ptr< WDataSetScalar > grayMatter,
37 boost::shared_ptr< WDataSetScalar > cerebrospinalFluid )
38 :
WDataSetSingle( convert( whiteMatter, grayMatter, cerebrospinalFluid ), whiteMatter->getGrid() )
40 boost::shared_ptr< WGrid > grid( whiteMatter->getGrid() );
44 boost::shared_ptr< WGrid > grid )
63 return "WDataSetSegmentation";
68 return "Segmentation of brain into white and gray matter, and CSF.";
113 boost::shared_ptr< WGridRegular3D > grid = boost::dynamic_pointer_cast<
WGridRegular3D >(
m_grid );
114 size_t id = x + y * grid->
getNbCoordsX() + z * grid->getNbCoordsX() * grid->getNbCoordsY();
121 boost::shared_ptr< WGridRegular3D > grid = boost::dynamic_pointer_cast<
WGridRegular3D >(
m_grid );
122 size_t id = x + y * grid->
getNbCoordsX() + z * grid->getNbCoordsX() * grid->getNbCoordsY();
129 boost::shared_ptr< WGridRegular3D > grid = boost::dynamic_pointer_cast<
WGridRegular3D >(
m_grid );
130 size_t id = x + y * grid->
getNbCoordsX() + z * grid->getNbCoordsX() * grid->getNbCoordsY();
136 boost::shared_ptr< WDataSetScalar > grayMatter,
137 boost::shared_ptr< WDataSetScalar > cerebrospinalFluid )
140 WAssert( whiteMatter,
"No white matter data given." );
141 WAssert( grayMatter,
"No gray matter data given." );
142 WAssert( cerebrospinalFluid,
"No CSF data given." );
145 boost::shared_ptr< WGridRegular3D > wm_grid = boost::dynamic_pointer_cast<
WGridRegular3D >( whiteMatter->getGrid() );
146 boost::shared_ptr< WGridRegular3D > gm_grid = boost::dynamic_pointer_cast<
WGridRegular3D >( grayMatter->getGrid() );
147 boost::shared_ptr< WGridRegular3D > csf_grid = boost::dynamic_pointer_cast<
WGridRegular3D >( cerebrospinalFluid->getGrid() );
149 WAssert( ( wm_grid->getNbCoordsX() == gm_grid->getNbCoordsX() ) && ( gm_grid->getNbCoordsX() == csf_grid->getNbCoordsX() ),
150 "Different X size of GrayMatter, WhiteMatter or CSF-Input" );
151 WAssert( ( wm_grid->getNbCoordsY() == gm_grid->getNbCoordsY() ) && ( gm_grid->getNbCoordsY() == csf_grid->getNbCoordsY() ),
152 "Different Y size of GrayMatter, WhiteMatter or CSF-Input" );
153 WAssert( ( wm_grid->getNbCoordsZ() == gm_grid->getNbCoordsZ() ) && ( gm_grid->getNbCoordsZ() == csf_grid->getNbCoordsZ() ),
154 "Different Z size of GrayMatter, WhiteMatter or CSF-Input" );
156 boost::shared_ptr< WValueSetBase > segmentation;
157 std::vector< boost::shared_ptr< WDataSetScalar > > dataSets;
158 dataSets.push_back( whiteMatter );
159 dataSets.push_back( grayMatter );
160 dataSets.push_back( cerebrospinalFluid );
162 switch( whiteMatter->getValueSet()->getDataType() )
164 case W_DT_UNSIGNED_CHAR:
166 boost::shared_ptr< std::vector< unsigned char > > data(
new std::vector< unsigned char > );
167 *data = copyDataSetsToArray< unsigned char >( dataSets );
168 segmentation = boost::shared_ptr< WValueSetBase >(
new WValueSet< unsigned char >( 1, dataSets.size(), data, W_DT_UNSIGNED_CHAR ) );
173 boost::shared_ptr< std::vector< int16_t > > data(
new std::vector< int16_t > );
174 *data = copyDataSetsToArray< int16_t >( dataSets );
175 segmentation = boost::shared_ptr< WValueSetBase >(
new WValueSet< int16_t >( 1, dataSets.size(), data, W_DT_INT16 ) );
178 case W_DT_SIGNED_INT:
180 boost::shared_ptr< std::vector< int32_t > > data(
new std::vector< int32_t > );
181 *data = copyDataSetsToArray< int32_t >( dataSets );
182 segmentation = boost::shared_ptr< WValueSetBase >(
new WValueSet< int32_t >( 1, dataSets.size(), data, W_DT_SIGNED_INT ) );
187 boost::shared_ptr< std::vector< float > > data(
new std::vector< float > );
188 *data = copyDataSetsToArray< float >( dataSets );
189 segmentation = boost::shared_ptr< WValueSetBase >(
new WValueSet< float >( 1, dataSets.size(), data, W_DT_FLOAT ) );
194 boost::shared_ptr< std::vector< double > > data(
new std::vector< double > );
195 *data = copyDataSetsToArray< double >( dataSets );
196 segmentation = boost::shared_ptr< WValueSetBase >(
new WValueSet< double >( 1, dataSets.size(), data, W_DT_DOUBLE ) );
200 WAssert(
false,
"Unknown data type in dataset." );
boost::shared_ptr< WGrid > m_grid
Stores the reference of the WGrid of this DataSetSingle instance.
static boost::shared_ptr< WValueSetBase > convert(boost::shared_ptr< WDataSetScalar > whiteMatter, boost::shared_ptr< WDataSetScalar > grayMatter, boost::shared_ptr< WDataSetScalar > cerebrospinalFluid)
This helper function converts the probabilities given by three separate WDataSetScalars to one WValue...
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
A grid that has parallelepiped cells which all have the same proportion.
virtual const std::string getDescription() const
Gets the description for this prototype.
boost::shared_ptr< WValueSetBase > getValueSet() const
float getWMProbability(int x, int y, int z) const
Returns the white matter probability for the given cell.
boost::shared_ptr< WGrid > getGrid() const
WDataSetSegmentation()
Construct an empty and unusable instance.
float getCSFProbability(int x, int y, int z) const
Returns the cerebrospinal fluid probability for the given cell.
A data set consisting of a set of values based on a grid.
virtual ~WDataSetSegmentation()
Destroys this DataSet instance.
boost::shared_ptr< WDataSetSingle > SPtr
Convenience typedef for a boost::shared_ptr.
Base Class for all value set types.
virtual const std::string getName() const
Gets the name of this prototype.
static boost::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
unsigned int getNbCoordsX() const
Returns the number of samples in x direction.
float getGMProbability(int x, int y, int z) const
Returns the gray matter probability for the given cell.
T getValueAt(size_t id)
Get the value stored at position of the value set.
virtual WDataSetSingle::SPtr clone() const
Creates a copy (clone) of this instance.