diff --git a/Dockerfile b/Dockerfile index 63d7983d246ae4d960bebbd4af9d3a6229570cac..9c39debd0607fc0404e4fecf65e16296e519664b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,10 @@ -FROM kitware/pulse:3.0.1 +FROM kitware/pulse:4.1.0 ################################################################################ # install some python packages -#RUN pip3 install - +COPY requirements.txt /tmp/ +RUN pip3 install --requirement /tmp/requirements.txt +RUN jupyter nbextension enable --py bqplot ################################################################################ # set up user @@ -37,9 +38,7 @@ RUN mv /pulse/bin/substances/ ${HOME}/data/ RUN mv /pulse/bin/*.json ${HOME}/data RUN mv /pulse/bin/PyPulse* ${HOME} # Copy pulse python files to ${HOME} -RUN mkdir ${HOME}/python -RUN mv /source/src/python/google/ ${HOME}/python/ -RUN mv /source/src/python/pulse/ ${HOME}/python/ +RUN mv /pulse/python/ ${HOME}/python/ ENV PYTHONPATH ${HOME}:${HOME}/python # Change ownership to the binder runner USER root diff --git a/HowTo_EngineUse.ipynb b/HowTo_EngineUse.ipynb index 034e40c8148f69d4c7b0efc36eb8cdff6c541e6d..d33d7790e5f1fbdcc15d39b3faa673b037720623 100644 --- a/HowTo_EngineUse.ipynb +++ b/HowTo_EngineUse.ipynb @@ -27,7 +27,7 @@ "\n", "### Items of Note\n", "\n", - "#### PulsePhysiologyEngine\n", + "#### PulseEngine\n", "Creating an object of this time will allocate a new Pulse Engine in C++.\n", "This Python object manages, controls and exchanges data between Python and the C++ Pulse engine. \n", " \n", @@ -78,21 +78,23 @@ } ], "source": [ - "from pulse.cpm.PulsePhysiologyEngine import PulsePhysiologyEngine\n", + "from pulse.engine.PulseEngine import PulseEngine\n", "from pulse.cdm.engine import SEDataRequest, SEDataRequestManager\n", + "from pulse.cdm.scalars import ElectricPotentialUnit, FrequencyUnit, LengthUnit, MassUnit, MassPerVolumeUnit, \\\n", + " PressureUnit, TemperatureUnit, TimeUnit, VolumeUnit, VolumePerTimeUnit\n", "\n", "# Allocate a new C++ engine\n", - "pulse = PulsePhysiologyEngine()\n", + "pulse = PulseEngine()\n", "\n", "# The data we want to get back from the engine\n", "data_req_mgr = SEDataRequestManager([])\n", "data_requests = [\n", - " SEDataRequest.create_physiology_request(\"HeartRate\", unit=\"1/min\"),\n", - " SEDataRequest.create_physiology_request(\"RespirationRate\", unit=\"1/min\"),\n", - " SEDataRequest.create_physiology_request(\"EndTidalCarbonDioxidePressure\", unit=\"mmHg\"),\n", - " SEDataRequest.create_gas_compartment_substance_request(\"Carina\", \"CarbonDioxide\", \"PartialPressure\", unit=\"mmHg\"),\n", - " SEDataRequest.create_substance_request(\"Oxygen\", \"AlveolarTransfer\", \"mL/s\"),\n", - " SEDataRequest.create_substance_request(\"CarbonDioxide\", \"AlveolarTransfer\", \"mL/s\"),\n", + " SEDataRequest.create_physiology_request(\"HeartRate\", unit=FrequencyUnit.Per_min),\n", + " SEDataRequest.create_physiology_request(\"RespirationRate\", unit=FrequencyUnit.Per_min),\n", + " SEDataRequest.create_physiology_request(\"EndTidalCarbonDioxidePressure\", unit=PressureUnit.mmHg),\n", + " SEDataRequest.create_gas_compartment_substance_request(\"Carina\", \"CarbonDioxide\", \"PartialPressure\", unit=PressureUnit.mmHg),\n", + " SEDataRequest.create_substance_request(\"Oxygen\", \"AlveolarTransfer\", VolumePerTimeUnit.mL_Per_s),\n", + " SEDataRequest.create_substance_request(\"CarbonDioxide\", \"AlveolarTransfer\", VolumePerTimeUnit.mL_Per_s),\n", "]\n", "data_req_mgr = SEDataRequestManager(data_requests)\n", "data_req_mgr.set_results_filename(\"./test_results/UseCase1.csv\")\n", @@ -120,7 +122,7 @@ "\n", "The ```process_action()``` function is used to pass an Action object to the engine for processing. The next cell demonstrates the creation of an AirwayObstruction action for the patient. This action will occour for the patient until another is sent which stops it.\n", "\n", - "For a list all actions Pulse supports, see: https://pulse.kitware.com/physeng.html#ProcessActions#ProcessActions\n", + "For a list all actions Pulse supports, see: https://pulse.kitware.com/physeng.html#ProcessActions\n", "\n", "#### advance_time_s\n", "\n", @@ -284,17 +286,17 @@ "from pulse.cdm.scalars import FrequencyUnit, LengthUnit, MassUnit, MassPerVolumeUnit, \\\n", " PressureUnit, TemperatureUnit, TimeUnit\n", "\n", - "pulse = PulsePhysiologyEngine()\n", + "pulse = PulseEngine()\n", "\n", "# The data we want to get back from the engine\n", "data_req_mgr = SEDataRequestManager([])\n", "data_requests = [\n", - " SEDataRequest.create_physiology_request(\"HeartRate\", unit=\"1/min\"),\n", - " SEDataRequest.create_physiology_request(\"RespirationRate\", unit=\"1/min\"),\n", - " SEDataRequest.create_physiology_request(\"EndTidalCarbonDioxidePressure\", unit=\"mmHg\"),\n", - " SEDataRequest.create_gas_compartment_substance_request(\"Carina\", \"CarbonDioxide\", \"PartialPressure\", unit=\"mmHg\"),\n", - " SEDataRequest.create_substance_request(\"Oxygen\", \"AlveolarTransfer\", \"mL/s\"),\n", - " SEDataRequest.create_substance_request(\"CarbonDioxide\", \"AlveolarTransfer\", \"mL/s\"),\n", + " SEDataRequest.create_physiology_request(\"HeartRate\", unit=FrequencyUnit.Per_min),\n", + " SEDataRequest.create_physiology_request(\"RespirationRate\", unit=FrequencyUnit.Per_min),\n", + " SEDataRequest.create_physiology_request(\"EndTidalCarbonDioxidePressure\", unit=PressureUnit.mmHg),\n", + " SEDataRequest.create_gas_compartment_substance_request(\"Carina\", \"CarbonDioxide\", \"PartialPressure\", unit=PressureUnit.mmHg),\n", + " SEDataRequest.create_substance_request(\"Oxygen\", \"AlveolarTransfer\", VolumePerTimeUnit.mL_Per_s),\n", + " SEDataRequest.create_substance_request(\"CarbonDioxide\", \"AlveolarTransfer\", VolumePerTimeUnit.mL_Per_s),\n", "]\n", "data_req_mgr = SEDataRequestManager(data_requests)\n", "data_req_mgr.set_results_filename(\"./test_results/UseCase1.csv\")\n", @@ -376,7 +378,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.4" + "version": "3.6.9" } }, "nbformat": 4, diff --git a/Multiplex_Ventilation.py b/Multiplex_Ventilation.py index 6a508592004a0cbf9d62edfbb22cc37b475678c7..4c59e13942febe440ee5341b1acd07810f71ca6f 100644 --- a/Multiplex_Ventilation.py +++ b/Multiplex_Ventilation.py @@ -4,7 +4,8 @@ import threading import numpy as np import bqplot as bq -from pulse.cdm.mechanical_ventilator import eConnection, eDriverWaveform +from pulse.cdm.engine import eSwitch +from pulse.cdm.mechanical_ventilator import eDriverWaveform from pulse.cdm.mechanical_ventilator_actions import SEMechanicalVentilatorConfiguration from pulse.cdm.scalars import FrequencyUnit, PressureUnit, TimeUnit from pulse.study.multiplex_ventilation.engine import MVEngine @@ -54,7 +55,7 @@ class MVSimExplorer(object): self.plots["AirwayPressure_cmH2O"] = PlotData() self.plots["ArterialCarbonDioxidePartialPressure_mmHg"] = PlotData() self.plots["ArterialOxygenPartialPressure_mmHg"] = PlotData() - self.plots["CarricoIndex_mmHg"] = PlotData() + self.plots["HorowitzIndex_mmHg"] = PlotData() self.plots["EndTidalCarbonDioxidePressure_mmHg"] = PlotData() self.plots["MeanAirwayPressure_cmH2O"] = PlotData() self.plots["OxygenationIndex"] = PlotData() @@ -103,8 +104,8 @@ class MVSimExplorer(object): self.update_ventilator = False self.ventilator = SEMechanicalVentilatorConfiguration() - self.v_cfg = self.ventilator.get_configuration() - self.v_cfg.set_connection(eConnection.Tube) + self.v_cfg = self.ventilator.get_settings() + self.v_cfg.set_connection(eSwitch.On) self.v_cfg.set_inspiration_waveform(eDriverWaveform.Square); self.v_cfg.set_expiration_waveform(eDriverWaveform.Square); @@ -486,7 +487,7 @@ class MVSimExplorer(object): self.plots["AirwayPressure_cmH2O"].update(p0.AirwayPressure_cmH2O,p1.AirwayPressure_cmH2O) self.plots["ArterialCarbonDioxidePartialPressure_mmHg"].update(p0.ArterialCarbonDioxidePartialPressure_mmHg,p1.ArterialCarbonDioxidePartialPressure_mmHg) self.plots["ArterialOxygenPartialPressure_mmHg"].update(p0.ArterialOxygenPartialPressure_mmHg,p1.ArterialOxygenPartialPressure_mmHg) - self.plots["CarricoIndex_mmHg"].update(p0.CarricoIndex_mmHg,p1.CarricoIndex_mmHg) + self.plots["HorowitzIndex_mmHg"].update(p0.HorowitzIndex_mmHg,p1.HorowitzIndex_mmHg) self.plots["EndTidalCarbonDioxidePressure_mmHg"].update(p0.EndTidalCarbonDioxidePressure_mmHg,p1.EndTidalCarbonDioxidePressure_mmHg) self.plots["MeanAirwayPressure_cmH2O"].update(p0.MeanAirwayPressure_cmH2O,p1.MeanAirwayPressure_cmH2O) self.plots["OxygenationIndex"].update(p0.OxygenationIndex,p1.OxygenationIndex)