def _roi(self): if self._roi_cache is None: url = self.url_prefix + 'roi' # http://slowpoke3:32770/api/node/6a5a7387b4ce4333aa18d9c8d8647f58/alpha_123_roi_dilated/roi roi = dvid_requester.get(url) self._roi_cache = roi return self._roi_cache
def info(self): if self._info_cache is None: url = self.url_prefix + 'info' response = dvid_requester.get(url) if not response.ok: print(response.url, response.text) try: self._info_cache = response.json() except: pass return self._info_cache
def request_good_components(uuid, exclude_strs, hostname='emdata1.int.janelia.org', port=7000): req = dvid_requester.get( url='http://{hostname}:{port}/api/node/{uuid}/annotations/key/annotations-body'.format( hostname=hostname, port=port, uuid=uuid, ) ) json_response = req.json() result = [] for item in json_response['data']: if 'name' not in item: body_should_be_excluded = True else: body_should_be_excluded = any(text in item['name'] for text in exclude_strs) if not body_should_be_excluded: result.append((long(item['body ID']))) return result
def __getitem__(self, slices): def as_slice(s): if type(s) is slice: return s else: return slice(s, s + 1, 1) slices = tuple(map(as_slice, slices)) shape_of_slices = tuple([s.stop - s.start for s in slices]) n_spatial_dims = len(slices) axes_str = '_'.join([str(a) for a in range(n_spatial_dims)]) shape = [s.stop - s.start for s in slices] shape_str = '_'.join(str(s) for s in shape) offset = [s.start for s in slices] offset_str = '_'.join([str(o) for o in offset]) url = self.url_prefix + 'raw/' + axes_str + '/' + shape_str + '/' + offset_str + '/nD' response = dvid_requester.get(url) dvid_octet_stream = response.content array = np.fromstring(dvid_octet_stream, dtype=self.dtype) array = array.reshape(shape_of_slices) return array
def request_good_components(uuid, exclude_strs, hostname='emdata1.int.janelia.org', port=7000): req = dvid_requester.get( url= 'http://{hostname}:{port}/api/node/{uuid}/annotations/key/annotations-body' .format( hostname=hostname, port=port, uuid=uuid, )) json_response = req.json() result = [] for item in json_response['data']: if 'name' not in item: body_should_be_excluded = True else: body_should_be_excluded = any(text in item['name'] for text in exclude_strs) if not body_should_be_excluded: result.append((long(item['body ID']))) return result
def __getitem__(self, slices): def as_slice(s): if type(s) is slice: return s else: return slice(s, s + 1, 1) slices = tuple(map(as_slice, slices)) shape_of_slices = tuple([s.stop - s.start for s in slices]) n_spatial_dims = len(slices) axes_str = '_'.join([str(a) for a in range(n_spatial_dims)]) shape = [s.stop - s.start for s in slices] shape = tuple(reversed(shape)) shape_str = '_'.join(str(s) for s in shape) offset = [s.start for s in slices] offset = tuple(reversed(offset)) offset_str = '_'.join([str(o) for o in offset]) url = self.url_prefix + 'raw/' + axes_str + '/' + shape_str + '/' + offset_str + '/nD' response = dvid_requester.get(url) dvid_octet_stream = response.content array = np.fromstring(dvid_octet_stream, dtype=self.dtype) array = array.reshape(shape_of_slices) return array