37 #include "PropagationPropertiesCalculator.hpp"
38 #include "CellProperties.hpp"
41 #include "HeartEventHandler.hpp"
44 const std::string voltageName)
45 : mpDataReader(pDataReader),
46 mVoltageName(voltageName),
47 mTimes(mpDataReader->GetUnlimitedDimensionValues()),
78 unsigned globalNodeIndex)
80 if (percentage < 1.0 || percentage >= 100.0)
82 EXCEPTION(
"First argument of CalculateActionPotentialDuration() is expected to be a percentage");
90 unsigned globalNodeIndex,
99 const double percentage,
100 unsigned lowerNodeIndex,
101 unsigned upperNodeIndex,
104 std::vector<std::vector<double> > output_data;
105 output_data.reserve(upperNodeIndex-lowerNodeIndex+1);
106 unsigned num_nodes_per_data_block = 100;
107 unsigned num_complete_blocks = (upperNodeIndex-lowerNodeIndex) / num_nodes_per_data_block;
108 unsigned size_last_block = (upperNodeIndex-lowerNodeIndex) % num_nodes_per_data_block;
110 for (
unsigned block_num=0;
111 block_num<num_complete_blocks+1;
114 unsigned num_nodes_to_read;
115 if (block_num != num_complete_blocks)
117 num_nodes_to_read = num_nodes_per_data_block;
121 num_nodes_to_read = size_last_block;
124 if (num_nodes_to_read > 0)
127 unsigned low_node = lowerNodeIndex + block_num*num_nodes_per_data_block;
128 unsigned high_node = low_node + num_nodes_to_read;
131 for (
unsigned node_within_block=0;
132 node_within_block < num_nodes_to_read;
135 std::vector<double>& r_voltages = voltages[node_within_block];
137 std::vector<double> apds;
141 assert(apds.size() != 0);
146 e.
GetShortMessage()==
"AP did not occur, never exceeded threshold voltage.");
148 assert(apds.size() == 1);
150 output_data.push_back(apds);
160 double max = -DBL_MAX;
161 for (
unsigned i=0; i<r_voltages.size(); i++)
163 if (r_voltages[i]>max)
172 unsigned globalFarNodeIndex,
173 const double euclideanDistance)
188 assert(aps_near_node > 0);
189 assert(aps_far_node > 0);
192 if (aps_near_node == aps_far_node)
200 else if (aps_near_node > aps_far_node)
212 if ((globalNearNodeIndex == globalFarNodeIndex) || ( fabs(t_far - t_near) < 1e-8))
221 return euclideanDistance / (t_far - t_near);
228 unsigned globalFarNodeIndex,
229 const double euclideanDistance)
231 std::vector<double> conduction_velocities;
233 std::vector<double> t_near;
234 std::vector<double> t_far;
235 unsigned number_of_aps = 0;
248 assert(t_near.size() !=0);
249 assert(t_far.size() !=0);
253 if (t_near.size() > t_far.size())
255 number_of_aps = t_far.size();
259 number_of_aps = t_near.size();
263 if (globalNearNodeIndex == globalFarNodeIndex)
266 for (
unsigned i = 0 ; i < number_of_aps;i++)
268 conduction_velocities.push_back(0.0);
273 for (
unsigned i = 0 ; i < number_of_aps;i++)
276 if ( fabs(t_far[i] - t_near[i]) < 1e-8)
279 conduction_velocities.push_back(0.0);
283 conduction_velocities.push_back(euclideanDistance / (t_far[i] - t_near[i]));
288 return conduction_velocities;
std::vector< double > GetAllActionPotentialDurations(const double percentage)
std::vector< double > mCachedVoltages
double GetLastMaxUpstrokeVelocity()
void SetHdf5DataReader(Hdf5DataReader *pDataReader)
PropagationPropertiesCalculator(Hdf5DataReader *pDataReader, const std::string voltageName="V")
std::vector< double > mTimes
double CalculatePeakMembranePotential(unsigned globalNodeIndex)
unsigned mCachedNodeGlobalIndex
#define EXCEPTION(message)
std::vector< double > CalculateAllMaximumUpstrokeVelocities(unsigned globalNodeIndex, double threshold)
std::vector< double > GetMaxUpstrokeVelocities()
virtual ~PropagationPropertiesCalculator()
unsigned GetNumberOfAboveThresholdDepolarisationsForLastAp()
Hdf5DataReader * mpDataReader
std::vector< double > CalculateAllConductionVelocities(unsigned globalNearNodeIndex, unsigned globalFarNodeIndex, const double euclideanDistance)
double CalculateMaximumUpstrokeVelocity(unsigned globalNodeIndex)
std::vector< unsigned > CalculateAllAboveThresholdDepolarisations(unsigned globalNodeIndex, double threshold)
double CalculateActionPotentialDuration(const double percentage, unsigned globalNodeIndex)
std::vector< std::vector< double > > GetVariableOverTimeOverMultipleNodes(const std::string &rVariableName, unsigned lowerIndex, unsigned upperIndex)
std::vector< double > & rGetCachedVoltages(unsigned globalNodeIndex)
std::vector< double > GetTimesAtMaxUpstrokeVelocity()
double GetLastActionPotentialDuration(const double percentage)
std::vector< double > CalculateAllActionPotentialDurations(const double percentage, unsigned globalNodeIndex, double threshold)
const unsigned UNSIGNED_UNSET
double CalculateConductionVelocity(unsigned globalNearNodeIndex, unsigned globalFarNodeIndex, const double euclideanDistance)
std::vector< unsigned > GetNumberOfAboveThresholdDepolarisationsForAllAps()
std::vector< double > GetVariableOverTime(const std::string &rVariableName, unsigned nodeIndex)
std::vector< double > CalculateUpstrokeTimes(unsigned globalNodeIndex, double threshold)
const std::string mVoltageName
unsigned CalculateAboveThresholdDepolarisationsForLastAp(unsigned globalNodeIndex, double threshold)
std::string GetShortMessage() const
std::vector< std::vector< double > > CalculateAllActionPotentialDurationsForNodeRange(const double percentage, unsigned lowerNodeIndex, unsigned upperNodeIndex, double threshold)
double GetTimeAtLastMaxUpstrokeVelocity()