class TestDownload(unittest.TestCase): def setUp(self): self.oo = OCP() def test_get_cutout_type(self): # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/ numpy_download = self.oo.get_cutout('kasthuri11', 'image', 1000, 1100, 1000, 1100, 1000, 1001, resolution=3) self.assertEqual(type(numpy_download), numpy.ndarray) def test_get_cutout(self): # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/ numpy_download = self.oo.get_cutout('kasthuri11', 'image', 1000, 1100, 1000, 1100, 1000, 1001, resolution=3) # We know this pixel is 132 self.assertEqual(numpy_download[0][0][0], 132) def test_get_volume_type(self): # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/ ramon_download = self.oo.get_volume('kasthuri11', 'image', 1000, 1100, 1000, 1100, 1000, 1001, resolution=3) self.assertEqual(type(ramon_download), ndio.ramon.RAMONVolume) def test_get_volume(self): # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/ ramon_download = self.oo.get_volume('kasthuri11', 'image', 1000, 1100, 1000, 1100, 1000, 1001, resolution=3) self.assertEqual(ramon_download.xyz_offset[0], 1000) self.assertEqual(ramon_download.resolution, 3) self.assertEqual(ramon_download.cutout[0][0][0], 132) def test_get_image_type(self): # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/ image_download = self.oo.get_image('kasthuri11', 'image', 1000, 1100, 1000, 1100, 1000, resolution=3) self.assertEqual(type(image_download), numpy.ndarray) self.assertEqual(image_download.shape, (100, 100))
def getTruth(db = False): # Careful of hardcoded filepath if db == False: vol = np.array([]) data = ndio.convert.png.import_png_collection('newdata/mito_anno_*') for img in data: vol = np.dstack([vol, img]) if vol.size else img return vol else: boundaries = getConfig() oo = OCP() #added +12 because first 10 images in stack aren't even annotated return oo.get_cutout('kasthuri2015_ramon_v1', 'mitochondria', 694 + boundaries[0], 694 + boundaries[1], 1750 + boundaries[2], 1750 + boundaries[3], 1004, 1154, resolution = 3)
def getRaw(x1,x2,y1,y2,z1,z2): """ Retrieve mitochondria image volume from neurodata given x,y,z parameters Arguments: x1/y1/z1: starting value for cut x2/y2/z2: ending cut value Returns: 3D Numpy Array of images (each image is in a 2D numpy array) """ oo = OCP() return oo.get_cutout('kasthuri11cc', 'image', x1, x2, y1, y2, z1, z2, resolution = 3)
# Get all tokens tokens = oo.get_public_tokens() # Membrane group image and annotation tokens for membrane image in datamap image_token = 'kasthuri11cc' annotation_token = 'cv_kasthuri11_membrane_2014' # Get channel ROI for token channel_ROI = nn.get_metadata('cv_kasthuri11_membrane_2014')['channels'] # Get membrane ROI coordinates membrane_group_ROI = channel_ROI['image']['rois']['ac4'] # Sets membrane query in Python membrane_query = { 'token': 'cv_kasthuri11_membrane_2014', 'channel': 'image', 'x_start': membrane_group_ROI['x'][0], 'x_stop': membrane_group_ROI['x'][1], 'y_start': membrane_group_ROI['y'][0], 'y_stop': membrane_group_ROI['y'][1], 'z_start': membrane_group_ROI['z'][0], 'z_stop': membrane_group_ROI['z'][1], 'resolution': membrane_group_ROI['resolution'], } # Sets cutout arguments membrane_images = oo.get_cutout(**membrane_query) ndtiff.export_tiff('membrane_pic1.tiff', membrane_images[0])
annotation_token = "kasthuri2015_ramon_v" segmentation_token = "ac3ac4" # Get channel ROI for token channel_ROI = nn.get_metadata(segmentation_token)["channels"] # Get membrane ROI coordinates membrane_group_ROI = channel_ROI["ac4_neuron_truth"]["rois"]["ac4"] # Sets membrane query in Python membrane_query = { "token": "ac3ac4", "channel": "ac4_neuron_truth", "x_start": membrane_group_ROI["x"][0], "x_stop": membrane_group_ROI["x"][1], "y_start": membrane_group_ROI["y"][0], "y_stop": membrane_group_ROI["y"][1], "z_start": membrane_group_ROI["z"][0], "z_stop": membrane_group_ROI["z"][1], "resolution": membrane_group_ROI["resolution"], } print "Getting images" # Sets cutout arguments for ground truth membrane annotation membrane_anno = oo.get_cutout(**membrane_query) print "Printing to file" np.save("nXp_ground.npy", membrane_anno) print "Done."
annotation_token = 'kasthuri2015_ramon_v' segmentation_token = 'ac3ac4' # Get channel ROI for token channel_ROI = nn.get_metadata(segmentation_token)['channels'] # Get membrane ROI coordinates membrane_group_ROI = channel_ROI['ac4_neuron_truth']['rois']['ac4'] # Sets membrane query in Python membrane_query = { 'token': 'ac3ac4', 'channel': 'ac4_neuron_truth', 'x_start': membrane_group_ROI['x'][0], 'x_stop': membrane_group_ROI['x'][1], 'y_start': membrane_group_ROI['y'][0], 'y_stop': membrane_group_ROI['y'][1], 'z_start': membrane_group_ROI['z'][0], 'z_stop': membrane_group_ROI['z'][1], 'resolution': membrane_group_ROI['resolution'], } print "Getting images" # Sets cutout arguments for ground truth membrane annotation membrane_anno = oo.get_cutout(**membrane_query) print "Printing to file" np.save('nXp_ground.npy', membrane_anno) print "Done."