Merge pull request #5243 from solgenomics/topic/observations_upload_catch_error
[sgn.git] / mason / breeders_toolbox / drone_imagery / drone_imagery_analytics.mas
blobb6f3228de380009749f31676ffc1fada76cbe663
1 <%args>
2 </%args>
4 <div class="modal fade" id="drone_imagery_analytics_dialog" name="drone_imagery_analytics_dialog" tabindex="-1" role="dialog" aria-labelledby="droneImageryAnalyticsDialog" data-backdrop="static">
5   <div class="modal-dialog modal-xl" role="document">
6     <div class="modal-content">
7       <div class="modal-header">
8         <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
9         <h4 class="modal-title" id="droneImageryAnalyticsDialog">Perform analytics on aerial image phenotypes</h4>
10       </div>
11       <div class="modal-body">
12         <div class="container-fluid">
14             <&| /util/workflow.mas, id=> "drone_imagery_analytics_workflow" &>
15                 <&| /util/workflow.mas:step, title=> "Field Trial" &>
16                     <& /page/page_title.mas, title=>"Select the field trial you are interested in. Select only one. Field trial MUST have row and column assigned and should be a rectangular design." &>
17                     <br/><br/>
18                     <form class="form-horizontal">
19                         <div class="form-group">
20                             <label class="col-sm-3 control-label">Field Trial(s): </label>
21                             <div class="col-sm-9" >
22                                 <div id="drone_imagery_analytics_trial_select_div"></div>
23                             </div>
24                         </div>
25                     </form>
26                     <center>
27                     <button class="btn btn-primary" id="drone_imagery_analytics_field_trial_select_step">Go to Next Step</button>
28                     </center>
29                 </&>
30                 <&| /util/workflow.mas:step, title=> "Analytics Reporting" &>
31                     <& /page/page_title.mas, title=>"Select an Analytics Protocol to save the results to or create a new one" &>
33                     <div id="drone_imagery_analytics_analytics_protocols_select_div">Loading...</div>
35                     <& /page/page_title.mas, title=>"Select the type of analysis to run" &>
37                     <div class="well well-sm">
38                         <select class="form-control" id="drone_imagery_analytics_select_input">
39                             <!--option value="">Sommer Multi/Uni Spatial 2Dspl, REMLf90 RR Identiy/Env, ASREML Uni Spatial AR1xAR1</option-->
40                             <!--option value="lmer_germplasmname_replicate">LMER BLUPs y~replicate+1|Germplasm. Univariate genetic effects</option-->
42                             <!--option value="sommer_grm_genetic_blups">Sommer GBLUPs Y~replicate+GRM. Multivariate genetic effects using GRM</option-->
44                             <option value="sommer_grm_spatial_genetic_blups">Sommer Spatial GBLUPs Y~replicate+GRM+Row+Col+2Dspline. Multivariate genetic + 2Dspl spatial effects</option>
45                             <option value="sommer_grm_spatial_pure_2dspl_genetic_blups">Sommer Spatial GBLUPs Y~replicate+GRM+2Dspline. Multivariate genetic + 2Dspl spatial effects</option>
46                             <option value="sommer_grm_univariate_spatial_genetic_blups">Sommer Spatial GBLUPs Y~replicate+GRM+Row+Col+2Dspline. Univariate genetic + 2Dspl spatial effects</option>
47                             <option value="sommer_grm_univariate_spatial_pure_2dspl_genetic_blups">Sommer Spatial GBLUPs Y~replicate+GRM+2Dspline. Univariate genetic + 2Dspl spatial effects</option>
49                             <!--option value="blupf90_grm_random_regression_dap_blups">BLUPf90 GBLUPs Y~replicate+GRM+temporal random regression using days after planting. Multivariate genetic + permanent environment effects</option>
50                             <option value="blupf90_grm_random_regression_gdd_blups">BLUPf90 GBLUPs Y~replicate+GRM+temporal random regression using growing degree days. Multivariate genetic + permanent environment effects</option-->
52                             <option value="airemlf90_grm_random_regression_dap_blups">AIREMLf90 GBLUPs Y~replicate+GRM+temporal random regression using days after planting. Multivariate genetic + permanent environment effects</option>
54                             <option value="asreml_grm_univariate_spatial_genetic_blups">ASREML Spatial GBLUPs Y~replicate+GRM+Row+Col+spatial. Univariate genetic + AR1xAR1 spatial effects</option>
55                             <option value="asreml_grm_univariate_pure_spatial_genetic_blups">ASREML Spatial GBLUPs Y~replicate+GRM+spatial. Univariate genetic + AR1xAR1 spatial effects</option>
56                             <option value="asreml_grm_multivariate_spatial_genetic_blups">ASREML Spatial GBLUPs Y~replicate+GRM+spatial. Multivariate genetic + AR1xAR1 spatial effects</option>
58                             <!--option value="airemlf90_grm_random_regression_gdd_blups">AIREMLf90 GBLUPs Y~replicate+GRM+temporal random regression using growing degree days. Multivariate genetic + permanent environment effects</option-->
60                             <!--option value="sommer_grm_temporal_random_regression_dap_genetic_blups">Sommer Temporal Random Regression GBLUPs Y~replicate+GRM+LegendrePoly. Multivariate genetic + permanent environment effects using days after planting</option>
61                             <option value="sommer_grm_temporal_random_regression_gdd_genetic_blups">Sommer Temporal Random Regression GBLUPs Y~replicate+GRM+LegendrePoly. Multivariate genetic + permanent environment effects using growing degree days</option>
62                             <option value="sommer_grm_genetic_only_random_regression_dap_genetic_blups">Sommer Random Regression GBLUPs Y~replicate+GRM+LegendrePoly. Multivariate genetic effects using days after planting</option>
63                             <option value="sommer_grm_genetic_only_random_regression_gdd_genetic_blups">Sommer Random Regression GBLUPs Y~replicate+GRM+LegendrePoly. Multivariate genetic effects using growing degree days</option-->
65                         </select>
67                         <br/><br/>
68                         <div class="form-horizontal">
69                             <div class="form-group">
70                                 <label class="col-sm-5 control-label">Simulated Environments (Linear, 1D-Normal, 2D-Normal, Random, AR1xAR1): </label>
71                                 <div class="col-sm-7" >
72                                     <select class="form-control" id="drone_imagery_analytics_select_sim_env_change_over_time_type">
73                                         <option value="">Constant over timepoints</option>
74                                         <option value="changing_gradual">Gradual change over timepoints</option>
75                                     </select>
76                                 </div>
77                             </div>
78                             <div class="form-group">
79                                 <label class="col-sm-5 control-label">Perform Cross Validation (Can take a long time): </label>
80                                 <div class="col-sm-7" >
81                                     <select class="form-control" id="drone_imagery_analytics_select_perform_cv">
82                                         <option value="0">No</option>
83                                         <option value="1">Yes</option>
84                                     </select>
85                                 </div>
86                             </div>
87                         </div>
88                     </div>
90                     <hr>
91                     <center>
92                         <button class="btn btn-default" id="drone_imagery_analytics_analytics_project_new_button">Create a New Analytics Protocol</button>
93                     </center>
95                     <div id="drone_imagery_analytics_analytics_project_new_div" style="display:none">
96                         <br/><br/>
97                         <div class="well well-sm">
98                             <div class="form-horizontal">
99                                 <div class="form-group">
100                                     <label class="col-sm-3 control-label">Analytics Name: </label>
101                                     <div class="col-sm-9" >
102                                         <input type="text" class="form-control" id="drone_imagery_analytics_select_analytics_name" />
103                                     </div>
104                                 </div>
105                                 <div class="form-group">
106                                     <label class="col-sm-3 control-label">Analytics Type: </label>
107                                     <div class="col-sm-9" >
108                                         <select class="form-control" id="drone_imagery_analytics_select_analytics_type">
109                                             <option value="minimize_local_env_effect">Minimize Spatial or PE Effects</option>
110                                             <!--option value="minimize_genetic_effect">Minimize Genetic Effects</option-->
111                                         </select>
112                                     </div>
113                                 </div>
114                                 <div class="form-group">
115                                     <label class="col-sm-3 control-label">Analytics Description: </label>
116                                     <div class="col-sm-9" >
117                                         <input type="text" class="form-control" id="drone_imagery_analytics_select_analytics_desc" />
118                                     </div>
119                                 </div>
120                                 <div class="form-group">
121                                     <label class="col-sm-3 control-label">Number Interations: </label>
122                                     <div class="col-sm-9" >
123                                         <select class="form-control" id="drone_imagery_analytics_number_iterations">
124                                             <option value="10">10</option>
125                                             <option value="2">2</option>
126                                             <option value="25">25</option>
127                                             <option value="1">1</option>
128                                         </select>
129                                     </div>
130                                 </div>
131                                 <div class="form-group">
132                                     <label class="col-sm-3 control-label">Env Variance: </label>
133                                     <div class="col-sm-9" >
134                                         <select class="form-control" id="drone_imagery_analytics_env_variance">
135                                             <option value="0.2">0.2</option>
136                                             <option value="0.1">0.1</option>
137                                             <option value="0.05">0.05</option>
138                                             <option value="0.01">0.01</option>
139                                             <option value="0.3">0.3</option>
140                                             <option value="0.2,0.1,0.05,0.01,0.3">0.2,0.1,0.05,0.01,0.3</option>
141                                         </select>
142                                     </div>
143                                 </div>
144                                 <div class="form-group">
145                                     <label class="col-sm-3 control-label">Simulated Environment Correlation Through Time: </label>
146                                     <div class="col-sm-9" >
147                                         <select class="form-control" id="drone_imagery_analytics_sim_env_change_over_time_correlation">
148                                             <option value="0.9">0.9</option>
149                                             <option value="0.75">0.75</option>
150                                             <option value="0.6">0.6</option>
151                                         </select>
152                                     </div>
153                                 </div>
154                             </div>
155                         </div>
157                         <& /page/page_title.mas, title=>"Select the observation variable(s) you are interested in" &>
159                         <div class="well well-sm">
160                             <div class="form-horizontal">
161                                 <div class="form-group">
162                                     <label class="col-sm-3 control-label">Observation Variable Type: </label>
163                                     <div class="col-sm-9" >
164                                         <select class="form-control" id="drone_imagery_analytics_select_observation_variable_type">
165                                             <option value="time_ontology">Time Series</option>
166                                             <option value="">Single Trait</option>
167                                         </select>
168                                     </div>
169                                 </div>
170                                 <div class="form-group">
171                                     <label class="col-sm-3 control-label">Observation Variables Phenotyped in the Selected Field Trial: </label>
172                                     <div class="col-sm-9" >
173                                         <div id="drone_imagery_analytics_trait_select_div">Loading...</div>
174                                     </div>
175                                 </div>
176                             </div>
177                         </div>
179                         <& /page/page_title.mas, title=>"Statistics Parameters" &>
181                         <div class="well well-sm">
182                             <div class="form-horizontal">
183                                 <div class="form-group">
184                                     <label class="col-sm-3 control-label">Relationship Matrix Type: </label>
185                                     <div class="col-sm-9" >
186                                         <select class="form-control" id="drone_imagery_analytics_relationship_matrix_type_select_div">
187                                             <option value="">Identity</option>
188                                             <option value="genotypes">Genotyping Data</option>
189                                             <option value="htp_phenotypes">High-throughput Phenotyping Data</option>
190                                         </select>
191                                     </div>
192                                 </div>
193                             </div>
195                             <div id="drone_imagery_analytics_genotyping_protocol_div" class="well well-sm" style="display:none">
196                                 <div class="form-horizontal">
197                                     <div class="form-group">
198                                         <label class="col-sm-3 control-label">Genotyping Protocol To Calculate Genomic Relationship Matrix (optional. If none selected, an identity matrix is used): </label>
199                                         <div class="col-sm-9" >
200                                             <div id="drone_imagery_analytics_genotyping_protocol_select_div"></div>
201                                         </div>
202                                     </div>
203                                     <div class="form-group">
204                                         <label class="col-sm-3 control-label">Compute Genotypes From Parents: </label>
205                                         <div class="col-sm-9" >
206                                             <select class="form-control" id="drone_image_analytics_genotyping_protocol_compute_from_parents_select">
207                                                 <option value="no">No</option>
208                                                 <option value="yes">Yes</option>
209                                             </select>
210                                         </div>
211                                     </div>
212                                     <div class="form-group" id="drone_image_analytics_genotyping_protocol_use_parental_grms_select_div" style="display:none">
213                                         <label class="col-sm-3 control-label">Use Parental Relationship Matrices: </label>
214                                         <div class="col-sm-9" >
215                                             <select class="form-control" id="drone_image_analytics_genotyping_protocol_use_parental_grms_select">
216                                                 <option value="no">No</option>
217                                                 <option value="yes">Yes</option>
218                                             </select>
219                                         </div>
220                                     </div>
221                                     <div class="form-group" id="drone_image_analytics_genotyping_protocol_include_pedigree_select_div" style="display:none">
222                                         <label class="col-sm-3 control-label">Include Pedigree Info Into Relationship Matrix: </label>
223                                         <div class="col-sm-9" >
224                                             <select class="form-control" id="drone_image_analytics_genotyping_protocol_include_pedigree_select">
225                                                 <option value="no">No</option>
226                                                 <option value="yes">Yes</option>
227                                             </select>
228                                         </div>
229                                     </div>
230                                 </div>
231                             </div>
233                             <div id="drone_imagery_analytics_htp_phenotypes_rel_matrix_div" class="well well-sm" style="display:none">
234                                 <div class="form-horizontal">
235                                     <div class="form-group">
236                                         <label class="col-sm-3 control-label">How to calculate the relationship matrix with high-throughput phenotypes: </label>
237                                         <div class="col-sm-9" >
238                                             <select class="form-control" id="drone_image_analytics_htp_phenotypes_rel_matrix_select">
239                                                 <option value="correlations">Correlations</option>
240                                                 <option value="blues">BLUEs</option>
241                                             </select>
242                                         </div>
243                                     </div>
244                                     <div class="form-group">
245                                         <label class="col-sm-3 control-label">Time Points to Use: </label>
246                                         <div class="col-sm-9" >
247                                             <select class="form-control" id="drone_image_analytics_htp_phenotypes_rel_matrix_times_select">
248                                                 <option value="all">All Available</option>
249                                                 <option value="latest_trait">Up to latest days after planting selecting in traits</option>
250                                                 <option value="vegetative" disabled>Vegetative Growth Stage</option>
251                                                 <option value="reproductive" disabled>Reproductive Growth Stage</option>
252                                                 <option value="mature" disabled>Mature Growth Stage</option>
253                                             </select>
254                                         </div>
255                                     </div>
256                                     <div class="form-group" id="drone_image_analytics_htp_phenotypes_rel_matrix_inversion_select_div" style="display:none">
257                                         <label class="col-sm-3 control-label">HTP BLUEs Inversion Tolerance: </label>
258                                         <div class="col-sm-9" >
259                                             <select class="form-control" id="drone_image_analytics_htp_phenotypes_rel_matrix_inversion_select">
260                                                 <option value="0.00001">0.00001</option>
261                                                 <option value="0.0001">0.0001</option>
262                                                 <option value="0.001">0.001</option>
263                                                 <option value="0.01">0.01</option>
264                                                 <option value="0.1">0.1</option>
265                                                 <option value="0.5">0.5</option>
266                                             </select>
267                                         </div>
268                                     </div>
269                                 </div>
270                             </div>
272                             <!--hr>
273                             <div class="form-horizontal">
274                                 <div class="form-group">
275                                     <label class="col-sm-3 control-label">Use Cumulative Area-Under-Curve Phenotype in Analysis: </label>
276                                     <div class="col-sm-9" >
277                                         <select class="form-control" id="drone_image_analytics_use_area_under_curve_select">
278                                             <option value="no">No</option>
279                                             <option value="yes">Yes</option>
280                                         </select>
281                                     </div>
282                                 </div>
283                             </div-->
285                             <hr>
286                             <div class="form-horizontal">
287                                 <div class="form-group">
288                                     <label class="col-sm-3 control-label">Inversion Tolerance: </label>
289                                     <div class="col-sm-9" >
290                                         <select class="form-control" id="drone_image_analytics_tolparinv_select">
291                                             <option value="0.000001">0.000001</option>
292                                             <option value="0.00001">0.00001</option>
293                                             <option value="0.0001">0.0001</option>
294                                             <option value="0.001">0.001</option>
295                                             <option value="0.01">0.01</option>
296                                             <option value="0.05">0.05</option>
297                                             <option value="0.08">0.08</option>
298                                             <option value="0.1">0.1</option>
299                                             <option value="0.2">0.2</option>
300                                             <option value="0.5">0.5</option>
301                                         </select>
302                                     </div>
303                                 </div>
304                                 <div class="form-group">
305                                     <label class="col-sm-3 control-label">Legendre Polynomial Order: </label>
306                                     <div class="col-sm-9" >
307                                         <select class="form-control" id="drone_image_analytics_legendre_order_number_select">
308                                             <option value="3">3</option>
309                                             <!--option value="1">1</option>
310                                             <option value="2">2</option>
311                                             <option value="4">4</option>
312                                             <option value="5">5</option-->
313                                         </select>
314                                     </div>
315                                 </div>
316                             </div>
318                             <hr>
319                             <div class="form-horizontal">
320                                 <div class="form-group">
321                                     <label class="col-sm-3 control-label">AIMREMLf90 Permanent Environment Structure: </label>
322                                     <div class="col-sm-9" >
323                                         <select class="form-control" id="drone_image_analytics_permanent_env_structure_select">
324                                             <option value="identity">Identity Matrix</option>
325                                             <option value="env_corr_structure">Simulated Phenotype Correlation Matrix</option>
326                                             <option value="phenotype_correlation">Phenotype Correlation Matrix</option>
327                                             <option value="phenotype_2dspline_effect">2D-Spline Effect of Phenotype</option>
328                                             <!--option value="phenotype_ar1xar1_effect">AR1xAR1 Effect of Phenotype</option-->
329                                             <option value="euclidean_rows_and_columns">Euclidean Distance From Rows and Columns Matrix</option>
330                                         </select>
331                                     </div>
332                                 </div>
333                             </div>
335                             <div id="drone_imagery_analytics_permanent_env_structure_phenotype_correlation_div" style="display:none">
336                                 <div class="form-horizontal">
337                                     <div class="form-group">
338                                         <label class="col-sm-3 control-label">Phenotypes For Correlation Matrix: </label>
339                                         <div class="col-sm-9" >
340                                             <div id="drone_imagery_analytics_permanent_env_structure_phenotype_correlation_select_div"></div>
341                                         </div>
342                                     </div>
343                                 </div>
344                             </div>
346                             <div id="drone_imagery_analytics_permanent_env_structure_phenotype_effect_select_div" style="display:none">
347                                 <div class="form-horizontal">
348                                     <div class="form-group">
349                                         <label class="col-sm-3 control-label">Phenotype For 2D-spline of AR1xAR1 Effect in Permanent Environment Structure: </label>
350                                         <div class="col-sm-9" >
351                                             <div id="drone_imagery_analytics_permanent_env_structure_phenotype_select_div"></div>
352                                         </div>
353                                     </div>
354                                 </div>
355                             </div>
357                             <hr>
358                             <div class="form-horizontal">
359                                 <div class="form-group">
360                                     <label class="col-sm-3 control-label">Simulated Environment Processes: </label>
361                                     <div class="col-sm-9" >
362                                         <select class="form-control" id="drone_imagery_analytics_simulated_environment_processes_select_div">
363                                             <option value="">Linear, 1D Normal, 2D Normal, AR1xAR1, Random, Real Data</option>
364                                         </select>
365                                     </div>
366                                 </div>
367                                 <div class="form-group">
368                                     <label class="col-sm-3 control-label">Trait For Real Data Environment Simulation: </label>
369                                     <div class="col-sm-9" >
370                                         <div id="drone_imagery_analytics_simulated_environment_real_data_trait_select_div"></div>
371                                     </div>
372                                 </div>
373                             </div>
375                             <hr>
376                             <div class="form-horizontal">
377                                 <div class="form-group">
378                                     <label class="col-sm-3 control-label">Fixed Effects: </label>
379                                     <div class="col-sm-9" >
380                                         <select class="form-control" id="drone_imagery_analytics_fixed_effect_select_div">
381                                             <option value="replicate">Replicate</option>
382                                             <option value="fixed_effect_trait">Select a continuous trait (e.g. soil elevation curvature)</option>
383                                         </select>
384                                     </div>
385                                 </div>
386                                 <div class="form-group" id="drone_imagery_analytics_fixed_effect_select_trait_div" style="display:none">
387                                     <label class="col-sm-3 control-label">Fixed Effect Trait: </label>
388                                     <div class="col-sm-9" >
389                                         <div id="drone_imagery_analytics_fixed_effect_trait_select_div"></div>
390                                     </div>
391                                 </div>
392                                 <div class="form-group" id="drone_imagery_analytics_fixed_effect_select_quantile_div" style="display:none">
393                                     <label class="col-sm-3 control-label">Fixed Effect Continuous Trait Quantile Binning: </label>
394                                     <div class="col-sm-9" >
395                                         <select class="form-control" id="drone_imagery_analytics_fixed_effect_select_quantile">
396                                             <option value="4">25% Quantiles</option>
397                                             <option value="5">20% Quantiles</option>
398                                             <option value="10">10% Quantiles</option>
399                                             <option value="3">33% Quantiles</option>
400                                         </select>
401                                     </div>
402                                 </div>
403                             </div>
404                         </div>
405                     </div>
407                     <hr>
408                     <center>
409                     <button class="btn btn-primary" id="drone_imagery_analytics_select_step">Submit</button>
410                     </center>
411                 </&>
412                 <&| /util/workflow.mas:step, title=> "Results" &>
413                     <& /page/page_title.mas, title=>"Statistics results" &>
415                     <hr>
416                     <button class="btn btn-primary" id="drone_imagery_analytics_analysis_save_blups_genetic_pe_residual" style="display:none">Go To Save Analysis Results For Genetic and Environment BLUPS and Residuals</button>
417                     <button class="btn btn-primary" id="drone_imagery_analytics_analysis_save_blups_genetic" style="display:none">Go To Save Analysis Results For Genetic BLUPS</button>
418                     <button class="btn btn-primary" id="drone_imagery_analytics_analysis_save_blups_spatial" style="display:none">Go To Save Analysis Results For Spatial BLUPS</button>
419                     <button class="btn btn-primary" id="drone_imagery_analytics_analysis_save_blups_pe" style="display:none">Go To Save Analysis Results For Permanent Environmental BLUPS</button>
420                     <button class="btn btn-primary" id="drone_imagery_analytics_analysis_save_residuals" style="display:none">Go To Save Analysis Results For Residuals</button>
421                     <button class="btn btn-primary" id="drone_imagery_analytics_analysis_save_fitted" style="display:none">Go To Save Analysis Results For Fitted Values</button>
422                     <hr>
424                     <div id ="drone_imagery_analytics_result_div">
425                     </div>
426                 </&>
427             </&>
429         </div>
431       </div>
432       <div class="modal-footer">
433         <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
434       </div>
435     </div>
436   </div>
437 </div>
439 <script>
440 jQuery(document).ready(function() {
441     jQuery('#drone_imagery_analytics_link').click(function(){
442         get_select_box('trials', 'drone_imagery_analytics_trial_select_div', { 'name' : 'drone_imagery_analytics_field_trial_id', 'id' : 'drone_imagery_analytics_field_trial_id', 'empty':1, 'multiple':1 });
444         jQuery('#drone_imagery_analytics_dialog').modal('show');
445     });
447     var manage_drone_imagery_analytics_field_trial_id_array = undefined;
448     var manage_drone_imagery_analytics_field_trial_id_string = "";
449     var manage_drone_imagery_analytics_observation_variable_type;
450     var manage_drone_imagery_analytics_trait_ids = [];
451     var manage_drone_imagery_analytics_trait_names = [];
452     var manage_drone_imagery_analytics_accession_names = [];
453     var manage_drone_imagery_analytics_plot_names = [];
454     var manage_drone_imagery_analytics_statistics_select = '';
455     var manage_drone_imagery_analytics_phenotype_training_file;
456     var manage_drone_imagery_analytics_grm_training_file;
457     var manage_drone_imagery_analytics_response = {};
458     var manage_drone_imagery_analytics_name = "";
459     var manage_drone_imagery_analytics_desc = "";
460     var manage_drone_imagery_analytics_type = "";
461     var manage_drone_imagery_analytics_protocol_id = undefined;
463     jQuery('#drone_imagery_analytics_field_trial_select_step').click(function(){
464         manage_drone_imagery_analytics_field_trial_id_array = undefined;
465         manage_drone_imagery_analytics_field_trial_id_string = "";
466         manage_drone_imagery_analytics_field_trial_id_array = jQuery('#drone_imagery_analytics_field_trial_id').val();
468         if (!manage_drone_imagery_analytics_field_trial_id_array || manage_drone_imagery_analytics_field_trial_id_array.length > 1) {
469             alert('Please only select a single field trial for now!');
470             return false;
471         }
473         manage_drone_imagery_analytics_field_trial_id_string = manage_drone_imagery_analytics_field_trial_id_array.join(",");
474         manage_drone_imagery_analytics_observation_variable_type = jQuery('#drone_imagery_analytics_select_observation_variable_type').val();
475         if (manage_drone_imagery_analytics_field_trial_id_string == '') {
476             alert('Please select a field trial first!');
477         } else {
478             if (manage_drone_imagery_analytics_observation_variable_type == 'time_ontology') {
479                 get_select_box('traits', 'drone_imagery_analytics_trait_select_div', { 'name' : 'drone_imagery_analytics_trait_id_select', 'id' : 'drone_imagery_analytics_trait_id_select', 'empty':1, 'multiple':1, 'size': 20, 'trial_ids':manage_drone_imagery_analytics_field_trial_id_string, 'stock_type':'plot', 'contains_composable_cv_type':manage_drone_imagery_analytics_observation_variable_type, 'select_format':'component_table_select' });
480             }
481             else {
482                 get_select_box('traits', 'drone_imagery_analytics_trait_select_div', { 'name' : 'drone_imagery_analytics_trait_id_select', 'id' : 'drone_imagery_analytics_trait_id_select', 'empty':1, 'multiple':1, 'size': 20, 'trial_ids':manage_drone_imagery_analytics_field_trial_id_string, 'stock_type':'plot', 'contains_composable_cv_type':manage_drone_imagery_analytics_observation_variable_type });
483             }
485             get_select_box('traits', 'drone_imagery_analytics_permanent_env_structure_phenotype_correlation_select_div', { 'name' : 'drone_imagery_analytics_permanent_env_structure_phenotype_correlation_select', 'id' : 'drone_imagery_analytics_permanent_env_structure_phenotype_correlation_select', 'empty':1, 'multiple':1, 'size': 20, 'trial_ids':manage_drone_imagery_analytics_field_trial_id_string, 'stock_type':'plot' });
487             get_select_box('traits', 'drone_imagery_analytics_permanent_env_structure_phenotype_select_div', { 'name' : 'drone_imagery_analytics_permanent_env_structure_phenotype_select', 'id' : 'drone_imagery_analytics_permanent_env_structure_phenotype_select', 'empty':1, 'multiple':1, 'size':20, 'trial_ids':manage_drone_imagery_analytics_field_trial_id_string, 'stock_type':'plot', 'contains_composable_cv_type':'time_ontology', 'select_format':'component_table_select' });
489             get_select_box('traits', 'drone_imagery_analytics_simulated_environment_real_data_trait_select_div', { 'name' : 'drone_imagery_analytics_simulated_environment_real_data_trait_select', 'id' : 'drone_imagery_analytics_simulated_environment_real_data_trait_select', 'empty':0, 'multiple':0, 'trial_ids':manage_drone_imagery_analytics_field_trial_id_string, 'stock_type':'plot' });
491             get_select_box('traits', 'drone_imagery_analytics_fixed_effect_trait_select_div', { 'name' : 'drone_imagery_analytics_fixed_effect_trait_select', 'id' : 'drone_imagery_analytics_fixed_effect_trait_select', 'empty':0, 'multiple':0, 'trial_ids':manage_drone_imagery_analytics_field_trial_id_string, 'stock_type':'plot' });
493             get_select_box('analytics_protocols', 'drone_imagery_analytics_analytics_protocols_select_div', { 'checkbox_name' : 'drone_imagery_analytics_analytics_protocols_select_id', 'analytics_protocol_type' : 'drone_imagery_analytics_env_simulation_protocol' });
495             get_select_box('genotyping_protocol', 'drone_imagery_analytics_genotyping_protocol_select_div', { 'name' : 'drone_image_analytics_genotyping_protocol_select', 'id' : 'drone_image_analytics_genotyping_protocol_select', 'empty':1 });
497             Workflow.complete("#drone_imagery_analytics_field_trial_select_step");
498             Workflow.focus('#drone_imagery_analytics_workflow', 1);
499         }
500         return false;
501     });
503     jQuery('#drone_imagery_analytics_select_observation_variable_type').change(function(){
504         manage_drone_imagery_analytics_observation_variable_type = jQuery('#drone_imagery_analytics_select_observation_variable_type').val();
505         if (manage_drone_imagery_analytics_observation_variable_type == 'time_ontology') {
506             get_select_box('traits', 'drone_imagery_analytics_trait_select_div', { 'name' : 'drone_imagery_analytics_trait_id_select', 'id' : 'drone_imagery_analytics_trait_id_select', 'empty':1, 'multiple':1, 'size': 20, 'trial_ids':manage_drone_imagery_analytics_field_trial_id_string, 'stock_type':'plot', 'contains_composable_cv_type':manage_drone_imagery_analytics_observation_variable_type, 'select_format':'component_table_select' });
507         }
508         else {
509             get_select_box('traits', 'drone_imagery_analytics_trait_select_div', { 'name' : 'drone_imagery_analytics_trait_id_select', 'id' : 'drone_imagery_analytics_trait_id_select', 'empty':1, 'multiple':1, 'size': 20, 'trial_ids':manage_drone_imagery_analytics_field_trial_id_string, 'stock_type':'plot', 'contains_composable_cv_type':manage_drone_imagery_analytics_observation_variable_type });
510         }
511     });
513     jQuery('#drone_imagery_analytics_analytics_project_new_button').click(function(){
514         jQuery('#drone_imagery_analytics_analytics_project_new_div').show();
515     });
517     jQuery('#drone_imagery_analytics_select_input').change(function(){
518         jQuery("#drone_imagery_analytics_relationship_matrix_type_select_div").val('').change();
519         jQuery("#drone_image_analytics_genotyping_protocol_compute_from_parents_select").val('no').change();
521         manage_drone_imagery_analytics_statistics_select = jQuery('#drone_imagery_analytics_select_input').val();
523         if (manage_drone_imagery_analytics_statistics_select == 'lmer_germplasmname_replicate') {
524             jQuery('#drone_imagery_analytics_genotyping_protocol_div').hide();
525             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic_pe_residual').hide();
526             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic').show();
527             jQuery('#drone_imagery_analytics_analysis_save_blups_spatial').hide();
528             jQuery('#drone_imagery_analytics_analysis_save_blups_pe').hide();
529             jQuery('#drone_imagery_analytics_analysis_save_residuals').hide();
530             jQuery('#drone_imagery_analytics_analysis_save_fitted').hide();
531         }
532         else if (manage_drone_imagery_analytics_statistics_select == 'sommer_grm_spatial_genetic_blups' || manage_drone_imagery_analytics_statistics_select == 'sommer_grm_spatial_pure_2dspl_genetic_blups') {
533             jQuery('#drone_imagery_analytics_genotyping_protocol_div').hide();
534             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic_pe_residual').show();
535             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic').hide();
536             jQuery('#drone_imagery_analytics_analysis_save_blups_spatial').hide();
537             jQuery('#drone_imagery_analytics_analysis_save_blups_pe').hide();
538             jQuery('#drone_imagery_analytics_analysis_save_residuals').hide();
539             jQuery('#drone_imagery_analytics_analysis_save_fitted').hide();
540         }
541         else if (manage_drone_imagery_analytics_statistics_select == 'sommer_grm_temporal_random_regression_dap_genetic_blups' || manage_drone_imagery_analytics_statistics_select == 'sommer_grm_temporal_random_regression_gdd_genetic_blups') {
542             jQuery('#drone_imagery_analytics_genotyping_protocol_div').hide();
543             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic_pe_residual').hide();
544             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic').show();
545             jQuery('#drone_imagery_analytics_analysis_save_blups_spatial').hide();
546             jQuery('#drone_imagery_analytics_analysis_save_blups_pe').show();
547             jQuery('#drone_imagery_analytics_analysis_save_residuals').hide();
548             jQuery('#drone_imagery_analytics_analysis_save_fitted').hide();
549         }
550         else if (manage_drone_imagery_analytics_statistics_select == 'sommer_grm_genetic_only_random_regression_dap_genetic_blups' || manage_drone_imagery_analytics_statistics_select == 'sommer_grm_genetic_only_random_regression_gdd_genetic_blups') {
551             jQuery('#drone_imagery_analytics_genotyping_protocol_div').hide();
552             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic_pe_residual').hide();
553             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic').show();
554             jQuery('#drone_imagery_analytics_analysis_save_blups_spatial').hide();
555             jQuery('#drone_imagery_analytics_analysis_save_blups_pe').hide();
556             jQuery('#drone_imagery_analytics_analysis_save_residuals').hide();
557             jQuery('#drone_imagery_analytics_analysis_save_fitted').hide();
558         }
559         else if (manage_drone_imagery_analytics_statistics_select == 'blupf90_grm_random_regression_dap_blups' || manage_drone_imagery_analytics_statistics_select == 'blupf90_grm_random_regression_gdd_blups' || manage_drone_imagery_analytics_statistics_select == 'airemlf90_grm_random_regression_dap_blups' || manage_drone_imagery_analytics_statistics_select == 'airemlf90_grm_random_regression_gdd_blups') {
560             jQuery('#drone_imagery_analytics_genotyping_protocol_div').hide();
561             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic_pe_residual').show();
562             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic').hide();
563             jQuery('#drone_imagery_analytics_analysis_save_blups_spatial').hide();
564             jQuery('#drone_imagery_analytics_analysis_save_blups_pe').hide();
565             jQuery('#drone_imagery_analytics_analysis_save_residuals').hide();
566             jQuery('#drone_imagery_analytics_analysis_save_fitted').hide();
567         }
568         else if (manage_drone_imagery_analytics_statistics_select == 'sommer_grm_genetic_blups') {
569             jQuery('#drone_imagery_analytics_genotyping_protocol_div').hide();
570             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic_pe_residual').hide();
571             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic').show();
572             jQuery('#drone_imagery_analytics_analysis_save_blups_spatial').hide();
573             jQuery('#drone_imagery_analytics_analysis_save_blups_pe').hide();
574             jQuery('#drone_imagery_analytics_analysis_save_residuals').hide();
575             jQuery('#drone_imagery_analytics_analysis_save_fitted').hide();
576         }
577         else {
578             jQuery('#drone_imagery_analytics_genotyping_protocol_div').hide();
579             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic_pe_residual').hide();
580             jQuery('#drone_imagery_analytics_analysis_save_blups_genetic').hide();
581             jQuery('#drone_imagery_analytics_analysis_save_blups_spatial').hide();
582             jQuery('#drone_imagery_analytics_analysis_save_blups_pe').hide();
583             jQuery('#drone_imagery_analytics_analysis_save_residuals').hide();
584             jQuery('#drone_imagery_analytics_analysis_save_fitted').hide();
585         }
587         jQuery('#drone_imagery_analytics_genotyping_protocol_div').hide();
588         jQuery('#drone_imagery_analytics_analysis_save_blups_genetic_pe_residual').hide();
589         jQuery('#drone_imagery_analytics_analysis_save_blups_genetic').hide();
590         jQuery('#drone_imagery_analytics_analysis_save_blups_spatial').hide();
591         jQuery('#drone_imagery_analytics_analysis_save_blups_pe').hide();
592         jQuery('#drone_imagery_analytics_analysis_save_residuals').hide();
593         jQuery('#drone_imagery_analytics_analysis_save_fitted').hide();
594     });
596     jQuery('#drone_imagery_analytics_relationship_matrix_type_select_div').change(function(){
597         if (jQuery(this).val() == 'genotypes') {
598             jQuery('#drone_imagery_analytics_genotyping_protocol_div').show();
599             jQuery('#drone_imagery_analytics_htp_phenotypes_rel_matrix_div').hide();
600         }
601         else if (jQuery(this).val() == 'htp_phenotypes') {
602             jQuery('#drone_imagery_analytics_genotyping_protocol_div').hide();
603             jQuery('#drone_imagery_analytics_htp_phenotypes_rel_matrix_div').show();
604         }
605         else {
606             jQuery('#drone_imagery_analytics_genotyping_protocol_div').hide();
607             jQuery('#drone_imagery_analytics_htp_phenotypes_rel_matrix_div').hide();
608         }
609     });
611     jQuery('#drone_image_analytics_htp_phenotypes_rel_matrix_select').change(function(){
612         if (jQuery(this).val() == 'blues') {
613             jQuery('#drone_image_analytics_htp_phenotypes_rel_matrix_inversion_select_div').show();
614         }
615         else {
616             jQuery('#drone_image_analytics_htp_phenotypes_rel_matrix_inversion_select_div').hide();
617         }
618     });
620     jQuery('#drone_image_analytics_genotyping_protocol_compute_from_parents_select').change(function(){
621         if (jQuery(this).val() == 'yes') {
622             jQuery('#drone_image_analytics_genotyping_protocol_include_pedigree_select_div').show();
623             jQuery('#drone_image_analytics_genotyping_protocol_use_parental_grms_select_div').show();
624         }
625         if (jQuery(this).val() == 'no') {
626             jQuery('#drone_image_analytics_genotyping_protocol_include_pedigree_select_div').hide();
627             jQuery('#drone_image_analytics_genotyping_protocol_use_parental_grms_select_div').hide();
628             jQuery('#drone_image_analytics_genotyping_protocol_include_pedigree_select option[value=no]').attr('selected','selected');
629             jQuery('#drone_image_analytics_genotyping_protocol_use_parental_grms_select option[value=no]').attr('selected','selected');
630         }
631     });
633     jQuery('#drone_image_analytics_genotyping_protocol_use_parental_grms_select').change(function(){
634         if (jQuery(this).val() == 'yes') {
635             jQuery('#drone_image_analytics_genotyping_protocol_include_pedigree_select option[value=no]').attr('selected','selected');
636             jQuery('#drone_image_analytics_genotyping_protocol_include_pedigree_select_div').hide();
637         }
638         if (jQuery(this).val() == 'no') {
639             jQuery('#drone_image_analytics_genotyping_protocol_include_pedigree_select_div').show();
640         }
641     });
643     jQuery('#drone_image_analytics_permanent_env_structure_select').change(function(){
644         if (jQuery(this).val() == 'euclidean_rows_and_columns') {
645             jQuery('#drone_imagery_analytics_permanent_env_structure_phenotype_correlation_div').hide();
646             jQuery('#drone_imagery_analytics_permanent_env_structure_phenotype_effect_select_div').hide();
647         }
648         else if (jQuery(this).val() == 'phenotype_correlation') {
649             jQuery('#drone_imagery_analytics_permanent_env_structure_phenotype_correlation_div').show();
650             jQuery('#drone_imagery_analytics_permanent_env_structure_phenotype_effect_select_div').hide();
651         }
652         else if (jQuery(this).val() == 'phenotype_2dspline_effect') {
653             jQuery('#drone_imagery_analytics_permanent_env_structure_phenotype_correlation_div').hide();
654             jQuery('#drone_imagery_analytics_permanent_env_structure_phenotype_effect_select_div').show();
655         }
656         else {
657             jQuery('#drone_imagery_analytics_permanent_env_structure_phenotype_correlation_div').hide();
658             jQuery('#drone_imagery_analytics_permanent_env_structure_phenotype_effect_select_div').hide();
659         }
660     });
662     jQuery('#drone_imagery_analytics_fixed_effect_select_div').change(function(){
663         if (jQuery(this).val() == 'replicate') {
664             jQuery('#drone_imagery_analytics_fixed_effect_select_trait_div').hide();
665             jQuery('#drone_imagery_analytics_fixed_effect_select_quantile_div').hide();
666         }
667         if (jQuery(this).val() == 'fixed_effect_trait') {
668             jQuery('#drone_imagery_analytics_fixed_effect_select_trait_div').show();
669             jQuery('#drone_imagery_analytics_fixed_effect_select_quantile_div').show();
670         }
671     });
673     jQuery('#drone_imagery_analytics_select_step').click(function(){
675         manage_drone_imagery_analytics_statistics_select = jQuery('#drone_imagery_analytics_select_input').val();
677         var manage_drone_imagery_analytics_protocol_ids = [];
678         jQuery('input[name="drone_imagery_analytics_analytics_protocols_select_id"]').each(function() {
679             if (this.checked){
680                 manage_drone_imagery_analytics_protocol_ids.push(jQuery(this).val());
681             }
682         });
684         if (manage_drone_imagery_analytics_protocol_ids.length > 1) {
685             alert('Please select only one protocol!');
686             return false;
687         }
688         if (manage_drone_imagery_analytics_protocol_ids.length == 1) {
689             manage_drone_imagery_analytics_protocol_id = manage_drone_imagery_analytics_protocol_ids[0];
690         }
692         manage_drone_imagery_analytics_name = jQuery('#drone_imagery_analytics_select_analytics_name').val();
693         manage_drone_imagery_analytics_desc = jQuery('#drone_imagery_analytics_select_analytics_desc').val();
694         manage_drone_imagery_analytics_type = jQuery('#drone_imagery_analytics_select_analytics_type').val();
696         if (!manage_drone_imagery_analytics_protocol_id && manage_drone_imagery_analytics_name == '') {
697             alert('Please give an analytics name or select a previously saved analytics report.');
698             return false;
699         }
700         if (!manage_drone_imagery_analytics_protocol_id && manage_drone_imagery_analytics_desc == '') {
701             alert('Please give an analytics description.');
702             return false;
703         }
704         if (manage_drone_imagery_analytics_protocol_id && manage_drone_imagery_analytics_name != '') {
705             alert('Please give an analytics name OR select a previously saved analytics report, not both!');
706             return false;
707         }
709         manage_drone_imagery_analytics_trait_ids = [];
711         if (manage_drone_imagery_analytics_observation_variable_type == 'time_ontology') {
712             jQuery('input[name="drone_imagery_analytics_trait_id_select"]').each(function() {
713                 if (this.checked){
714                     manage_drone_imagery_analytics_trait_ids.push(jQuery(this).val());
715                 }
716             });
717         }
718         else {
719             manage_drone_imagery_analytics_trait_ids = jQuery('#drone_imagery_analytics_trait_id_select').val();
720             if (manage_drone_imagery_analytics_trait_ids == null || manage_drone_imagery_analytics_trait_ids == undefined) {
721                 alert('Please select at least one observation variable!');
722                 return false;
723             }
724         }
726         if (!manage_drone_imagery_analytics_protocol_id && manage_drone_imagery_analytics_trait_ids.length < 1){
727             alert('Please select at least one observation variable!');
728             return false;
729         }
731         if (jQuery('#drone_image_analytics_genotyping_protocol_include_pedigree_select').val() == 'yes' && jQuery('#drone_image_analytics_genotyping_protocol_compute_from_parents_select').val() != 'yes') {
732             alert('You can only use pedigree info in the relationship matrix if you will compute the genotypes from the parents!');
733             return false;
734         }
735         if (jQuery('#drone_image_analytics_genotyping_protocol_use_parental_grms_select').val() == 'yes' && jQuery('#drone_image_analytics_genotyping_protocol_compute_from_parents_select').val() != 'yes') {
736             alert('You can only use parental relationship matrices if you will compute the genotypes from the parents!');
737             return false;
738         }
740         var manage_drone_imagery_analytics_rr_structure_phenotype_correlation = [];
741         if (jQuery('#drone_image_analytics_permanent_env_structure_select').val() == 'phenotype_correlation') {
742             manage_drone_imagery_analytics_rr_structure_phenotype_correlation = jQuery('#drone_imagery_analytics_permanent_env_structure_phenotype_correlation_select').val();
743             if (!manage_drone_imagery_analytics_rr_structure_phenotype_correlation || manage_drone_imagery_analytics_rr_structure_phenotype_correlation.length < 3) {
744                 alert('Please select at least three phenotypes to use in random regression permanent environment phenotype correlation structure!');
745                 return false;
746             }
747         }
749         var manage_drone_imagery_analytics_rr_env_structure_trait_ids = [];
750         jQuery('input[name="drone_imagery_analytics_permanent_env_structure_phenotype_select"]').each(function() {
751             if (this.checked){
752                 manage_drone_imagery_analytics_rr_env_structure_trait_ids.push(jQuery(this).val());
753             }
754         });
756         jQuery.ajax({
757             url : '/api/drone_imagery/calculate_analytics',
758             type : 'POST',
759             data : {
760                 'observation_variable_id_list':JSON.stringify(manage_drone_imagery_analytics_trait_ids),
761                 'field_trial_id_list':JSON.stringify(manage_drone_imagery_analytics_field_trial_id_array),
762                 'statistics_select':manage_drone_imagery_analytics_statistics_select,
763                 'analytics_protocol_id':manage_drone_imagery_analytics_protocol_id,
764                 'analytics_protocol_name':manage_drone_imagery_analytics_name,
765                 'analytics_protocol_desc':manage_drone_imagery_analytics_desc,
766                 'analytics_select':manage_drone_imagery_analytics_type,
767                 'number_iterations':jQuery('#drone_imagery_analytics_number_iterations').val(),
768                 'relationship_matrix_type':jQuery('#drone_imagery_analytics_relationship_matrix_type_select_div').val(),
769                 'protocol_id':jQuery('#drone_image_analytics_genotyping_protocol_select').val(),
770                 'compute_from_parents':jQuery('#drone_image_analytics_genotyping_protocol_compute_from_parents_select').val(),
771                 'use_parental_grms_if_compute_from_parents':jQuery('#drone_image_analytics_genotyping_protocol_use_parental_grms_select').val(),
772                 'include_pedgiree_info_if_compute_from_parents':jQuery('#drone_image_analytics_genotyping_protocol_include_pedigree_select').val(),
773                 'htp_pheno_rel_matrix_type':jQuery('#drone_image_analytics_htp_phenotypes_rel_matrix_select').val(),
774                 'htp_pheno_rel_matrix_time_points':jQuery('#drone_image_analytics_htp_phenotypes_rel_matrix_times_select').val(),
775                 'htp_pheno_rel_matrix_blues_inversion':jQuery('#drone_image_analytics_htp_phenotypes_rel_matrix_inversion_select').val(),
776                 'tolparinv':jQuery('#drone_image_analytics_tolparinv_select').val(),
777                 'legendre_order_number':jQuery('#drone_image_analytics_legendre_order_number_select').val(),
778                 'use_area_under_curve':jQuery('#drone_image_analytics_use_area_under_curve_select').val(),
779                 'permanent_environment_structure':jQuery('#drone_image_analytics_permanent_env_structure_select').val(),
780                 'permanent_environment_structure_phenotype_correlation_traits':JSON.stringify(manage_drone_imagery_analytics_rr_structure_phenotype_correlation),
781                 'permanent_environment_structure_phenotype_trait_ids':JSON.stringify(manage_drone_imagery_analytics_rr_env_structure_trait_ids),
782                 'sim_env_change_over_time':jQuery('#drone_imagery_analytics_select_sim_env_change_over_time_type').val(),
783                 'env_variance_percent':jQuery('#drone_imagery_analytics_env_variance').val(),
784                 'simulated_environment_real_data_trait_id':jQuery('#drone_imagery_analytics_simulated_environment_real_data_trait_select').val(),
785                 'sim_env_change_over_time_correlation':jQuery('#drone_imagery_analytics_sim_env_change_over_time_correlation').val(),
786                 'fixed_effect_type':jQuery('#drone_imagery_analytics_fixed_effect_select_div').val(),
787                 'fixed_effect_trait_id':jQuery('#drone_imagery_analytics_fixed_effect_trait_select').val(),
788                 'fixed_effect_quantiles':jQuery('#drone_imagery_analytics_fixed_effect_select_quantile').val()
789             },
790             beforeSend: function() {
791                 jQuery("#working_modal").modal("show");
792             },
793             success: function(response){
794                 console.log(response);
795                 jQuery("#working_modal").modal("hide");
797                 if (response.error) {
798                     alert(response.error);
799                 }
800                 else {
801                     manage_drone_imagery_analytics_response = response;
802                     manage_drone_imagery_analytics_protocol_id = response.analytics_protocol_id;
804                     var html = '<h4>Summary :</h4><ul>';
805                     if (response.sum_square_residual_original) {
806                         html = html + '<li>Sum square residual original: '+response.sum_square_residual_original+'</li>';
807                     }
808                     if (response.sum_square_residual_altered) {
809                         html = html + '<li>Sum square residual altered: '+response.sum_square_residual_altered+'</li>';
810                     }
811                     if (response.genetic_effect_sum_original) {
812                         html = html + '<li>Genetic effect sum original: '+response.genetic_effect_sum_original+'</li>';
813                     }
814                     if (response.genetic_effect_sum_altered) {
815                         html = html + '<li>Genetic effect sum altered: '+response.genetic_effect_sum_altered+'</li>';
816                     }
817                     if (response.env_effect_sum_original) {
818                         html = html + '<li>Env effect sum original: '+response.env_effect_sum_original+'</li>';
819                     }
820                     if (response.env_effect_sum_altered) {
821                         html = html + '<li>Env effect sum altered: '+response.env_effect_sum_altered+'</li>';
822                     }
823                     html = html + '</ul>';
825                     if (response.simulated_environment_to_effect_correlations) {
826                         html = html + '<h4>Simulated Env to Effects Correlations:</h4><ul>';
827                         for(var i=0; i<response.simulated_environment_to_effect_correlations.length; i++) {
828                             html = html + '<li>' + response.simulated_environment_to_effect_correlations[i] + '</li>';
829                         }
830                         html = html + '</ul><hr>';
831                     }
833                     if (response.spatial_effects_plots) {
834                         for (i=0; i<response.spatial_effects_plots.length; i++) {
835                             html = html + '<p>'+response.spatial_effects_plots[i][1]+'</p><img src="'+response.spatial_effects_plots[i][0]+'"><hr>';
836                         }
837                     }
839                     if (response.unique_accessions.length > 0 && response.unique_traits.length > 0 && response.result_blup_genetic_data_altered) {
840                         manage_drone_imagery_analytics_accession_names = response.unique_accessions;
841                         manage_drone_imagery_analytics_trait_names = response.unique_traits;
842                         manage_drone_imagery_analytics_phenotype_training_file = response.stats_tempfile;
843                         manage_drone_imagery_analytics_grm_training_file = response.grm_file;
845                         html = html + '<table class="table table-bordered table-hover"><thead><tr><th>Accessions</th>';
846                         for (var i=0; i<manage_drone_imagery_analytics_trait_names.length; i++) {
847                             html = html + '<th>'+manage_drone_imagery_analytics_trait_names[i]+'</th>';
848                         }
849                         html = html + '</tr></thead><tbody>';
850                         for (var k=0; k<response.unique_accessions.length; k++) {
851                             var acc = response.unique_accessions[k];
852                             html = html + '<tr><td>'+acc+'</td>';
853                             for (var i=0; i<manage_drone_imagery_analytics_trait_names.length; i++) {
854                                 if (response.result_blup_genetic_data_altered[acc] && response.result_blup_genetic_data_altered[acc][manage_drone_imagery_analytics_trait_names[i]]) {
855                                     html = html + '<td>'+response.result_blup_genetic_data_altered[acc][manage_drone_imagery_analytics_trait_names[i]][0]+'</td>';
856                                 }
857                                 else {
858                                     html = html + '<td>NA</td>';
859                                 }
860                             }
861                             html = html + '</tr>';
862                         }
863                         html = html + '</tbody></table>';
864                     }
866                     if (response.unique_plots.length > 0 && response.unique_traits.length > 0 && response.result_blup_spatial_data_altered) {
867                         manage_drone_imagery_analytics_plot_names = response.unique_plots;
868                         manage_drone_imagery_analytics_trait_names = response.unique_traits;
870                         html = html + '<table class="table table-bordered table-hover"><thead><tr><th>Plots</th>';
871                         for (var i=0; i<response.unique_traits.length; i++) {
872                             html = html + '<th>'+response.unique_traits[i]+'</th>';
873                         }
874                         html = html + '</tr></thead><tbody>';
875                         for (var k=0; k<response.unique_plots.length; k++) {
876                             var plot = response.unique_plots[k];
877                             html = html + '<tr><td>'+plot+'</td>';
878                             for (var i=0; i<response.unique_traits.length; i++) {
879                                 html = html + '<td>'+response.result_blup_spatial_data_altered[plot][response.unique_traits[i]][0]+'</td>';
880                             }
881                             html = html + '</tr>';
882                         }
883                         html = html + '</tbody></table>';
884                     }
886                     if (response.unique_plots.length > 0 && response.unique_traits.length > 0 && response.result_blup_pe_data_altered) {
887                         manage_drone_imagery_analytics_plot_names = response.unique_plots;
888                         manage_drone_imagery_analytics_trait_names = response.unique_traits;
890                         html = html + '<table class="table table-bordered table-hover"><thead><tr><th>Plots</th>';
891                         for (var i=0; i<response.unique_traits.length; i++) {
892                             html = html + '<th>'+response.unique_traits[i]+'</th>';
893                         }
894                         html = html + '</tr></thead><tbody>';
895                         for (var k=0; k<response.unique_plots.length; k++) {
896                             var plot = response.unique_plots[k];
897                             html = html + '<tr><td>'+plot+'</td>';
898                             for (var i=0; i<response.unique_traits.length; i++) {
899                                 if (response.result_blup_pe_data_altered[plot] && response.result_blup_pe_data_altered[plot][response.unique_traits[i]]) {
900                                     html = html + '<td>'+response.result_blup_pe_data_altered[plot][response.unique_traits[i]][0]+'</td>';
901                                 }
902                                 else {
903                                     html = html + '<td>NA</td>';
904                                 }
905                             }
906                             html = html + '</tr>';
907                         }
908                         html = html + '</tbody></table>';
909                     }
911                     html = html + '<hr><a href="'+response.stats_out_tempfile_string+'.log" target=_blank>Stats file or log</a>';
913                     if (jQuery('#drone_imagery_analytics_relationship_matrix_type_select_div').val() == 'htp_phenotypes') {
914                         html = html + '<hr><a href="'+response.stats_out_htp_rel_tempfile_out_string+'" target=_blank>HTP Relationship Matrix</a>';
915                     }
917                     jQuery('#drone_imagery_analytics_result_div').html(html);
919                     Workflow.complete("#drone_imagery_analytics_select_step");
920                     Workflow.focus('#drone_imagery_analytics_workflow', 2);
921                 }
922             },
923             error: function(response){
924                 jQuery("#working_modal").modal("hide");
925                 alert('Error calculating statistics analytics!')
926             }
927         });
928     });
931 </script>