Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pulse Physiology Suite
engine
Commits
13c44737
Commit
13c44737
authored
Oct 09, 2019
by
Aaron Bray
Browse files
Baroreceptor clean up and serialization support
parent
5706e673
Changes
5
Hide whitespace changes
Inline
Side-by-side
engine/cpp/controller/System.h
View file @
13c44737
...
...
@@ -14,7 +14,7 @@ protected:
/** @brief - Default system values to their homeostatic values */
virtual
void
Initialize
()
{
SetUp
();
}
virtual
void
SetUp
()
=
0
;
virtual
void
SetUp
()
=
0
;
// Called after Initialize if stablizing, or after serialization if reading in a state
/// Notify systems that steady state has been achieved
virtual
void
AtSteadyState
()
{};
...
...
engine/cpp/io/protobuf/PBPulsePhysiology.cpp
View file @
13c44737
...
...
@@ -322,6 +322,9 @@ void PBPulsePhysiology::Serialize(const NervousData& src, Nervous& dst)
dst
.
m_FeedbackActive
=
true
;
dst
.
m_ArterialOxygenBaseline_mmHg
=
src
.
arterialoxygenbaseline_mmhg
();
dst
.
m_ArterialCarbonDioxideBaseline_mmHg
=
src
.
arterialcarbondioxidebaseline_mmhg
();
dst
.
m_BaroreceptorFeedbackStatus
=
src
.
baroreceptorfeedbackstatus
();
dst
.
m_BaroreceptorActiveTime_s
=
src
.
baroreceptoractivetime_s
();
dst
.
m_BaroreceptorMeanArterialPressureBaseline_mmHg
=
src
.
baroreceptormeanarterialpressurebaseline_mmhg
();
}
NervousData
*
PBPulsePhysiology
::
Unload
(
const
Nervous
&
src
)
{
...
...
@@ -334,6 +337,9 @@ void PBPulsePhysiology::Serialize(const Nervous& src, NervousData& dst)
PBPhysiology
::
Serialize
(
src
,
*
dst
.
mutable_common
());
dst
.
set_arterialoxygenbaseline_mmhg
(
src
.
m_ArterialOxygenBaseline_mmHg
);
dst
.
set_arterialcarbondioxidebaseline_mmhg
(
src
.
m_ArterialCarbonDioxideBaseline_mmHg
);
dst
.
set_baroreceptorfeedbackstatus
(
src
.
m_BaroreceptorFeedbackStatus
);
dst
.
set_baroreceptoractivetime_s
(
src
.
m_BaroreceptorActiveTime_s
);
dst
.
set_baroreceptormeanarterialpressurebaseline_mmhg
(
src
.
m_BaroreceptorMeanArterialPressureBaseline_mmHg
);
}
void
PBPulsePhysiology
::
Load
(
const
RenalData
&
src
,
Renal
&
dst
)
...
...
engine/cpp/physiology/Nervous.cpp
View file @
13c44737
...
...
@@ -57,7 +57,6 @@ void Nervous::Initialize()
{
PulseSystem
::
Initialize
();
m_FeedbackActive
=
false
;
m_BaroreceptorFeedbackStatus
=
false
;
GetBaroreceptorHeartRateScale
().
SetValue
(
1.0
);
GetBaroreceptorHeartElastanceScale
().
SetValue
(
1.0
);
GetBaroreceptorResistanceScale
().
SetValue
(
1.0
);
...
...
@@ -72,7 +71,9 @@ void Nervous::Initialize()
// Set when feedback is turned on
m_ArterialOxygenBaseline_mmHg
=
0
;
m_ArterialCarbonDioxideBaseline_mmHg
=
0
;
m_BaroreceptorActivityTime_s
=
0.0
;
m_BaroreceptorActiveTime_s
=
0.0
;
m_BaroreceptorFeedbackStatus
=
false
;
m_BaroreceptorMeanArterialPressureBaseline_mmHg
=
0
;
}
//--------------------------------------------------------------------------------------------------
...
...
@@ -85,17 +86,15 @@ void Nervous::Initialize()
void
Nervous
::
SetUp
()
{
m_dt_s
=
m_data
.
GetTimeStep
().
GetValue
(
TimeUnit
::
s
);
m_normalizedGammaHeartRate
=
m_data
.
GetConfiguration
().
GetNormalizedHeartRateIntercept
();
m_normalizedGammaElastance
=
m_data
.
GetConfiguration
().
GetNormalizedHeartElastanceIntercept
();
m_normalizedGammaCompliance
=
m_data
.
GetConfiguration
().
GetNormalizedComplianceIntercept
();
m_normalizedGammaResistance
=
m_data
.
GetConfiguration
().
GetNormalizedResistanceIntercept
();
m_normalizedAlphaHeartRate
=
m_data
.
GetConfiguration
().
GetNormalizedHeartRateSympatheticSlope
();
m_normalizedAlphaElastance
=
m_data
.
GetConfiguration
().
GetNormalizedHeartElastanceSympatheticSlope
();
m_normalizedAlphaCompliance
=
m_data
.
GetConfiguration
().
GetNormalizedComplianceParasympatheticSlope
();
m_normalizedAlphaResistance
=
m_data
.
GetConfiguration
().
GetNormalizedResistanceSympatheticSlope
();
m_normalizedBetaHeartRate
=
m_data
.
GetConfiguration
().
GetNormalizedHeartRateParasympatheticSlope
();
m_meanArtrialPressurePatientBaseline_mmHg
=
m_data
.
GetPatient
().
GetMeanArterialPressureBaseline
().
GetValue
(
PressureUnit
::
mmHg
);
m_meanArterialPressureBaseline_mmHg
=
m_meanArtrialPressurePatientBaseline_mmHg
;
m_NormalizedGammaHeartRate
=
m_data
.
GetConfiguration
().
GetNormalizedHeartRateIntercept
();
m_NormalizedGammaElastance
=
m_data
.
GetConfiguration
().
GetNormalizedHeartElastanceIntercept
();
m_NormalizedGammaCompliance
=
m_data
.
GetConfiguration
().
GetNormalizedComplianceIntercept
();
m_NormalizedGammaResistance
=
m_data
.
GetConfiguration
().
GetNormalizedResistanceIntercept
();
m_NormalizedAlphaHeartRate
=
m_data
.
GetConfiguration
().
GetNormalizedHeartRateSympatheticSlope
();
m_NormalizedAlphaElastance
=
m_data
.
GetConfiguration
().
GetNormalizedHeartElastanceSympatheticSlope
();
m_NormalizedAlphaCompliance
=
m_data
.
GetConfiguration
().
GetNormalizedComplianceParasympatheticSlope
();
m_NormalizedAlphaResistance
=
m_data
.
GetConfiguration
().
GetNormalizedResistanceSympatheticSlope
();
m_NormalizedBetaHeartRate
=
m_data
.
GetConfiguration
().
GetNormalizedHeartRateParasympatheticSlope
();
}
void
Nervous
::
AtSteadyState
()
...
...
@@ -106,7 +105,7 @@ void Nervous::AtSteadyState()
// The set-points (Baselines) get reset at the end of each stabilization period.
m_ArterialOxygenBaseline_mmHg
=
m_data
.
GetBloodChemistry
().
GetArterialOxygenPressure
(
PressureUnit
::
mmHg
);
m_ArterialCarbonDioxideBaseline_mmHg
=
m_data
.
GetBloodChemistry
().
GetArterialCarbonDioxidePressure
(
PressureUnit
::
mmHg
);
m_
m
eanArtrialPressure
Patient
Baseline_mmHg
=
m_data
.
GetPatient
().
GetMeanArterialPressureBaseline
().
GetValue
(
PressureUnit
::
mmHg
);
m_
BaroreceptorM
eanArt
e
rialPressureBaseline_mmHg
=
m_data
.
GetPatient
().
GetMeanArterialPressureBaseline
().
GetValue
(
PressureUnit
::
mmHg
);
// The baroreceptor scales need to be reset any time the baselines are reset.
GetBaroreceptorHeartRateScale
().
SetValue
(
1.0
);
GetBaroreceptorHeartElastanceScale
().
SetValue
(
1.0
);
...
...
@@ -124,8 +123,11 @@ void Nervous::AtSteadyState()
//--------------------------------------------------------------------------------------------------
void
Nervous
::
PreProcess
()
{
BaroreceptorFeedback
();
ChemoreceptorFeedback
();
if
(
m_FeedbackActive
)
{
BaroreceptorFeedback
();
ChemoreceptorFeedback
();
}
}
//--------------------------------------------------------------------------------------------------
...
...
@@ -163,55 +165,80 @@ void Nervous::PostProcess()
/// These fractions are used to update the scaling parameters of heart rate, heart elastance, resistance and compliance
/// for each time step.
//--------------------------------------------------------------------------------------------------
/// \todo Add decompensation. Perhaps a reduction in the effect that is a function of blood volume below a threshold... and maybe time.
void
Nervous
::
BaroreceptorFeedback
()
{
if
(
!
m_FeedbackActive
)
return
;
//First calculate the sympathetic and parasympathetic firing rates:
double
nu
=
m_data
.
GetConfiguration
().
GetResponseSlope
();
double
meanArterialPressure_mmHg
=
m_data
.
GetCardiovascular
().
GetMeanArterialPressure
(
PressureUnit
::
mmHg
);
UpdateBaroreceptorThresholds
();
//Dampen response due to sedation
double
sedationDampeningEffect
=
m_data
.
GetDrugs
().
GetSedationLevel
().
GetValue
()
*
0.35
;
//maximum slope reduction of 35% - making that up right now
//update nu - the slope response of the firing rate
//nu *= (1 - sedationDampeningEffect); TODO: Add this back when I have data for validation
//Adjusting the mean arterial pressure set-point to account for cardiovascular drug effects
m_
meanArterialPressureBaseline_mmHg
=
m_
meanArtrialPressurePatientBaseline_mmHg
//m_
MeanArterialPressure
NoFeedback
Baseline_mmHg
double
meanArterialPressure
Combined
Baseline_mmHg
=
m_
Baroreceptor
MeanArterialPressureBaseline_mmHg
+
m_data
.
GetDrugs
().
GetMeanBloodPressureChange
(
PressureUnit
::
mmHg
)
+
m_data
.
GetEnergy
().
GetExerciseMeanArterialPressureDelta
(
PressureUnit
::
mmHg
);
double
sympatheticFraction
=
1.0
/
(
1.0
+
pow
(
meanArterialPressure_mmHg
/
m_meanArterialPressureBaseline_mmHg
,
nu
));
double
parasympatheticFraction
=
1.0
/
(
1.0
+
pow
(
meanArterialPressure_mmHg
/
m_meanArterialPressureBaseline_mmHg
,
-
nu
));
//Determine if barorectors are active and for how long
double
pressureDeviation
=
meanArterialPressure_mmHg
-
meanArterialPressureCombinedBaseline_mmHg
;
double
pressureDeviationFraction
=
std
::
abs
(
pressureDeviation
)
/
meanArterialPressureCombinedBaseline_mmHg
;
if
(
pressureDeviationFraction
>
0.05
)
{
if
(
!
m_BaroreceptorFeedbackStatus
)
{
m_BaroreceptorActiveTime_s
=
0.0
;
m_BaroreceptorFeedbackStatus
=
true
;
}
else
{
m_BaroreceptorActiveTime_s
+=
m_dt_s
;
//Need to change the threshold every 7 minutes based on over activation
if
(
m_BaroreceptorActiveTime_s
>
420.0
/*s*/
)
{
//Reset the time
m_BaroreceptorActiveTime_s
=
0.0
;
//Adjust the threshold by up to 30%
m_BaroreceptorMeanArterialPressureBaseline_mmHg
+=
0.35
*
pressureDeviation
;
m_ss
<<
"Baroreceptor MAP Baseline updated to "
<<
m_BaroreceptorMeanArterialPressureBaseline_mmHg
<<
" mmHg"
;
Info
(
m_ss
);
}
}
}
else
{
m_BaroreceptorFeedbackStatus
=
false
;
}
// \todo Dampen Baroreceptor response due to sedation
//double sedationDampeningEffect = m_data.GetDrugs().GetSedationLevel().GetValue() * 0.35; //maximum slope reduction of 35% - making that up right now
//update nu - the slope response of the firing rate
//nu *= (1 - sedationDampeningEffect); TODO: Add this back when I have data for validation
double
sympatheticFraction
=
1.0
/
(
1.0
+
pow
(
meanArterialPressure_mmHg
/
meanArterialPressureCombinedBaseline_mmHg
,
nu
));
double
parasympatheticFraction
=
1.0
/
(
1.0
+
pow
(
meanArterialPressure_mmHg
/
meanArterialPressureCombinedBaseline_mmHg
,
-
nu
));
//Calculate the normalized change in heart rate
double
normalizedHeartRate
=
GetBaroreceptorHeartRateScale
().
GetValue
();
double
tauHeartRate_s
=
m_data
.
GetConfiguration
().
GetHeartRateDistributedTimeDelay
(
TimeUnit
::
s
);
double
deltaNormalizedHeartRate
=
(
1.0
/
tauHeartRate_s
)
*
(
-
normalizedHeartRate
+
m_
n
ormalizedAlphaHeartRate
*
sympatheticFraction
-
m_
n
ormalizedBetaHeartRate
*
parasympatheticFraction
+
m_
n
ormalizedGammaHeartRate
)
*
m_dt_s
;
double
deltaNormalizedHeartRate
=
(
1.0
/
tauHeartRate_s
)
*
(
-
normalizedHeartRate
+
m_
N
ormalizedAlphaHeartRate
*
sympatheticFraction
-
m_
N
ormalizedBetaHeartRate
*
parasympatheticFraction
+
m_
N
ormalizedGammaHeartRate
)
*
m_dt_s
;
normalizedHeartRate
+=
deltaNormalizedHeartRate
;
GetBaroreceptorHeartRateScale
().
SetValue
(
normalizedHeartRate
);
//Calculate the normalized change in heart elastance
double
normalizedHeartElastance
=
GetBaroreceptorHeartElastanceScale
().
GetValue
();
double
tauElastance_s
=
m_data
.
GetConfiguration
().
GetHeartElastanceDistributedTimeDelay
(
TimeUnit
::
s
);
double
deltaNormalizedHeartElastance
=
(
1.0
/
tauElastance_s
)
*
(
-
normalizedHeartElastance
+
m_
n
ormalizedAlphaElastance
*
sympatheticFraction
+
m_
n
ormalizedGammaElastance
)
*
m_dt_s
;
double
deltaNormalizedHeartElastance
=
(
1.0
/
tauElastance_s
)
*
(
-
normalizedHeartElastance
+
m_
N
ormalizedAlphaElastance
*
sympatheticFraction
+
m_
N
ormalizedGammaElastance
)
*
m_dt_s
;
normalizedHeartElastance
+=
deltaNormalizedHeartElastance
;
GetBaroreceptorHeartElastanceScale
().
SetValue
(
normalizedHeartElastance
);
//Calculate the normalized change in flow resistance for any cardiovascular resistor
double
normalizedResistance
=
GetBaroreceptorResistanceScale
().
GetValue
();
double
tauResistance_s
=
m_data
.
GetConfiguration
().
GetSystemicResistanceDistributedTimeDelay
(
TimeUnit
::
s
);
double
deltaNormalizedResistance
=
(
1.0
/
tauResistance_s
)
*
(
-
normalizedResistance
+
m_
n
ormalizedAlphaResistance
*
sympatheticFraction
+
m_
n
ormalizedGammaResistance
)
*
m_dt_s
;
double
deltaNormalizedResistance
=
(
1.0
/
tauResistance_s
)
*
(
-
normalizedResistance
+
m_
N
ormalizedAlphaResistance
*
sympatheticFraction
+
m_
N
ormalizedGammaResistance
)
*
m_dt_s
;
normalizedResistance
+=
deltaNormalizedResistance
;
GetBaroreceptorResistanceScale
().
SetValue
(
normalizedResistance
);
//Calculate the normalized change in flow compliance for any cardiovascular compliance
double
normalizedCompliance
=
GetBaroreceptorComplianceScale
().
GetValue
();
double
tauCompliance_s
=
m_data
.
GetConfiguration
().
GetVenousComplianceDistributedTimeDelay
(
TimeUnit
::
s
);
double
deltaNormalizedCompliance
=
(
1.0
/
tauCompliance_s
)
*
(
-
normalizedCompliance
+
m_
n
ormalizedAlphaCompliance
*
parasympatheticFraction
+
m_
n
ormalizedGammaCompliance
)
*
m_dt_s
;
double
deltaNormalizedCompliance
=
(
1.0
/
tauCompliance_s
)
*
(
-
normalizedCompliance
+
m_
N
ormalizedAlphaCompliance
*
parasympatheticFraction
+
m_
N
ormalizedGammaCompliance
)
*
m_dt_s
;
normalizedCompliance
+=
deltaNormalizedCompliance
;
GetBaroreceptorComplianceScale
().
SetValue
(
normalizedCompliance
);
#ifdef VERBOSE
...
...
@@ -223,65 +250,6 @@ void Nervous::BaroreceptorFeedback()
#endif
}
//--------------------------------------------------------------------------------------------------
/// \brief
/// Dampens the response of the baroreceptors based on sedation and extended activity.
///
/// \details
/// The baroreceptor setpoints are updated as activity time lengthens, this checks to see if they are active
/// (a greater than 10% deviation from the mean arterial pressure).
//--------------------------------------------------------------------------------------------------
void
Nervous
::
UpdateBaroreceptorThresholds
()
{
UpdateBaroreceptorActivityStatus
();
//Need to change the threshold every 7 minutes based on over activation
double
thresholdChangeTime_s
=
420.0
;
if
(
m_BaroreceptorFeedbackStatus
&&
m_BaroreceptorActivityTime_s
>
thresholdChangeTime_s
)
{
//Adjust the threshold by up to 30%
double
meanArterialPressure_mmHg
=
m_data
.
GetCardiovascular
().
GetMeanArterialPressure
(
PressureUnit
::
mmHg
);
double
pressureDeviation
=
meanArterialPressure_mmHg
-
m_meanArterialPressureBaseline_mmHg
;
m_meanArtrialPressurePatientBaseline_mmHg
+=
0.35
*
pressureDeviation
;
//Reset the time
m_BaroreceptorActivityTime_s
=
0.0
;
}
}
//--------------------------------------------------------------------------------------------------
/// \brief
/// Checks to see if the baroreceptors are active and if so how long
///
/// \details
/// The baroreceptor setpoints are updated as activity time lengthens, this checks to see if they are active
/// (a greater than 10% deviation from the mean arterial pressure).
//--------------------------------------------------------------------------------------------------
void
Nervous
::
UpdateBaroreceptorActivityStatus
()
{
//Determine if barorectors are active and for how long
double
meanArterialPressure_mmHg
=
m_data
.
GetCardiovascular
().
GetMeanArterialPressure
(
PressureUnit
::
mmHg
);
double
pressureDeviationFraction
=
std
::
abs
(
meanArterialPressure_mmHg
-
m_meanArterialPressureBaseline_mmHg
)
/
m_meanArterialPressureBaseline_mmHg
;
if
(
pressureDeviationFraction
>
0.05
)
{
if
(
!
m_BaroreceptorFeedbackStatus
)
{
m_BaroreceptorActivityTime_s
=
0.0
;
m_BaroreceptorFeedbackStatus
=
true
;
}
else
{
m_BaroreceptorActivityTime_s
+=
m_dt_s
;
}
}
else
{
if
(
m_BaroreceptorFeedbackStatus
)
{
m_BaroreceptorFeedbackStatus
=
false
;
}
}
}
//--------------------------------------------------------------------------------------------------
/// \brief
/// Checks metrics in the brain to determine events to be thrown
...
...
@@ -330,9 +298,6 @@ void Nervous::CheckBrainStatus()
//--------------------------------------------------------------------------------------------------
void
Nervous
::
ChemoreceptorFeedback
()
{
if
(
!
m_FeedbackActive
)
return
;
double
normalized_pO2
=
m_data
.
GetBloodChemistry
().
GetArterialOxygenPressure
(
PressureUnit
::
mmHg
)
/
m_ArterialOxygenBaseline_mmHg
;
double
normalized_pCO2
=
m_data
.
GetBloodChemistry
().
GetArterialCarbonDioxidePressure
(
PressureUnit
::
mmHg
)
/
m_ArterialCarbonDioxideBaseline_mmHg
;
...
...
engine/cpp/physiology/Nervous.h
View file @
13c44737
...
...
@@ -28,40 +28,36 @@ protected:
// Set pointers and other member variables common to both homeostatic initialization and loading a state
void
SetUp
();
void
AtSteadyState
();
void
AtSteadyState
();
void
PreProcess
();
void
Process
();
void
PostProcess
();
void
BaroreceptorFeedback
();
void
UpdateBaroreceptorActivityStatus
();
void
UpdateBaroreceptorThresholds
();
void
CheckBrainStatus
();
void
ChemoreceptorFeedback
();
void
SetPupilEffects
();
// Serializable member variables (Set in Initialize and in schema)
// Serializable member variables (Set in Initialize and in schema)
double
m_ArterialOxygenBaseline_mmHg
;
double
m_ArterialCarbonDioxideBaseline_mmHg
;
//Baroreceptor threshold parameters
bool
m_BaroreceptorFeedbackStatus
;
double
m_BaroreceptorActiveTime_s
;
double
m_BaroreceptorMeanArterialPressureBaseline_mmHg
;
// Stateless member variable (Set in SetUp())
bool
m_FeedbackActive
;
bool
m_BaroreceptorFeedbackStatus
;
bool
m_FeedbackActive
;
// An overall flag used to turn off baro/chemo receptors during stabilization
double
m_dt_s
;
//Baroreceptor threshold parameters
double
m_BaroreceptorActivityTime_s
;
double
m_meanArterialPressureBaseline_mmHg
;
double
m_meanArtrialPressurePatientBaseline_mmHg
;
// Configuration fractions representing the amount by which each quantity can change due to baroreceptors;
double
m_
n
ormalizedGammaHeartRate
;
double
m_
n
ormalizedGammaElastance
;
double
m_
n
ormalizedGammaCompliance
;
double
m_
n
ormalizedGammaResistance
;
double
m_
n
ormalizedAlphaHeartRate
;
double
m_
n
ormalizedAlphaElastance
;
double
m_
n
ormalizedAlphaCompliance
;
double
m_
n
ormalizedAlphaResistance
;
double
m_
n
ormalizedBetaHeartRate
;
double
m_
N
ormalizedGammaHeartRate
;
double
m_
N
ormalizedGammaElastance
;
double
m_
N
ormalizedGammaCompliance
;
double
m_
N
ormalizedGammaResistance
;
double
m_
N
ormalizedAlphaHeartRate
;
double
m_
N
ormalizedAlphaElastance
;
double
m_
N
ormalizedAlphaCompliance
;
double
m_
N
ormalizedAlphaResistance
;
double
m_
N
ormalizedBetaHeartRate
;
};
schema/proto/pulse/PulsePhysiology.proto
View file @
13c44737
...
...
@@ -95,6 +95,9 @@ message NervousData
cdm.NervousSystemData
Common
=
1
;
double
ArterialOxygenBaseline_mmHg
=
2
;
double
ArterialCarbonDioxideBaseline_mmHg
=
3
;
bool
BaroreceptorFeedbackStatus
=
4
;
double
BaroreceptorActiveTime_s
=
5
;
double
BaroreceptorMeanArterialPressureBaseline_mmHg
=
6
;
}
message
RenalData
...
...
Aaron Bray
@aaron.bray
mentioned in commit
9d81580b
·
Oct 09, 2019
mentioned in commit
9d81580b
mentioned in commit 9d81580b3c3f36371f3f5056ff46094e040bce5e
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment