How to use the ndlib.ndtype.UINT32 function in ndlib

To help you get started, we’ve selected a few ndlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neurodata / ndstore / test / test_graphgen.py View on Github external
import pytest
from contextlib import closing
import networkx as nx
import makeunitdb
from ndlib.ndtype import ANNOTATION, UINT32
from params import Params
from ramonmethods import H5AnnotationFile, setField, getField, queryField, makeAnno, createSpecificSynapse
from postmethods import putAnnotation, getAnnotation, getURL, postURL
from test_settings import *

p = Params()
p.token = 'unittest'
p.resolution = 0
p.channels = ['ANNO1']
p.channel_type = ANNOTATION
p.datatype = UINT32

@pytest.mark.skipif(True, reason='Test not necessary for dev mode')
class Test_GraphGen:

  def setup_class(self):
    """Create the unittest database"""
    makeunitdb.createTestDB(p.token, channel_list=p.channels, public=True, readonly=0, ximagesize=100, yimagesize=100, zimagesize=100)

    cutout1 = "0/2,5/1,3/1,3"
    cutout2 = "0/1,3/4,6/2,5"
    cutout3 = "0/4,6/2,5/5,7"
    cutout4 = "0/6,8/5,9/2,4"

    syn_segments1 = [7, 3]
    syn_segments2 = [7, 4]
    syn_segments3 = [3, 9]
github neurodata / ndstore / webservices / ndwsingest.py View on Github external
for b in range(zsupercubedim):
            if (slice_number + b < zimagesz):
              try:
                # reading the raw data
                file_name = "{}{}".format(self.path, self.generateFileName(slice_number+b))
                # print "Open filename {}".format(file_name)
                logger.info("Open filename {}".format(file_name))
                
                if ch.channel_datatype in [UINT8, UINT16] and ch.channel_type in IMAGE_CHANNELS:
                  try:
                    image_data = np.asarray(Image.open(file_name, 'r'))
                    slab[b,:,:] = image_data
                  except Exception as e:
                    slab[b,:,:] = np.zeros((yimagesz, ximagesz), dtype=ND_dtypetonp.get(ch.channel_datatype))
                    logger.warning("File corrupted. Cannot open file. {}".format(e))
                elif ch.channel_datatype in [UINT32] and ch.channel_type in IMAGE_CHANNELS:
                  image_data = np.asarray(Image.open(file_name, 'r').convert('RGBA'))
                  slab[b,:,:] = np.left_shift(image_data[:,:,3], 24, dtype=np.uint32) | np.left_shift(image_data[:,:,2], 16, dtype=np.uint32) | np.left_shift(image_data[:,:,1], 8, dtype=np.uint32) | np.uint32(image_data[:,:,0])
                elif ch.channel_type in ANNOTATION_CHANNELS:
                  image_data = np.asarray(Image.open(file_name, 'r'))
                  slab[b,:,:] = image_data
                else:
                  logger.error("Cannot ingest this data yet")
                  raise NDWSError("Cannot ingest this data yet")
              except IOError, e:
                logger.warning("IOError {}.".format(e))
                slab[b,:,:] = np.zeros((yimagesz, ximagesz), dtype=ND_dtypetonp.get(ch.channel_datatype))
          
          for y in range ( 0, yimagesz+1, ysupercubedim ):
            for x in range ( 0, ximagesz+1, xsupercubedim ):

              # Getting a Cube id and ingesting the data one cube at a time