29 #include "WDataSetScalar.h"
30 #include "WDataSetSegmentation.h"
36 std::shared_ptr< WDataSetScalar > grayMatter,
37 std::shared_ptr< WDataSetScalar > cerebrospinalFluid )
38 :
WDataSetSingle( convert( whiteMatter, grayMatter, cerebrospinalFluid ), whiteMatter->getGrid() )
40 std::shared_ptr< WGrid > grid( whiteMatter->getGrid() );
44 std::shared_ptr< WGrid > grid )
63 return "WDataSetSegmentation";
68 return "Segmentation of brain into white and gray matter, and CSF.";
118 std::shared_ptr< WGridRegular3D > grid = std::dynamic_pointer_cast< WGridRegular3D >(
m_grid );
119 size_t id = x + y * grid->getNbCoordsX() + z * grid->getNbCoordsX() * grid->getNbCoordsY();
126 std::shared_ptr< WGridRegular3D > grid = std::dynamic_pointer_cast< WGridRegular3D >(
m_grid );
127 size_t id = x + y * grid->getNbCoordsX() + z * grid->getNbCoordsX() * grid->getNbCoordsY();
134 std::shared_ptr< WGridRegular3D > grid = std::dynamic_pointer_cast< WGridRegular3D >(
m_grid );
135 size_t id = x + y * grid->getNbCoordsX() + z * grid->getNbCoordsX() * grid->getNbCoordsY();
141 std::shared_ptr< WDataSetScalar > grayMatter,
142 std::shared_ptr< WDataSetScalar > cerebrospinalFluid )
145 WAssert( whiteMatter,
"No white matter data given." );
146 WAssert( grayMatter,
"No gray matter data given." );
147 WAssert( cerebrospinalFluid,
"No CSF data given." );
150 std::shared_ptr< WGridRegular3D > wm_grid = std::dynamic_pointer_cast< WGridRegular3D >( whiteMatter->getGrid() );
151 std::shared_ptr< WGridRegular3D > gm_grid = std::dynamic_pointer_cast< WGridRegular3D >( grayMatter->getGrid() );
152 std::shared_ptr< WGridRegular3D > csf_grid = std::dynamic_pointer_cast< WGridRegular3D >( cerebrospinalFluid->getGrid() );
154 WAssert( ( wm_grid->getNbCoordsX() == gm_grid->getNbCoordsX() ) && ( gm_grid->getNbCoordsX() == csf_grid->getNbCoordsX() ),
155 "Different X size of GrayMatter, WhiteMatter or CSF-Input" );
156 WAssert( ( wm_grid->getNbCoordsY() == gm_grid->getNbCoordsY() ) && ( gm_grid->getNbCoordsY() == csf_grid->getNbCoordsY() ),
157 "Different Y size of GrayMatter, WhiteMatter or CSF-Input" );
158 WAssert( ( wm_grid->getNbCoordsZ() == gm_grid->getNbCoordsZ() ) && ( gm_grid->getNbCoordsZ() == csf_grid->getNbCoordsZ() ),
159 "Different Z size of GrayMatter, WhiteMatter or CSF-Input" );
161 std::shared_ptr< WValueSetBase > segmentation;
162 std::vector< std::shared_ptr< WDataSetScalar > > dataSets;
163 dataSets.push_back( whiteMatter );
164 dataSets.push_back( grayMatter );
165 dataSets.push_back( cerebrospinalFluid );
167 switch( whiteMatter->getValueSet()->getDataType() )
169 case W_DT_UNSIGNED_CHAR:
171 std::shared_ptr< std::vector< unsigned char > > data(
new std::vector< unsigned char > );
172 *data = copyDataSetsToArray< unsigned char >( dataSets );
173 segmentation = std::shared_ptr< WValueSetBase >(
new WValueSet< unsigned char >( 1, dataSets.size(), data, W_DT_UNSIGNED_CHAR ) );
178 std::shared_ptr< std::vector< int16_t > > data(
new std::vector< int16_t > );
179 *data = copyDataSetsToArray< int16_t >( dataSets );
180 segmentation = std::shared_ptr< WValueSetBase >(
new WValueSet< int16_t >( 1, dataSets.size(), data, W_DT_INT16 ) );
183 case W_DT_SIGNED_INT:
185 std::shared_ptr< std::vector< int32_t > > data(
new std::vector< int32_t > );
186 *data = copyDataSetsToArray< int32_t >( dataSets );
187 segmentation = std::shared_ptr< WValueSetBase >(
new WValueSet< int32_t >( 1, dataSets.size(), data, W_DT_SIGNED_INT ) );
192 std::shared_ptr< std::vector< float > > data(
new std::vector< float > );
193 *data = copyDataSetsToArray< float >( dataSets );
194 segmentation = std::shared_ptr< WValueSetBase >(
new WValueSet< float >( 1, dataSets.size(), data, W_DT_FLOAT ) );
199 std::shared_ptr< std::vector< double > > data(
new std::vector< double > );
200 *data = copyDataSetsToArray< double >( dataSets );
201 segmentation = std::shared_ptr< WValueSetBase >(
new WValueSet< double >( 1, dataSets.size(), data, W_DT_DOUBLE ) );
205 WAssert(
false,
"Unknown data type in dataset." );
WDataSetSegmentation()
Construct an empty and unusable instance.
float getGMProbability(int x, int y, int z) const
Returns the gray matter probability for the given cell.
float getCSFProbability(int x, int y, int z) const
Returns the cerebrospinal fluid probability for the given cell.
virtual const std::string getDescription() const
Gets the description for this prototype.
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
float getWMProbability(int x, int y, int z) const
Returns the white matter probability for the given cell.
virtual const std::string getName() const
Gets the name of this prototype.
static std::shared_ptr< WValueSetBase > convert(std::shared_ptr< WDataSetScalar > whiteMatter, std::shared_ptr< WDataSetScalar > grayMatter, std::shared_ptr< WDataSetScalar > cerebrospinalFluid)
This helper function converts the probabilities given by three separate WDataSetScalars to one WValue...
static std::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
virtual ~WDataSetSegmentation()
Destroys this DataSet instance.
virtual WDataSetSingle::SPtr clone() const
Creates a copy (clone) of this instance.
A data set consisting of a set of values based on a grid.
std::shared_ptr< WValueSetBase > getValueSet() const
std::shared_ptr< WGrid > m_grid
Stores the reference of the WGrid of this DataSetSingle instance.
std::shared_ptr< WGrid > getGrid() const
double getSingleRawValue(size_t id) const
Get the raw scalar value stored at id-th position of the raw array of the value set.
std::shared_ptr< WDataSetSingle > SPtr
Convenience typedef for a std::shared_ptr.
Base Class for all value set types.