MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
NeuroNode.cpp File Reference
#include "header.h"
#include "SparseMatrix.h"
#include "Boundary.h"
#include "MeshEntry.h"
#include "VoxelJunction.h"
#include "ChemCompt.h"
#include "MeshCompt.h"
#include "CubeMesh.h"
#include "../utility/Vec.h"
#include "../utility/strutil.h"
#include "CylBase.h"
#include "NeuroNode.h"
+ Include dependency graph for NeuroNode.cpp:

Go to the source code of this file.

Functions

static bool checkForSpine (unsigned int dendIndex, Id compt, vector< Id > &shaftId, vector< Id > &headId, vector< unsigned int > &spineParent)
 
void diagnoseTree (const vector< NeuroNode > &tree, const vector< NeuroNode > &nodes)
 
static vector< IdfindAllConnectedCompartments (Id compt)
 
bool isPartOfDend (ObjId i)
 
void reassignNodeIndices (vector< NeuroNode > &temp, const vector< unsigned int > &nodeToTempMap)
 
static void sortByShaftIds (vector< Id > &shaftId, vector< Id > &headId, vector< unsigned int > &spineParent)
 
static void spinyTraverse (unsigned int dendIndex, vector< Id > &dend, const unordered_map< Id, unsigned int > &dendMap, vector< int > &seen, unsigned int numSeen, vector< Id > &shaftId, vector< Id > &headId, vector< int > &dendParent, vector< unsigned int > &spineParent)
 

Function Documentation

static bool checkForSpine ( unsigned int  dendIndex,
Id  compt,
vector< Id > &  shaftId,
vector< Id > &  headId,
vector< unsigned int > &  spineParent 
)
static

Definition at line 391 of file NeuroNode.cpp.

References Id::element(), findAllConnectedCompartments(), Element::getName(), and name.

Referenced by spinyTraverse().

