-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
133 lines (115 loc) · 5.81 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
ob_start();
header('Content-Type: text/html; charset=utf-8');
header('Cache-Control: no-cache');
ini_set('display_errors',1);
error_reporting(E_ALL ^ E_NOTICE);
set_time_limit(300);
ini_set('max_execution_time', '300');
$DIR_PYTHON = '/rsna-iaip/rsna-iaip-demo/';
$DIR_DATA = '/rsna-iaip/2025-data/';
$DIR_CTP = '/rsna-iaip/apps/ctp';
$TEAMS = [
0 => ['name'=>'curie-adam', 'folder'=>'curie-adam', 'label'=>'Curie (Patient Adam)'],
1 => ['name'=>'curie-sarah', 'folder'=>'curie-sarah', 'label'=>'Curie (Patient Sarah)'],
2 => ['name'=>'ettinger', 'folder'=>'ettinger', 'label'=>'Ettinger'],
3 => ['name'=>'quimby', 'folder'=>'quimby-prior', 'label'=>'Quimby PRIORS'],
4 => ['name'=>'quimby', 'folder'=>'quimby', 'label'=>'Quimby CURRENTS'],
];
?>
<html>
<head>
<title>RSNA Imaging AI in Practice Demonstration</title>
<h1>Demo Data Generator Self-Serve</h1>
<!-- BOOTSTRAP -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</head>
<body style="padding: 15px; width: 100%;">
<?php
function is_running()
{
$pid_cpt = shell_exec("ps fax | grep -v 'grep' | grep CTP | head -n1 | sed 's/^ *//g' | cut -f 1 -d ' '");
$pid_storescu = shell_exec("ps fax | grep -v 'grep' | grep storescu | head -n1 | sed 's/^ *//g' | cut -f 1 -d ' '");
$pid_stowrs = shell_exec("ps fax | grep -v 'grep' | grep stowrs | head -n1 | sed 's/^ *//g' | cut -f 1 -d ' '");
//print("pid_cpt={$pid_cpt} pid_storescu={$pid_storescu} pid_stowrs={$pid_stowrs} \n");
if( $pid_cpt != '' || $pid_storescu != '' || $pid_stowrs != '' ) {
return true;
}
return false;
}
$is_running = is_running();
$diabled = $is_running ? 'disabled="true"':'';
$mode = array_key_exists('mode', $_REQUEST) ? $_REQUEST['mode']:'';
$team_id = array_key_exists('team_id', $_REQUEST) ? intval($_REQUEST['team_id']):0;
$new_demographics = array_key_exists('new_demographics', $_REQUEST);
$months_offset = array_key_exists('months_offset', $_REQUEST) ? intval($_REQUEST['months_offset']):0;
switch( $mode )
{
case 'run':
if( $is_running )
{
echo "<div class='alert alert-error'>Sorry - request failed due to another session that got started by someone else.</div>\n";
break;
}
if( !in_array($team_id, array_keys($TEAMS)) )
{
echo "<div class='alert alert-error'>Sorry - Unkown team!!</div>\n";
break;
}
$team = $TEAMS[$team_id];
echo "<p>About to kick-off a demo dataset - please hold for the patient name and MRN</p>";
ob_flush();
flush();
// Kick off the generator
$cmd = "cd {$DIR_PYTHON}; python main.py -c {$DIR_CTP} -t {$team['name']} -l './logs' -d {$DIR_DATA}{$team['folder']}";
if( $new_demographics ) {
$cmd .= " -nd True";
}
if( $months_offset > 0 ) {
$cmd .= " -m " . $months_offset;
}
//echo "{$cmd}<br />\n";
$output = shell_exec($cmd);
//var_export($output);
$lines = explode("\n", $output != null ? $output:'');
foreach( $lines as $line )
{
if( strpos($line, 'Patient name') > 0 )
{
echo "<p>{$line}</p>\n";
}
}
echo "<div class='alert alert-success'>Success! Generated a dataset for {$team['label']}</div>\n";
break;
}
if( is_running() )
{
echo "<div class='alert alert-warning'>Warning: Another data generation session is already in progress. Please wait a bit, then refresh to start another session</div>\n";
}
?>
<h2>Generate a new set</h2>
<form action="?" method="POST">
<p>Which team do you want to generate data for?</p>
<?php
foreach( $TEAMS as $index => $team )
{
echo "<input type='radio' name='team_id' id='{$team['folder']}' value='{$index}' /> <label for={$team['folder']}>{$team['label']}</label><br />\n";
}
?>
<input type="checkbox" id="new_demographics" name="new_demographics" value="true" checked="true" /> <label for="new_demographics">Generate new demographics?</label><br />
<p>If checked, new patient demographics will be generated (name, MRN). Otherwise, the demographics from the last run will be used (useful for generating priors and currents)</p>
<label for="months_offset">Months offset</label> <input type="text" name="months_offset" id="months_offset" value="0" /><br />
<p>When generating priors, enter a value like "9" to give them a study date from nine months ago. Otherwise, leave it at zero for today's date.</p>
<input type="hidden" name="mode" value="run" />
<input type="submit" name="submit" value="Submit" class="btn btn-primary" <?php echo $diabled; ?> />
<p>Warning: Once you submit, the page may take a full minute or two before it loads, please hold for the patient name and MRN.</p>
</body>
</html>
<?php
ob_end_flush();
?>