So I used to be able to do the following in Unity to create my state but it seems like a lot of these methods are now gone? Any guidance on how to achieve the same?
public void GenerateEditorStateFromScenario()
{
Debug.Log("Using Pulse version " + PulseEngine.Version() + "-" + PulseEngine.Hash());
string scenarioPath = AssetDatabase.GetAssetPath(initialScenarioFile);
//The path for the data to create a state
string pulseDataPath="";
SEScenarioExec execOpts = new SEScenarioExec();
var appDirectory = new DirectoryInfo(Application.dataPath);
if (appDirectory.Exists)
{
var rootPath = appDirectory.Parent;
pulseDataPath = $"{CourseHelper.Instance.GetCaffeinePackagePath()}3RD/PulsePhysiologyEngine/Data";
}
// Set the directory where Pulse can find its data files (usally bin/install)
execOpts.SetDataRootDirectory(pulseDataPath);
// Where do you want any states created by scenarios to go?
execOpts.SetSerializationDirectory(Application.persistentDataPath + "/" +
gameObject.name + "/states/");
// Set empty CSV dir if you do not want a csv file
execOpts.SetDataRequestCSVFilename("");
//execOpts.SetDataRequestCSVFilename("");
execOpts.SetLogFilename(Application.persistentDataPath + "/" +
gameObject.name + "/scenarios/PulseScenarioRunner.log");
execOpts.SetScenarioFilename(scenarioPath);
//Modify the path to serialize
JObject scenarioJSON = JObject.Parse(initialScenarioFile.text);
string newStatePath = Application.dataPath + "/Pulse States/" + initialScenarioFile.name + "_state.json";
scenarioJSON.SelectToken("..Filename").Replace(newStatePath);
//Overwrite with new content
File.WriteAllText(scenarioPath, scenarioJSON.ToString());
PulseUnityEngine pulse = new PulseUnityEngine();
if (!pulse.ExecuteScenario(execOpts))
Debug.Log("Error running scenario");
AssetDatabase.Refresh();
initialState = AssetDatabase.LoadAssetAtPath("Assets" + "/Pulse States/" + initialScenarioFile.name + "_state.json", typeof(TextAsset)) as TextAsset;
}
Please, I started to use pulse engine in unity, and all i know to do is to run an existing scenario, and now i need to creat my own, can i have some guidance please, and thank you
Thank you again for your response, i have a second question, in my case, I want to simulate a COPD/pneumonia scenario in which I ask two questions to the participant.
The first question will be to ask them to identify the relevant clinical cues, in this initial state, I need to have specific vitals displayed on the monitor, I believe this would be my T0 state.
The second question will ask the participant to perform an action, and these actions should have an effect on the vital signs shown on the monitor.
So, my first question is: do I only need to use states, or do I need to use a full scenario?
And my second question, sorry for asking so much, is: what is the workflow to create a state file from an edited scenario?
In Pulse Explorer, it seems I only have the option to save a scenario, not a state.
Your application should use a state file. T0 as you describe it.
You should save the scenario that makes your state into your code repository.
As Pulse evolves from version to version, the variables in the state file no longer reflect changes in the variables of the new version. We may add new variables that your state does not have. We may remove variables that your state has. Needless to say, it would be quite an undertaking to maintain backwards compatibility of state files.
The solution to this is to save a scenario file that runs Pulse to create your state file.
Scenarios are also not backwards compatible, but the actions they contain rarely change (but it does happen) but its pretty simple to manually update those files if needed.
But as Pulse is always changing, a model update can affect the expected physiology of your state. So as you upgrade Pulse versions, you should ensure you state files still demonstrate the learning objectives you need. For example, we have been working with subject matter experts to improve our ARDS/COPD models to improve their validation. These updates are not in the current Unity asset. They may or may not have impacts on your application learning objectives. (Hopefully for the better, we are putting a lot of effort into this work)
On to your question as to how create states in the explorer. Just use a Serialization action from the actions tab.
Once you have a scenario that creates the patient physiology you want along with the serializtion action to create that state for your application, save that scenario out and keep it, so you can rerun it when our next version comes out.
One of the issues I’m currently facing is related to temperature. In Pulse Explorer, when I save a state, the temperature is 37.1°C. However, when I run the same state using the Pulse Engine Driver in unity, the temperature is 32°C. And when I run a scenario using that same state, the temperature starts to rise and doesn’t stop, it exceeds 50°C.