From fe0c75394f642a4e30cea5981c5f9e82206cbe8e Mon Sep 17 00:00:00 2001 From: pranathivemuri Date: Fri, 11 Mar 2016 14:13:24 -0600 Subject: [PATCH] added functions to find average segment length, tortuoisity in a network --- stim/biomodels/network.h | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+), 0 deletions(-) diff --git a/stim/biomodels/network.h b/stim/biomodels/network.h index 29f4fe5..d24a81b 100644 --- a/stim/biomodels/network.h +++ b/stim/biomodels/network.h @@ -90,6 +90,7 @@ class network{ return ss.str(); } + }; protected: @@ -109,6 +110,72 @@ public: return V.size(); } + std::vector operator*(T s){ + for (unsigned i=0; i< vertices; i ++ ){ + V[i] = V[i] * s; + } + return V; + } + + std::vector operator*(vec s){ + for (unsigned i=0; i< vertices; i ++ ){ + for (unsigned dim = 0 ; dim< 3; dim ++){ + V[i][dim] = V[i][dim] * s[dim]; + } + } + return V; + } + + // Returns an average of fiber/edge lengths in the network + double Lengths(){ + stim::vec L;double sumLength = 0; + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network + L.push_back(E[e].length()); //append the edge length + sumLength = sumLength + E[e].length(); + } + double avg = sumLength / E.size(); + return avg; + } + + + // Returns an average of tortuosities in the network + double Tortuosities(){ + stim::vec t; + stim::vec id1, id2; // starting and ending vertices of the edge + //std::vector< stim::vec > vert; // list of visited vertices + //std::vector>::iterator it; //create an iterator for searching the id2vert array + //std::vector daughters; // to count number of daughter vessels at branch points + //stim::vec visitedVert; + //unsigned visited; + double distance;double tortuosity;double sumTortuosity = 0; + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network + id1 = E[e][0]; //get the edge starting point + id2 = E[e][E[e].size() - 1]; //get the edge ending point + distance = (id1 - id2).len(); //displacement between the starting and ending points + //it = find(vert.begin(), vert.end(), id1); //look for the first node has a daughter vessel already + //visitedVert = std::distance(vert.begin(), it); //index where it already exists + //if(visitedVert == id1){ + // visited += 1; + // daughters[e] = visited; + //} + //else{ + // vert.push_back(id1); + // daughters[e] = 1; + //} + if(distance > 0){ + tortuosity = E[e].length()/ distance ; // tortuoisty = edge length / edge displacement + } + else{ + tortuosity = 0;} + t.push_back(tortuosity); + sumTortuosity += tortuosity; + } + double avg = sumTortuosity / E.size(); + //std::cout<<"number of unique branch points"< get_cylinder(unsigned f){ return E[f]; //return the specified edge (casting it to a fiber) } -- libgit2 0.21.4