def testFrangi(self): input_array = np.array([[1000, 1000, 1000, 2000, 3000], [5000, 8000, 13000, 21000, 34000]]) result = np.zeros(input_array.shape) ij.op().filter().frangiVesselness(imglyb.to_imglib(result), imglyb.to_imglib(input_array), [1, 1], 4) correct_result = np.array([[0, 0, 0, 0.94282, 0.94283], [0, 0, 0, 0.94283, 0.94283]]) result = np.ndarray.round(result, decimals=5) self.assertTrue((result == correct_result).all())
def to_java(self, data): """ Converts the data into a java equivalent. For numpy arrays, the java image points to the python array """ if self._is_memoryarraylike(data): return imglyb.to_imglib(data) return to_java(data)
def to_java(self, data): """ Converts the data into a java equivalent. For numpy arrays, the java image points to the python array """ if type(data) == numpy.ndarray: return imglyb.to_imglib(data) return to_java(data)
def to_java(self, data): """ Converts the data into a java equivalent. For numpy arrays, the java image points to the python array. In addition to the scyjava types, we allow ndarray-like and xarray-like variables """ if self._is_memoryarraylike(data): return imglyb.to_imglib(data) if self._is_xarraylike(data): return self.to_dataset(data) return to_java(data)
def add_labels( self, data, name, max_id, resolution = [1.0] * 3, offset = [0.0] * 3): import imglyb from .jfx import invoke_on_jfx_application_thread img = imglyb.to_imglib(data) invoke_on_jfx_application_thread(lambda: self._add_labels(img, resolution, offset, max_id, name))
def add_raw( self, data, name, resolution = [1.0] * 3, offset = [0.0] * 3, minv = 0.0, maxv = 1.0): import imglyb from .jfx import invoke_on_jfx_application_thread img = imglyb.to_imglib(data) invoke_on_jfx_application_thread(lambda: self._add_raw(img, resolution, offset, minv, maxv, name))
def testGaussian(self): input_array = np.array([[1000, 1000, 1000, 2000, 3000], [5000, 8000, 13000, 21000, 34000]]) output_array = ij.op().filter().gauss(imglyb.to_imglib(input_array), 10) result = [] correct_result = [8440, 8440, 8439, 8444] ra = output_array.randomAccess() for x in [0, 1]: for y in [0, 1]: ra.setPosition(x, y) result.append(ra.get().get()) self.assertEqual(result, correct_result)
def testImageMath(self): Views = autoclass('net.imglib2.view.Views') input_array = np.array([[1, 1, 2], [3, 5, 8]]) result = [] correct_result = [192, 198, 205, 192, 198, 204] java_in = Views.iterable(imglyb.to_imglib(input_array)) java_out = ij.op().image().equation( java_in, "64 * (Math.sin(0.1 * p[0]) + Math.cos(0.1 * p[1])) + 128") itr = java_out.iterator() while itr.hasNext(): result.append(itr.next().get()) self.assertEqual(result, correct_result)
def create_display(status): status[1] = display.createDisplay( title, imglyb.to_imglib(img) if isinstance(img, (np.ndarray, )) else img) status[0] = True
def _numpy_to_dataset(self, data): rai = imglyb.to_imglib(data) return self._java_to_dataset(rai)
payntera.jfx.init_platform() PainteraBaseView = autoclass( 'org.janelia.saalfeldlab.paintera.PainteraBaseView') viewer = PainteraBaseView.defaultView() pbv = viewer.baseView scene, stage = payntera.jfx.start_stage(viewer.paneWithStatus.getPane()) shape = (80, 80, 50) x, y, z = np.indices(shape) fx, fy, fz = 2 * np.pi / np.array(shape) * np.array([10, 1, 3]) raw = (1 + np.sin(x * fx)) * (1 + np.sin(y * fy)) * ( 1 + x * y / (shape[0] * shape[1]))**2 * (1 + np.cos(z * fz)) * ( (x + y + z) / np.sum(shape)) raw_img = imglyb.to_imglib(raw) labels, nb = scipy.ndimage.label(raw > 0.5) labels_img = imglyb.to_imglib(labels) raw_state = pbv.addSingleScaleRawSource(raw_img, [1.0, 1.0, 1.0], [0.0, 0.0, 0.0], np.min(raw), 7, 'blub') state = pbv.addSingleScaleLabelSource(labels_img, [1.0, 1.0, 1.0], [0.0, 0.0, 0.0], nb + 1, 'bla') viewer.keyTracker.installInto(scene) scene.addEventFilter( autoclass('javafx.scene.input.MouseEvent').ANY, viewer.mouseTracker) while stage.isShowing(): time.sleep(0.1)
neuron_ids_dataset = f['volumes/labels/neuron_ids'] raw_res = [x for x in raw_dataset.attrs['resolution'][::-1] ] if 'resolution' in raw_dataset.attrs else [1.0, 1.0, 1.0] raw_off = [x for x in raw_dataset.attrs['offset'][::-1] ] if 'offset' in raw_dataset.attrs else [1.0, 1.0, 1.0] neuron_ids_res = [ x for x in neuron_ids_dataset.attrs['resolution'][::-1] ] if 'resolution' in neuron_ids_dataset.attrs else [1.0, 1.0, 1.0] neuron_ids_off = [ x for x in neuron_ids_dataset.attrs['offset'][::-1] ] if 'offset' in neuron_ids_dataset.attrs else [1.0, 1.0, 1.0] raw = raw_dataset.value neuron_ids = neuron_ids_dataset.value max_id = np.max(neuron_ids) + 1 img = imglyb.to_imglib(neuron_ids) state = LabelSourceState.simpleSourceFromSingleRAI( img, neuron_ids_res, neuron_ids_off, max_id, 'neuron ids', viewer.baseView.viewer3D().meshesGroup(), viewer.baseView.getMeshManagerExecutorService(), viewer.baseView.getMeshWorkerExecutorService()) raw_img = imglyb.to_imglib(raw) raw_state = RawSourceState.simpleSourceFromSingleRAI(raw_img, raw_res, raw_off, 0.0, 255.0, 'raw') viewer.keyTracker.installInto(scene) scene.addEventFilter( autoclass('javafx.scene.input.MouseEvent').ANY, viewer.mouseTracker) payntera.jfx.invoke_on_jfx_application_thread(