OpenWalnut 1.2.5
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WDATASETRAWHARDI_H 00026 #define WDATASETRAWHARDI_H 00027 00028 #include <string> 00029 #include <vector> 00030 00031 #include "WDataSetSingle.h" 00032 #include "../common/math/linearAlgebra/WLinearAlgebra.h" 00033 #include "WExportDataHandler.h" 00034 00035 /** 00036 * This data set type contains raw HARDI and its gradients. 00037 * \ingroup dataHandler 00038 */ 00039 class OWDATAHANDLER_EXPORT WDataSetRawHARDI : public WDataSetSingle // NOLINT 00040 { 00041 public: 00042 00043 /** 00044 * Constructs an instance out of: 00045 * - an appropriate value set with a vector of measure values for each voxel, 00046 * - a grid and 00047 * - the gradients used during the measurement of the different values. 00048 * 00049 * \param newValueSet the vector value set to use 00050 * \param newGrid the grid which maps world space to the value set 00051 * \param newGradients the Gradients of the 00052 * \param diffusionBValue Strength of the gradient 00053 */ 00054 WDataSetRawHARDI( boost::shared_ptr< WValueSetBase > newValueSet, 00055 boost::shared_ptr< WGrid > newGrid, 00056 boost::shared_ptr< std::vector< WVector3d > > newGradients, 00057 double diffusionBValue = 1.0 ); 00058 00059 /** 00060 * Construct an empty and unusable instance. This is needed for the prototype mechanism. 00061 */ 00062 WDataSetRawHARDI(); 00063 00064 /** 00065 * Destroys this DataSet instance 00066 */ 00067 virtual ~WDataSetRawHARDI(); 00068 00069 /** 00070 * Creates a copy (clone) of this instance but allows to change the valueset. Unlike copy construction, this is a very useful function if you 00071 * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle. 00072 * 00073 * \param newValueSet the new valueset. 00074 * 00075 * \return the clone 00076 */ 00077 virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const; 00078 00079 /** 00080 * Creates a copy (clone) of this instance but allows to change the grid. Unlike copy construction, this is a very useful function if you 00081 * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle. 00082 * 00083 * \param newGrid the new grid. 00084 * 00085 * \return the clone 00086 */ 00087 virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const; 00088 00089 /** 00090 * Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you 00091 * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle. 00092 * 00093 * \return the clone 00094 */ 00095 virtual WDataSetSingle::SPtr clone() const; 00096 00097 /** 00098 * Returns a prototype instantiated with the true type of the deriving class. 00099 * 00100 * \return the prototype. 00101 */ 00102 static boost::shared_ptr< WPrototyped > getPrototype(); 00103 00104 /** 00105 * Returns the gradient for the index. 00106 * 00107 * \return gradient of measurement 00108 * 00109 * \param index 00110 */ 00111 const WVector3d& getGradient( size_t index ) const; 00112 00113 /** 00114 * Returns the count of measurements per voxel, which is equal to the count of the used gradients. 00115 * 00116 * \return measurements per voxel 00117 */ 00118 std::size_t getNumberOfMeasurements() const; 00119 00120 /** 00121 * Gets the name of this prototype. 00122 * 00123 * \return the name. 00124 */ 00125 virtual const std::string getName() const; 00126 00127 /** 00128 * Gets the description for this prototype. 00129 * 00130 * \return the description 00131 */ 00132 virtual const std::string getDescription() const; 00133 00134 /** 00135 * Get the orientations. 00136 * 00137 * \return A vector of orientations. 00138 */ 00139 std::vector< WVector3d > const& getOrientations() const; 00140 00141 /** 00142 * Get the indexes of zero gradients. 00143 * 00144 * \return Returns the indexes for the which gradient is zero. 00145 */ 00146 std::vector< size_t > const& getZeroGradientIndexes() const; 00147 00148 /** 00149 * Get the indexes of non-zero gradients. 00150 * 00151 * \return Returns the indexes for the which gradient is non-zero. 00152 */ 00153 std::vector< size_t > const& getNonZeroGradientIndexes() const; 00154 00155 /** 00156 * Returns only the measurements for which the gradient was non-zero. 00157 * 00158 * \param index the index of the voxel. 00159 * 00160 * \return non-zero gradient signals 00161 */ 00162 template< typename T > WValue< T > getNonZeroGradientSignals( size_t index ) const; 00163 00164 /** 00165 * Returns the \e b-value of the diffusion. 00166 * 00167 * \return b-value as double 00168 */ 00169 double getDiffusionBValue() const; 00170 00171 protected: 00172 00173 /** 00174 * The prototype as singleton. 00175 */ 00176 static boost::shared_ptr< WPrototyped > m_prototype; 00177 00178 private: 00179 /** 00180 * Build indexes for the zero and non-zero gradients. 00181 */ 00182 void buildGradientIndexes(); 00183 00184 boost::shared_ptr< std::vector< WVector3d > > m_gradients; //!< Gradients of measurements 00185 /** 00186 * Strength (b-value) of the so-called magnetic diffusion gradient. 00187 */ 00188 double m_diffusionBValue; 00189 00190 /** 00191 * The indexes for the which gradient is zero. 00192 */ 00193 std::vector< size_t > m_zeroGradientIndexes; 00194 00195 /** 00196 * The indexes for the which gradient is non-zero. 00197 */ 00198 std::vector< size_t > m_nonZeroGradientIndexes; 00199 }; 00200 00201 inline std::vector< size_t > const& WDataSetRawHARDI::getZeroGradientIndexes() const 00202 { 00203 return m_zeroGradientIndexes; 00204 } 00205 00206 inline std::vector< size_t > const& WDataSetRawHARDI::getNonZeroGradientIndexes() const 00207 { 00208 return m_nonZeroGradientIndexes; 00209 } 00210 00211 template< typename T > WValue< T > WDataSetRawHARDI::getNonZeroGradientSignals( size_t index ) const 00212 { 00213 WValue< T > result( m_nonZeroGradientIndexes.size() ); 00214 size_t idx = 0; 00215 boost::shared_ptr< WValueSet< T > > vs = boost::shared_dynamic_cast< WValueSet< T > >( m_valueSet ); 00216 WValue< T > signal( vs->getWValue( index ) ); 00217 for ( std::vector< size_t >::const_iterator cit = m_nonZeroGradientIndexes.begin(); cit != m_nonZeroGradientIndexes.end(); ++cit ) 00218 { 00219 result[ idx ] = signal[ *cit ]; 00220 ++idx; 00221 } 00222 return result; 00223 } 00224 00225 00226 #endif // WDATASETRAWHARDI_H