Implementing arythmia patterns

Hello,

I wish to implement new “states” for the engine as to simulate a variety of arythmic cardiac patterns. I am wondering if you might have advise or guidance on how to go about that? where to look? where to start? Does it already exists and I just missed it?

Here is what I understood so far:

  • I think I will have to download the c++ source code, add my stuff and compile it again.
  • I will have to add some “cases” into the C# project in unity in order to find them.

I am not sure to understand fully how the changes on the curves are applied and would like to understand the philosophy and architecture of the engine before going into “details”.

ofc I would like to contribute and publish this on your rep if you allow me and would do my best to comply to your “standards”.

Oh, and the project I work on runs in unity.

While looking forward for getting an answer I wish you all the best!

Here are the arythmias we would like to use:

  1. Sinus dysrhythmia;
  2. Sinus pause;
  3. Premature atrial contraction (PAC);
  4. Wolf-Parkinson-White
  5. Atrial ectopic tachycardia
  6. Atrial fibrillation
  7. Atrial flutter;
  8. Supraventricular tachycardia;
  9. Junctional rythme;
  10. Junctional tachycardia;
  11. AV blocks (1st degree, 2nd degree (type 1 and 2), 3rd degree)
  12. Premature ventricular contraction (PVC)
  13. Torsade de pointes
  14. accelerated idioventricular rythme
  15. accelerated jonctionnal rythme

Our current supported arrhythmia’s are

enum eHeartRhythm
{
  NormalSinus                      = 0; /**<< @brief Normal electical signal and mechanical function. */ 
  SinusBradycardia                 = 1; /**<< @brief Normal electical signal with reduced heart rate.   */
  SinusTachycardia                 = 2; /**<< @brief Normal electical signal and increased heart rate.  */
  SinusPulselessElectricalActivity = 3; /**<< @brief Electical signal, but no mechanical function. */
  Asystole                         = 4; /**<< @brief No electrical signal or mechanical function. */
  CoarseVentricularFibrillation    = 5; /**<< @brief No organized electrical signal, no mechanical function. */
  FineVentricularFibrillation      = 6; /**<< @brief No organized electrical signal, reduced amplitude compared to coarse VF, no mechanical function. */
  PulselessVentricularTachycardia  = 7; /**<< @brief Normal electical signal with reduced amplitude, but no mechanical function. */
  StableVentricularTachycardia     = 8; /**<< @brief Ventricular tachycardia electrical signal with increased heart rate.  */
  UnstableVentricularTachycardia   = 9; /**<< @brief Ventricular tachycardia electrical signal with increased heart rate, reduced heart elastance. */
}

Generally,

  1. You will need to do a literature search and find citations in papers describing how this new arrhythmia affects the physiology
    (Does it increase\decrease blood pressures\heart rates? and by how much 2x/3x etc.)

  2. Implement those changes here
    https://gitlab.kitware.com/physiology/engine/-/blob/4.x/src/cpp/engine/common/system/physiology/CardiovascularModel.cpp#L1654
    Depending on what the literature says, we may need to add logic in other places in the code

  3. Provide an ECG wavefrom associated with that arrhythmia.
    This would be an array of mV for one cardiac cycle of the arrhythmia.
    So you would need to find and digitize a single cardiac cycle of your new arrhythmia
    You can see that data on the ECG tab of our data.xls
    https://gitlab.kitware.com/physiology/engine/-/blob/master/data/Data.xlsx
    Then associate an ecg waveform with one or more arrhythmias
    https://gitlab.kitware.com/physiology/engine/-/blob/4.x/src/cpp/engine/common/system/equipment/ElectroCardioGramModel.cpp#L88

From there, there are more things to do, but at a high level, that’s the process

Hello,

Some guidance on code contribution can be found in our wiki here.

You would be extending the Arrhythmia action.

If you would like to discuss this, we would be happy to have a quick call to give some guidance. You are welcome to email me at rachel.clipp@kitware.com to set up a time to talk.

Thanks,
Rachel

hi,I added three patterns and ECG wavefrom. Then, export dll to unity. It runs good with standmale.json. But when I test howtocreatepatient in c++ solution, it crash. HeartBaseline pointer is null. I don’t know why.
30B25A3B-4F6A-4086-870D-018C102951CB

There is an if check to test for a null pointer.
I don’t think your pointer is null…

I’d need to see a call stack to help diagnose any further


This is call stack. Thanks!

my pulse engine version is 4.2.0

Try building and running in Debug Mode

Put a break point in SEScalarFrequency& SEPatient::GetHeartRateBaseline()
This method will be hit and the m_HeartRateBaseline pointer should be null in that function and get allocated there

Then break in the double SEPatient::GetHeartRateBaseline(const FrequencyUnit& unit) const and ensure the m_HeartRateBaseline pointer has the same memory address that it was allocated to

I fix it. I invoke GetCurrentPatient in SubstanceManager::InitializeLiquidCompartmentNonGases() . Then replace GetInitialPatient. It works.
Thanks!
pulse is very good. I like it.

Ok, I assume you have other code changes as you shouldn’t have to do that with the public code base…

But great!