This class allows to compute stats for sections.
#include <nsol/nsol.h>
#ifdef Win32
#include < time.h >
#include <windows.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timezone
{
int tz_minuteswest;
int tz_dsttime;
};
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tmpres /= 10;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
long seconds;
_get_timezone( &seconds );
tz->tz_minuteswest = seconds / 60;
int hours;
_get_daylight( &hours );
tz->tz_dsttime = hours;
}
return 0;
}
#else
#include <sys/time.h>
#endif
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 with stats" << std::endl;
std::cout << "Reading neuron with cached stats" << std::endl;
if ( ! neuronWithStats || ! neuronWithCachedStats )
{
std::cerr << "Could not read neurons" << std::endl;
return -1;
}
std::cout << std::endl;
std::cout << "Non-cached stats" << std::endl;
printNeuronMorphologyStats( neuronWithStats->morphology( ));
std::cout << "Cached stats" << std::endl;
printNeuronMorphologyStats( neuronWithCachedStats->morphology( ));
struct timeval startTime, endTime;
long totalTime;
gettimeofday(&startTime, NULL);
for ( int i = 0; i < 10000; i++ )
computeNeuronMorphologyStats( neuronWithStats->morphology( ));
gettimeofday(&endTime, NULL);
totalTime = (endTime.tv_sec - startTime.tv_sec) * 1000000L;
totalTime += (endTime.tv_usec - startTime.tv_usec);
std::cout << "Compute non-cached stats 1000 times. Time elapsed: "
<< (totalTime/1000L) / 1000.0f << std::endl;
gettimeofday(&startTime, NULL);
for ( int i = 0; i < 1000; i++ )
computeNeuronMorphologyStats( neuronWithCachedStats->morphology( ));
gettimeofday(&endTime, NULL);
totalTime = (endTime.tv_sec - startTime.tv_sec) * 1000000L;
totalTime += (endTime.tv_usec - startTime.tv_usec);
std::cout << "Compute cached stats 1000 times. Time elapsed: "
<< (totalTime/1000L) / 1000.0f << std::endl;
std::cout << std::endl;
return 0;
}
{
NSOL_DEBUG_CHECK( morphology , "morphology is null" );
NSOL_DEBUG_CHECK( morphology->stats( ) , "no stats" );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::DENDRITIC_VOLUME );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::AXON_VOLUME );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::NEURITIC_VOLUME );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::SOMA_VOLUME );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::VOLUME );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::DENDRITIC_SURFACE );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::AXON_SURFACE );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::NEURITIC_SURFACE );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::SOMA_SURFACE );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::SURFACE );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::DENDRITIC_LENGTH );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::AXON_LENGTH );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::NEURITIC_LENGTH
);
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::DENDRITIC_BIFURCATIONS );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::AXON_BIFURCATIONS );
morphology->stats( )->getStat(
nsol::NeuronMorphologyStats::NEURITIC_BIFURCATIONS );
}
{
NSOL_DEBUG_CHECK( morphology , "morphology is null" );
NSOL_DEBUG_CHECK( morphology->stats( ) , "no stats" );
#define NMS morphology->stats( )
std::cout << "\tDendritic surface:\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_SURFACE )
<< " "
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_SURFACE,
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_SURFACE,
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_SURFACE,
<< std::endl;
std::cout << "\tAxon surface:\t\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_SURFACE )
<< " "
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_SURFACE,
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_SURFACE,
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_SURFACE,
<< std::endl;
std::cout << "\tNeuritic surface:\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_SURFACE )
<< " "
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_SURFACE,
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_SURFACE,
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_SURFACE,
<< std::endl;
std::cout << "\tSoma surface:\t\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::SOMA_SURFACE )
<< std::endl;
std::cout << "\tSurface:\t\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::SURFACE )
<< std::endl;
std::cout << std::endl;
std::cout << "\tDendritic volume:\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_VOLUME )
<< " "
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_VOLUME,
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_VOLUME,
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_VOLUME,
<< std::endl;
std::cout << "\tAxon volume:\t\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_VOLUME )
<< " "
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_VOLUME,
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_VOLUME,
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_VOLUME,
<< std::endl;
std::cout << "\tNeuritic volume:\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_VOLUME )
<< " "
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_VOLUME,
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_VOLUME,
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_VOLUME,
<< std::endl;
std::cout << "\tSoma volume:\t\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::SOMA_VOLUME )
<< std::endl;
std::cout << "\tVolume:\t\t\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::VOLUME )
<< std::endl;
std::cout << std::endl;
std::cout << "\tDendritic length:\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_LENGTH )
<< " "
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_LENGTH,
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_LENGTH,
<< NMS->getStat( nsol::NeuronMorphologyStats::DENDRITIC_LENGTH,
<< std::endl;
std::cout << "\tAxon length:\t\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_LENGTH )
<< " "
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_LENGTH,
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_LENGTH,
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_LENGTH,
<< std::endl;
std::cout << "\tNeuritic length:\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_LENGTH )
<< " "
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_LENGTH,
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_LENGTH,
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_LENGTH,
<< std::endl;
std::cout << std::endl;
std::cout << "\tDendritic bifurcations:\t"
<< NMS->getStat(
nsol::NeuronMorphologyStats::DENDRITIC_BIFURCATIONS )
<< " "
<< NMS->getStat(
nsol::NeuronMorphologyStats::DENDRITIC_BIFURCATIONS,
<< NMS->getStat(
nsol::NeuronMorphologyStats::DENDRITIC_BIFURCATIONS,
<< NMS->getStat(
nsol::NeuronMorphologyStats::DENDRITIC_BIFURCATIONS,
<< std::endl;
std::cout << "\tAxon bifurcations:\t"
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_BIFURCATIONS )
<< " "
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_BIFURCATIONS,
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_BIFURCATIONS,
<< NMS->getStat( nsol::NeuronMorphologyStats::AXON_BIFURCATIONS,
<< std::endl;
std::cout << "\tNeuritic bifurcations:\t"
<< NMS->getStat(
nsol::NeuronMorphologyStats::NEURITIC_BIFURCATIONS )
<< " "
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_BIFURCATIONS,
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_BIFURCATIONS,
<< NMS->getStat( nsol::NeuronMorphologyStats::NEURITIC_BIFURCATIONS,
<< std::endl;
std::cout << std::endl;
}