In [13]:
from intern.remote.boss import BossRemote
from intern.resource.boss.resource import *
from intern.utils.parallel import block_compute
from requests import HTTPError
import h5py
import numpy as np

rmt = BossRemote('config.ini')

In [54]:
#chan = rmt.list_channels("collman", "collman14v2")
#chres = ChannelResource("annotation","collman","collman14v2",'annotation',datatype='uint64')
#exres = ExperimentResource("collman", "collman14v2")
#cf = CoordinateFrameResource("collman_collman14v2")
#cfr = rmt.get_project(cf)

#chan = rmt.list_channels("collman", "collman15v2")
#chres = ChannelResource("annotation","collman","collman15v2",'annotation',datatype='uint64')
#exres = ExperimentResource("collman", "collman15v2")
#cf = CoordinateFrameResource("collman_collman15v2")
#cfr = rmt.get_project(cf)

#chan = rmt.list_channels("kharris15", "apical")
#chres = ChannelResource("anno","kharris15","apical",'annotation',datatype='uint64')
#exres = ExperimentResource("kharris15", "anno")
#cf = CoordinateFrameResource("kharris15apical")
#cfr = rmt.get_project(cf)

chan = rmt.list_channels("collman", "M247514_Rorb_1_Site3Align2_LENS_Session1_CROP")
#chres = ChannelResource("annotation","collman","collman14v2",'annotation',datatype='uint64')
exres = ExperimentResource("collman", "M247514_Rorb_1_Site3Align2_LENS_Session1_CROP")
cf = CoordinateFrameResource("collman_M247514_Rorb_1_Site3Align2_LENS_Session1_CROP")
cfr = rmt.get_project(cf)

chName = "nomads-classifier_collman_M247514_Rorb_1_light_z_0_101_y_8800_9200_x_4500_4900_All_segmented"
chres = ChannelResource(chName,"collman_nomads","nomads_predictions",'annotation',datatype='uint64')

cf = CoordinateFrameResource("collman_nomads_nomads_predictions_nomads-classifier_collman_M247514_Rorb_1_light_z_0_101_y_8800_9200_x_4500_4900_All_segmented")
cf = CoordinateFrameResource("collman_M247514_Rorb_1_light")
cfr = rmt.get_project(cf)

In [ ]:


In [86]:
ex = {"x": cfr.x_stop, "y": cfr.y_stop, "z": cfr.z_stop}
#ex = {"x": 5000, "y": 9300, "z": cfr.z_stop}
ex


Out[86]:
{'x': 14215, 'y': 11123, 'z': 101}

In [136]:
blocks = block_compute(0,ex['x'],0,ex['y'],0,ex['z'], \
               origin = (0,0,0), block_size = (1024, 1024, 101))
               #origin = (0,0,0), block_size = (512, 512, 16))
    
    
    
len(blocks)


Out[136]:
154

In [137]:
rid = []
for b in blocks:
    rid = rid + rmt.get_ids_in_region(chres, 0, b[0], b[1], b[2], [0,1])

In [154]:
rid1 = rmt.get_ids_in_region(chres, 0, (0, 14215), (0, 11123), (0, 49), [0,1])
rid2 = rmt.get_ids_in_region(chres, 0, (0, 14215), (0, 11123), (50, 90), [0,1])
len(rid1)
len(rid2)


---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-154-895aa5fc695f> in <module>()
      1 rid1 = rmt.get_ids_in_region(chres, 0, (0, 14215), (0, 11123), (0, 49), [0,1])
----> 2 rid2 = rmt.get_ids_in_region(chres, 0, (0, 14215), (0, 11123), (50, 90), [0,1])
      3 len(rid1)
      4 len(rid2)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/intern/remote/remote.py in get_ids_in_region(self, resource, resolution, x_range, y_range, z_range, time_range)
    234         """
    235         return self._volume.get_ids_in_region(
--> 236             resource, resolution, x_range, y_range, z_range, time_range)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/intern/service/boss/volume.py in wrapper(*args, **kwargs)
     35                     'ChannelResource not fully initialized.  Use intern.remote.BossRemote.get_channel({}, {}, {})'.format(
     36                         args[1].name, args[1].coll_name, args[1].exp_name))
---> 37         return fcn(*args, **kwargs)
     38 
     39     return wrapper

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/intern/service/boss/volume.py in get_ids_in_region(self, resource, resolution, x_range, y_range, z_range, time_range)
    163         return self.service.get_ids_in_region(
    164             resource, resolution, x_range, y_range, z_range, time_range,
--> 165             self.url_prefix, self.auth, self.session, self.session_send_opts)
    166 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/intern/service/boss/v1/volume.py in get_ids_in_region(self, resource, resolution, x_range, y_range, z_range, time_range, url_prefix, auth, session, send_opts)
    316         msg = ('Get bounding box failed on {}, got HTTP response: ({}) - {}'.format(
    317             resource.name, resp.status_code, resp.text))
--> 318         raise HTTPError(msg, request=req, response=resp)

HTTPError: Get bounding box failed on nomads-classifier_collman_M247514_Rorb_1_light_z_0_101_y_8800_9200_x_4500_4900_All_segmented, got HTTP response: (500) - <h1>Server Error (500)</h1>

In [63]:
k = 4
ids = rmt.get_ids_in_region(chres, resolution = 0, 
                            x_range = [blocks[k][0][0],blocks[k][0][1]], 
                            y_range = [blocks[k][1][0],blocks[k][1][1]], 
                            z_range = [blocks[k][2][0],blocks[k][2][1]])
ids


Out[63]:
[]

In [144]:
blocks[40]


Out[144]:
((4096, 5120), (8192, 9216), (0, 101))

In [ ]:


In [ ]:


In [ ]:


In [ ]: