Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
04db17f4
Commit
04db17f4
authored
Feb 14, 2011
by
reichenbach
Browse files
[CHANGE] Gridchanges! reintroduced selection of transformation matrices into data module
parent
90e24c23
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
224 additions
and
42 deletions
+224
-42
src/dataHandler/WDataSet.cpp
src/dataHandler/WDataSet.cpp
+4
-0
src/dataHandler/WDataSet.h
src/dataHandler/WDataSet.h
+9
-0
src/dataHandler/WDataSetDTI.cpp
src/dataHandler/WDataSetDTI.cpp
+6
-0
src/dataHandler/WDataSetDTI.h
src/dataHandler/WDataSetDTI.h
+9
-0
src/dataHandler/WDataSetScalar.cpp
src/dataHandler/WDataSetScalar.cpp
+4
-0
src/dataHandler/WDataSetScalar.h
src/dataHandler/WDataSetScalar.h
+9
-0
src/dataHandler/WDataSetSingle.cpp
src/dataHandler/WDataSetSingle.cpp
+5
-0
src/dataHandler/WDataSetSingle.h
src/dataHandler/WDataSetSingle.h
+9
-0
src/dataHandler/WDataSetSphericalHarmonics.cpp
src/dataHandler/WDataSetSphericalHarmonics.cpp
+5
-0
src/dataHandler/WDataSetSphericalHarmonics.h
src/dataHandler/WDataSetSphericalHarmonics.h
+9
-0
src/dataHandler/WDataSetTimeSeries.h
src/dataHandler/WDataSetTimeSeries.h
+1
-0
src/dataHandler/WDataSetVector.cpp
src/dataHandler/WDataSetVector.cpp
+5
-0
src/dataHandler/WDataSetVector.h
src/dataHandler/WDataSetVector.h
+9
-0
src/dataHandler/io/WReaderNIfTI.cpp
src/dataHandler/io/WReaderNIfTI.cpp
+21
-2
src/dataHandler/io/WReaderNIfTI.h
src/dataHandler/io/WReaderNIfTI.h
+27
-0
src/kernel/modules/data/WMData.cpp
src/kernel/modules/data/WMData.cpp
+79
-6
src/kernel/modules/data/WMData.h
src/kernel/modules/data/WMData.h
+13
-34
No files found.
src/dataHandler/WDataSet.cpp
View file @
04db17f4
...
...
@@ -119,3 +119,7 @@ boost::shared_ptr< WProperties > WDataSet::getInformationProperties() const
return
m_infoProperties
;
}
boost
::
shared_ptr
<
WDataSet
>
WDataSet
::
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
,
boost
::
shared_ptr
<
WGrid
>
)
const
{
return
boost
::
shared_ptr
<
WDataSet
>
();
}
src/dataHandler/WDataSet.h
View file @
04db17f4
...
...
@@ -149,6 +149,15 @@ public:
*/
boost
::
shared_ptr
<
WProperties
>
getInformationProperties
()
const
;
/**
* Returns a new dataset with the given valueset and grid that is of the same type as this dataset.
*
* \param vs The valueset.
* \param grid The grid.
* \return The new dataset.
*/
virtual
boost
::
shared_ptr
<
WDataSet
>
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
vs
,
boost
::
shared_ptr
<
WGrid
>
grid
)
const
;
protected:
/**
...
...
src/dataHandler/WDataSetDTI.cpp
View file @
04db17f4
...
...
@@ -49,3 +49,9 @@ wmath::WTensorSym< 2, 3, float > WDataSetDTI::getTensor( size_t index ) const
WAssert
(
values
,
"The value set of a WDataSetDTI must be a WValueSet< float >, nothing else!"
);
return
wmath
::
WTensorSym
<
2
,
3
,
float
>
(
values
->
getWValue
(
index
)
);
}
boost
::
shared_ptr
<
WDataSet
>
WDataSetDTI
::
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
vs
,
boost
::
shared_ptr
<
WGrid
>
grid
)
const
{
return
boost
::
shared_ptr
<
WDataSet
>
(
new
WDataSetDTI
(
vs
,
grid
)
);
}
src/dataHandler/WDataSetDTI.h
View file @
04db17f4
...
...
@@ -61,6 +61,15 @@ public:
*/
wmath
::
WTensorSym
<
2
,
3
,
float
>
getTensor
(
size_t
index
)
const
;
/**
* Returns a new dataset with the given valueset and grid that is of the same type as this dataset.
*
* \param vs The valueset.
* \param grid The grid.
* \return The new dataset.
*/
virtual
boost
::
shared_ptr
<
WDataSet
>
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
vs
,
boost
::
shared_ptr
<
WGrid
>
grid
)
const
;
protected:
/**
* The prototype as singleton.
...
...
src/dataHandler/WDataSetScalar.cpp
View file @
04db17f4
...
...
@@ -152,3 +152,7 @@ boost::shared_ptr< const WValueSetHistogram > WDataSetScalar::getHistogram( size
return
m_histograms
[
buckets
];
}
boost
::
shared_ptr
<
WDataSet
>
WDataSetScalar
::
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
vs
,
boost
::
shared_ptr
<
WGrid
>
grid
)
const
{
return
boost
::
shared_ptr
<
WDataSet
>
(
new
WDataSetScalar
(
vs
,
grid
)
);
}
src/dataHandler/WDataSetScalar.h
View file @
04db17f4
...
...
@@ -121,6 +121,15 @@ public:
*/
static
boost
::
shared_ptr
<
WPrototyped
>
getPrototype
();
/**
* Returns a new dataset with the given valueset and grid that is of the same type as this dataset.
*
* \param vs The valueset.
* \param grid The grid.
* \return The new dataset.
*/
virtual
boost
::
shared_ptr
<
WDataSet
>
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
vs
,
boost
::
shared_ptr
<
WGrid
>
grid
)
const
;
protected:
/**
...
...
src/dataHandler/WDataSetSingle.cpp
View file @
04db17f4
...
...
@@ -154,3 +154,8 @@ double WDataSetSingle::getValueAt( size_t id ) const
return
0.0
;
// should not be reached. Just there to quiet compiler.
}
boost
::
shared_ptr
<
WDataSet
>
WDataSetSingle
::
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
vs
,
boost
::
shared_ptr
<
WGrid
>
grid
)
const
{
return
boost
::
shared_ptr
<
WDataSet
>
(
new
WDataSetSingle
(
vs
,
grid
)
);
}
src/dataHandler/WDataSetSingle.h
View file @
04db17f4
...
...
@@ -137,6 +137,15 @@ public:
*/
static
boost
::
shared_ptr
<
WPrototyped
>
getPrototype
();
/**
* Returns a new dataset with the given valueset and grid that is of the same type as this dataset.
*
* \param vs The valueset.
* \param grid The grid.
* \return The new dataset.
*/
virtual
boost
::
shared_ptr
<
WDataSet
>
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
vs
,
boost
::
shared_ptr
<
WGrid
>
grid
)
const
;
protected:
/**
...
...
src/dataHandler/WDataSetSphericalHarmonics.cpp
View file @
04db17f4
...
...
@@ -135,3 +135,8 @@ bool WDataSetSphericalHarmonics::isTexture() const
{
return
false
;
}
boost
::
shared_ptr
<
WDataSet
>
WDataSetSphericalHarmonics
::
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
vs
,
boost
::
shared_ptr
<
WGrid
>
grid
)
const
{
return
boost
::
shared_ptr
<
WDataSet
>
(
new
WDataSetSphericalHarmonics
(
vs
,
grid
)
);
}
src/dataHandler/WDataSetSphericalHarmonics.h
View file @
04db17f4
...
...
@@ -109,6 +109,15 @@ public:
*/
virtual
bool
isTexture
()
const
;
/**
* Returns a new dataset with the given valueset and grid that is of the same type as this dataset.
*
* \param vs The valueset.
* \param grid The grid.
* \return The new dataset.
*/
virtual
boost
::
shared_ptr
<
WDataSet
>
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
vs
,
boost
::
shared_ptr
<
WGrid
>
grid
)
const
;
protected:
/**
...
...
src/dataHandler/WDataSetTimeSeries.h
View file @
04db17f4
...
...
@@ -46,6 +46,7 @@ class WDataSetTimeSeriesTest;
* A dataset that stores a time series.
*
* \note Only works for scalar datasets at the moment!
* \note this is only a temporary solution
*/
class
OWDATAHANDLER_EXPORT
WDataSetTimeSeries
:
public
WDataSet
{
...
...
src/dataHandler/WDataSetVector.cpp
View file @
04db17f4
...
...
@@ -151,3 +151,8 @@ bool WDataSetVector::isTexture() const
{
return
true
;
}
boost
::
shared_ptr
<
WDataSet
>
WDataSetVector
::
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
vs
,
boost
::
shared_ptr
<
WGrid
>
grid
)
const
{
return
boost
::
shared_ptr
<
WDataSet
>
(
new
WDataSetVector
(
vs
,
grid
)
);
}
src/dataHandler/WDataSetVector.h
View file @
04db17f4
...
...
@@ -96,6 +96,15 @@ public:
*/
boost
::
shared_ptr
<
WDataSetVector
>
isVectorDataSet
();
/**
* Returns a new dataset with the given valueset and grid that is of the same type as this dataset.
*
* \param vs The valueset.
* \param grid The grid.
* \return The new dataset.
*/
virtual
boost
::
shared_ptr
<
WDataSet
>
clone
(
boost
::
shared_ptr
<
WValueSetBase
>
vs
,
boost
::
shared_ptr
<
WGrid
>
grid
)
const
;
protected:
/**
...
...
src/dataHandler/io/WReaderNIfTI.cpp
View file @
04db17f4
...
...
@@ -51,7 +51,9 @@
#include "WReaderNIfTI.h"
WReaderNIfTI
::
WReaderNIfTI
(
std
::
string
fileName
)
:
WReader
(
fileName
)
:
WReader
(
fileName
),
m_sform
(
4
,
4
),
m_qform
(
4
,
4
)
{
}
...
...
@@ -179,8 +181,10 @@ boost::shared_ptr< WDataSet > WReaderNIfTI::load( DataSetType dataSetType )
throw
e
;
}
m_sform
=
convertMatrix
(
header
->
sto_xyz
);
m_qform
=
convertMatrix
(
header
->
qto_xyz
);
newGrid
=
boost
::
shared_ptr
<
WGridRegular3D
>
(
new
WGridRegular3D
(
columns
,
rows
,
frames
,
WGridTransformOrtho
(
convertMatrix
(
header
->
sto_xyz
)
)
)
);
new
WGridRegular3D
(
columns
,
rows
,
frames
,
WGridTransformOrtho
(
getStandardTransform
(
)
)
)
);
boost
::
shared_ptr
<
WDataSet
>
newDataSet
;
// known description
...
...
@@ -402,3 +406,18 @@ boost::shared_ptr< WDataSet > WReaderNIfTI::load( DataSetType dataSetType )
return
newDataSet
;
}
wmath
::
WMatrix
<
double
>
WReaderNIfTI
::
getStandardTransform
()
const
{
return
wmath
::
WMatrix
<
double
>
(
4
,
4
).
makeIdentity
();
}
wmath
::
WMatrix
<
double
>
WReaderNIfTI
::
getSFormTransform
()
const
{
return
m_sform
;
}
wmath
::
WMatrix
<
double
>
WReaderNIfTI
::
getQFormTransform
()
const
{
return
m_qform
;
}
src/dataHandler/io/WReaderNIfTI.h
View file @
04db17f4
...
...
@@ -64,6 +64,27 @@ public:
*/
virtual
boost
::
shared_ptr
<
WDataSet
>
load
(
DataSetType
dataSetType
=
W_DATASET_NONE
);
/**
* Returns a standard transformation.
*
* \return A Wmatrix that represents the dataset's transformation.
*/
wmath
::
WMatrix
<
double
>
getStandardTransform
()
const
;
/**
* Returns the SForm transformation stored in the nifti file's header.
*
* \return A Wmatrix that represents the dataset's transformation.
*/
wmath
::
WMatrix
<
double
>
getSFormTransform
()
const
;
/**
* Returns the QForm transformation stored in the nifti file's header.
*
* \return A Wmatrix that represents the dataset's transformation.
*/
wmath
::
WMatrix
<
double
>
getQFormTransform
()
const
;
protected:
private:
/**
...
...
@@ -81,6 +102,12 @@ private:
* \param in this matrix will be converted.
*/
wmath
::
WMatrix
<
double
>
convertMatrix
(
const
mat44
&
in
);
//! the sform transform stored in the file header
wmath
::
WMatrix
<
double
>
m_sform
;
//! the qform transform stored in the file header
wmath
::
WMatrix
<
double
>
m_qform
;
};
#endif // WREADERNIFTI_H
src/kernel/modules/data/WMData.cpp
View file @
04db17f4
...
...
@@ -33,6 +33,7 @@
#include "../../../dataHandler/WDataSetScalar.h"
#include "../../../dataHandler/WDataSetTimeSeries.h"
#include "../../../dataHandler/WDataSetVector.h"
#include "../../../dataHandler/WDataSetRawHARDI.h"
#include "../../../dataHandler/WSubject.h"
#include "../../../dataHandler/WDataHandler.h"
#include "../../../dataHandler/WDataTexture3D.h"
...
...
@@ -54,7 +55,10 @@
WMData
::
WMData
()
:
WModule
(),
m_fileNameSet
(
false
),
m_isTexture
()
m_isTexture
(),
m_transformNoMatrix
(
4
,
4
),
m_transformSForm
(
4
,
4
),
m_transformQForm
(
4
,
4
)
{
// initialize members
}
...
...
@@ -124,13 +128,20 @@ void WMData::connectors()
void
WMData
::
properties
()
{
m_propCondition
=
boost
::
shared_ptr
<
WCondition
>
(
new
WCondition
()
);
// properties
m_dataName
=
m_infoProperties
->
addProperty
(
"Filename"
,
"The filename of the dataset."
,
std
::
string
(
""
)
);
m_dataType
=
m_infoProperties
->
addProperty
(
"Data type"
,
"The type of the the single data values."
,
std
::
string
(
""
)
);
// use this callback for the other properties
WPropertyBase
::
PropertyChangeNotifierType
propertyCallback
=
boost
::
bind
(
&
WMData
::
propertyChanged
,
this
,
_1
);
m_matrixSelectionsList
=
boost
::
shared_ptr
<
WItemSelection
>
(
new
WItemSelection
()
);
m_matrixSelectionsList
->
addItem
(
"No matrix"
,
""
);
m_matrixSelectionsList
->
addItem
(
"qform"
,
""
);
m_matrixSelectionsList
->
addItem
(
"sform"
,
""
);
m_matrixSelection
=
m_properties
->
addProperty
(
"Transformation matrix"
,
"matrix"
,
m_matrixSelectionsList
->
getSelectorFirst
(),
m_propCondition
);
WPropertyHelper
::
PC_SELECTONLYONE
::
addTo
(
m_matrixSelection
);
}
void
WMData
::
propertyChanged
(
boost
::
shared_ptr
<
WPropertyBase
>
property
)
...
...
@@ -180,6 +191,9 @@ void WMData::notifyStop()
void
WMData
::
moduleMain
()
{
m_moduleState
.
setResetable
(
true
,
true
);
m_moduleState
.
add
(
m_propCondition
);
WAssert
(
m_fileNameSet
,
"No filename specified."
);
using
wiotools
::
getSuffix
;
...
...
@@ -210,6 +224,10 @@ void WMData::moduleMain()
WReaderNIfTI
niiLoader
(
fileName
);
m_dataSet
=
niiLoader
.
load
();
m_transformNoMatrix
=
niiLoader
.
getStandardTransform
();
m_transformSForm
=
niiLoader
.
getSFormTransform
();
m_transformQForm
=
niiLoader
.
getQFormTransform
();
m_isTexture
=
m_dataSet
->
isTexture
();
boost
::
shared_ptr
<
WDataSetSingle
>
dss
=
boost
::
shared_dynamic_cast
<
WDataSetSingle
>
(
m_dataSet
);
...
...
@@ -299,8 +317,63 @@ void WMData::moduleMain()
m_output
->
updateData
(
m_dataSet
);
ready
();
// go to idle mode
waitForStop
();
// WThreadedRunner offers this for us. It uses boost::condition to avoid wasting CPU cycles with while loops.
while
(
!
m_shutdownFlag
()
)
{
m_moduleState
.
wait
();
if
(
m_shutdownFlag
()
)
{
break
;
}
// change transform matrix
if
(
m_matrixSelection
->
changed
()
)
{
// a new grid
boost
::
shared_ptr
<
WGrid
>
newGrid
;
boost
::
shared_ptr
<
WDataSetSingle
>
ds
=
boost
::
shared_dynamic_cast
<
WDataSetSingle
>
(
m_dataSet
);
boost
::
shared_ptr
<
WGridRegular3D
>
oldGrid
=
boost
::
shared_dynamic_cast
<
WGridRegular3D
>
(
ds
->
getGrid
()
);
switch
(
m_matrixSelection
->
get
(
true
).
getItemIndexOfSelected
(
0
)
)
{
case
0
:
newGrid
=
boost
::
shared_ptr
<
WGrid
>
(
new
WGridRegular3D
(
oldGrid
->
getNbCoordsX
(),
oldGrid
->
getNbCoordsY
(),
oldGrid
->
getNbCoordsZ
(),
WGridTransformOrtho
(
m_transformNoMatrix
)
)
);
break
;
case
1
:
newGrid
=
boost
::
shared_ptr
<
WGrid
>
(
new
WGridRegular3D
(
oldGrid
->
getNbCoordsX
(),
oldGrid
->
getNbCoordsY
(),
oldGrid
->
getNbCoordsZ
(),
WGridTransformOrtho
(
m_transformSForm
)
)
);
break
;
case
2
:
newGrid
=
boost
::
shared_ptr
<
WGrid
>
(
new
WGridRegular3D
(
oldGrid
->
getNbCoordsX
(),
oldGrid
->
getNbCoordsY
(),
oldGrid
->
getNbCoordsZ
(),
WGridTransformOrtho
(
m_transformQForm
)
)
);
break
;
}
if
(
boost
::
shared_dynamic_cast
<
WDataSetRawHARDI
>
(
m_dataSet
)
)
{
typedef
std
::
vector
<
wmath
::
WVector3D
>
OrientationType
;
// hardi datasets are a morre difficult case because of additional parameters
boost
::
shared_ptr
<
WDataSetRawHARDI
>
hardi
=
boost
::
shared_dynamic_cast
<
WDataSetRawHARDI
>
(
m_dataSet
);
m_dataSet
=
boost
::
shared_ptr
<
WDataSet
>
(
new
WDataSetRawHARDI
(
hardi
->
getValueSet
(),
newGrid
,
boost
::
shared_ptr
<
OrientationType
>
(
new
OrientationType
(
hardi
->
getOrientations
()
)
),
hardi
->
getDiffusionBValue
()
)
);
// TODO( reichenbach ): remove copying orientations
}
else
{
// this creates a dataset of the same type as m_dataSet without explicit knowledge of the correct type
m_dataSet
=
m_dataSet
->
clone
(
ds
->
getValueSet
(),
newGrid
);
}
// the clone() may have returned a zero-pointer, only update if it hasn't
// this may happen if the clone() operation has not been implemented in the derived dataset class
if
(
m_dataSet
)
{
m_output
->
updateData
(
m_dataSet
);
}
}
}
// remove dataset from datahandler
if
(
m_dataSet
->
isTexture
()
)
...
...
src/kernel/modules/data/WMData.h
View file @
04db17f4
...
...
@@ -159,6 +159,9 @@ protected:
*/
virtual
void
notifyStop
();
//! a condition for property changes
boost
::
shared_ptr
<
WCondition
>
m_propCondition
;
/**
* The filename of the dataset to load.
*/
...
...
@@ -179,28 +182,6 @@ protected:
*/
WPropString
m_dataType
;
// { TODO(ebaum): this is deprecated and will be replaced by WGEColormapping
/**
* \deprecated Be aware that this will be replaced by WGEColormapping
* Grouping the texture display properties
*/
WPropGroup
m_groupTex
;
/**
* Interpolation?
*/
WPropBool
m_interpolation
;
/**
* A list of color map selection types
*/
boost
::
shared_ptr
<
WItemSelection
>
m_colorMapSelectionsList
;
/**
* Selection property for color map
*/
WPropSelection
m_colorMapSelection
;
/**
* A list of color map selection types
*/
...
...
@@ -211,18 +192,6 @@ protected:
*/
WPropSelection
m_matrixSelection
;
/**
* Threshold value for this data.
*/
WPropDouble
m_threshold
;
/**
* Opacity value for this data.
*/
WPropInt
m_opacity
;
// }
bool
m_isTexture
;
//!< Indicates whether the loaded dataSet will be available as texture.
/**
...
...
@@ -232,6 +201,16 @@ protected:
*/
void
propertyChanged
(
boost
::
shared_ptr
<
WPropertyBase
>
property
);
// in case of a nifti file, there may be several transforms specified in the file
//! a standard transform (should be an identity transform)
wmath
::
WMatrix
<
double
>
m_transformNoMatrix
;
//! a standard transform (should be an identity transform)
wmath
::
WMatrix
<
double
>
m_transformSForm
;
//! a standard transform (should be an identity transform)
wmath
::
WMatrix
<
double
>
m_transformQForm
;
private:
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment