Beispiel #1
0
    def test_arraylike(self, sj_fixture):
        Views = imglyb.util.Views

        shape = (3, 5)
        data = np.arange(np.prod(shape)).reshape(shape)
        block_size = (2, 2)
        img, _ = imglyb.as_cell_img(data,
                                    block_size,
                                    access_type='native',
                                    cache=1)

        cursor = Views.flatIterable(img).cursor()
        expected = 0
        while cursor.hasNext():
            assert expected == cursor.next().get()
            expected += 1

BdvFunctions = imglyb.util.BdvFunctions
BdvOptions = imglyb.util.BdvOptions
VolatileTypeMatcher = autoclass('bdv.util.volatiles.VolatileTypeMatcher')
VolatileViews = autoclass('bdv.util.volatiles.VolatileViews')

block_size = (30, ) * 3
file = h5py.File(path, 'r')
ds = file['volumes/raw']
data = da.from_array(ds, chunks=block_size)
sigma = (0.1, 1.0, 1.0)
smoothed = ndfilters.gaussian_filter(data, sigma=sigma)
img1, s1 = imglyb.as_cell_img(ds,
                              block_size,
                              cache=100,
                              access_type='native',
                              chunk_as_array=identity)
img2, s2 = imglyb.as_cell_img(smoothed,
                              block_size,
                              cache=100,
                              access_type='native',
                              chunk_as_array=compute)
try:
    vimg1 = VolatileViews.wrapAsVolatile(img1)
    vimg2 = VolatileViews.wrapAsVolatile(img2)
except JavaException as e:
    print(e.classname)
    print(e.innermessage)
    if e.stacktrace:
        for s in e.stacktrace:
Beispiel #3
0
BdvFunctions = imglyb.util.BdvFunctions
BdvOptions = imglyb.util.BdvOptions
VolatileTypeMatcher = autoclass('bdv.util.volatiles.VolatileTypeMatcher')
VolatileViews = autoclass('bdv.util.volatiles.VolatileViews')

shape = (150, 100, 125)
block_size = (32, ) * 3
data1 = da.random.randint(0,
                          256,
                          size=shape,
                          chunks=block_size,
                          dtype=np.uint8)
img1, s1 = imglyb.as_cell_img(data1,
                              block_size,
                              access_type='native',
                              chunk_as_array=lambda x: x.compute(),
                              cache=100)
data2 = da.random.randint(0,
                          256,
                          size=shape,
                          chunks=block_size,
                          dtype=np.uint8)
img2, s2 = imglyb.as_cell_img(data2,
                              block_size,
                              access_type='native',
                              chunk_as_array=lambda x: x.compute(),
                              cache=100)
try:
    vimg1 = VolatileViews.wrapAsVolatile(img1)
    vimg2 = VolatileViews.wrapAsVolatile(img2)
Beispiel #4
0
scyjava_config.add_endpoints('sc.fiji:bigdataviewer-vistools:1.0.0-beta-18')

import imglyb
from jnius import autoclass, JavaException

path = '/home/hanslovskyp/Downloads/sample_A_padded_20160501.hdf'

BdvFunctions = imglyb.util.BdvFunctions
VolatileTypeMatcher = autoclass('bdv.util.volatiles.VolatileTypeMatcher')
VolatileViews = autoclass('bdv.util.volatiles.VolatileViews')

file = h5py.File(path, 'r')
ds = file['volumes/raw']
block_size = (32, ) * 3
img, _ = imglyb.as_cell_img(ds, block_size, access_type='array', cache=10000)
try:
    vimg = VolatileViews.wrapAsVolatile(img)
except JavaException as e:
    print(e.classname)
    print(e.innermessage)
    if e.stacktrace:
        for s in e.stacktrace:
            print(s)
    raise e

bdv = BdvFunctions.show(vimg, 'raw')


def runUntilBdvDoesNotShow():
    panel = bdv.getBdvHandle().getViewerPanel()
Beispiel #5
0
import scyjava_config
scyjava_config.add_endpoints('sc.fiji:bigdataviewer-vistools:1.0.0-beta-18')

import imglyb
import numpy as np
from jnius import cast

Views = imglyb.util.Views

shape      = (3, 5)
data       = np.arange(np.prod(shape)).reshape(shape)
block_size = (2, 2)
img, _     = imglyb.as_cell_img(data, block_size, access_type='native', cache=1)

print(data)
print(img.toString())
cursor = Views.flatIterable(img).cursor()

print('Cell Img')
while cursor.hasNext():
    print(cursor.next().toString())

print()
print('ndarray')
for d in data.flat:
    print(d)
print(data)

print()
print('cells')
cursor = cast('net.imglib2.IterableInterval', img.getCells()).cursor()