Simple ventilator not improving patient's health (for ARDS)

Howdy,

Loving Pulse. I’m trying to do some experiments regarding the efficacy of different ventilator modes for patients affected with ARDS. But I’m having some trouble getting the ventilators to improve the patient’s health at all.

I’m closely following the code provided in the HowTo_MechanicalVentilator.py file, and I’m using Pulse 4.1.0 through the Docker image.

def init_patient(
        pulse,
        data_mgr,
        ards_left=0, 
        ards_right=0,
        ards_severity=0,
    ):
        # Load a default patient
        data_root_dir = "/mnt/data/"
        pc = SEPatientConfiguration()
        pc.set_data_root_dir(data_root_dir)
        pc.set_patient_file(f"{data_root_dir}/patients/StandardMale.json")

        # ARDS - must set before initialisation
        ards = pc.get_conditions().get_acute_respiratory_distress_syndrome()
        ards.get_left_lung_affected().set_value(ards_left)
        ards.get_right_lung_affected().set_value(ards_right)
        ards.get_severity().set_value(ards_severity)

        # Don't need to initialize if we serialize from file
        # https://gitlab.kitware.com/physiology/engine/-/blob/stable/src/python/pulse/howto/HowTo_AsthmaAttack.py#L3
        # Initialize the engine with our configuration
        # In this case we've given the patient a condition (ARDS) so it needs to stabilise to a 
        # steady state (i.e. a converged system) so that we can work with it. Actions however are
        # considred acute responses and do not require stabilization. Conditions can only be
        # changed at run time via exacerbations
        if not pulse.initialize_engine(pc, data_mgr):
            print("Unable to load stabilize engine")
            return
        # May see something like this: 'Convergence took 26.5s to simulate 437s to get engine to a steady state'
        # But note that the time 'in the sim' is still t=0 until we advance time
        
        # Get default data at time 0s from the engine post initialization
        print("Engine and patient initialized")

    ards_setting = 0.8
    init_patient(
        pulse,
        data_mgr,
        ards_left=ards_setting, 
        ards_right=ards_setting,
        ards_severity=ards_setting,
    )

I’m using the standard male patient and setting their ARDS as shown above^^.

I simulate the patient for 8 minutes with no ventilation, and then I apply a ventilator (pc_ac) and simulate for another 8 minutes. The vent is set like so:

    pc_ac = SEMechanicalVentilatorPressureControl()
    pc_ac.set_connection(eSwitch.On)
    pc_ac.set_mode(eMechanicalVentilator_PressureControlMode.AssistedControl)
    pc_ac.get_fraction_inspired_oxygen().set_value(0.21)
    pc_ac.get_inspiratory_period().set_value(1.0, TimeUnit.s)
    pc_ac.get_inspiratory_pressure().set_value(13.0, PressureUnit.cmH2O)
    pc_ac.get_positive_end_expired_pressure().set_value(5.0, PressureUnit.cmH2O)
    pc_ac.get_respiration_rate().set_value(12.0, FrequencyUnit.Per_min)
    pc_ac.get_slope().set_value(0.1, TimeUnit.s)
    pulse.process_action(pc_ac)

Here’s an example of the patient’s readings throughout the simulation:

As you can see, the patient’s health for the first half of the simulation is as expected for severe ARDS, then as soon as the ventilator action is applied their health degrades significantly. awRR goes to 0, HR jumps, PLETH and SpO2 to zero … what have I done wrong here? It seems that the ventilator is not helping at all.

Any advice appreciated,
Isaac

Hi @isaac

Pulse 4.1 is pretty old, and there has been significant improvement to the models you are working with.
I do need to push Pulse 4.2 containers to dockerhub…
Have you tried using our Pulse Explorer for your investigation?
We have ventilator interface you can interact with.

But we are also improving these models currently on our integration branch.
It might be worth while to build our integration branch to get the latest models.

Pertaining to your question though, do you have a log file associated with your experiment?

Thanks!

Hi @abray,

