-
Notifications
You must be signed in to change notification settings - Fork 0
/
getCounts.php
300 lines (255 loc) · 9.61 KB
/
getCounts.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<?php
include ("permission_check.php");
$research = $_REQUEST['research'];
// Define all the necessary classes needed for the application
require_once('class/class.type.php');
require_once('class/class.izhmodelsmodel.php');
require_once('counts/class/class.counts.php');
define('ORANGE', '#FF8C00');
define('BLUE', '#0000FF');
define('BROWN', '#7A5230');
define('GRAY', '#808080');
define('WHITE', '#FFFFFF');
// check for link
/*
* $id - Type id
* $img - img path
* $key - DG_Smo For Type SMo 0f DG
* $color - red/blue or violet
* */
if(!isset($_GET['page'])) $page=1;
else $page = $_GET['page'];
//page=1&rows=5&sidx=1&sord=asc
// get how many rows we want to have into the grid - rowNum parameter in the grid
if(!isset($_GET['rows'])) $limit=200;
else $limit = $_GET['rows'];
// get index row - i.e. user click to sort. At first time sortname parameter -
// after that the index from colModel
if(!isset($_GET['sidx'])) $sidx=1;
else $sidx = $_GET['sidx'];
// sorting order - at first time sortorder
if(!isset($_GET['sord'])) $sord="asc";
else $sord = $_GET['sord'];
// if we not pass at first time index use the first column for the index or what you want
if(!$sidx) $sidx =1;
$number_type = 0;
$type = new type($class_type);
$izhmodelsmodel = new izhmodelsmodel($class_izhmodels_model);
$counts = new counts($class_counts);
$research = $_REQUEST['research'];
$table = $_REQUEST['table_result'];
if (isset($research)) // From page of search; retrieve the id from search_table (temporary) -----------------------
{
echo("<script>console.log('PHP: In ifvich.php');</script>");
$table_result = $_REQUEST['table_result'];
$temporary_result_neurons = new temporary_result_neurons();
$temporary_result_neurons -> setName_table($table_result);
$temporary_result_neurons -> retrieve_id_array();
$n_id_res = $temporary_result_neurons -> getN_id();
$number_type = 0;
for ($i2=0; $i2<$n_id_res; $i2++)
{
$id2 = $temporary_result_neurons -> getID_array($i2); // Retrieve each ID corresponding to the id Array
if (strpos($id2, '0_') == 1);
else
{
$type -> retrive_by_id($id2); // For each Id retrieve the type characteristics
$status = $type -> getStatus(); // Retrieve the status for each id
if ($status == 'active')
{
$id_search[$number_type] = $id2;
$position_search[$number_type] = $type -> getPosition();
$number_type = $number_type + 1;
}
}
} // END $i2
array_multisort($position_search, $id_search);
// sort($id_search);
}
else // not from search page --------------
{
echo("<script>console.log('PHP: In elsevich.php');</script>");
if($_GET['_search']=='false') // Condition to check ifthe
{
$type -> retrive_id();
$number_type = $type->getNumber_type();
}
else{
//Retrieve types by Search conditions
//echo "Search ".$_GET['_search'];
/* echo "Search Field : ".$_GET['searchField']; // – the name of the field defined in colModel
echo "Search String : ".$_GET['searchString']; // – the string typed in the search field
echo "Search Operator : ".$_GET['searchOper']; //– the operator choosen in the search field (ex. equal, greater than, …) */
}
}
$count = $number_type;
//echo "The number of elements are ".$count." and the limit is ".$limit;
if($count <= $limit)
$limit = $count;
// calculate the total pages for the query
if( $count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
// if for some reasons the requested page is greater than the total
// set the requested page to total page
if ($page > $total_pages)
$page=$total_pages;
// calculate the starting position of the rows
$start = $limit*$page - $limit;
// if for some reasons start position is negative set it to 0
// typical case is that the user type 0 for the requested page
if($start <0)
$start = 0;
$n_DG = 0;
$n_CA3 = 0;
$n_CA2 = 0;
$n_CA1 = 0;
$n_SUB = 0;
$n_EC = 0;
//header("Content-type: application/json;charset=utf-8");
$responce = (object) array('page' => $page, 'total' => $total_pages, 'records' =>$count, 'rows' => "");
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
if($research!="1")
{
//$type -> retieve_ordered_List($start,$limit);
$type -> retrive_id();
$number_type = $type->getNumber_type();
$type -> retrieve_id_by_subregion_v1p0('DG');
$nDG = $type->getNumber_subregion_type();
$type -> retrieve_id_by_subregion_v1p0('CA3');
$nCA3 = $type->getNumber_subregion_type();
$type -> retrieve_id_by_subregion_v1p0('CA2');
$nCA2 = $type->getNumber_subregion_type();
$type -> retrieve_id_by_subregion_v1p0('CA1');
$nCA1 = $type->getNumber_subregion_type();
$type -> retrieve_id_by_subregion_v1p0('Sub');
$nSub = $type->getNumber_subregion_type();
$type -> retrieve_id_by_subregion_v1p0('EC');
$nEC = $type->getNumber_subregion_type();
}
$neuron = array("DG"=>'DG('.$nDG.')',"CA3"=>'CA3('.$nCA3.')',"CA3c"=>'CA3('.$nCA3.')',"CA2"=>'CA2('.$nCA2.')',"CA1"=>'CA1('.$nCA1.')',"Sub"=>'Sub('.$nSub.')',"EC"=>'EC('.$nEC.')');
//$neuron = array("DG"=>'DG(35)',"CA3"=>'CA3(35)',"CA3c"=>'CA3(35)',"CA2"=>'CA2(5)',"CA1"=>'CA1(60)',"Sub"=>'Sub(7)',"EC"=>'EC(33)');
$neuronColor = array("DG"=>'#770000',"CA3"=>'#C08181',"CA3c"=>'#C08181',"CA2"=>'#FFCC00',"CA1"=>'#FF6103',"SUB"=>'#FFCC33',"EC"=>'#336633');
echo("<script>console.log('PHP: In getizhikevich.php');</script>");
// main logic for calculating anf filling json starts here -->
$ii = -1;
for($i = 0; $i<$number_type; $i++)
{
if(isset($id_search))
{
$id = $id_search[$i];
}
else
{
$id = $type->getID_array($i);
}
$type -> retrive_by_id($id); // Retrieve id
$nickname = $type->getNickname(); // Retrieve nick name
$name = $type->getName();
$position = $type->getPosition(); // Retrieve the position
$subregion = $type -> getSubregion(); // Retrieve the sub region
$excit_inhib =$type-> getExcit_Inhib(); //Retrieve the Excit or Inhib
$optimum = $counts -> retrieve_counts($id);
$lower_bound = $counts -> retrieve_lower_bound($id);
$upper_bound = $counts -> retrieve_upper_bound($id);
/*
$izhmodelsmodelArray = $izhmodelsmodel->getElementsArray($id);
$min;
$max;
$mean;
//initialise the min max and mean array...
foreach($izhmodelsmodelArray as $izIteration)
{
$min[$izIteration] = 10000; // setting min greater than max absolute value in the table.
$max[$izIteration] = -99999; // setting the max lesser than min absolute value in the table.
$mean[$izIteration] = -99999;
}
$getterString;
$getterValue;
$iterator = 0;
$izValues = $izhmodelsmodel->get_all_id($id);
foreach ($izValues as $variable) {
$iterator++;
foreach($izhmodelsmodelArray as $izIteration)
{
$getterString = "get".$izIteration;
$getterValue = $variable->{$getterString}(); // gets the getter for that specific colunm
error_log("ID ".$id." For getter ".$getterString." , the value is ".$getterValue);
if((string)$getterValue===""){
if($min[$izIteration]==10000){
$min[$izIteration] = "";
}
if($max[$izIteration]==-99999){
$max[$izIteration] = "";
}
if($mean[$izIteration]==-99999){
$mean[$izIteration] = "";
}
continue;
}
if($min[$izIteration]>$getterValue)
{
$min[$izIteration] = round($getterValue,4);
}
if($max[$izIteration] < $getterValue)
{
$max[$izIteration] = round($getterValue,4);
}
if($variable->getPreferred() == 'Y')
{
$mean[$izIteration] = round($getterValue,4);
}
}
}
*/
$type -> retrieve_v2p0_by_id($id);
$v2p0 = $type -> getV2p0();
if ($v2p0 == 0)
{
$ii = $ii + 1;
//Code for Json generation starts...
if ($excit_inhib == 'e')
$fontColor='#339900';
elseif ($excit_inhib == 'i')
$fontColor='#CC0000';
if ($type->get_type_subtype($id) == 'subtype')
{
$fontColor='#000099';
if ($excit_inhib == 'i')
$fontColor='#CC5500';
$rows[$ii]['cell'][0] = '<span style="color:'.$neuronColor[$subregion].'"><strong>'.$neuron[$subregion].'</strong></span>';
$rows[$ii]['cell'][1] = " ".'<a href="neuron_page.php?id='.$id.'" target="blank" title="'.$type->getName().'"><font color="'.$fontColor.'">'.$nickname.'</font></a>';
if ($optimum == 0){
$rows[$ii]['cell'][2] = '';
}else{
$rows[$ii]['cell'][2] = '<span class="link_left font4"><a href = "property_page_counts.php?id_neuron='.$id.'&val_property=counts" target="_blank">'.$optimum.'<span class = "link_left"> ['.$lower_bound.', '.$upper_bound.']</span></a></span>';
}
if ($optimum == 0){
$rows[$ii]['cell'][3] = '';
}else{
$rows[$ii]['cell'][3] = '<span class="link_left font4">'.round($optimum*0.41).'</span>';
}
}
else
{
$rows[$ii]['cell'][0] = '<span style="color:'.$neuronColor[$subregion].'"><strong>'.$neuron[$subregion].'</strong></span>';
$rows[$ii]['cell'][1] = '<a href="neuron_page.php?id='.$id.'" target="blank" title="'.$type->getName().'"><font color="'.$fontColor.'">'.$nickname.'</font></a>';
if ($optimum == 0){
$rows[$ii]['cell'][2] = '';
}else{
$rows[$ii]['cell'][2] = '<span class="link_left font4"><a href = "property_page_counts.php?id_neuron='.$id.'&val_property=counts" target="_blank">'.$optimum.'<span class = "link_left"> ['.$lower_bound.', '.$upper_bound.']</span></a></span>';
}
if ($optimum == 0){
$rows[$ii]['cell'][3] = '';
}else{
$rows[$ii]['cell'][3] = '<span class="link_left font4">'.round($optimum*0.41).'</span>';
}
}
}
$responce->rows = $rows;
}
?>