Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clientside viewer #22

Merged
merged 92 commits into from
Jan 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
0f3fd14
better use of new preload flag
thejohnhoffer Nov 3, 2016
2fd7b96
update openseadragon
thejohnhoffer Nov 4, 2016
e8327bf
correct use of preload
thejohnhoffer Nov 4, 2016
f91f903
update openseadragon
thejohnhoffer Nov 4, 2016
3b8944d
remove comment
thejohnhoffer Nov 4, 2016
54ae72b
slightly better fully loaded check
thejohnhoffer Nov 4, 2016
3e83855
limit depth
thejohnhoffer Nov 4, 2016
ceb76f3
ready for testing
thejohnhoffer Nov 4, 2016
2ea4d90
check for fully loaded has nothing to do with lastDrawn
thejohnhoffer Nov 4, 2016
82bf9b2
fix misnomer
thejohnhoffer Nov 4, 2016
b282380
remove redundant call to fullyLoaded
thejohnhoffer Nov 4, 2016
c68f6fd
do not draw undrawable tiles
thejohnhoffer Nov 4, 2016
719b975
fully loaded demo
thejohnhoffer Nov 4, 2016
538dced
Revert "fully loaded demo"
thejohnhoffer Nov 4, 2016
02c7a43
update openseadragon
thejohnhoffer Nov 4, 2016
60ac7d8
fancy debug log
thejohnhoffer Nov 5, 2016
8d70ae7
fancy debug log
thejohnhoffer Nov 5, 2016
f94a153
remove useless call
thejohnhoffer Nov 5, 2016
1cead63
remove troublesome call
thejohnhoffer Nov 5, 2016
ed5c5d6
stable layering
thejohnhoffer Nov 7, 2016
78f23d3
propper depth handling
thejohnhoffer Nov 7, 2016
097b0b5
ignore debugging
thejohnhoffer Nov 8, 2016
87fedad
allow 24 bit IDs encoded in pngs
thejohnhoffer Nov 9, 2016
e890f24
clearer naming
thejohnhoffer Nov 14, 2016
d6c2a86
allow setting z stack in url
thejohnhoffer Nov 14, 2016
29d7556
Merge branch 'client' into server
thejohnhoffer Nov 14, 2016
7fddf28
pip removed pytree- link must be added to requirements.txt
thejohnhoffer Nov 14, 2016
d7bb536
downgrade dependency
thejohnhoffer Nov 15, 2016
7c516a2
remove excess tabs
thejohnhoffer Nov 15, 2016
84802fb
no comment
thejohnhoffer Nov 15, 2016
c12218c
cleaner reshaping
thejohnhoffer Nov 16, 2016
d083f87
add cutout logic to mojo
thejohnhoffer Nov 17, 2016
414834a
shorten api
thejohnhoffer Nov 17, 2016
f61ae1d
remove extra methods from core
thejohnhoffer Nov 17, 2016
b89b161
functional
thejohnhoffer Nov 18, 2016
181b223
regular image stack
thejohnhoffer Nov 18, 2016
83982ee
refactor and clean up
thejohnhoffer Nov 18, 2016
6febb5e
remove redundant try catch
thejohnhoffer Nov 18, 2016
8d177cd
parameter as integer
thejohnhoffer Nov 18, 2016
bd7d0cf
refactor exceptions
thejohnhoffer Nov 18, 2016
6cc2684
parameter change
thejohnhoffer Nov 21, 2016
5408704
default get dtype
thejohnhoffer Nov 21, 2016
cb8d97b
default dtype
thejohnhoffer Nov 21, 2016
44108f7
one channel per datasource enforced
thejohnhoffer Nov 28, 2016
18c0e63
remove segmentation from loading
thejohnhoffer Nov 28, 2016
fc3f8cc
tab styling
thejohnhoffer Nov 28, 2016
328f04f
better indexing
thejohnhoffer Nov 28, 2016
d07c726
client uses rest API
thejohnhoffer Nov 29, 2016
f6e8464
missing var
thejohnhoffer Nov 29, 2016
a081237
datapath
thejohnhoffer Nov 29, 2016
cd8c54a
conditional zip
thejohnhoffer Nov 29, 2016
b575242
rest api working
thejohnhoffer Nov 29, 2016
0cd68fa
tilesource crop fix
thejohnhoffer Nov 29, 2016
bb20517
remove logs
thejohnhoffer Nov 29, 2016
d52d74b
added tilespecs
thejohnhoffer Nov 30, 2016
61705a1
hdf5 now returns boundaries
thejohnhoffer Nov 30, 2016
b1fbef8
correct datatypes when rendering tiles
thejohnhoffer Dec 1, 2016
7668011
only uint8 for images
thejohnhoffer Dec 1, 2016
d7aa0d3
no need for format when loading
thejohnhoffer Dec 1, 2016
350c7f7
treats each processed datasource as a channel
thejohnhoffer Dec 1, 2016
555d246
remove old comment
thejohnhoffer Dec 2, 2016
a1a820d
cli parses directory structure into experiments, samples, and datasets
thejohnhoffer Dec 2, 2016
00d9f38
client renders urls properly
thejohnhoffer Dec 2, 2016
1d67917
client allows periods in channel names
thejohnhoffer Dec 2, 2016
b83e877
max depth
thejohnhoffer Dec 2, 2016
9ce7a6d
refactor auto-indexing
thejohnhoffer Dec 5, 2016
9fa5788
allow folder path one directory above experiments
thejohnhoffer Dec 5, 2016
699d5ee
save indexed yaml file
thejohnhoffer Dec 5, 2016
861b719
save indexed yaml file
thejohnhoffer Dec 5, 2016
1d2166a
testing flattening
thejohnhoffer Dec 5, 2016
3fa6f87
testing flattening
thejohnhoffer Dec 5, 2016
daec6e2
restrict file depth to below number of categories
thejohnhoffer Dec 5, 2016
3023f47
better function for flattening experiments
thejohnhoffer Dec 5, 2016
83d90d3
stable new indexing
thejohnhoffer Dec 6, 2016
c68748b
bfly_indexed saved to home directory
thejohnhoffer Dec 7, 2016
2747ecd
yaml now saves to file given by --out or -o flag
thejohnhoffer Dec 7, 2016
22f7c8d
allow requesting less than a single tile
thejohnhoffer Dec 8, 2016
f75fac4
typecast tile corner indices to integers
thejohnhoffer Dec 8, 2016
0fae9f2
allow image data of to be zipped with propper dtype
thejohnhoffer Dec 8, 2016
4549c25
If --out filename, port is saved in addition to experiments
thejohnhoffer Dec 8, 2016
a6286f6
remove all logging
thejohnhoffer Dec 11, 2016
242af04
merge new changes from master
thejohnhoffer Dec 13, 2016
92a22a8
remove logging function
thejohnhoffer Dec 13, 2016
74c4075
fix error for hdf5 file without fson file
thejohnhoffer Dec 13, 2016
3cb7273
fix lost reference in load call of hdf5
thejohnhoffer Dec 13, 2016
baf4569
update .gitignore
thejohnhoffer Dec 13, 2016
a1048f1
Merge branch 'master' into dev_master
thejohnhoffer Dec 16, 2016
27df83f
Merge branch 'master' into dev_master
thejohnhoffer Dec 17, 2016
a579f77
allow CORS
thejohnhoffer Jan 18, 2017
474dadb
allow float images
thejohnhoffer Jan 19, 2017
7f82103
allow float images
thejohnhoffer Jan 19, 2017
0e2b996
set min height and width to 512
thejohnhoffer Jan 19, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions butterfly/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def initialize(self, core):
'''
self.core = core

self.set_header("Access-Control-Allow-Origin", "*")
self.set_header('Access-Control-Allow-Methods', 'GET')

def get(self, command):
'''Handle an HTTP GET request'''

Expand Down
15 changes: 11 additions & 4 deletions butterfly/static/index/setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
log = console.log.bind(window.console);
//log = console.log.bind(window.console);
//-----------------------------------
//
// DOJO.Setup: request data from server
Expand All @@ -20,7 +20,6 @@ DOJO.Setup.prototype = {
'dataset','channel',
'channel_metadata'
],
output: [],
start: function(old){
return this.loader(['root'],{old:old},0);
},
Expand Down Expand Up @@ -65,9 +64,17 @@ DOJO.Setup.prototype = {
return this.write.main(terms);
},
draw: function(parent, depth, result) {
var constant = {
old: result.old,
depth: depth
}
var target = {
self: parent.concat(0),
parent: parent,
target: 'body'
}
var loader = this.loader.bind(this);
var build = this.build.bind(this,{old: result.old, depth: depth});
var target = {self:parent.concat(0), parent:parent, target:'body'};
var build = this.build.bind(this,constant);
if (result.out instanceof Array){
var promises = result.out.map(function(name,i){
target.target = 'head';
Expand Down
11 changes: 3 additions & 8 deletions butterfly/static/index/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ DOJO.Write.prototype = {
copy: function(id,i){
return document.getElementById(id).children[i].cloneNode(1);
},
chan: [
new RegExp('(seg|id).*', 'i'),
new RegExp('(syn).*', 'i')
],
grandparent: function(el){
return el.parentElement.parentElement;
},
Expand Down Expand Up @@ -48,11 +44,10 @@ DOJO.Write.prototype = {
var uncle = this.grandkid(ancestor,[1,1]);
var size = source.dimensions;
var dtype = source['data-type'];
var withGL = Number(dtype!='uint8');
var [w,h,d] = [size.x,size.y,size.z];
var channel = withGL + source.channel;
var path = 'viz.html?depth='+d+'&width='+w+'&height='+h;
var channel = Number(!dtype.match(/float|uint8/)) + source.channel;
var old = source.old.replace(/&channel=([^&]+)/,'&channel='+channel);;
var [w,h,d] = [Math.max(size.x,512),Math.max(size.y,512),size.z];
var path = 'viz.html?depth='+d+'&width='+w+'&height='+h;
cousin.children[0].href = path + '&' + old;
if (uncle.children[0].href) {
uncle.children[0].href += ',' + channel;
Expand Down
172 changes: 86 additions & 86 deletions butterfly/static/viz/realtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,95 +10,95 @@


DOJO.RealTime = function(scope) {
this.stack = scope.stack;
this.seaGL = new openSeadragonGL(scope.openSD);
this.seaGL.vShader = './shaders/vertex/rect.glsl';
this.seaGL.fShader = './shaders/fragment/rect.glsl';
this.stack = scope.stack;
this.seaGL = new openSeadragonGL(scope.openSD);
this.seaGL.vShader = './shaders/vertex/rect.glsl';
this.seaGL.fShader = './shaders/fragment/rect.glsl';
}

DOJO.RealTime.prototype = {
init: function(input){
var seaGL = this.seaGL;
var stack = this.stack;
var fun = function(){ };
var found = input.findings;
var rgb2id = function(rgb){
return rgb[0] + 256*rgb[1] + 65536*rgb[2];
}
var isTarget = fun.call.bind(function(){
return this.source && this.source.gl;
});
var isDojo = fun.call.bind(function(){
return this.source && this.source.dojo;
});
var nearTile = function(tile){
var where = new OpenSeadragon.Point(tile.x,tile.y);
return this.level == tile.level && this.xy.equals(where);
}
var isTile = function(tile){
var here = this.bounds.getTopLeft();
var where = tile.bounds.getTopLeft();
return this.level == tile.level && here.equals(where);
}
var contextualize = function(tile){
return tile.cacheImageRecord.getRenderedContext();
}
var pointColor = function(point,tile) {
var shape = tile.bounds.getSize();
var space = tile.bounds.getTopLeft();
var inImg = contextualize(tile);
var inCanv = inImg.canvas;
var d = point.minus(space);
var tmp = [d.x/shape.x, d.y/shape.y];
var xy = [inCanv.width*tmp[0], inCanv.height*tmp[1]].map(Math.ceil);
return inImg.getImageData(xy[0], xy[1], 1, 1).data;
}
var click = function(callback,e){
var point = stack.vp.viewerElementToViewportCoordinates(e.position);
var allItems = stack.findLayer(0).reverse();
var targets = allItems.filter(isTarget)[0];
var dojo = stack.getDojo();
if(dojo && targets && targets.lastDrawn.length){
var here = {level: targets.lastDrawn[0].level};
here.xy = dojo.source.getTileAtPoint(here.level,point);
var hereTile = targets.lastDrawn.filter(nearTile.bind(here))[0];
if(hereTile){
this.viaGL.clickID = pointColor(point,hereTile);
found[1].childNodes[1].innerHTML = rgb2id(this.viaGL.clickID);
this.openSD.forceRedraw();
}
}
}
var draw = function(callback,e){
var allItems = stack.findLayer(0);
var dojo = e.tiledImage.source.dojo;
if (!dojo){
return;
}
var targets = allItems.filter(isTarget)[0];
if(targets && targets.lastDrawn.length){
var fromTile = targets.lastDrawn.filter(isTile.bind(e.tile))[0];
if(fromTile){
e.output = contextualize(e.tile);
e.rendered = contextualize(fromTile);
callback(e);
}
}
}
// Load for glsl
var GLloaded = function(program) {
this.clicker = this.gl.getUniformLocation(program, 'u_click_id');
init: function(input){
var seaGL = this.seaGL;
var stack = this.stack;
var fun = function(){ };
var found = input.findings;
var rgb2id = function(rgb){
return rgb[0] + 256*rgb[1] + 65536*rgb[2];
}
var isTarget = fun.call.bind(function(){
return this.source && this.source.target;
});
var isDojo = fun.call.bind(function(){
return this.source && this.source.dojo;
});
var nearTile = function(tile){
var where = new OpenSeadragon.Point(tile.x,tile.y);
return this.level == tile.level && this.xy.equals(where);
}
var isTile = function(tile){
var here = this.bounds.getTopLeft();
var where = tile.bounds.getTopLeft();
return this.level == tile.level && here.equals(where);
}
var contextualize = function(tile){
return tile.cacheImageRecord.getRenderedContext();
}
var pointColor = function(point,tile) {
var shape = tile.bounds.getSize();
var space = tile.bounds.getTopLeft();
var inImg = contextualize(tile);
var inCanv = inImg.canvas;
var d = point.minus(space);
var tmp = [d.x/shape.x, d.y/shape.y];
var xy = [inCanv.width*tmp[0], inCanv.height*tmp[1]].map(Math.ceil);
return inImg.getImageData(xy[0], xy[1], 1, 1).data;
}
var click = function(callback,e){
var point = stack.vp.viewerElementToViewportCoordinates(e.position);
var allItems = stack.findLayer(0).reverse();
var targets = allItems.filter(isTarget)[0];
var dojo = stack.getDojo();
if(dojo && targets && targets.lastDrawn.length){
var here = {level: targets.lastDrawn[0].level};
here.xy = dojo.source.getTileAtPoint(here.level,point);
var hereTile = targets.lastDrawn.filter(nearTile.bind(here))[0];
if(hereTile){
this.viaGL.clickID = pointColor(point,hereTile);
found[1].childNodes[1].innerHTML = rgb2id(this.viaGL.clickID);
this.openSD.forceRedraw();
}
// Draw for glsl
var GLdrawing = function() {
var clickID = this.clickID || [-1,-1,-1,-1];
this.gl.uniform4f(this.clicker, clickID[0], clickID[1], clickID[2], clickID[3]);
}
}
var draw = function(callback,e){
var allItems = stack.findLayer(0);
var dojo = e.tiledImage.source.dojo;
if (!dojo){
return;
}
var targets = allItems.filter(isTarget)[0];
if(targets && targets.lastDrawn.length){
var fromTile = targets.lastDrawn.filter(isTile.bind(e.tile))[0];
if(fromTile){
e.output = contextualize(e.tile);
e.rendered = contextualize(fromTile);
callback(e);
}
found[1].childNodes[1].innerHTML = 0;
seaGL.addHandler('gl-drawing',GLdrawing);
seaGL.addHandler('gl-loaded',GLloaded);
seaGL.addHandler('canvas-click',click);
seaGL.addHandler('tile-drawing',draw);
return seaGL.init();
}
}
// Load for glsl
var GLloaded = function(program) {
this.clicker = this.gl.getUniformLocation(program, 'u_click_id');
}
}
// Draw for glsl
var GLdrawing = function() {
var clickID = this.clickID || [-1,-1,-1,-1];
this.gl.uniform4f(this.clicker, clickID[0], clickID[1], clickID[2], clickID[3]);
}
found[1].childNodes[1].innerHTML = 0;
seaGL.addHandler('gl-drawing',GLdrawing);
seaGL.addHandler('gl-loaded',GLloaded);
seaGL.addHandler('canvas-click',click);
seaGL.addHandler('tile-drawing',draw);
return seaGL.init();
}
}
21 changes: 1 addition & 20 deletions butterfly/static/viz/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// -- Made by main.js
// -- Init by main.js
//-----------------------------------
log = console.log.bind(window.console);
//log = console.log.bind(window.console);

DOJO.Stack = function(src_terms){

Expand Down Expand Up @@ -161,25 +161,6 @@ DOJO.Stack.prototype = {
}
return newBuff;
},
log: function(newBuff){
log('z:' + this.z);
log('buffer: [' + newBuff.down + ':' + newBuff.up+']');
for (var zb = -newBuff.down; zb <= newBuff.up; zb++){
var tab = ' ';
var star = zb===0? '*' : ' ';
var image = this.findLayer(zb).pop();
if (image) {
var zeta = image.source.z;
var alpha = image.getOpacity();
var preload = image.getPreload();
}
log(star+tab+'layer '+ zeta || 'null' );
log(tab+tab+'opacity:'+alpha || 'null');
log(tab+tab+'preload:'+preload || 'null');
log(tab+tab+'index: ['+this.findIndex(zb)+']');
};
log(' ');
},
refresher: function(e){
e.item.addHandler('fully-loaded-change',function(e){
var image = e.eventSource;
Expand Down
3 changes: 2 additions & 1 deletion butterfly/static/viz/tools/osd/zipjob.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ ZipJob.prototype = {
},

set: function(raw) {
var size = this.parse(this.src).size.split(",").slice(0,2).map(Number);
var src = this.parse(this.src);
var size = [src.width, src.height].map(Number);
var output = this.viaGL.toCanvas(raw,size);
this.image.onload = this.finish.bind(this);
this.image.src = output.toDataURL();
Expand Down
2 changes: 1 addition & 1 deletion butterfly/static/viz/tools/osd/ziploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ZipLoader.prototype = {
abort: options.abort
};
// Cool Hack from 2016-09-26
if (options.src.slice(-3) == 'zip') {
if (options.src.indexOf('&format=zip') >= 0) {
var newJob = new ZipJob( this.viaGL, jobOptions );
}
else {
Expand Down
2 changes: 1 addition & 1 deletion butterfly/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def handle(self, handler):
# Rotate out of numpy array
volume = volume.transpose(1, 0, 2)
zipped_data = zlib.compress(
volume.astype(np.uint32).tostring('F'))
volume.astype(out_dtype).tostring('F'))

output = StringIO.StringIO()
output.write(zipped_data)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
tornado==4.3
h5py==2.6.0
scipy==0.16.0
https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/pyrtree/source-archive.zip
https://github.com/Rhoana/rh_config/archive/1.0.0.tar.gz#egg=rh_config-1.0.0
https://github.com/Rhoana/rh_logger/archive/2.0.0.tar.gz#egg=rh_logger-2.0.0
https://github.com/Rhoana/dataspec/archive/1.1.1.tar.gz#egg=dataspec-1.1.1
Expand Down