Appreciate the response! RE your points:

  • I went ahead and used the latest version of pulse from the gitlab page using the provided Dockerfile (I would love it if you could push the new containers to dockerhub though! Would definitely make it easier for people like me working in python to get up and running).
  • I have used Pulse Explorer but as a part of this investigation we’re looking to develop some control algorithms for optimal ventilation. A programmatic interface will be needed.
  • Which branch should I look at? feature/ventilator_updates?
  • No log file - where would I find this?

I am getting a different error however; after initializing pulse and the data request manager I run this code:

Load a default patient

data_root_dir = "/pulse/bin/"
pc = SEPatientConfiguration()
pc.set_patient_file(f"{data_root_dir}/patients/StandardMale.json")

# ARDS - must set before initialisation
ards = pc.get_conditions().get_acute_respiratory_distress_syndrome()
ards.get_severity(eLungCompartment.LeftLung).set_value(ards_left)
ards.get_severity(eLungCompartment.RightLung).set_value(ards_right)

print("Initializing engine")
if not pulse.initialize_engine(pc, data_mgr):
    print("Unable to load stabilize engine on patient initialization")
    return

# Get default data at time 0s from the engine post initialization
print("Engine initialized, results at time 0s:")
pulse.print_results()

But the pulse.initialize_engine(pc, data_mgr) line causes a segmentation fault. I can’t seem to find any documentation on how to resolve this?

Cheers,
Isaac

@abray - you can disregard my last message. Apologies - some of my filepaths to the Pulse data folder had changed after working in the new docker container. My bad! Running my previous experiments now and will post my results shortly.

And I followed the HowToARDS example and can see how to save log files - I’ll include those in future posts.

Best,
Isaac

That makes sense
Have you looked at our basic howto for python?
It shows various ways for logging.
I suspect the data directory of pules/bin may not be correct?

When I build a new container, I will use the stable branch as that is the official 4.2 version
The integration branch is safe and has the latest and greatest on it which includes some updates to the ventilator as we are running through some ventilation validation for other projects.

Thanks @abray . I’ve checked out the logging and fixed the data directory issue.

These are my results when using the integration branch:

The results certainly seem smoother but again, the patient seems to be getting a lot worse on the ventilator. Is there something wrong with my strategy here? It’s the same experimental setup as in my first post: 0.8 ARDS severity in each lung, StandardMale, no ventilator for the first 8 minutes, then a PC-AC ventilator for the next 8 minutes. These are my ventilator settings:

pc_ac = SEMechanicalVentilatorPressureControl()
pc_ac.set_connection(eSwitch.On)
pc_ac.set_mode(eMechanicalVentilator_PressureControlMode.AssistedControl)
pc_ac.get_fraction_inspired_oxygen().set_value(0.21)
pc_ac.get_inspiratory_period().set_value(1.0, TimeUnit.s)
pc_ac.get_inspiratory_pressure().set_value(13.0, PressureUnit.cmH2O)
pc_ac.get_positive_end_expired_pressure().set_value(5.0, PressureUnit.cmH2O)
pc_ac.get_respiration_rate().set_value(12.0, FrequencyUnit.Per_min)
pc_ac.get_slope().set_value(0.1, TimeUnit.s)
pulse.process_action(pc_ac)

Is there some example of simulating ARDS and ‘treating’ it with a ventilator strategy that I could cross reference? I’m unsure if my results here are expected.

Here is the log file for this experiment.

I don’t seem to have access to get the log

FYI there are scenario json files here that show ARDS combined with the ventilator

https://gitlab.kitware.com/physiology/engine/-/tree/integration/data/human/adult/scenarios/equipment?ref_type=heads

Looking at those scenario files now, thanks. Can you access the log file here? https://filebin.net/ys5mabeus0o7uq9z/pulse.log

Yes, thanks!

I think the main issue is that you’re calling a MechanicalVentilatorHold and never releasing it. I would remove that action completely.

I would also recommend just setting the LeftLung and RightLung compartments for ARDS. We don’t support separate lobes yet.

You also don’t need to set the Slope on the ventilator with the default square waveform. Although, I think it will just be ignored.

You might also want to call the tracheal intubation action. Otherwise, it will assume a mask is used instead.