Skip to content

Commit

Permalink
fix: microviewer installation, pixel value update, scroll direction (#…
Browse files Browse the repository at this point in the history
…231)

* misc enhancements

* feat: export Vec class for use in other applications

* update displayed pixel value on change of slice

* make mousewheel scrolling direction match w/s keyboard and neuroglancer behavior

* avoid files ending up in site-packages/ext upon installation in python

* refactor: move viewer to microviewer and edit MANIFEST.in

* update_pxvalue for hyperview too. Removed extra lines from merge.
  • Loading branch information
shangmu authored and william-silversmith committed Jun 21, 2019
1 parent e6ab953 commit 23b811c
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 22 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Manuel Castro <[email protected]>
Nicholas Turner <[email protected]>
Nico Kemnitz <[email protected]>
Pat Gunn <[email protected]>
Shang Mu <[email protected]>
Thomas Macrina <[email protected]>
William Silversmith <[email protected]>
William Silversmith <[email protected]>
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
recursive-include ext
include LICENSE
4 changes: 2 additions & 2 deletions cloudvolume/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from . import secrets
from . import txrx

from . import viewer
from .viewer import view, hyperview
from . import microviewer
from .microviewer import view, hyperview

__version__ = '0.50.0'
8 changes: 4 additions & 4 deletions cloudvolume/viewer.py → cloudvolume/microviewer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
from tqdm import tqdm

from .lib import Vec, Bbox, mkdir, save_images, ExtractedPath, yellow
from cloudvolume.lib import Vec, Bbox, mkdir, save_images, ExtractedPath, yellow

DEFAULT_PORT = 8080

Expand All @@ -35,7 +35,7 @@ def getoffset(img, offset):
return Vec(0,0,0)

def to_volumecutout(img, image_type, resolution=None, offset=None, hostname='localhost'):
from . import VolumeCutout
from cloudvolume.volumecutout import VolumeCutout
if type(img) == VolumeCutout:
try:
img.dataset_name # check if it's an intact VolumeCutout
Expand Down Expand Up @@ -85,7 +85,7 @@ def view(
img, segmentation=False, resolution=None, offset=None,
hostname="localhost", port=DEFAULT_PORT
):
from . import VolumeCutout
from cloudvolume.volumecutout import VolumeCutout

img = to3d(img)
resolution = getresolution(img, resolution)
Expand Down Expand Up @@ -202,6 +202,6 @@ def serve_file(self):
path = 'index.html'

dirname = os.path.dirname(__file__)
filepath = os.path.join(dirname, '../ext/microviewer/' + path)
filepath = os.path.join(dirname, './' + path)
with open(filepath, 'rb') as f:
self.wfile.write(f.read())
File renamed without changes.
File renamed without changes.
28 changes: 16 additions & 12 deletions ext/microviewer/index.html → cloudvolume/microviewer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@
SLICE.z = (y * (SIZE.z - 1))|0;
}

PXVALUE = [ vol.channel.get(SLICE.x, SLICE.y, SLICE.z) ];

vol.hover_id = null;
if (vol.is_segmentation) {
vol.hover_id = PXVALUE[0];
}

render();
});
}
Expand Down Expand Up @@ -152,10 +145,6 @@
SLICE.z = (y * (SIZE.z - 1))|0;
}

PXVALUE = [ vol.channel.get(SLICE.x, SLICE.y, SLICE.z) ];
vol.hover_id = vol.segmentation.get(SLICE.x, SLICE.y, SLICE.z);
PXVALUE.push(vol.hover_id);

render();
});

Expand Down Expand Up @@ -254,7 +243,7 @@

$(document).on('wheel', function (e) {
var delta = clamp(e.originalEvent.deltaY, -1, 1);
delta = Math.round(delta);
delta = -Math.round(delta);
move_slice(delta);
});

Expand Down Expand Up @@ -361,7 +350,22 @@
elems.shape.text( `<${SIZE.x}, ${SIZE.y}, ${SIZE.z}>` );
}

function update_pxvalue () {
PXVALUE = [ vol.channel.get(SLICE.x, SLICE.y, SLICE.z) ];

vol.hover_id = null;
if (vol.is_segmentation) {
vol.hover_id = PXVALUE[0];
}

if (vol.segmentation) {
vol.hover_id = vol.segmentation.get(SLICE.x, SLICE.y, SLICE.z);
PXVALUE.push(vol.hover_id);
}
}

function render () {
update_pxvalue();
_needsrender = true;
}

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions cloudvolume/volumecutout.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from .lib import mkdir, save_images

from . import viewer
from . import microviewer

class VolumeCutout(np.ndarray):

Expand Down Expand Up @@ -78,4 +78,4 @@ def save_images(self, directory=None, axis='z', channel=None, global_norm=True,

def viewer(self, port=8080):
"""Start a local web app on the given port that lets you explore this cutout."""
viewer.run([ self ], port=port)
microviewer.run([ self ], port=port)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
package_data={
'cloudvolume': [
'../ext/microviewer/*',
'./microviewer/*',
],
},
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 23b811c

Please sign in to comment.