An update will be applied January 25th, between 12PM and 1:00PM EST (UTC -5:00). The site may be slow during that time.

Commit c927548e authored by Jeff Webb's avatar Jeff Webb
Browse files

Merge branch 'feature/respiratory_disease' of...

Merge branch 'feature/respiratory_disease' of https://gitlab.kitware.com/physiology/engine into feature/respiratory_disease
parents ff5e75b0 663c3813
......@@ -3,6 +3,7 @@
root_dir=@CMAKE_SOURCE_DIR@/
data_dir=@CMAKE_SOURCE_DIR@/data
scenario_dir=@CMAKE_SOURCE_DIR@/test/scenarios
test_config_dir=@CMAKE_SOURCE_DIR@/test/config
validation_dir=@CMAKE_SOURCE_DIR@/test/validation
verification_dir=@CMAKE_INSTALL_PREFIX@/bin/verification
\ No newline at end of file
......@@ -166,6 +166,8 @@ const SEScalar* SERespiratorySystem::GetScalar(const std::string& name)
return &GetInspiratoryPulmonaryResistance();
if (name.compare("IntrapleuralPressure") == 0)
return &GetIntrapleuralPressure();
if (name.compare("IntrapulmonaryPressure") == 0)
return &GetIntrapulmonaryPressure();
if (name.compare("LungCompliance") == 0)
return &GetLungCompliance();
if (name.compare("MaximalInspiratoryPressure") == 0)
......@@ -216,6 +218,8 @@ const SEScalar* SERespiratorySystem::GetScalar(const std::string& name)
return &GetTransalveolarPressure();
if (name.compare("TransChestWallPressure") == 0)
return &GetTransChestWallPressure();
if (name.compare("TransMusclePressure") == 0)
return &GetTransMusclePressure();
if (name.compare("TranspulmonaryPressure") == 0)
return &GetTranspulmonaryPressure();
if (name.compare("TransrespiratoryPressure") == 0)
......
......@@ -14,16 +14,18 @@ import org.jfree.util.Log;
*/
public class RunConfiguration
{
protected String rootDirectory;
protected String rootDirectory;
protected String dataDirectory;
protected String scenarioDirectory;
protected String testConfigDirectory;
protected String validationDirectory;
protected String verificationDirectory;
public String getRootDirectory() { return rootDirectory; }
public String getDataDirectory() { return dataDirectory; }
public String getScenarioDirectory() { return scenarioDirectory; }
public String getTestConfigDirectory() { return testConfigDirectory; }
public String getValidationDirectory() { return validationDirectory; }
public String getValidationDirectory() { return validationDirectory; }
public String getVerificationDirectory() { return verificationDirectory; }
......@@ -32,6 +34,7 @@ public class RunConfiguration
// Default values
rootDirectory = "./";
dataDirectory = "./";
scenarioDirectory = "./";
testConfigDirectory = "./";
validationDirectory = "./";
verificationDirectory = "./";
......@@ -83,6 +86,18 @@ public class RunConfiguration
Log.error("data_dir set to invalid directory "+val+", ignoring and using default ("+this.dataDirectory+")");
}
}
if(properties.containsKey("scenario_dir"))
{
String val = properties.get("scenario_dir").toString();
if(!val.startsWith("@"))
{
File dir = new File(val);
if(dir.exists() && dir.isDirectory())
scenarioDirectory = val;
else
Log.error("scenario_dir set to invalid directory "+val+", ignoring and using default ("+this.scenarioDirectory+")");
}
}
if(properties.containsKey("test_config_dir"))
{
String val = properties.get("test_config_dir").toString();
......
......@@ -16,162 +16,158 @@ import com.kitware.physiology.utilities.RunConfiguration;
public class Rebase
{
public static void main(String[] args)
{
jniBridge.initialize();
rebase();
jniBridge.deinitialize();
}
public static void rebase()
{
RunConfiguration cfg = new RunConfiguration();
Log.setFileName("Rebase.log");
String toDir = "./test_results/rebase/";
List<String> configFiles = new ArrayList<String>();
try
{
File file = new File(cfg.getTestConfigDirectory()+"/Rebase.config");
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String line;
while ((line = bufferedReader.readLine()) != null)
{
line = line.trim();
if(line.indexOf("#")>-1)
continue;
if(line.indexOf(".config")==-1)
continue;
configFiles.add(line);
}
fileReader.close();
}
catch(IOException ex)
{
Log.error("Unable to open Rebase.config, check your run.config file test_config_dir");
return;
}
// Replace back slashes with forward slashes
toDir = toDir.replaceAll("\\\\", "/");
toDir += new SimpleDateFormat("yyyy-MM-dd").format(new Date());
// Ask git what the current revision hash is
try
{
FileRepository repo = new FileRepository(cfg.getRootDirectory()+"/.git");
ObjectId head = repo.resolve("HEAD");
if(head!=null)
toDir += " - "+head.getName().substring(0,8);
repo.close();
}
catch(IOException ex)
{
Log.error("Unable to read git hash, check your run.config file root_dir");
}
toDir += "/";
public static void main(String[] args)
{
jniBridge.initialize();
rebase();
jniBridge.deinitialize();
}
public static void rebase()
{
RunConfiguration cfg = new RunConfiguration();
Log.setFileName("Rebase.log");
String toDir = "./test_results/rebase/";
List<String> configFiles = new ArrayList<String>();
try
{
File file = new File(cfg.getTestConfigDirectory()+"/Rebase.config");
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String line;
while ((line = bufferedReader.readLine()) != null)
{
line = line.trim();
if(line.indexOf("#")>-1)
continue;
if(line.indexOf(".config")==-1)
continue;
configFiles.add(line);
}
fileReader.close();
}
catch(IOException ex)
{
Log.error("Unable to open Rebase.config, check your run.config file test_config_dir");
return;
}
// Replace back slashes with forward slashes
toDir = toDir.replaceAll("\\\\", "/");
toDir += new SimpleDateFormat("yyyy-MM-dd").format(new Date());
// Ask git what the current revision hash is
try
{
FileRepository repo = new FileRepository(cfg.getRootDirectory()+"/.git");
ObjectId head = repo.resolve("HEAD");
if(head!=null)
toDir += " - "+head.getName().substring(0,8);
repo.close();
}
catch(IOException ex)
{
Log.error("Unable to read git hash, check your run.config file root_dir");
}
toDir += "/";
Log.info("Rebasing to "+toDir);
Log.info("Rebasing to "+toDir);
// Make sure from/to dir ends with a slash
if(!toDir.endsWith("/"))
toDir = toDir + "/";
try
{
FileUtils.delete(toDir);
FileUtils.createDirectory(toDir);
}
catch(Exception ex)
{
Log.error("Could not create to Directory : "+toDir,ex);
return;
}
// Make sure from/to dir ends with a slash
if(!toDir.endsWith("/"))
toDir = toDir + "/";
try
{
FileUtils.delete(toDir);
FileUtils.createDirectory(toDir);
}
catch(Exception ex)
{
Log.error("Could not create to Directory : "+toDir,ex);
return;
}
String log_file;
String scenario_file;
String result_path;
List<String> result_files = new ArrayList<String>();
String log_file;
String result_path;
List<String> result_files = new ArrayList<String>();
for(String configFile : configFiles)
{
Log.info("Rebasing config "+configFile);
SETestConfiguration config = new SETestConfiguration();
config.processConfigFile(new File(cfg.getTestConfigDirectory()+"/"+configFile), cfg);
for(String configFile : configFiles)
{
Log.info("Rebasing config "+configFile);
SETestConfiguration config = new SETestConfiguration();
config.processConfigFile(new File(cfg.getTestConfigDirectory()+"/"+configFile), cfg);
for(SETestJob job : config.jobs)
{
if(job.computedFiles.size()<=0)
{
Log.error("A job has no expected result files!?!?");
continue;
}
if(!job.PlottableResults && !job.isAssessment)
continue;// Nothing to plot/compare, nothing to zip
// We assume all json will have something to zip...
log_file = "";
scenario_file = "";
result_files.clear();
result_path = job.computedFiles.get(0);
if(!new File(result_path).exists())
{
Log.error("Unable to find file to rebase for "+job.name+" at path "+result_path);
continue;
}
// If there is no baselineDirectory, then this must be an assessment...
if(job.name.endsWith(".json") && !job.isAssessment)
{
scenario_file = job.baselineDirectory+job.name;
if(job.computedFiles.size()>1)
{
Log.error("A scenario file has more than one result file!?!?");
continue;
}
result_files.add(result_path);
log_file = result_files.get(0).replaceAll("Results"+SETestConfiguration.ext, ".log");
result_files.add(log_file);
result_files.add(scenario_file);
Log.info("Adding scenario file"+scenario_file);
}
else
{
// Its a unit test, only zip up the results
result_files.addAll(job.computedFiles);
}
for(SETestJob job : config.jobs)
{
if(job.computedFiles.size()<=0)
{
Log.error("A job has no expected result files!?!?");
continue;
}
if(!job.PlottableResults && !job.isAssessment)
continue;// Nothing to plot/compare, nothing to zip
// We assume all json will have something to zip...
log_file = "";
result_files.clear();
result_path = job.computedFiles.get(0);
if(!new File(result_path).exists())
{
Log.error("Unable to find file to rebase for "+job.name+" at path "+result_path);
continue;
}
// If there is no baselineDirectory, then this must be an assessment...
if(job.name.endsWith(".json") && !job.isAssessment)
{
if(job.computedFiles.size()>1)
{
Log.error("A scenario file has more than one result file!?!?");
continue;
}
result_files.add(result_path);
log_file = result_files.get(0).replaceAll("Results"+SETestConfiguration.ext, ".log");
result_files.add(log_file);
Log.info("Creating zip for "+result_files.get(0));
}
else
{
// Its a unit test, only zip up the results
result_files.addAll(job.computedFiles);
}
String prepend = result_path.substring(result_path.indexOf("test_results/")+13,result_path.lastIndexOf("."));
int ridx = prepend.indexOf("Results");
if(ridx>-1)
prepend = prepend.substring(0,ridx);
String newFile = toDir + prepend + ".zip";
String prepend = result_path.substring(result_path.indexOf("test_results/")+13,result_path.lastIndexOf("."));
int ridx = prepend.indexOf("Results");
if(ridx>-1)
prepend = prepend.substring(0,ridx);
String newFile = toDir + prepend + ".zip";
Log.info("Creating new file "+newFile);
String rPath = "";
for(String rDir : newFile.split("/"))
{
if(rDir.endsWith(".zip"))
{
break;
}
rPath += rDir + "/";
}
try
{
Log.info("Creating new file "+newFile);
String rPath = "";
for(String rDir : newFile.split("/"))
{
if(rDir.endsWith(".zip"))
{
break;
}
rPath += rDir + "/";
}
try
{
Log.info("Creating "+rPath);
FileUtils.createDirectory(rPath);
}
catch (IOException ex)
{
Log.error("Could not create directory : "+rPath, ex);
}
File oldZip = new File(newFile);
if(oldZip.exists())
oldZip.delete();
String[] files = new String[result_files.size()];
files = result_files.toArray(files);
FileUtils.zipFiles(files, newFile,prepend+".zip");
}
}
}
FileUtils.createDirectory(rPath);
}
catch (IOException ex)
{
Log.error("Could not create directory : "+rPath, ex);
}
File oldZip = new File(newFile);
if(oldZip.exists())
oldZip.delete();
String[] files = new String[result_files.size()];
files = result_files.toArray(files);
FileUtils.zipFiles(files, newFile,prepend+".zip");
}
}
}
}
......@@ -26,6 +26,8 @@ public class SETestJob extends LogListener
public boolean PlottableResults = false;
public PlotType plotType = PlotType.FastPlot;//Only plot every nth data point
public double percentDifference;
public List<String> scenarioFiles = new ArrayList<String>();
public String scenarioDirectory = null;
public List<String> baselineFiles = new ArrayList<String>();
public String baselineDirectory = null;
public List<String> computedFiles = new ArrayList<String>();
......
......@@ -22,10 +22,10 @@ public class ScenarioTestDriver implements SETestDriver.Executor
String outputFile = job.computedDirectory+"/"+job.name;
String log;
String results;
String json = FileUtils.readFile(job.baselineDirectory+"/"+job.name);
String json = FileUtils.readFile(job.scenarioDirectory+"/"+job.name);
if(json==null)
{
Log.error("Could not read file : "+job.baselineDirectory+"/"+job.name);
Log.error("Could not read file : "+job.scenarioDirectory+"/"+job.name);
return false;
}
ScenarioData.Builder builder;
......@@ -44,7 +44,7 @@ public class ScenarioTestDriver implements SETestDriver.Executor
}
catch(InvalidProtocolBufferException ex2)
{
Log.error("Unable to read scenario"+job.baselineDirectory+"/"+job.name,ex2);
Log.error("Unable to read scenario"+job.scenarioDirectory+"/"+job.name,ex2);
return false;
}
}
......
{
"Name": "Cynthia",
"Description": "Inject Cynthia with Midazolam. Reaction to sedative causes an airway obstruction. An anesthesia machine mask is applied to attempt to supply Oxygen. Ketamine is administered and the airway obstruction is cleared. Rocuronium is administered. Patient is then intubated.",
"StartType": {
"PatientConfiguration": {
"PatientFile": "Cynthia.json"
}
},
"DataRequestManager": {
"DataRequest": [{
"DecimalFormat": {
"Precision": 1
},
"PropertyName": "Weight",
"Unit": "kg"
}, {
"DecimalFormat": {
"Precision": 2
},
"Category": "Physiology",
"PropertyName": "HeartRate",
"Unit": "1/min"
}, {
"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": 1
},
"Category": "Physiology",
"PropertyName": "ArterialPressure",
"Unit": "mmHg"
}, {
"DecimalFormat": {
"Precision": 1
},
"Category": "Physiology",
"PropertyName": "MeanArterialPressure",
"Unit": "mmHg"
}, {
"DecimalFormat": {
},
"Category": "Physiology",
"PropertyName": "SystolicArterialPressure",
"Unit": "mmHg"
}, {
"DecimalFormat": {
"Precision": 1
},
"Category": "Physiology",
"PropertyName": "DiastolicArterialPressure",
"Unit": "mmHg"
}, {
"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"
}, {
"DecimalFormat": {
"Precision": 2
},
"Category": "Physiology",
"PropertyName": "TotalLungVolume",
"Unit": "L"
}, {
"DecimalFormat": {
"Precision": 2
},
"Category": "Physiology",
"PropertyName": "RespirationRate",
"Unit": "1/min"
}, {
"DecimalFormat": {
"Precision": 3
},
"Category": "Physiology",
"PropertyName": "OxygenSaturation",
"Unit": "unitless"
}, {
"DecimalFormat": {
"Precision": 3
},
"Category": "Physiology",
"PropertyName": "CarbonDioxideSaturation",
"Unit": "unitless"
}, {
"DecimalFormat": {
"Precision": 4
},
"Category": "Physiology",
"PropertyName": "EndTidalCarbonDioxideFraction",
"Unit": "unitless"
}, {
"DecimalFormat": {
"Precision": 2
},
"Category": "Physiology",
"PropertyName": "TotalAlveolarVentilation",
"Unit": "L/min"
}, {
"DecimalFormat": {
"Precision": 2
},
"Category": "Physiology",
"PropertyName": "TranspulmonaryPressure",
"Unit": "cmH2O"
}, {
"DecimalFormat": {
"Precision": 1
},
"Category": "Physiology",
"PropertyName": "CoreTemperature",
"Unit": "degC"
}, {