Unity Running Scenario: Unable to initialize patient

I am sure the answer is already given somewhere but I can’t find it so i apologize in advance.
I’m trying to run the VitalsMonitorScenario scene in the Unity package. The ultimate goal is to design my own scenario and integrate Pulse with a VR app I’m making. But I’m stuck at the first step which is running a sample scenario. I selected different scenarios for the Pulse Engine Scenario Driver Script scenario file and tried leaving it empty or on the actual empty file that exists under scenarios folder but all I get after i press play on my Unity is: PulsePhysiologyEngine: Unable to initialize patient
UnityEngine.Logger:LogError (string,object)
PulseEngineScenarioDriver:Start () (at Assets/PulsePhysiologyEngine/Scripts/PulseEngineScenarioDriver.cs:166)

I’d appreciate any help or if you could point me to a document or thread that can help me get started with the Unity package. Thanks.

Have you run the VitalsMonitor scene rather than the VitalsMonitorScenario scene?

The VitalsMonitorScenario scene requires that you have created a StreamingAssets folder in the root of your application’s Assets folder (not the PulsePhysiologyEngine folder). Then copy the Pulse asset Data directory into that folder.

Thank you for your response. Yes, and then VitalsMonitor works. But I need to create a scenario using the Pulse Explorer and then have that scenario being shown. Can I do that with the vitals monitor rather than the scenario driver?
One more question if you don’t mind:
Can I get the plots that I can see in the ventilator tab of the Explorer, in Unity somehow? I’m referring to the pressure, volume, and flow plots. In Pulse Data Line Renderer - Data Field, I can’t find flow or volume.

Ok, then you need to follow the VitalsMonitorScenario scene.
Just need to setup your application to have all the data it needs to run the Scenario like I said in the previous post. Or look in our documentation

You will need to build your own plot displaying scene to get something like the Explorer plots.
But just use the Pulse LineRenderer
The Data Field drop down is populated based on the hard coded DataRequests have here

So you will need to add all flow and volume requests you want in that block to be able to build static plot windows similar to the vitals monitor in your application.

If you want dynamic selection and creation of plots at run time… that is going to take much more work, but is possible.

1 Like

I see. Okay but now the problem is, the Pulse Engine Scenario Driver doesn’t accept the Scenario files that are in StreamingAssets>Data>scenarios. It is as if the data type isn’t compatible with the Scenario File field. Even though I just copied the data folder from PulsePhysiologyEngine folder and it does accept them from there. (I think I may have downloaded the scenarios separately though not with the package from Unity store)

To be clear, the same exact files can be used as a Scenario File when they are under PulsePhysiologyEngine>Data>scenarios (the application doesn’t run successfully, but at least I can assign the files as a Scenario File) but not when they are under the StreamingAssets path.

This might be more of a Unity problem that I need to figure out though. I was just wondering if you had any ideas about what’s happening.

Yeah, I am always confusing myself on what needs to be under the StreamingAssets folder, and what can be under the actual asset.

I believe I am demonstrating 2 different ways to get data into Unity here

You can hardcode a path to a file and read it from the StreamingAssets folder
I think that is the only place you can inspect and read from disk in a Unity application

You can also see that the scenarioJson content is actually provided by the Editor, so if you drag a file into a PulseEngineScenarioDriver object in the editor, the editor will read the file and provide the constents as a text stream to the PulseEngineScenarioDriver

So I think you can pick which one works for you and do it

Understood. So I will use the inspector to point at a scenario. However, now I’m back at receiving:

PulsePhysiologyEngine: Unable to initialize patient
UnityEngine.Logger:LogError (string,object)
PulseEngineScenarioDriver:Start () (at Assets/PulsePhysiologyEngine/Scripts/PulseEngineScenarioDriver.cs:166)

I tried different scenarios and receive the same error. I know Unity isn’t your main thing so I really do appreciate you trying to help me.

I assume you are doing sometihng like this

I think Pulse is failing to find the data files it needs from disk

Try adding this line before your InitializeEngine call:


Those directories should be under that Data folder
Hopefully Pulse will then be able to find the files its looking for

Sorry but I just can’t seem to get it to work, I have one scenario that works when I assign it in the inspector. But I want to have this application on VR headsets so I put all the data in streaming assets folder and I’m loading the scenario using:

      string streamingScenarioFilename = Application.streamingAssetsPath + "/Data/scenarios/testPatient.json";
      Debug.Log("Scenario from Streaming assets, file path: " + streamingScenarioFilename);
if (!scenario.SerializeFromFile(streamingScenarioFilename))
        Debug.unityLogger.LogError("PulsePhysiologyEngine", "Unable to load scenario file "+ streamingScenarioFilename);

The if does not run so I’m assuming it can find the scenario. However, I get the error from this if:

if (scenario.HasEngineState())
      Debug.Log("Scenario has engine state");
      // This code is assuming the scenario engine state file is relative to the application streaming path
      string state = Application.streamingAssetsPath+"/Data/states/"+scenario.GetEngineState();
      Debug.Log("Engine State path is " + state);
      if (!engine.SerializeFromFile(state, scenario.GetDataRequestManager()))
        Debug.unityLogger.LogError("PulsePhysiologyEngine", "Unable to load state file " + state);
    else if(scenario.HasPatientConfiguration())
      if (!engine.InitializeEngine(scenario.GetPatientConfiguration(), scenario.GetDataRequestManager()))
        Debug.unityLogger.LogError("PulsePhysiologyEngine", "Unable to initialize patient");

But apparently my scenario does NOT have an engine state and it goes to the second if and i get the error: “Unable to initialize patient”
However, this is in my scenario JSON:

 "Name": "testScenario",
 "Description": "My created scenario.",
 "DataRequestManager": {
      { "DecimalFormat": { "Precision": 1 }, "Category": "Physiology", "PropertyName": "HeartStrokeVolume",                 "Unit": "mL" },
      { "DecimalFormat": { "Precision": 2 }, "Category": "Physiology", "PropertyName": "BloodVolume",                       "Unit": "L" },
      { "DecimalFormat": { "Precision": 1 }, "Category": "Physiology", "PropertyName": "ExtravascularFluidVolume",          "Unit": "L" },
      { "DecimalFormat": { "Precision": 2 }, "Category": "Physiology", "PropertyName": "CardiacOutput",                     "Unit": "L/min" },
      { "DecimalFormat": {                }, "Category": "Physiology", "PropertyName": "HemoglobinContent",                 "Unit": "g" },
      { "DecimalFormat": { "Precision": 2 }, "Category": "Physiology", "PropertyName": "CentralVenousPressure",             "Unit": "mmHg" },
      { "DecimalFormat": { "Precision": 2 }, "Category": "Physiology", "PropertyName": "PulmonaryCapillariesWedgePressure", "Unit": "mmHg" },
      { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TidalVolume",                       "Unit": "mL" }

So it does have a state file and data request manager. So I’m not sure why the state file isn’t visible to the scenario driver.
I tried hard coding the state in too but that didn’t work either and I get the same Unable to initialize patient error:

string state = Application.streamingAssetsPath+"/Data/states/Soldier@0s.pbb";

You can inspect the scenario object when running in the unity editor

It looks like maybe you could have both an engine state and a patient configuration maybe? And it will default to use the patient configuration…