OpenWalnut  1.3.1
WDataSetRawHARDI.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <string>
26 #include <vector>
27 
28 #include "../common/WAssert.h"
29 #include "WDataSetSingle.h"
30 
31 #include "WDataSetRawHARDI.h"
32 
33 // prototype instance as singleton
34 boost::shared_ptr< WPrototyped > WDataSetRawHARDI::m_prototype = boost::shared_ptr< WPrototyped >();
35 
36 WDataSetRawHARDI::WDataSetRawHARDI( boost::shared_ptr< WValueSetBase > newValueSet,
37  boost::shared_ptr< WGrid > newGrid,
38  boost::shared_ptr< std::vector< WVector3d > > newGradients,
39  double diffusionBValue )
40  : WDataSetSingle( newValueSet, newGrid ), m_gradients( newGradients ), m_diffusionBValue( diffusionBValue )
41 {
42  WAssert( newValueSet, "No value set given." );
43  WAssert( newGrid, "No grid given." );
44  WAssert( newGradients, "No gradients given." );
45  WAssert( newValueSet->size() == newGrid->size(), "Number of voxel entries unequal number of positions in grid." );
46  WAssert( newValueSet->order() != newGradients->size(), "Number of gradients unequal number of entries in value set." );
48 }
49 
51 {
52  std::vector< size_t > validIndices;
53  for( size_t i = 0; i < m_gradients->size(); ++i )
54  {
55  const WVector3d& grad = ( *m_gradients )[ i ];
56  if( ( grad[ 0 ] != 0.0 ) || ( grad[ 1 ] != 0.0 ) || ( grad[ 2 ] != 0.0 ) )
57  {
58  m_nonZeroGradientIndexes.push_back( i );
59  }
60  else
61  {
62  m_zeroGradientIndexes.push_back( i );
63  }
64  }
65 }
66 
68  : WDataSetSingle()
69 {
70 }
71 
73 {
74 }
75 
76 WDataSetSingle::SPtr WDataSetRawHARDI::clone( boost::shared_ptr< WValueSetBase > newValueSet ) const
77 {
79 }
80 
81 WDataSetSingle::SPtr WDataSetRawHARDI::clone( boost::shared_ptr< WGrid > newGrid ) const
82 {
84 }
85 
87 {
89 }
90 
91 boost::shared_ptr< WPrototyped > WDataSetRawHARDI::getPrototype()
92 {
93  if( !m_prototype )
94  {
95  m_prototype = boost::shared_ptr< WPrototyped >( new WDataSetRawHARDI() );
96  }
97 
98  return m_prototype;
99 }
100 
101 const WVector3d& WDataSetRawHARDI::getGradient( size_t index ) const
102 {
103 #ifdef DEBUG
104  return m_gradients->at( index );
105 #else
106  return (*m_gradients)[ index ];
107 #endif
108 }
109 
110 std::vector< WVector3d > const& WDataSetRawHARDI::getOrientations() const
111 {
112  return *m_gradients;
113 }
114 
116 {
117  return m_diffusionBValue;
118 }
119 
121 {
122  return m_gradients->size();
123 }
124 
125 const std::string WDataSetRawHARDI::getName() const
126 {
127  return "WDataSetRawHARDI";
128 }
129 
130 const std::string WDataSetRawHARDI::getDescription() const
131 {
132  return "Contains HARDI measurements.";
133 }