Commit f98902cc authored by Janez K's avatar Janez K
Browse files

hbp use case 3

parent d1bc5482
This diff is collapsed.
......@@ -121,3 +121,9 @@ def cforange_hierarchical_clustering(request,input_dict,output_dict,widget):
hierarchy = json.dumps(hierarchy)
return render(request, 'interactions/cforange_hierarchical_clustering.html', {'widget' : widget, 'hierarchy' : hierarchy, 'attributes':attributes,'vizualization':input_dict['visualization']})
def filter_table(request, input_dict, output_dict, widget):
from workflows.visualization_views import orng_table_to_dict
data = input_dict['data']
return render(request, 'interactions/cforange_filter_table.html', {'widget' : widget,'input_dict' : input_dict,'output_dict' : orng_table_to_dict(data)})
......@@ -512,3 +512,16 @@ def cforange_hierarchical_clustering_finished(postdata, input_dict, output_dict)
else: # Attribute distance
centroids, selected_table, unselected_table = None, None, None
return {'centroids' : centroids, 'selected_examples' : selected_table, 'unselected_examples' : unselected_table}
def filter_table(input_dict):
return {'altered_data' : None}
def filter_table_finished(postdata, input_dict, output_dict):
print postdata
import Orange
from Orange.feature import Type
widget_id = postdata['widget_id'][0]
# Parse the changes
new_table = Orange.data.Table(input_dict['data']).getitems([int(x) for x in postdata.get('include',[])])
return {'altered_data' : new_table}
<div id="widgetinteract-{{widget.pk}}" rel="{{widget.pk}}" class="widgetinteractdialog" title="{{widget.name}} interaction" width="700" height="500">
<center>
<form>
<table cellpadding="0" cellspacing="0" border="0" class="display" id="datasetTable{{widget.pk}}">
<!-- header -->
<thead>
<tr>
<th>Include</th>
{% for att in output_dict.attrs %}
<th>{{att}}</th>
{% endfor %}
{% if output_dict.class_var %}
<th>{{output_dict.class_var}} [class]</th>
{% endif %}
{% for att in output_dict.metas %}
<th>{{att}} [meta]</th>
{% endfor %}
</tr>
</thead>
<tbody>
<!-- instances -->
{% for inst in output_dict.data %}
<tr>
<td><input type="checkbox" name="include" value="{{forloop.counter0}}" style="float:left; display:inline;"></td>
{% for att, v in inst %}
<td id="cell_{{forloop.parentloop.counter0}}_{{att}}">{{v}}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
<input type="hidden" name="widget_id" value="{{widget.pk}}"/>
</form>
</center>
<script type="text/javascript">
$(function () {
$(document).ready(function() {
$('#datasetTable{{widget.pk}}').dataTable( {
"bSortCellsTop" : true,
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
} );
});
</script>
</div>
\ No newline at end of file
from django.shortcuts import render
def cforange_display_summation(request,input_dict,output_dict,widget):
if sum(input_dict['intList']) == input_dict['sum']:
check = 'The calculation appears correct.'
else:
check = 'The calculation appears incorrect!'
return render(request, 'visualizations/cforange_display_integers.html',{'widget':widget,'input_dict':input_dict, 'output_dict':output_dict, 'check':check})
......@@ -11,6 +11,64 @@
"name": "HBP"
}
},
{
"pk": 138,
"model": "workflows.abstractwidget",
"fields": {
"category": 6,
"treeview_image": "",
"windows_queue": false,
"name": "Interactive analysis",
"is_streaming": false,
"uid": "1d829d71-be0d-4f8e-829d-70616db7c257",
"interaction_view": "hbp_interactive_analysis",
"image": "",
"package": "hbp",
"static_image": "",
"post_interact_action": "hbp_interactive_analysis_post",
"user": null,
"visualization_view": "",
"streaming_visualization_view": "",
"action": "hbp_interactive_analysis",
"wsdl_method": "",
"wsdl": "",
"interactive": true,
"has_progress_bar": false,
"order": 1,
"description": ""
}
},
{
"pk": 254,
"model": "workflows.abstractinput",
"fields": {
"widget": 138,
"name": "Dataset",
"short_name": "odt",
"uid": "1551b5dc-2127-4b6d-9430-a0316e83f84b",
"default": "",
"required": false,
"multi": false,
"parameter_type": null,
"variable": "Dataset",
"parameter": false,
"order": 1,
"description": ""
}
},
{
"pk": 150,
"model": "workflows.abstractoutput",
"fields": {
"widget": 138,
"name": "Results",
"short_name": "res",
"variable": "results",
"uid": "1a042d29-37f8-4acc-ac4d-fa21ffa8ecce",
"order": 1,
"description": "The results"
}
},
{
"pk": 35,
"model": "workflows.abstractwidget",
......
from django.shortcuts import render
def hbp_interactive_analysis(request, input_dict, ouput_dict, widget):
return render(request, 'interactions/hbp_interactive_analysis.html',
{'widget':widget})
def hbp_construct_query(request, input_dict,output_dict,widget):
return render(request, 'interactions/hbp_construct_query.html',
{'widget':widget})
......
def hbp_interactive_analysis(input_dict):
return {}
def hbp_interactive_analysis_post(postdata,input_dict,output_dict):
import orange
import tempfile
import arff
import os
import numpy
d = input_dict['Dataset']
dset = arff.load(open(os.path.dirname(os.path.abspath(__file__))+"/new_adni.arff",'rb'))
b = {}
b['attributes'] = []
feature_names = [x.name for x in d.domain]
if 'Classification' in feature_names:
b['attributes'].append(('Classification',[u'CN', u'AD', u'LMCI', u'EMCI', u'SMC']))
if 'geo' in feature_names:
b['attributes'].append(('geo',[u'Africa', u'Asia', u'Australia', u'Europe', u'North America', u'South America']))
if 'age' in feature_names:
b['attributes'].append(('age',[u'1-18', u'18-24', u'25-34', u'35-44', u'45-54', u'55-64', u'65+']))
for v in postdata['variables']:
b['attributes'].append((v+"_avg","NUMERIC"))
b['attributes'].append((v+"_stdev","NUMERIC"))
b['attributes'].append(('count','NUMERIC'))
b['description'] = ""
b['relation'] = "HBP"
b['data'] = []
for i in d:
new_i = []
if 'Classification' in feature_names:
clas = i[feature_names.index('Classification')].value
new_i.append(clas)
else:
clas = None
if 'geo' in feature_names:
geo = i[feature_names.index('geo')].value
new_i.append(geo)
else:
geo = None
if 'age' in feature_names:
age = i[feature_names.index('age')].value
new_i.append(age)
else:
age = None
sums = {}
for v in postdata['variables']:
sums[v] = 0
vcounts = {}
for v in postdata['variables']:
vcounts[v] = 0
vvalues = {}
for v in postdata['variables']:
vvalues[v] = []
count = 0
attrs = [x[0] for x in dset['attributes']]
for ins in dset['data']:
if (ins[-1]==clas or clas==None) and (ins[0]==geo or geo==None) and (ins[1]==age or age==None):
count = count + 1
for k,v in sums.items():
try:
sums[k] = v + ins[attrs.index(k)]
vcounts[k] = vcounts[k]+1
vvalues[k].append(v)
except:
pass
for v in postdata['variables']:
print vvalues[v]
stdev = numpy.std(vvalues[v])
try:
avg = sums[v]/vcounts[v]
except:
avg = -2
new_i.append(avg)
new_i.append(stdev)
new_i.append(count)
b['data'].append(new_i)
f = tempfile.NamedTemporaryFile(delete=False,suffix='.arff')
f.write(arff.dumps(b))
f.close()
output_dict = {}
output_dict['results'] = orange.ExampleTable(f.name)
return output_dict
def hbp_search_criteria(input_dict):
return {}
......
<div id="widgetinteract-{{widget.pk}}" height="500" rel="{{widget.pk}}" class="widgetinteractdialog" title="{{widget.name}} wants your input!">
<form id="interactionform-{{widget.pk}}" name="interactionform-{{widget.pk}}">
<b>Select variables</b><br>
<label><input type="checkbox" value="APOE4" name="variables" style="display:inline;width:auto;"> APOE4<br></label>
<label><input type="checkbox" value="CDRSB_bl" name="variables" style="display:inline;width:auto;"> CDRSB_bl<br></label>
<label><input type="checkbox" value="ADAS13_bl" name="variables" style="display:inline;width:auto;"> ADAS13_bl<br></label>
<label><input type="checkbox" value="MMSE_bl" name="variables" style="display:inline;width:auto;"> MMSE_bl<br></label>
<label><input type="checkbox" value="RAVLT_immediate_bl" name="variables" style="display:inline;width:auto;"> RAVLT_immediate_bl<br></label>
<label><input type="checkbox" value="RAVLT_learning_bl" name="variables" style="display:inline;width:auto;"> RAVLT_learning_bl<br></label>
<label><input type="checkbox" value="RAVLT_forgetting_bl" name="variables" style="display:inline;width:auto;"> RAVLT_forgetting_bl<br></label>
<label><input type="checkbox" value="RAVLT_perc_forgetting_bl" name="variables" style="display:inline;width:auto;"> RAVLT_perc_forgetting_bl<br></label>
<label><input type="checkbox" value="FAQ_bl" name="variables" style="display:inline;width:auto;"> FAQ_bl<br></label>
<label><input type="checkbox" value="Ventricles_bl" name="variables" style="display:inline;width:auto;"> Ventricles_bl<br></label>
<label><input type="checkbox" value="Hippocampus_bl" name="variables" style="display:inline;width:auto;"> Hippocampus_bl<br></label>
<label><input type="checkbox" value="WholeBrain_bl" name="variables" style="display:inline;width:auto;"> WholeBrain_bl<br></label>
<label><input type="checkbox" value="Entorhinal_bl" name="variables" style="display:inline;width:auto;"> Entorhinal_bl<br></label>
<label><input type="checkbox" value="Fusiform_bl" name="variables" style="display:inline;width:auto;"> Fusiform_bl<br></label>
<label><input type="checkbox" value="MidTemp_bl" name="variables" style="display:inline;width:auto;"> MidTemp_bl<br></label>
<label><input type="checkbox" value="ICV_bl" name="variables" style="display:inline;width:auto;"> ICV_bl<br></label>
<label><input type="checkbox" value="MOCA_bl" name="variables" style="display:inline;width:auto;"> MOCA_bl<br></label>
<label><input type="checkbox" value="EcogPtMem_bl" name="variables" style="display:inline;width:auto;"> EcogPtMem_bl<br></label>
<label><input type="checkbox" value="EcogPtLang_bl" name="variables" style="display:inline;width:auto;"> EcogPtLang_bl<br></label>
<label><input type="checkbox" value="EcogPtVisspat_bl" name="variables" style="display:inline;width:auto;"> EcogPtVisspat_bl<br></label>
<label><input type="checkbox" value="EcogPtPlan_bl" name="variables" style="display:inline;width:auto;"> EcogPtPlan_bl<br></label>
<label><input type="checkbox" value="EcogPtOrgan_bl" name="variables" style="display:inline;width:auto;"> EcogPtOrgan_bl<br></label>
<label><input type="checkbox" value="EcogPtDivatt_bl" name="variables" style="display:inline;width:auto;"> EcogPtDivatt_bl<br></label>
<label><input type="checkbox" value="EcogPtTotal_bl" name="variables" style="display:inline;width:auto;"> EcogPtTotal_bl<br></label>
<label><input type="checkbox" value="EcogSPMem_bl" name="variables" style="display:inline;width:auto;"> EcogSPMem_bl<br></label>
<label><input type="checkbox" value="EcogSPLang_bl" name="variables" style="display:inline;width:auto;"> EcogSPLang_bl<br></label>
<label><input type="checkbox" value="EcogSPVisspat_bl" name="variables" style="display:inline;width:auto;"> EcogSPVisspat_bl<br></label>
<label><input type="checkbox" value="EcogSPPlan_bl" name="variables" style="display:inline;width:auto;"> EcogSPPlan_bl<br></label>
<label><input type="checkbox" value="EcogSPOrgan_bl" name="variables" style="display:inline;width:auto;"> EcogSPOrgan_bl<br></label>
<label><input type="checkbox" value="EcogSPDivatt_bl" name="variables" style="display:inline;width:auto;"> EcogSPDivatt_bl<br></label>
<label><input type="checkbox" value="EcogSPTotal_bl" name="variables" style="display:inline;width:auto;"> EcogSPTotal_bl<br></label>
<label><input type="checkbox" value="FDG_bl" name="variables" style="display:inline;width:auto;"> FDG_bl<br></label>
<label><input type="checkbox" value="AV45_bl" name="variables" style="display:inline;width:auto;"> AV45_bl<br></label>
<input type="hidden" name="widget_id" value="{{widget.pk}}">
</form>
</div>
\ No newline at end of file
......@@ -36,8 +36,6 @@ def dynamic_import_globals(name, package, localSetAttrFunc):
m = None
try:
m = __import__(name, globals(), locals(), ['*'])
except ImportError:
pass
except:
import sys, traceback
print "Exception in user code:"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment