CAVEconnectome / CAVEclient

This is the python client for accessing REST APIs within the Connectome Annotation Versioning Engine.
https://caveconnectome.github.io/CAVEclient/
MIT License
19 stars 12 forks source link

Added L2Cache interface #45

Closed sdorkenw closed 2 years ago

sdorkenw commented 2 years ago

Examples:

import numpy as np
import datetime
from caveclient import CAVEclient

datastack_name = "flywire_fafb_production"
client = CAVEclient(datastack_name)

l2_ids = [175137943013294113, 175137943013294114, 175137943013294118, 175137943013294119,]

client.l2cache.get_l2data(l2_ids)
{'175137943013294113': {},
 '175137943013294114': {'area_nm2': 253952,
  'chunk_intersect_count': [[0, 0, 0], [0, 0, 0]],
  'max_dt_nm': 62,
  'mean_dt_nm': 25.390625,
  'pca': [[-0.18603515625, 0.7392578125, -0.6474609375],
   [-0.2296142578125, -0.67333984375, -0.70263671875],
   [0.95556640625, -0.0178680419921875, -0.294921875]],
  'rep_coord_nm': [535088, 248800, 164880],
  'size_nm3': 4239360},
 '175137943013294118': {'area_nm2': 2432,
  'chunk_intersect_count': [[0, 0, 0], [0, 0, 0]],
  'max_dt_nm': 16,
  'mean_dt_nm': 16.0,
  'pca': [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]],
  'rep_coord_nm': [536240, 251008, 164920],
  'size_nm3': 10240},
 '175137943013294119': {}}
client.l2cache.get_l2data(l2_ids, attributes=["size_nm3", "pca", "rep_coord_nm"])
{'175137943013294113': {},
 '175137943013294114': {'pca': [[-0.18603515625, 0.7392578125, -0.6474609375],
   [-0.2296142578125, -0.67333984375, -0.70263671875],
   [0.95556640625, -0.0178680419921875, -0.294921875]],
  'rep_coord_nm': [535088, 248800, 164880],
  'size_nm3': 4239360},
 '175137943013294118': {'pca': [[1.0, 0.0, 0.0],
   [0.0, 1.0, 0.0],
   [0.0, 0.0, 1.0]],
  'rep_coord_nm': [536240, 251008, 164920],
  'size_nm3': 10240},
 '175137943013294119': {}}
client.l2cache.cache_metadata()
{'area_nm2': "<class 'numpy.uint32'>",
 'chunk_intersect_count': "<class 'numpy.uint16'>",
 'max_dt_nm': "<class 'numpy.uint16'>",
 'mean_dt_nm': "<class 'numpy.float16'>",
 'pca': "<class 'numpy.float16'>",
 'rep_coord_nm': "<class 'numpy.uint64'>",
 'size_nm3': "<class 'numpy.uint32'>"}
fcollman commented 2 years ago

looks good.. if i were gonna add anything it would be a testing module that goes along with it that follows the pattern of the others mocking out the expected result.