nsol  0.4.1
Nsol - Neuroscience Objects Library
nsol::DendriteCachedStats Class Reference

This class allows to compute stats for dendrites. More...

#include <DendriteCachedStats.h>

+ Inheritance diagram for nsol::DendriteCachedStats:
+ Collaboration diagram for nsol::DendriteCachedStats:

Public Member Functions

 DendriteCachedStats (TDendriteType dendriteType_=BASAL)
 
virtual NeuriteStatsstats (void)
 Returns object as NeuriteStats. More...
 
- Public Member Functions inherited from nsol::DendriteStats
 DendriteStats (TDendriteType dendriteType_=BASAL)
 
- Public Member Functions inherited from nsol::Dendrite
 Dendrite (TDendriteType dendriteType=BASAL)
 
TDendriteTypedendriteType (void)
 Get the type of neurite.
 
virtual NeuritePtr clone (void) const final
 
- Public Member Functions inherited from nsol::Neurite
 Neurite (TNeuriteType neuriteType=DENDRITE)
 Default constructor.
 
TNeuriteTypeneuriteType (void)
 Get the type of neurite.
 
NeuronMorphologyPtr morphology (void) const
 
NeuronMorphologyPtr morphology (NeuronMorphologyPtr morphology)
 
bool hasMorphology (void) const
 
NeuronMorphologySectionPtr firstSection (void) const
 
Sections sections (void) const
 
void computeBranchBifurcations (void)
 
unsigned int numBranches (void)
 
unsigned int numBifurcations (void)
 
bool operator== (Neurite &other)
 
bool operator!= (Neurite &other)
 
- Public Member Functions inherited from nsol::NeuriteStats
 NeuriteStats (TNeuriteType neuriteType=DENDRITE)
 Default constructor.
 
- Public Member Functions inherited from nsol::NeuriteCachedStats
 NeuriteCachedStats (TNeuriteType neuriteType=DENDRITE)
 Default constructor.
 
virtual ~NeuriteCachedStats (void)
 Default destructor.
 
virtual void setAndPropagateDirty (unsigned int id)
 Set dirty a cached stat and propagates dirty to parent neurite. More...
 
virtual void setAndPropagateDirty (void)
 Set dirty all cached stats and propagates dirty to parent neurite.
 
virtual void firstSection (NeuronMorphologySectionPtr section)
 Set dirty all cached stats and propagates dirty to parent neurite.
 
virtual float getStat (TNeuriteStat stat, TAggregation agg=TOTAL) const
 Returns the stat given if the cache is clean and if it is dirty then computes the stat and stores the value in the cache. More...
 
- Public Member Functions inherited from nsol::Cached<>
bool dirty (unsigned int id_) const
 
void setDirty (unsigned int id_)
 
void setDirty (void)
 
void cacheValue (const unsigned int id_, floatvalue_) const
 
float getValue (const unsigned int id_) const
 

Additional Inherited Members

- Public Types inherited from nsol::Dendrite
enum  TDendriteType { BASAL = 0, APICAL }
 Type of dendrite.
 
typedef enum nsol::Dendrite::TDendriteType TDendriteType
 Type of dendrite.
 
- Public Types inherited from nsol::Neurite
enum  TNeuriteType { DENDRITE = 0, AXON }
 Possible types of neurite.
 
- Public Types inherited from nsol::NeuriteStats
enum  TNeuriteStat {
  SURFACE = 0, VOLUME, LENGTH, BIFURCATIONS,
  NEURITE_NUM_STATS
}
 Enumeration of the stats that can be computed for Neurite.
 
- Protected Member Functions inherited from nsol::Neurite
void _addBifurcationCount (unsigned int numBifurcations)
 
void _addBranchCount (unsigned int numBranches)
 
void _clone (NeuritePtr neurite) const
 
- Protected Attributes inherited from nsol::Dendrite
TDendriteType _dendriteType
 Type of dendrite.
 
- Protected Attributes inherited from nsol::Neurite
TNeuriteType _neuriteType
 
NeuronMorphologySectionPtr _firstSection
 
NeuronMorphologyPtr _morphology
 
unsigned int _numBranches
 
unsigned int _numBifurcations
 
- Protected Attributes inherited from nsol::Cached<>
std::map< unsigned int, float > _values
 Container of the cached values. Is mutable to allow const methods to modify the cache if needed.
 

Detailed Description

This class allows to compute stats for dendrites.

Using this class instead of Dendrite when constructing the hierarchy allows to call the method stats from base Dendrite class and get the corresponding volume, surface and length.

Example:

/*
* Copyright (c) 2014-2017 GMRV/URJC.
*
* This file is part of nsol <https://github.com/gmrvvis/nsol>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library 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 this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
/*
* Example to show how to use stats and cached stats
*/
#include <nsol/nsol.h>
void ComputeAndPrintSurface( nsol::NeuronPtr n )
{
unsigned int i = 0;
for ( const auto& neurite : n->morphology( )->neurites( ))
{
std::cout << "\tDendrite " << i++ << " type: "
<< neurite->neuriteType( ) << " ";
if ( neurite->neuriteType( ) == nsol::Neurite::DENDRITE )
std::cout << NSOL_DYNAMIC_CAST( nsol::Dendrite, neurite )->dendriteType( );
std::cout << " surface: ";
if ( neurite->stats( ))
{
std::cout << " " << neurite->stats( )->getStat(
nsol::NeuriteStats::SURFACE ) << " ";
const nsol::Sections& sections = neurite->sections( );
std::cout << "[ ";
for ( const auto& section : sections )
{
std::cout << dynamic_cast< nsol::NeuronMorphologySectionPtr >(
section )->stats( )->getStat(
nsol::NeuronMorphologySectionStats::/*TSectionStat::*/SURFACE ) << " ";
}
std::cout << "]";
}
else
std::cout << "No stats available";
std::cout << std::endl;
}
}
void PrintCachedSurfaceState( nsol::NeuronPtr n )
{
unsigned int i = 0;
for ( const auto& neurite : n->morphology( )->neurites( ))
{
std::cout << "\tDendrite " << i++ << " type: "
<< neurite->neuriteType( ) << " ";
if ( neurite->neuriteType( ) == nsol::Neurite::DENDRITE )
std::cout << NSOL_DYNAMIC_CAST( nsol::Dendrite, ( neurite ))
std::cout << " surface: ";
if ( neurite->stats( ))
{
nsol::Cached<> * cached =
NSOL_DYNAMIC_CAST( nsol::Cached<>, neurite->stats( ));
if ( cached )
std::cout << ( !cached->dirty( nsol::NeuriteCachedStats::SURFACE )
? "C" : "D" );
nsol::Sections sections = neurite->sections( );
std::cout << " [ ";
for ( const auto& section : sections )
{
cached =
NSOL_DYNAMIC_CAST(
nsol::Cached<>, dynamic_cast< nsol::NeuronMorphologySectionPtr >(
section )->stats( ));
if ( cached )
std::cout <<
( ! cached->dirty(
nsol::NeuronMorphologySectionCachedStats::SURFACE )
? "C " : "D " );
}
std::cout << "]";
}
else
std::cout << "No stats available";
std::cout << std::endl;
}
}
int main ( int argc, char ** argv )
{
std::cout << std::endl;
if ( argc < 2 )
{
std::cerr << "Error. Usage: " << argv[0]
<< " swc_input_file" << std::endl;
return -1;
}
std::cout << "Reading neuron without stats" << std::endl;
nsol::SwcReader readerWithoutStats;
nsol::NeuronPtr neuron = readerWithoutStats.readNeuron( argv[1] );
std::cout << "Reading neuron with stats" << std::endl;
nsol::SwcReaderStats readerWithStats;
nsol::NeuronPtr neuronWithStats = readerWithStats.readNeuron( argv[1] );
std::cout << "Reading neuron with cached stats" << std::endl;
nsol::SwcReaderCachedStats readerWithCachedStats;
nsol::NeuronPtr neuronWithCachedStats =
readerWithCachedStats.readNeuron( argv[1] );
if ( ! neuron || ! neuronWithStats || ! neuronWithCachedStats )
{
std::cerr << "Could not read neurons" << std::endl;
return -1;
}
std::cout << std::endl;
std::cout << "Compute and print neuron stats when not available" << std::endl;
ComputeAndPrintSurface( neuron );
std::cout << std::endl;
std::cout << "Compute and print neuron stats when not cacheable" << std::endl;
ComputeAndPrintSurface( neuronWithStats );
std::cout << std::endl;
std::cout << "Print cached stats" << std::endl;
PrintCachedSurfaceState( neuronWithCachedStats );
std::cout << std::endl;
std::cout << "Compute and print cacheable stats" << std::endl;
ComputeAndPrintSurface( neuronWithCachedStats );
std::cout << std::endl;
std::cout << "Print cached stats" << std::endl;
PrintCachedSurfaceState( neuronWithCachedStats );
std::cout << std::endl;
PrintCachedSurfaceState( neuronWithCachedStats );
std::cout << std::endl;
ComputeAndPrintSurface( neuronWithCachedStats );
std::cout << std::endl;
PrintCachedSurfaceState( neuronWithCachedStats );
std::cout << std::endl;
return 0;
}

Definition at line 40 of file DendriteCachedStats.h.

Member Function Documentation

virtual NeuriteStats* nsol::DendriteCachedStats::stats ( void  )
inlinevirtual

Returns object as NeuriteStats.

Returns
pointer to NeuriteStats object

Reimplemented from nsol::NeuriteStats.

Definition at line 51 of file DendriteCachedStats.h.


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