Brion  2.0.0
The Blue Brain C++ I/O library
brion::CompartmentReport Class Reference

Read & write access to a CompartmentReport. More...

#include <compartmentReport.h>

+ Inheritance diagram for brion::CompartmentReport:
+ Collaboration diagram for brion::CompartmentReport:

Public Member Functions

 ~CompartmentReport ()
 Close compartment report. More...
 
 CompartmentReport (const URI &uri, int mode, const GIDSet &gids=GIDSet())
 Open given URI to a compartment report for reading and/or writing. More...
 
Read API
void updateMapping (const GIDSet &gids)
 Update compartment mapping wrt the given GIDs. More...
 
const GIDSetgetGIDs () const
 
size_t getIndex (const uint32_t gid) const
 
const SectionOffsetsgetOffsets () const
 Get the current mapping of each section of each neuron in each simulation frame buffer. More...
 
const CompartmentCountsgetCompartmentCounts () const
 Get the number of compartments for each section of each neuron provided by the GID set via updateMapping(). More...
 
size_t getNumCompartments (size_t index) const
 Get the number of compartments for the given neuron. More...
 
double getStartTime () const
 
double getEndTime () const
 
double getTimestep () const
 
const std::string & getDataUnit () const
 
const std::string & getTimeUnit () const
 
size_t getFrameSize () const
 
std::future< floatsPtr > loadFrame (double timestamp) const
 Load report values at the given time stamp. More...
 
std::future< FramesloadFrames (double start, double end) const
 Load all frames inside a given time window. More...
 
size_t getNeuronSize (uint32_t gid) const
 
std::future< floatsPtr > loadNeuron (uint32_t gid) const
 Load report values for the given neuron. More...
 
void setBufferSize (const size_t size)
 Set the size of the stream buffer for loaded frames. More...
 
size_t getBufferSize () const
 
void clearBuffer ()
 Clears all buffered frames to free memory. More...
 
Write API
void writeHeader (double startTime, double endTime, double timestep, const std::string &dunit, const std::string &tunit)
 Write the header information of this report. More...
 
bool writeCompartments (uint32_t gid, const uint16_ts &counts)
 Write the compartment counts for each section for one cell. More...
 
bool writeFrame (uint32_t gid, const floats &values, double timestamp)
 Write the values for one cell at a point in time. More...
 
bool writeFrame (uint32_t gid, const float *values, size_t size, double timestamp)
 
bool flush ()
 Flush data to output. More...
 
bool erase ()
 Remove all data of the report from storage. More...
 

Static Public Member Functions

static std::string getDescriptions ()
 

Detailed Description

Read & write access to a CompartmentReport.

The supported types are binary (r), HDF5 (rw) and stream (rw) reports.

Following RAII, this class is ready to use after the creation and will ensure release of resources upon destruction.

Definition at line 44 of file brion/compartmentReport.h.

Constructor & Destructor Documentation

brion::CompartmentReport::~CompartmentReport ( )

Close compartment report.

Version
1.0
brion::CompartmentReport::CompartmentReport ( const URI &  uri,
int  mode,
const GIDSet gids = GIDSet() 
)

Open given URI to a compartment report for reading and/or writing.

Parameters
uriURI to compartment report. The report type is deduced from here.
modethe brion::AccessMode bitmask
gidsthe neurons of interest in READ_MODE
Exceptions
std::runtime_errorif compartment report could be opened for read or write, cannot be overwritten or it is not valid
Version
1.0

Member Function Documentation

void brion::CompartmentReport::clearBuffer ( )

Clears all buffered frames to free memory.

Version
1.0
bool brion::CompartmentReport::erase ( )

Remove all data of the report from storage.

May not be implemented by all backends, such as file-based reports.

Returns
true if data was removed.
Version
1.0
bool brion::CompartmentReport::flush ( )

Flush data to output.

Returns
true on success.
Version
1.0
size_t brion::CompartmentReport::getBufferSize ( ) const
Returns
the number of the simulation frame buffers.
Version
1.0
const CompartmentCounts& brion::CompartmentReport::getCompartmentCounts ( ) const

Get the number of compartments for each section of each neuron provided by the GID set via updateMapping().

The neuron index is derived from the order in the GID set provided by updateMapping().

Returns
the compartment counts for each section for each neuron
Version
1.0
const std::string& brion::CompartmentReport::getDataUnit ( ) const
Returns
the data unit of the report.
Version
1.0
static std::string brion::CompartmentReport::getDescriptions ( )
static
Returns
the descriptions of all loaded report backends.
Version
1.0
double brion::CompartmentReport::getEndTime ( ) const
Returns
the current end time of the report.
Version
1.0
size_t brion::CompartmentReport::getFrameSize ( ) const
Returns
the number of values of a loaded report frame.
Version
1.0
const GIDSet& brion::CompartmentReport::getGIDs ( ) const
Returns
the current considered GIDs.
Version
1.0
size_t brion::CompartmentReport::getIndex ( const uint32_t  gid) const
Returns
the index of the given gid.
Version
1.0
Exceptions
std::runtime_errorif the gid is not mapped
size_t brion::CompartmentReport::getNeuronSize ( uint32_t  gid) const
Parameters
gidthe neuron report to be loaded.
Returns
the number of values of the given neuron report.
Exceptions
std::runtime_errorif gid is not mapped.
Version
1.0
size_t brion::CompartmentReport::getNumCompartments ( size_t  index) const

Get the number of compartments for the given neuron.

The neuron index is derived from the order in the GID set provided by updateMapping().

Parameters
indexneuron index per current GID set
Returns
number of compartments for the given neuron
Version
1.0
const SectionOffsets& brion::CompartmentReport::getOffsets ( ) const

Get the current mapping of each section of each neuron in each simulation frame buffer.

For instance, getOffsets()[1][15] retrieves the lookup index for the frame buffer for section 15 of neuron with index 1. The neuron index is derived from the order in the GID set provided by updateMapping().

Returns
the offset for each section for each neuron
Version
1.0
double brion::CompartmentReport::getStartTime ( ) const
Returns
the current start time of the report.
Version
1.0
double brion::CompartmentReport::getTimestep ( ) const
Returns
the sampling time interval of the report.
Version
1.0
const std::string& brion::CompartmentReport::getTimeUnit ( ) const
Returns
the time unit of the report.
Version
1.0
std::future<floatsPtr> brion::CompartmentReport::loadFrame ( double  timestamp) const

Load report values at the given time stamp.

Parameters
timestampthe time stamp of interest
Returns
the report values if found at timestamp, nullptr otherwise
Note
Until the completion of this operation, the report shouldn't be modified
Version
2.0
std::future<Frames> brion::CompartmentReport::loadFrames ( double  start,
double  end 
) const

Load all frames inside a given time window.

The result will be empty if the window is invalid or falls outside the report window.

Parameters
startclose left side of the time interval
endopen right side of time interval
Returns
a future with the frames overlapped by the time window [start, end) and the start timestamps of these frames.
Version
2.0
std::future<floatsPtr> brion::CompartmentReport::loadNeuron ( uint32_t  gid) const

Load report values for the given neuron.

May not be implemented by all backends (e.g. HDF5).

Parameters
gidthe neuron identifier
Returns
the report values if neuron is found, nullptr otherwise
Note
Until the completion of this operation, the report shouldn't be modified
Version
2.0
void brion::CompartmentReport::setBufferSize ( const size_t  size)

Set the size of the stream buffer for loaded frames.

Configures the number of simulation frame buffers for stream readers. When the consumer is slower than the producer, the producer will block once these buffers are exhausted, otherwise the consumer will block on data availability. A minimum of 1 frame is buffered.

Parameters
sizethe new size of the frame buffer.
Version
1.0
void brion::CompartmentReport::updateMapping ( const GIDSet gids)

Update compartment mapping wrt the given GIDs.

Allows to change the GIDs in an open report without throwing away the already opened data, i.e., avoiding the overhead of always creating a new compartment report object when the desired GID set changes. An empty gids set loads all data from the report.

Parameters
gidsthe neurons of interest
Version
1.0
bool brion::CompartmentReport::writeCompartments ( uint32_t  gid,
const uint16_ts &  counts 
)

Write the compartment counts for each section for one cell.

This should only be called after writeHeader().

Parameters
gidthe GID of the cell
countsthe number of compartments per section
Returns
false if saving was not successful, true otherwise
Version
1.0
bool brion::CompartmentReport::writeFrame ( uint32_t  gid,
const floats &  values,
double  timestamp 
)
inline

Write the values for one cell at a point in time.

This should only be called after all the required mapping has been saved before.

Parameters
gidthe GID of the cell
valuesthe values per compartment to save
timestampthe timestamp in ms where for this values
Returns
false if saving was not successful, true otherwise
Version
1.0

Definition at line 242 of file brion/compartmentReport.h.

bool brion::CompartmentReport::writeFrame ( uint32_t  gid,
const float *  values,
size_t  size,
double  timestamp 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void brion::CompartmentReport::writeHeader ( double  startTime,
double  endTime,
double  timestep,
const std::string &  dunit,
const std::string &  tunit 
)

Write the header information of this report.

Parameters
startTimethe start time of the report
endTimethe end time of the report
timestepthe timestep between report frames
dunitthe unit of the data, e.g. mV
tunitthe unit of the time, e.g. ms
Exceptions
std::invalid_argumentif any passed argument is invalid
Version
1.0

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