OpenWalnut
1.4.0
|
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/WVectorFixed.h" 00033 00034 00035 /** 00036 * This data set type contains raw HARDI and its gradients. 00037 * \ingroup dataHandler 00038 */ 00039 class WDataSetRawHARDI : public WDataSetSingle // NOLINT 00040 { 00041 public: 00042 /** 00043 * Constructs an instance out of: 00044 * - an appropriate value set with a vector of measure values for each voxel, 00045 * - a grid and 00046 * - the gradients used during the measurement of the different values. 00047 * 00048 * \param newValueSet the vector value set to use 00049 * \param newGrid the grid which maps world space to the value set 00050 * \param newGradients the Gradients of the 00051 * \param diffusionBValue Strength of the gradient 00052 */ 00053 WDataSetRawHARDI( boost::shared_ptr< WValueSetBase > newValueSet, 00054 boost::shared_ptr< WGrid > newGrid, 00055 boost::shared_ptr< std::vector< WVector3d > > newGradients, 00056 double diffusionBValue = 1.0 ); 00057 00058 /** 00059 * Construct an empty and unusable instance. This is needed for the prototype mechanism. 00060 */ 00061 WDataSetRawHARDI(); 00062 00063 /** 00064 * Destroys this DataSet instance 00065 */ 00066 virtual ~WDataSetRawHARDI(); 00067 00068 /** 00069 * Creates a copy (clone) of this instance but allows one to change the valueset. Unlike copy construction, this is a very useful function if you 00070 * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle. 00071 * 00072 * \param newValueSet the new valueset. 00073 * 00074 * \return the clone 00075 */ 00076 virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const; 00077 00078 /** 00079 * Creates a copy (clone) of this instance but allows one to change the grid. Unlike copy construction, this is a very useful function if you 00080 * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle. 00081 * 00082 * \param newGrid the new grid. 00083 * 00084 * \return the clone 00085 */ 00086 virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const; 00087 00088 /** 00089 * Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you 00090 * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle. 00091 * 00092 * \return the clone 00093 */ 00094 virtual WDataSetSingle::SPtr clone() const; 00095 00096 /** 00097 * Returns a prototype instantiated with the true type of the deriving class. 00098 * 00099 * \return the prototype. 00100 */ 00101 static boost::shared_ptr< WPrototyped > getPrototype(); 00102 00103 /** 00104 * Returns the gradient for the index. 00105 * 00106 * \return gradient of measurement 00107 * 00108 * \param index 00109 */ 00110 const WVector3d& getGradient( size_t index ) const; 00111 00112 /** 00113 * Returns the count of measurements per voxel, which is equal to the count of the used gradients. 00114 * 00115 * \return measurements per voxel 00116 */ 00117 std::size_t getNumberOfMeasurements() const; 00118 00119 /** 00120 * Gets the name of this prototype. 00121 * 00122 * \return the name. 00123 */ 00124 virtual const std::string getName() const; 00125 00126 /** 00127 * Gets the description for this prototype. 00128 * 00129 * \return the description 00130 */ 00131 virtual const std::string getDescription() const; 00132 00133 /** 00134 * Get the orientations. 00135 * 00136 * \return A vector of orientations. 00137 */ 00138 std::vector< WVector3d > const& getOrientations() const; 00139 00140 /** 00141 * Get the indexes of zero gradients. 00142 * 00143 * \return Returns the indexes for the which gradient is zero. 00144 */ 00145 std::vector< size_t > const& getZeroGradientIndexes() const; 00146 00147 /** 00148 * Get the indexes of non-zero gradients. 00149 * 00150 * \return Returns the indexes for the which gradient is non-zero. 00151 */ 00152 std::vector< size_t > const& getNonZeroGradientIndexes() const; 00153 00154 /** 00155 * Returns only the measurements for which the gradient was non-zero. 00156 * 00157 * \param index the index of the voxel. 00158 * 00159 * \return non-zero gradient signals 00160 */ 00161 template< typename T > WValue< T > getNonZeroGradientSignals( size_t index ) const; 00162 00163 /** 00164 * Returns the \e b-value of the diffusion. 00165 * 00166 * \return b-value as double 00167 */ 00168 double getDiffusionBValue() const; 00169 00170 protected: 00171 /** 00172 * The prototype as singleton. 00173 */ 00174 static boost::shared_ptr< WPrototyped > m_prototype; 00175 00176 private: 00177 /** 00178 * Build indexes for the zero and non-zero gradients. 00179 */ 00180 void buildGradientIndexes(); 00181 00182 boost::shared_ptr< std::vector< WVector3d > > m_gradients; //!< Gradients of measurements 00183 /** 00184 * Strength (b-value) of the so-called magnetic diffusion gradient. 00185 */ 00186 double m_diffusionBValue; 00187 00188 /** 00189 * The indexes for the which gradient is zero. 00190 */ 00191 std::vector< size_t > m_zeroGradientIndexes; 00192 00193 /** 00194 * The indexes for the which gradient is non-zero. 00195 */ 00196 std::vector< size_t > m_nonZeroGradientIndexes; 00197 }; 00198 00199 inline std::vector< size_t > const& WDataSetRawHARDI::getZeroGradientIndexes() const 00200 { 00201 return m_zeroGradientIndexes; 00202 } 00203 00204 inline std::vector< size_t > const& WDataSetRawHARDI::getNonZeroGradientIndexes() const 00205 { 00206 return m_nonZeroGradientIndexes; 00207 } 00208 00209 template< typename T > WValue< T > WDataSetRawHARDI::getNonZeroGradientSignals( size_t index ) const 00210 { 00211 WValue< T > result( m_nonZeroGradientIndexes.size() ); 00212 size_t idx = 0; 00213 boost::shared_ptr< WValueSet< T > > vs = boost::dynamic_pointer_cast< WValueSet< T > >( m_valueSet ); 00214 WValue< T > signal( vs->getWValue( index ) ); 00215 for( std::vector< size_t >::const_iterator cit = m_nonZeroGradientIndexes.begin(); cit != m_nonZeroGradientIndexes.end(); ++cit ) 00216 { 00217 result[ idx ] = signal[ *cit ]; 00218 ++idx; 00219 } 00220 return result; 00221 } 00222 00223 00224 #endif // WDATASETRAWHARDI_H