Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
39fd8419
Commit
39fd8419
authored
Sep 10, 2010
by
reichenbach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD] a preliminary version of a viewer module for functional mri data
parent
4a0ca327
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
305 additions
and
13 deletions
+305
-13
src/dataHandler/WDataSetTimeSeries.cpp
src/dataHandler/WDataSetTimeSeries.cpp
+4
-2
src/dataHandler/WDataSetTimeSeries.h
src/dataHandler/WDataSetTimeSeries.h
+2
-1
src/dataHandler/test/WDataSetTimeSeries_test.h
src/dataHandler/test/WDataSetTimeSeries_test.h
+12
-10
src/modules/functionalMRIViewer/CMakeLists.txt
src/modules/functionalMRIViewer/CMakeLists.txt
+42
-0
src/modules/functionalMRIViewer/WMFunctionalMRIViewer.cpp
src/modules/functionalMRIViewer/WMFunctionalMRIViewer.cpp
+128
-0
src/modules/functionalMRIViewer/WMFunctionalMRIViewer.h
src/modules/functionalMRIViewer/WMFunctionalMRIViewer.h
+116
-0
src/modules/modules-base.toolbox
src/modules/modules-base.toolbox
+1
-0
No files found.
src/dataHandler/WDataSetTimeSeries.cpp
View file @
39fd8419
...
...
@@ -118,7 +118,7 @@ boost::shared_ptr< WDataSetScalar const > WDataSetTimeSeries::getDataSetPtrAtTim
return
boost
::
shared_ptr
<
WDataSetScalar
const
>
();
}
boost
::
shared_ptr
<
WDataSetScalar
const
>
WDataSetTimeSeries
::
calcDataSetAtTime
(
float
time
)
const
boost
::
shared_ptr
<
WDataSetScalar
const
>
WDataSetTimeSeries
::
calcDataSetAtTime
(
float
time
,
std
::
string
const
&
name
)
const
{
WAssert
(
!
boost
::
math
::
isnan
(
time
),
""
);
if
(
time
<
getMinTime
()
||
time
>
getMaxTime
()
)
...
...
@@ -170,7 +170,9 @@ boost::shared_ptr< WDataSetScalar const > WDataSetTimeSeries::calcDataSetAtTime(
throw
WException
(
"Unsupported datatype in WDataSetTimeSeries::calcDataSetAtTime()"
);
break
;
}
return
boost
::
shared_ptr
<
WDataSetScalar
const
>
(
new
WDataSetScalar
(
vs
,
m_dataSets
.
front
().
first
->
getGrid
()
)
);
boost
::
shared_ptr
<
WDataSetScalar
>
ds
(
new
WDataSetScalar
(
vs
,
m_dataSets
.
front
().
first
->
getGrid
()
)
);
ds
->
setFileName
(
name
);
return
ds
;
}
bool
WDataSetTimeSeries
::
TimeSliceCompare
::
operator
()
(
TimeSlice
const
&
t0
,
TimeSlice
const
&
t1
)
...
...
src/dataHandler/WDataSetTimeSeries.h
View file @
39fd8419
...
...
@@ -144,9 +144,10 @@ public:
* a NULL-pointer will be returned.
*
* \param time The time.
* \param name The name of the new dataset.
* \return A new interpolated dataset.
*/
boost
::
shared_ptr
<
WDataSetScalar
const
>
calcDataSetAtTime
(
float
time
)
const
;
boost
::
shared_ptr
<
WDataSetScalar
const
>
calcDataSetAtTime
(
float
time
,
std
::
string
const
&
name
)
const
;
/**
* Interpolate a value for a single point in space and time.
...
...
src/dataHandler/test/WDataSetTimeSeries_test.h
View file @
39fd8419
...
...
@@ -28,6 +28,7 @@
#include <vector>
#include <limits>
#include <algorithm>
#include <string>
#include <boost/shared_ptr.hpp>
#include <cxxtest/TestSuite.h>
...
...
@@ -358,31 +359,32 @@ public:
boost
::
shared_ptr
<
WDataSetScalar
const
>
null
;
boost
::
shared_ptr
<
WDataSetScalar
const
>
ds
;
std
::
string
name
(
"a name"
);
ds
=
ts
.
calcDataSetAtTime
(
-
std
::
numeric_limits
<
float
>::
infinity
()
);
ds
=
ts
.
calcDataSetAtTime
(
-
std
::
numeric_limits
<
float
>::
infinity
()
,
name
);
TS_ASSERT_EQUALS
(
ds
,
null
);
ds
=
ts
.
calcDataSetAtTime
(
-
wlimits
::
FLT_EPS
);
ds
=
ts
.
calcDataSetAtTime
(
-
wlimits
::
FLT_EPS
,
name
);
TS_ASSERT_EQUALS
(
ds
,
null
);
ds
=
ts
.
calcDataSetAtTime
(
std
::
numeric_limits
<
float
>::
infinity
()
);
ds
=
ts
.
calcDataSetAtTime
(
std
::
numeric_limits
<
float
>::
infinity
()
,
name
);
TS_ASSERT_EQUALS
(
ds
,
null
);
ds
=
ts
.
calcDataSetAtTime
(
2.0
f
+
2.0
f
*
wlimits
::
FLT_EPS
);
ds
=
ts
.
calcDataSetAtTime
(
2.0
f
+
2.0
f
*
wlimits
::
FLT_EPS
,
name
);
TS_ASSERT_EQUALS
(
ds
,
null
);
ds
=
ts
.
calcDataSetAtTime
(
0.0
f
);
ds
=
ts
.
calcDataSetAtTime
(
0.0
f
,
name
);
TS_ASSERT_EQUALS
(
ds
,
d
[
0
]
);
ds
=
ts
.
calcDataSetAtTime
(
1.0
f
);
ds
=
ts
.
calcDataSetAtTime
(
1.0
f
,
name
);
TS_ASSERT_EQUALS
(
ds
,
d
[
1
]
);
ds
=
ts
.
calcDataSetAtTime
(
2.0
f
);
ds
=
ts
.
calcDataSetAtTime
(
2.0
f
,
name
);
TS_ASSERT_EQUALS
(
ds
,
d
[
2
]
);
{
std
::
vector
<
double
>
v
(
27
,
1.35
);
ds
=
ts
.
calcDataSetAtTime
(
0.35
f
);
ds
=
ts
.
calcDataSetAtTime
(
0.35
f
,
name
);
TS_ASSERT
(
ds
);
boost
::
shared_ptr
<
WValueSet
<
double
>
>
vs
=
boost
::
shared_dynamic_cast
<
WValueSet
<
double
>
>
(
ds
->
getValueSet
()
);
TS_ASSERT
(
vs
);
...
...
@@ -393,7 +395,7 @@ public:
}
{
std
::
vector
<
double
>
v
(
27
,
1.99
);
ds
=
ts
.
calcDataSetAtTime
(
0.99
f
);
ds
=
ts
.
calcDataSetAtTime
(
0.99
f
,
name
);
TS_ASSERT
(
ds
);
boost
::
shared_ptr
<
WValueSet
<
double
>
>
vs
=
boost
::
shared_dynamic_cast
<
WValueSet
<
double
>
>
(
ds
->
getValueSet
()
);
TS_ASSERT
(
vs
);
...
...
@@ -404,7 +406,7 @@ public:
}
{
std
::
vector
<
double
>
v
(
27
,
2.598
);
ds
=
ts
.
calcDataSetAtTime
(
1.598
f
);
ds
=
ts
.
calcDataSetAtTime
(
1.598
f
,
name
);
TS_ASSERT
(
ds
);
boost
::
shared_ptr
<
WValueSet
<
double
>
>
vs
=
boost
::
shared_dynamic_cast
<
WValueSet
<
double
>
>
(
ds
->
getValueSet
()
);
TS_ASSERT
(
vs
);
...
...
src/modules/functionalMRIViewer/CMakeLists.txt
0 → 100644
View file @
39fd8419
FILE
(
GLOB_RECURSE MODULES_SRC
"*.cpp"
"*.h"
)
# Grab module name and setup target directories
GET_FILENAME_COMPONENT
(
MODULE_NAME
${
CMAKE_CURRENT_SOURCE_DIR
}
NAME
)
SET
(
MODULE_TARGET_DIR
${
CMAKE_LIBRARY_OUTPUT_DIRECTORY
}
/modules/
${
MODULE_NAME
}
)
SET
(
CMAKE_LIBRARY_OUTPUT_DIRECTORY
${
MODULE_TARGET_DIR
}
)
SET
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
${
MODULE_TARGET_DIR
}
)
SET
(
MODULE_DIRNAME
${
MODULE_NAME
}
)
SET
(
MODULE_NAME
"OWmodule_
${
MODULE_NAME
}
"
)
# prefix all module names with "OWmodule_" to separate them from other libs
# Build module lib
ADD_LIBRARY
(
${
MODULE_NAME
}
SHARED
${
MODULES_SRC
}
)
TARGET_LINK_LIBRARIES
(
${
MODULE_NAME
}
OWkernel
${
Teem_LIBRARIES
}
)
# Copy local shaders to module target directory
IF
(
OW_COPY_SHADERS AND EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/shaders
)
# copy shaders only if the user wants it
ADD_CUSTOM_TARGET
(
${
MODULE_NAME
}
_CopyShaders
COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
CMAKE_CURRENT_SOURCE_DIR
}
/shaders
${
MODULE_TARGET_DIR
}
/shaders/
COMMENT
"Copy shaders of
${
MODULE_NAME
}
"
)
ADD_DEPENDENCIES
(
${
MODULE_NAME
}
${
MODULE_NAME
}
_CopyShaders
)
ENDIF
()
# Build unit tests
IF
(
OW_COMPILE_TESTS
)
# This ensures that the test is copied to the module directory
SET
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
${
MODULE_TARGET_DIR
}
)
CXXTEST_ADD_TESTS_FROM_LIST
(
"
${
MODULES_SRC
}
"
"OWkernel;
${
MODULE_NAME
}
"
)
# Copy fixtures if they exist
IF
(
EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/fixtures
)
ADD_CUSTOM_TARGET
(
${
MODULE_NAME
}
_CopyFixtures
# as the "test" target runs in CMakes temporary build dir, the fixtures need to be placed there too.
COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/fixtures
${
CMAKE_BINARY_DIR
}
/modules/
${
MODULE_DIRNAME
}
/fixtures/
COMMENT
"Copy fixtures of
${
MODULE_NAME
}
"
)
ADD_DEPENDENCIES
(
${
MODULE_NAME
}
${
MODULE_NAME
}
_CopyFixtures
)
ENDIF
(
EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/fixtures
)
ENDIF
(
OW_COMPILE_TESTS
)
src/modules/functionalMRIViewer/WMFunctionalMRIViewer.cpp
0 → 100644
View file @
39fd8419
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <string>
#include <sstream>
#include "../../kernel/WKernel.h"
#include "../../dataHandler/WDataHandler.h"
#include "WMFunctionalMRIViewer.h"
// This line is needed by the module loader to actually find your module. Do not remove. Do NOT add a ";" here.
W_LOADABLE_MODULE
(
WMFunctionalMRIViewer
)
WMFunctionalMRIViewer
::
WMFunctionalMRIViewer
()
:
WModule
()
{
}
WMFunctionalMRIViewer
::~
WMFunctionalMRIViewer
()
{
// Cleanup!
}
boost
::
shared_ptr
<
WModule
>
WMFunctionalMRIViewer
::
factory
()
const
{
// See "src/modules/template/" for an extensively documented example.
return
boost
::
shared_ptr
<
WModule
>
(
new
WMFunctionalMRIViewer
()
);
}
const
char
**
WMFunctionalMRIViewer
::
getXPMIcon
()
const
{
return
NULL
;
}
const
std
::
string
WMFunctionalMRIViewer
::
getName
()
const
{
return
"FunctionalMRIViewer"
;
}
const
std
::
string
WMFunctionalMRIViewer
::
getDescription
()
const
{
return
"Allows to select a point of time and to show the dataset at that point of time."
;
}
void
WMFunctionalMRIViewer
::
connectors
()
{
m_input
=
boost
::
shared_ptr
<
WModuleInputData
<
WDataSetTimeSeries
>
>
(
new
WModuleInputData
<
WDataSetTimeSeries
>
(
shared_from_this
(),
"in"
,
"A time series."
)
);
addConnector
(
m_input
);
WModule
::
connectors
();
}
void
WMFunctionalMRIViewer
::
properties
()
{
m_propCondition
=
boost
::
shared_ptr
<
WCondition
>
(
new
WCondition
()
);
m_time
=
m_properties
->
addProperty
(
"Time"
,
"The current time."
,
0.0
,
m_propCondition
);
m_time
->
setMax
(
1.0
);
m_time
->
setMin
(
0.0
);
}
void
WMFunctionalMRIViewer
::
moduleMain
()
{
m_moduleState
.
setResetable
(
true
,
true
);
m_moduleState
.
add
(
m_propCondition
);
ready
();
while
(
!
m_shutdownFlag
()
)
{
debugLog
()
<<
"Waiting."
;
m_moduleState
.
wait
();
boost
::
shared_ptr
<
WDataSetTimeSeries
>
inData
=
m_input
->
getData
();
bool
dataChanged
=
(
m_dataSet
!=
inData
);
if
(
dataChanged
&&
inData
)
{
// remove old texture
if
(
m_dataSetAtTime
)
{
WDataHandler
::
deregisterDataSet
(
m_dataSetAtTime
);
m_dataSetAtTime
=
boost
::
shared_ptr
<
WDataSetScalar
>
();
}
m_dataSet
=
inData
;
m_time
->
setMin
(
m_dataSet
->
getMinTime
()
);
m_time
->
setMax
(
m_dataSet
->
getMaxTime
()
);
m_time
->
ensureValidity
(
m_dataSet
->
getMinTime
()
);
}
if
(
m_dataSet
)
{
float
time
=
m_time
->
get
(
true
);
if
(
m_dataSetAtTime
)
{
WDataHandler
::
deregisterDataSet
(
m_dataSetAtTime
);
}
std
::
stringstream
s
;
s
<<
m_dataSet
->
getFileName
()
<<
"_time"
<<
time
;
boost
::
shared_ptr
<
WDataSetScalar
const
>
ds
=
m_dataSet
->
calcDataSetAtTime
(
time
,
s
.
str
()
);
m_dataSetAtTime
=
boost
::
shared_ptr
<
WDataSetScalar
>
(
new
WDataSetScalar
(
ds
->
getValueSet
(),
ds
->
getGrid
()
)
);
WDataHandler
::
registerDataSet
(
m_dataSetAtTime
);
}
}
}
src/modules/functionalMRIViewer/WMFunctionalMRIViewer.h
0 → 100644
View file @
39fd8419
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WMFUNCTIONALMRIVIEWER_H
#define WMFUNCTIONALMRIVIEWER_H
#include <string>
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
#include "../../kernel/WModuleOutputData.h"
#include "../../dataHandler/WDataSetTimeSeries.h"
/**
* Views a time series at different points in time.
*
* \class WMFunctionalMRIViewer
* \ingroup modules
*/
class
WMFunctionalMRIViewer
:
public
WModule
{
public:
/**
* Standard constructor.
*/
WMFunctionalMRIViewer
();
/**
* Standard destructor.
*/
virtual
~
WMFunctionalMRIViewer
();
/**
* Gives back the name of this module.
* \return the module's name.
*/
virtual
const
std
::
string
getName
()
const
;
/**
* Gives back a description of this module.
* \return description to module.
*/
virtual
const
std
::
string
getDescription
()
const
;
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
*
* \return the prototype used to create every module in OpenWalnut.
*/
virtual
boost
::
shared_ptr
<
WModule
>
factory
()
const
;
/**
* Get the icon for this module in XPM format.
*/
virtual
const
char
**
getXPMIcon
()
const
;
protected:
/**
* Entry point after loading the module. Runs in separate thread.
*/
virtual
void
moduleMain
();
/**
* Initialize the connectors this module is using.
*/
virtual
void
connectors
();
/**
* Initialize the properties for this module.
*/
virtual
void
properties
();
private:
//! The current input.
boost
::
shared_ptr
<
WDataSetTimeSeries
>
m_dataSet
;
//! The dataset at the current time.
boost
::
shared_ptr
<
WDataSetScalar
>
m_dataSetAtTime
;
//! The input Connector for the SH data.
boost
::
shared_ptr
<
WModuleInputData
<
WDataSetTimeSeries
>
>
m_input
;
//! The current time.
WPropDouble
m_time
;
//! A condition for property changes.
boost
::
shared_ptr
<
WCondition
>
m_propCondition
;
};
#endif // WMFUNCTIONALMRIVIEWER_H
src/modules/modules-base.toolbox
View file @
39fd8419
...
...
@@ -6,6 +6,7 @@ ADD_SUBDIRECTORY( coordinateHUD )
ADD_SUBDIRECTORY( coordinateSystem )
ADD_SUBDIRECTORY( distanceMap )
ADD_SUBDIRECTORY( distanceMapIsosurface )
ADD_SUBDIRECTORY( functionalMRIViewer )
ADD_SUBDIRECTORY( gridRenderer )
ADD_SUBDIRECTORY( hud )
ADD_SUBDIRECTORY( isosurfaceRaytracer )
...
...
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