How to use the ndlib.ndtype.UINT16 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_time.py View on Github external
def setup_class(self):
    # Testing a different datatype now
    p.datatype = UINT16
    makeunitdb.createTestDB(p.token, channel_list=p.channels, channel_type=p.channel_type, channel_datatype=p.datatype, time=p.time, window=p.window, default=True)
github neurodata / ndstore / test / test_image.py View on Github external
def setup_class(self):
    # Testing a different datatype now
    p.datatype = UINT16
    makeunitdb.createTestDB(p.token, channel_list=p.channels, channel_type=p.channel_type, channel_datatype=p.datatype, window=p.window, default=True)
github neurodata / ndstore / webservices / ndwsingest.py View on Github external
slab = np.zeros([zsupercubedim, yimagesz, ximagesz ], dtype=ND_dtypetonp.get(ch.channel_datatype))
          # fetch 16 slices at a time
          if ch.channel_type in TIMESERIES_CHANNELS:
            time_value = timestamp
          else:
            time_value = None
          self.fetchData(range(slice_number, slice_number+zsupercubedim) if slice_number+zsupercubedim<=zimagesz else range(slice_number, zimagesz), time_value=time_value)
          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:
github neurodata / ndstore / django / stats / views.py View on Github external
# get the project
    projectobj = tokenobj.project
    # get the channel
    chanobj = get_object_or_404(Channel, project = projectobj, channel_name = channel)
    # get the dataset
    datasetobj = projectobj.dataset

    if (chanobj.readonly == READONLY_TRUE):
      # we can only generate histograms on writeable channels
      return HttpResponseBadRequest("Error: Channel must not be readonly to generate histograms.")

    # now that we have a channel, kickoff the background job that will generate the histogram
    # determine number of bits (2**bits = numbins)
    if (chanobj.channel_datatype == UINT8):
      bits = 8
    elif (chanobj.channel_datatype == UINT16):
      bits = 16
    #elif (chanobj.channel_datatype == UINT32):
    #  bits = 32
    else:
      return HttpResponseBadRequest("Error: Unsupported datatype ({})".format(chanobj.channel_datatype))
    # run the background job
    result = stats.tasks.generateHistogramTask.delay(tokenobj.token_name, chanobj.channel_name, chanobj.resolution, bits)

    jsondict = {}
    jsondict['token'] = tokenobj.token_name
    jsondict['channel'] = chanobj.channel_name
    jsondict['jobid'] = result.id
    jsondict['state'] = result.state

    return HttpResponse(json.dumps(jsondict, sort_keys=True, indent=4), content_type="application/json")