394 {
395  const string& name = compt.element()->getName();
396  if ( name.find( "shaft" ) != string::npos ||
397  name.find( "neck" ) != string::npos ) {
398  spineParent.push_back( dendIndex );
399  shaftId.push_back( compt );
400  vector< Id > conn = findAllConnectedCompartments( compt );
401  bool foundHead = false;
402  for ( vector< Id >::iterator i =
403  conn.begin(); i != conn.end(); ++i ) {
404  const string& n2 = i->element()->getName();
405  if ( n2.find( "spine" ) != string::npos ||
406  n2.find( "head" ) != string::npos ) {
407  headId.push_back( *i );
408  foundHead = true;
409  break;
410  }
411  }
412  if (!foundHead) {
413  headId.push_back( Id() );
414  }
415  return true;
416  }
417  return false;
418 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
static char name[]
Definition: mfield.cpp:401
Definition: Id.h:17
static vector< Id > findAllConnectedCompartments(Id compt)
Definition: NeuroNode.cpp:151
const string & getName() const
Definition: Element.cpp:56

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void diagnoseTree ( const vector< NeuroNode > &  tree,
const vector< NeuroNode > &  nodes 
)

static func

Definition at line 298 of file NeuroNode.cpp.

References Id::path().

Referenced by NeuroNode::traverse().

300 {
301  map< Id , const NeuroNode* > m;
302  for ( vector< NeuroNode >::const_iterator
303  i = tree.begin(); i != tree.end(); ++i ) {
304  m[ i->elecCompt() ] = &( *i );
305  }
306  unsigned int j = 0;
307  for ( vector< NeuroNode >::const_iterator
308  i = nodes.begin(); i != nodes.end(); ++i ) {
309  if ( m.find( i->elecCompt() ) == m.end() ) {
310  Id pa;
311  if ( i->parent() != ~0U && i->parent() < nodes.size() )
312  pa = nodes[ i->parent() ].elecCompt();
313  cout << "diagnoseTree:" << j++ << " " << i->elecCompt().path() <<
314  ", pa = " << i->parent() << ", " << pa.path() << endl;
315  }
316  }
317 }
std::string path(const std::string &separator="/") const
Definition: Id.cpp:76
Definition: Id.h:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static vector< Id > findAllConnectedCompartments ( Id  compt)
static

Finds all the compartments connected to current node, put them all into the return vector even if they may be 'parent' by the messaging. This is because this function has to be robust enough to sort this out

Definition at line 151 of file NeuroNode.cpp.

References axialOut, Element::cinfo(), cylinderOut(), distalOut(), Id::element(), Cinfo::find(), Cinfo::findFinfo(), Element::getNeighbors(), Cinfo::isA(), proximalOut(), raxialOut, and sumRaxialOut().

Referenced by checkForSpine(), NeuroNode::findConnectedCompartments(), and spinyTraverse().

152 {
153  static const Finfo* axialOut = Cinfo::find( "CompartmentBase" )->findFinfo( "axialOut" );
154  static const Finfo* raxialOut = Cinfo::find( "CompartmentBase" )->findFinfo( "raxialOut" );
155  static const Finfo* distalOut = Cinfo::find( "SymCompartment" )->findFinfo( "distalOut" );
156  static const Finfo* proximalOut = Cinfo::find( "SymCompartment" )->findFinfo( "proximalOut" );
157  static const Finfo* cylinderOut = Cinfo::find( "SymCompartment" )->findFinfo( "cylinderOut" );
158  static const Finfo* sumRaxialOut = Cinfo::find( "SymCompartment" )->findFinfo( "sumRaxialOut" );
159  assert( axialOut );
160  assert( raxialOut );
161  assert( distalOut );
162  assert( proximalOut );
163  assert( cylinderOut );
164  assert( sumRaxialOut );
165 
166  const Cinfo* cinfo = compt.element()->cinfo();
167  vector< Id > all;
168  if ( cinfo->isA( "SymCompartment" ) ) { // Check derived first.
169  vector< Id > ret;
170  compt.element()->getNeighbors( ret, distalOut );
171  all.insert( all.end(), ret.begin(), ret.end() );
172  compt.element()->getNeighbors( ret, proximalOut );
173  all.insert( all.end(), ret.begin(), ret.end() );
174  compt.element()->getNeighbors( ret, cylinderOut );
175  all.insert( all.end(), ret.begin(), ret.end() );
176  compt.element()->getNeighbors( ret, sumRaxialOut );
177  all.insert( all.end(), ret.begin(), ret.end() );
178  }
179  // In addition, check if the bog standard messaging applies.
180  assert( cinfo->isA( "CompartmentBase" ) );
181  vector< Id > ret;
182  compt.element()->getNeighbors( ret, axialOut );
183  all.insert( all.end(), ret.begin(), ret.end() );
184  compt.element()->getNeighbors( ret, raxialOut );
185  all.insert( all.end(), ret.begin(), ret.end() );
186 
187  sort( all.begin(), all.end() );
188  all.erase( unique( all.begin(), all.end() ), all.end() ); //@#$%&* C++
189  // Now we have a list of all compartments connected to the current one.
190  return all;
191 }
static SrcFinfo2< double, double > * cylinderOut()
static SrcFinfo2< double, double > * proximalOut()
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
static const Cinfo * find(const std::string &name)
Definition: Cinfo.cpp:200
const SrcFinfo2< double, double > * raxialOut
Definition: Compartment.cpp:66
bool isA(const string &ancestor) const
Definition: Cinfo.cpp:280
const Cinfo * cinfo() const
Definition: Element.cpp:66
static SrcFinfo2< double, double > * distalOut()
unsigned int getNeighbors(vector< Id > &ret, const Finfo *finfo) const
Definition: Element.cpp:949
const SrcFinfo1< double > * axialOut
Definition: Compartment.cpp:62
Definition: Cinfo.h:18
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
Definition: Finfo.h:12
static SrcFinfo1< double > * sumRaxialOut()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool isPartOfDend ( ObjId  i)

Definition at line 376 of file NeuroNode.cpp.

References Element::cinfo(), ObjId::element(), Element::getName(), Cinfo::isA(), and name.

Referenced by NeuroNode::buildSpinyTree().

377 {
378  if ( i.element()->cinfo()->isA( "CompartmentBase" ) ) {
379  string name = i.element()->getName();
380  if ( name.find( "shaft" ) == string::npos &&
381  name.find( "neck" ) == string::npos &&
382  name.find( "spine" ) == string::npos &&
383  name.find( "head" ) == string::npos )
384  {
385  return true;
386  }
387  }
388  return false;
389 }
bool isA(const string &ancestor) const
Definition: Cinfo.cpp:280
const Cinfo * cinfo() const
Definition: Element.cpp:66
Element * element() const
Definition: ObjId.cpp:124
static char name[]
Definition: mfield.cpp:401
const string & getName() const
Definition: Element.cpp:56

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void reassignNodeIndices ( vector< NeuroNode > &  temp,
const vector< unsigned int > &  nodeToTempMap 
)

Definition at line 591 of file NeuroNode.cpp.

Referenced by NeuroNode::filterSpines().

593 {
594  for ( vector< NeuroNode >::iterator
595  i = temp.begin(); i != temp.end(); ++i ) {
596  unsigned int pa = i->parent();
597  if ( pa != ~0U ) {
598  assert( nodeToTempMap[ pa ] != ~0U );
599  i->setParent( nodeToTempMap[ pa ] );
600  }
601 
602  vector< unsigned int > kids = i->children();
603  i->clearChildren();
604  for ( unsigned int j = 0; j < kids.size(); ++j ) {
605  unsigned int newKid = nodeToTempMap[ kids[j] ];
606  if ( newKid != ~0U ) // Some may be spine shafts, no longer here
607  i->addChild( newKid );
608  }
609  }
610 }

+ Here is the caller graph for this function:

static void sortByShaftIds ( vector< Id > &  shaftId,
vector< Id > &  headId,
vector< unsigned int > &  spineParent 
)
static

Definition at line 457 of file NeuroNode.cpp.

Referenced by NeuroNode::buildSpinyTree().

459 {
460  size_t sortedIndex(0);
461  vector<int> y(shaftId.size());
462  generate(begin(y), end(y), [&]{ return sortedIndex++; });
463  sort( begin(y), end(y),
464  [&](int i1, int i2) { return shaftId[i1] < shaftId[i2]; } );
465 
466  assert( sortedIndex == shaftId.size() );
467  assert( sortedIndex == headId.size() );
468  assert( sortedIndex == spineParent.size() );
469 
470  auto a = shaftId;
471  auto b = headId;
472  auto c = spineParent;
473  for ( size_t i = 0; i < sortedIndex; ++i) {
474  shaftId[i] = a[y[i]];
475  headId[i] = b[y[i]];
476  spineParent[i] = c[y[i]];
477  }
478 }

+ Here is the caller graph for this function:

static void spinyTraverse ( unsigned int  dendIndex,
vector< Id > &  dend,
const unordered_map< Id, unsigned int > &  dendMap,
vector< int > &  seen,
unsigned int  numSeen,
vector< Id > &  shaftId,
vector< Id > &  headId,
vector< int > &  dendParent,
vector< unsigned int > &  spineParent 
)
static

spinyTraverse goes takes current dend entry and finds everything connected to it, recursively. Paints the 'seen' entries with the latest index for the number seen so we keep track of which subgroup the dend set belongs to. This does a depth-first recursive traverse. Looks for spines on every dend compt found.

Definition at line 429 of file NeuroNode.cpp.

References checkForSpine(), and findAllConnectedCompartments().

Referenced by NeuroNode::buildSpinyTree().

435 {
436  vector< Id > conn = findAllConnectedCompartments( dend[dendIndex] );
437  seen[ dendIndex ] = numSeen;
438  for ( vector< Id >::iterator i = conn.begin(); i != conn.end(); ++i ) {
439  unordered_map< Id, unsigned int >::const_iterator idLookup =
440  dendMap.find( *i );
441  if ( idLookup != dendMap.end() ) {
442  if ( !seen[ idLookup->second ] ) {
443  dendParent[ idLookup->second ] = dendIndex;
444  spinyTraverse( idLookup->second, dend, dendMap,
445  seen, numSeen,
446  shaftId, headId, dendParent, spineParent );
447  }
448  } else {
449  checkForSpine( dendIndex, *i, shaftId, headId, spineParent );
450  }
451  }
452 }
static void spinyTraverse(unsigned int dendIndex, vector< Id > &dend, const unordered_map< Id, unsigned int > &dendMap, vector< int > &seen, unsigned int numSeen, vector< Id > &shaftId, vector< Id > &headId, vector< int > &dendParent, vector< unsigned int > &spineParent)
Definition: NeuroNode.cpp:429
static bool checkForSpine(unsigned int dendIndex, Id compt, vector< Id > &shaftId, vector< Id > &headId, vector< unsigned int > &spineParent)
Definition: NeuroNode.cpp:391
static vector< Id > findAllConnectedCompartments(Id compt)
Definition: NeuroNode.cpp:151

+ Here is the call graph for this function:

+ Here is the caller graph for this function: