29 #include "core/common/WAssert.h"
30 #include "core/common/WIOTools.h"
31 #include "core/common/WPropertyHelper.h"
32 #include "core/dataHandler/exceptions/WDHException.h"
33 #include "core/dataHandler/WDataHandler.h"
34 #include "core/dataHandler/WDataSet.h"
35 #include "core/dataHandler/WDataSetScalar.h"
36 #include "core/dataHandler/WDataSetSingle.h"
37 #include "core/dataHandler/WDataSetTimeSeries.h"
38 #include "core/dataHandler/WDataSetVector.h"
39 #include "core/dataHandler/WDataTexture3D.h"
40 #include "core/dataHandler/WEEG2.h"
41 #include "core/dataHandler/WSubject.h"
42 #include "core/graphicsEngine/WGEColormapping.h"
43 #include "core/kernel/WDataModuleInputFile.h"
44 #include "core/kernel/WDataModuleInputFilterFile.h"
45 #include "core/kernel/WModuleOutputData.h"
47 #ifdef WBIOSIG_ENABLED
48 #include "io/WReaderBiosig.h"
50 #include "io/WReaderClustering.h"
51 #include "io/WReaderCSV.h"
52 #include "io/WReaderEEGASCII.h"
53 #include "io/WReaderELC.h"
54 #include "io/WReaderFiberVTK.h"
56 #include "io/WReaderLibeep.h"
57 #include "io/WPagerEEGLibeep.h"
59 #include "io/WReaderNIfTI.h"
60 #include "io/WReaderVTK.h"
69 m_transformNoMatrix( 4, 4 ),
70 m_transformSForm( 4, 4 ),
71 m_transformQForm( 4, 4 )
83 return std::shared_ptr< WModule >(
new WMData() );
98 return "This module encapsulates data.";
103 std::vector< WDataModuleInputFilter::ConstSPtr > filters;
109 #ifdef WBIOSIG_ENABLED
124 shared_from_this(),
"out",
"A loaded dataset." )
179 m_output->updateData( std::shared_ptr< WDataSet >() );
229 switch( ( *dss ).getValueSet()->getDataType() )
235 result =
"binary (1 bit)";
237 case W_DT_UNSIGNED_CHAR:
238 result =
"unsigned char (8 bits)";
240 case W_DT_SIGNED_SHORT:
241 result =
"signed short (16 bits)";
243 case W_DT_SIGNED_INT:
244 result =
"signed int (32 bits)";
247 result =
"float (32 bits)";
253 result =
"double (64 bits)";
256 result =
"RGB triple (24 bits)";
259 result =
"ALL (not very useful)";
262 result =
"signed char (8 bits)";
265 result =
"unsigned short (16 bits)";
268 result =
"unsigned int (32 bits)";
274 result =
"unsigned long long (64 bits)";
277 result =
"float (128 bits)";
279 case W_DT_COMPLEX128:
280 result =
"double pair (128 bits)";
282 case W_DT_COMPLEX256:
283 result =
" long double pair (256 bits)";
286 result =
"4 byte RGBA (32 bits)";
289 WAssert(
false,
"Unknow data type in getDataTypeString" );
302 for(
size_t i = 0; i < 4; ++i )
304 for(
size_t j = 0; j < 4; ++j )
306 result( i, j ) = matrix( i, j );
316 if( std::dynamic_pointer_cast< WDataSetSingle >(
m_dataSet ) )
318 debugLog() <<
"Matrix mode update.";
321 std::shared_ptr< WGrid > newGrid;
322 std::shared_ptr< WGridRegular3D > oldGrid = std::dynamic_pointer_cast< WGridRegular3D >(
m_dataSetAsSingle->getGrid() );
327 newGrid = std::shared_ptr< WGrid >(
new WGridRegular3D( oldGrid->getNbCoordsX(), oldGrid->getNbCoordsY(), oldGrid->getNbCoordsZ(),
331 newGrid = std::shared_ptr< WGrid >(
new WGridRegular3D( oldGrid->getNbCoordsX(), oldGrid->getNbCoordsY(), oldGrid->getNbCoordsZ(),
335 newGrid = std::shared_ptr< WGrid >(
new WGridRegular3D( oldGrid->getNbCoordsX(), oldGrid->getNbCoordsY(), oldGrid->getNbCoordsZ(),
375 std::shared_ptr< WProperties > result(
new WProperties(
"Transformations",
"Availabe transformation matrices for data-set " ) );
376 WPropGroup transformation = result->addPropertyGroup(
"Transformation",
377 "The transformation of this grid." );
378 WPropMatrix4X4 noMatrixTransformation = result->addProperty(
"No matrix transformation",
379 "The no matrix transformation for this data set.",
381 WPropMatrix4X4 sformMatrixTransformation = result->addProperty(
"sform matrix transformation",
382 "The sform matrix transformation for this data set.",
384 WPropMatrix4X4 qformMatrixTransformation = result->addProperty(
"qform matrix transformation",
385 "The qform matrix transformation for this data set.",
404 if( dataSet->isTexture() )
410 m_properties->addProperty( dataSet->getTexture()->getProperties() );
411 m_infoProperties->addProperty( dataSet->getTexture()->getInformationProperties() );
455 std::string fileName = inputFile->getFilename().string();
457 std::shared_ptr< WProgress > progress1(
new WProgress(
"Loading" ) );
464 debugLog() <<
"Loading data from \"" << fileName <<
"\".";
468 std::string suffix = getSuffix( fileName );
469 if( suffix ==
".nii" || ( suffix ==
".gz" && ::nifti_compiled_with_zlib() ) )
471 if( suffix ==
".gz" )
473 boost::filesystem::path p( fileName );
474 p.replace_extension(
"" );
476 if( boost::filesystem::exists( p ) && !boost::filesystem::is_directory( p ) )
478 warnLog() <<
"Loading file " << fileName <<
" and a file with the name " << p <<
479 " was found. This may lead to problems loading the data due to an issue with the niftiio-lib.";
482 suffix = getSuffix( p.string() );
483 WAssert( suffix ==
".nii",
"Currently only nii files may be gzipped." );
494 std::shared_ptr< WDataSetSingle > dss = std::dynamic_pointer_cast< WDataSetSingle >(
m_dataSet );
498 if( dss->isTexture() )
500 switch( ( *dss ).getValueSet()->getDataType() )
502 case W_DT_UNSIGNED_CHAR:
506 case W_DT_SIGNED_INT:
507 m_dataSet->getTexture()->colormap()->set(
513 if( std::dynamic_pointer_cast< WDataSetVector >(
m_dataSet ) )
515 m_dataSet->getTexture()->colormap()->set(
518 m_dataSet->getTexture()->interpolation()->set(
false );
522 m_dataSet->getTexture()->colormap()->set(
528 WAssert(
false,
"Could not load \"" + fileName +
"\". Reason: unknown data type in Data module" );
533 #ifdef WBIOSIG_ENABLED
534 else if( suffix ==
".edf" )
536 WReaderBiosig biosigLoader( fileName );
540 else if( suffix ==
".asc" )
546 else if( suffix ==
".cnt" )
548 std::shared_ptr< WPagerEEG > pager(
new WPagerEEGLibeep( fileName ) );
550 std::string elcFileName = fileName;
551 elcFileName.resize( elcFileName.size() - 3 );
552 elcFileName +=
"elc";
554 std::shared_ptr< WEEGPositionsLibrary > eegPositionsLibrary = elcReader.
read();
556 m_dataSet = std::shared_ptr< WEEG2 >(
new WEEG2( pager, eegPositionsLibrary ) );
559 else if( suffix ==
".fib" )
564 else if( suffix ==
".fdg" )
569 else if( suffix ==
".vtk" )
574 else if( suffix ==
".csv" )
581 throw WDHException( std::string(
"Could not load \"" + fileName +
"\". Reason: unknown file type: \"" + suffix +
"\"" ) );
586 throw WDHException( std::string(
"Could not load \"" + fileName +
"\". Possibly format not supported." ) );
virtual void wait() const
Wait for the condition.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
virtual void notify()
Notifies all waiting threads.
Class to encapsulate boost::condition_variable_any.
General purpose exception and therefore base class for all DataHandler related exceptions.
Base for all data loader modules.
bool getSuppressColormaps() const
Checks whether suppression of colormaps is active.
std::shared_ptr< WDataSet > SPtr
Shared pointer abbreviation to a instance of this class.
Class which contains EEG recording data, read from a WPagerEEG.
static void registerTexture(osg::ref_ptr< WGETexture3D > texture, std::string name="")
Register the specified texture to the colormapper.
static void deregisterTexture(osg::ref_ptr< WGETexture3D > texture)
De-register the specified texture to the colormapper.
A grid that has parallelepiped cells which all have the same proportion.
A class containing a list of named items.
std::vector< size_t > IndexList
The type used for storing index lists.
virtual void properties()
Initialize properties in this function.
std::shared_ptr< WDataSet > m_oldDataSet
Keep track of the old dataset.
void load()
Do the loading.
osg::ref_ptr< WDataTexture3D > m_oldColormap
Keep track of registered colormaps.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
void updateColorMap(std::shared_ptr< WDataSet > dataSet)
Add the colormapping.
std::shared_ptr< WItemSelection > m_matrixSelectionsList
A list of color map selection types.
WPropSelection m_matrixSelection
Selection property for color map.
virtual std::vector< WDataModuleInputFilter::ConstSPtr > getInputFilter() const
Define a list of file filters we support.
std::shared_ptr< WProperties > getTransformationProperties() const
Returns info property group with the three availabe transformation matrixes.
WMatrix< double > m_transformQForm
a standard transform (should be an identity transform)
void propertyChanged(std::shared_ptr< WPropertyBase > property)
Called whenever a property changes.
WMatrix< double > m_transformSForm
a standard transform (should be an identity transform)
WDataSetSingle::SPtr m_dataSetAsSingle
As single.
virtual void connectors()
Initialize connectors in this function.
virtual void handleInputChange()
Handle a newly set input.
WPropString m_dataName
The name of the dataset.
virtual const std::string getDescription() const
Gives back a description of this module.
std::shared_ptr< WModuleOutputData< WDataSet > > m_output
The only output of this data module.
std::string getDataTypeString(std::shared_ptr< WDataSetSingle > dss)
Get a string for the datatype of the given dataset.
WMatrix< double > m_transformNoMatrix
a standard transform (should be an identity transform)
WMData()
Default constructor.
std::shared_ptr< WCondition > m_propCondition
a condition for the matrix selection
bool m_isTexture
Indicates whether the loaded dataSet will be available as texture.
virtual ~WMData()
Destructor.
bool m_reload
True if the load function needs to be called.
virtual const std::string getName() const
Gives back the name of this module.
std::shared_ptr< WDataSet > m_dataSet
The associated dataset.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
virtual void moduleMain()
void matrixUpdate()
Update matrix.
WPropString m_dataType
The basic type of data used in this data set (e.g.
WPropString m_dataSetType
The name of the dataset type created from the data (e.g.
size_t getNbRows() const
Get number of rows.
size_t getNbCols() const
Get number of columns.
WMatrix & makeIdentity()
Makes the matrix contain the identity matrix, i.e.
Class offering an instantiate-able data connection between modules.
virtual void properties()
Initialize properties in this function.
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
void addConnector(std::shared_ptr< WModuleInputConnector > con)
Adds the specified connector to the list of inputs.
wlog::WStreamedLogger warnLog() const
Logger instance for comfortable warning- logs.
std::shared_ptr< WProperties > m_properties
The property object for the module.
std::shared_ptr< WProperties > m_infoProperties
The property object for the module containing only module whose purpose is "PV_PURPOSE_INFORMNATION".
void ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
WPropBool m_active
True whenever the module should be active.
WPropString m_runtimeName
This property holds a user specified name for the current module instance.
std::shared_ptr< WProgressCombiner > m_progress
Progress indicator used as parent for all progress' of this module.
virtual void connectors()
Initialize connectors in this function.
void waitRestored()
This method waits for the module to be restored completely.
Class managing progress inside of modules.
boost::function< void(std::shared_ptr< WPropertyBase >)> PropertyChangeNotifierType
Signal signature emitted during set operations.
Class to manage properties of an object and to provide convenience methods for easy access and manipu...
Read content from a CSV file.
virtual std::shared_ptr< WDataSetCSV > read()
Read the file and create a dataset as a vector.
Reads a hierarchical clustering from a FDG file.
virtual std::shared_ptr< WDataSetHierarchicalClustering > read()
Reads the clustering file and creates a dataset out of it.
Reader for EEG data in ASCII fromat.
virtual std::shared_ptr< WDataSet > load()
Loads the dataset.
Read electrode positions from an ELC file.
std::shared_ptr< WEEGPositionsLibrary > read()
Read the file and create a dataset out of it.
Reads fibers from a VTK file.
virtual std::shared_ptr< WDataSetFibers > read()
Reads the fiber file and creates a dataset out of it.
Reader for the NIfTI file format.
WMatrix< double > getQFormTransform() const
Returns the QForm transformation stored in the nifti file's header.
WMatrix< double > getSFormTransform() const
Returns the SForm transformation stored in the nifti file's header.
WMatrix< double > getStandardTransform() const
Returns a standard transformation.
virtual std::shared_ptr< WDataSet > load(DataSetType dataSetType=W_DATASET_NONE)
Loads the dataset.
virtual std::shared_ptr< WDataSet > read()
Reads the data file and creates a dataset out of it.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.