aimsdata  5.1.2
Neuroimaging data handling
aims::AimsGraphReader Class Reference

Reader / postprocessor for graph reading. More...

#include <aims/io/aimsGraphR.h>

Inheritance diagram for aims::AimsGraphReader:
Collaboration diagram for aims::AimsGraphReader:

Classes

struct  ElementInfo
 
struct  ObjectWrapper
 
class  PostProcessor
 
struct  Wrapper
 

Public Member Functions

 AimsGraphReader (const std::string &filename)
 
virtual ~AimsGraphReader ()
 
virtual void readElements (Graph &g, int mask=1)
 Reads internal objects and stores them in the graph. More...
 
void setReadFilter (const std::set< std::string > &toread)
 Filters objects IDs in the graph file to be read as Aims objects. More...
 
void setExcludeFilter (const std::set< std::string > &toexclude)
 Filters objects IDs in the graph file to be read as Aims objects. More...
 
void setInsertionFunction (const std::string &objType, const std::string &dataType, ProcFunc procFunc)
 Registers a post-processing function. More...
 
- Public Member Functions inherited from aims::Process
 Process ()
 Attempts to read the header of filename and, if successful, calls the operator() of the process \process. More...
 
virtual ~Process ()
 
void registerProcessType (const std::string &objType, const std::string &dataType, ProcFunc procFunc)
 Registers the process to call on a given (object type, data type) couple (just fills the map) More...
 
bool execute (const std::string &filename)
 Executes the process on the object / data type found in the given file. More...
 
bool execute (Finder &f, const std::string &filename)
 Same as above but the header has already been read (or hand-made to fake it!) More...
 
const std::map< std::string, std::map< std::string, ProcFunc > > & processTypes () const
 Query registered process types. More...
 
void setReadOptions (carto::Object options)
 Set reading options. More...
 

Static Public Member Functions

template<class T >
static bool read (Process &, const std::string &, Finder &)
 Aims object reading function - called by the Process mechanism. More...
 
static void loadAllMissingElements (Graph &)
 convenient function to load everything that can be loaded. More...
 

Friends

struct internal::AimsGraphReader_Private
 

Additional Inherited Members

- Public Types inherited from aims::Process
typedef bool(* ProcFunc) (Process &, const std::string &, Finder &)
 Process function type. More...
 
- Protected Attributes inherited from aims::Process
std::map< std::string, std::map< std::string, ProcFunc > > _execs
 
carto::Object _options
 

Detailed Description

Reader / postprocessor for graph reading.

Reads Aims objects referred in the input graph and appropriately stores them in the graph vertices / edges

Definition at line 58 of file aimsGraphR.h.

Constructor & Destructor Documentation

◆ AimsGraphReader()

aims::AimsGraphReader::AimsGraphReader ( const std::string &  filename)

◆ ~AimsGraphReader()

virtual aims::AimsGraphReader::~AimsGraphReader ( )
virtual

Member Function Documentation

◆ loadAllMissingElements()

static void aims::AimsGraphReader::loadAllMissingElements ( Graph )
static

convenient function to load everything that can be loaded.

◆ read()

template<class T >
bool aims::AimsGraphReader::read ( Process p,
const std::string &  fname,
Finder f 
)
static

Aims object reading function - called by the Process mechanism.

By default only BucketMap<Void> and AimsSurfaceTriangle objects are read. If you need other types, use the registerProcessType function with appropriate types. In this case, you'll have to include <aims/io/aimsGraphR_d.h> to allow the template functions to be compiled on the new types.

You never need to call this function, but you shoud register its variant on new types by calling registerProcessType() and passing a pointer to it

Definition at line 106 of file aimsGraphR_d.h.

References carto::DataTypeCode< class >::dataType(), aims::Finder::dataType(), aims::AimsGraphReader::ElementInfo::object, carto::DataTypeCode< class >::objectType(), aims::Finder::objectType(), aims::Process::processTypes(), aims::Reader< T >::read(), and aims::Process::registerProcessType().

◆ readElements()

virtual void aims::AimsGraphReader::readElements ( Graph g,
int  mask = 1 
)
virtual

Reads internal objects and stores them in the graph.

Objects are stored by an insertion function that you can change by setInsertionFunction, the default function stores reference counting pointers to the Aims objects in graph elements attributes.

Some tables are stored in the graph to help finding the loaded objects in the graph elements. These tables are global graph attributes:

  • object_attributes_colors of type rc_ptr<map<string, vector<int> > > is only used in graphical applications (Anatomist...) and affects a color to an attribute (attributes in graph elements)

Another table describes how things are actually loaded and stored in the graph:

  • aims_objects_table of type rc_ptr<GraphElementTable> ( map<string,map<string,GraphElementCode> > ) gives the correspondance for each syntactic type of an identifier and a decriptor of Aims object. The identifier is made from the attribute name used in the graph elements and tries to be the same if the graph has been saved in "global objects mode" and in "local objects mode". To do so, any _filename or _label suffixes are removed from the attribute name as these are the suffixes used resp. in local and global saving mode

The mask parameter specifies which elements have to be read:

  • 0: none
  • 1: nodes
  • 2: relations
  • 3: both

◆ setExcludeFilter()

void aims::AimsGraphReader::setExcludeFilter ( const std::set< std::string > &  toexclude)

Filters objects IDs in the graph file to be read as Aims objects.

Objects listed here will NOT be read. setReadFilter and setExcludeFilter are mututally exclusive: when you use setExcludeFilter, read filters are erased and vice versa

◆ setInsertionFunction()

void aims::AimsGraphReader::setInsertionFunction ( const std::string &  objType,
const std::string &  dataType,
ProcFunc  procFunc 
)

Registers a post-processing function.

After loading an Aims object, it has to be inserted in the graph element (node, edge). The default behaviour is to insert a ref-counting pointer to it in the attribute like described in readElements() for the aims_objects_table graph attribute. If you need to do something else with the new objects, you can use your own function instead.

The registration procedure is exactly like the Process::registerProcessType mechanism: in fact we use a hidden Process (PostProcessor) to do so.

You can access current graph, graph element and data via the PostProcessor::elementInfo() structure

◆ setReadFilter()

void aims::AimsGraphReader::setReadFilter ( const std::set< std::string > &  toread)

Filters objects IDs in the graph file to be read as Aims objects.

Only objects listed here will be read. These IDs are those used in the aims_objects_table attribute (see readElements) ans correspond to attributes describing a file (in local objects mode) or an index in a global object, with the suffix "_filename" or "_index" removed. Ex: "ss" for "ss_filename" (in cortical folds graphs, local mode) or "roi" for "roi_label" (in ROI graphs, global mode).

setReadFilter and setExcludeFilter are mututally exclusive: when you use setReadFilter, exclusion filters are erased and vice versa

Friends And Related Function Documentation

◆ internal::AimsGraphReader_Private

friend struct internal::AimsGraphReader_Private
friend

Definition at line 61 of file aimsGraphR.h.


The documentation for this class was generated from the following files: