def test_special_z_translation(self): """ This tests the special """ tiled_volume = TiledVolume( self.data_setup.SPECIAL_Z_VOLUME_DESCRIPTION_FILE) tiled_volume.TEST_MODE = True reference_roi = numpy.array([(20, 150, 100), (40, 550, 550)]) result_out = numpy.zeros(reference_roi[1] - reference_roi[0], dtype=tiled_volume.description.dtype) roi_translated = reference_roi - [11, 0, 0] tiled_volume.read(roi_translated, result_out) ref_path_comp = PathComponents(self.data_setup.REFERENCE_VOL_PATH) with h5py.File(ref_path_comp.externalPath, 'r') as f: ref_data = f[ref_path_comp.internalPath][:] expected = ref_data[roiToSlice(*reference_roi)] #numpy.save('/tmp/expected.npy', expected) #numpy.save('/tmp/result_out.npy', result_out) assert (expected == result_out).all()
def testBasic(self): tiled_volume = TiledVolume(self.data_setup.LOCAL_VOLUME_DESCRIPTION_FILE) tiled_volume.TEST_MODE = True roi = numpy.array([(10, 150, 100), (30, 550, 550)]) result_out = numpy.zeros(roi[1] - roi[0], dtype=tiled_volume.description.dtype) tiled_volume.read(roi, result_out) ref_path_comp = PathComponents(self.data_setup.REFERENCE_VOL_PATH) with h5py.File(ref_path_comp.externalPath, "r") as f: ref_data = f[ref_path_comp.internalPath][:] expected = ref_data[roiToSlice(*roi)] # numpy.save('/tmp/expected.npy', expected) # numpy.save('/tmp/result_out.npy', result_out) assert (expected == result_out).all()
def testBasic(self): tiled_volume = TiledVolume( self.data_setup.LOCAL_VOLUME_DESCRIPTION_FILE ) tiled_volume.TEST_MODE = True roi = numpy.array( [(10, 150, 100), (30, 550, 550)] ) result_out = numpy.zeros( roi[1] - roi[0], dtype=tiled_volume.description.dtype ) tiled_volume.read( roi, result_out ) ref_path_comp = PathComponents(self.data_setup.REFERENCE_VOL_PATH) with h5py.File(ref_path_comp.externalPath, 'r') as f: ref_data = f[ref_path_comp.internalPath][:] expected = ref_data[roiToSlice(*roi)] #numpy.save('/tmp/expected.npy', expected) #numpy.save('/tmp/result_out.npy', result_out) assert (expected == result_out).all()
def testMissingTiles(self): tiled_volume = TiledVolume(self.data_setup.VOLUME_DESCRIPTION_FILE) tiled_volume.TEST_MODE = True # The test data should be missing slice 2, and the config doesn't remap the data. roi = numpy.array([(0, 150, 100), (10, 550, 550)]) result_out = numpy.zeros(roi[1] - roi[0], dtype=tiled_volume.description.dtype) tiled_volume.read(roi, result_out) ref_path_comp = PathComponents(self.data_setup.REFERENCE_VOL_PATH) with h5py.File(ref_path_comp.externalPath, "r") as f: ref_data = f[ref_path_comp.internalPath][:] # Slice 2 is missing from the server data expected = ref_data[roiToSlice(*roi)] expected[2] = 0 # numpy.save('/tmp/expected.npy', expected) # numpy.save('/tmp/result_out.npy', result_out) assert (expected == result_out).all()
def testMissingTiles(self): tiled_volume = TiledVolume( self.data_setup.VOLUME_DESCRIPTION_FILE ) tiled_volume.TEST_MODE = True # The test data should be missing slice 2, and the config doesn't remap the data. roi = numpy.array( [(0, 150, 100), (10, 550, 550)] ) result_out = numpy.zeros( roi[1] - roi[0], dtype=tiled_volume.description.dtype ) tiled_volume.read( roi, result_out ) ref_path_comp = PathComponents(self.data_setup.REFERENCE_VOL_PATH) with h5py.File(ref_path_comp.externalPath, 'r') as f: ref_data = f[ref_path_comp.internalPath][:] # Slice 2 is missing from the server data expected = ref_data[roiToSlice(*roi)] expected[2] = 0 #numpy.save('/tmp/expected.npy', expected) #numpy.save('/tmp/result_out.npy', result_out) assert (expected == result_out).all()
def testViewOriginOffset(self): tiled_volume = TiledVolume( self.data_setup.TRANSLATED_VOLUME_DESCRIPTION_FILE) tiled_volume.TEST_MODE = True reference_roi = numpy.array([(10, 150, 100), (30, 550, 550)]) result_out = numpy.zeros(reference_roi[1] - reference_roi[0], dtype=tiled_volume.description.dtype) roi_translated = reference_roi - [10, 20, 30] tiled_volume.read(roi_translated, result_out) ref_path_comp = PathComponents(self.data_setup.REFERENCE_VOL_PATH) with h5py.File(ref_path_comp.externalPath, "r") as f: ref_data = f[ref_path_comp.internalPath][:] expected = ref_data[roiToSlice(*reference_roi)] # numpy.save('/tmp/expected.npy', expected) # numpy.save('/tmp/result_out.npy', result_out) assert (expected == result_out).all()
def test_special_z_translation(self): """ This tests the special """ tiled_volume = TiledVolume(self.data_setup.SPECIAL_Z_VOLUME_DESCRIPTION_FILE) tiled_volume.TEST_MODE = True reference_roi = numpy.array([(20, 150, 100), (40, 550, 550)]) result_out = numpy.zeros(reference_roi[1] - reference_roi[0], dtype=tiled_volume.description.dtype) roi_translated = reference_roi - [11, 0, 0] tiled_volume.read(roi_translated, result_out) ref_path_comp = PathComponents(self.data_setup.REFERENCE_VOL_PATH) with h5py.File(ref_path_comp.externalPath, "r") as f: ref_data = f[ref_path_comp.internalPath][:] expected = ref_data[roiToSlice(*reference_roi)] # numpy.save('/tmp/expected.npy', expected) # numpy.save('/tmp/result_out.npy', result_out) assert (expected == result_out).all()
def testRemappedTiles(self): # The config above specifies that slices 45:47 get their data from slice 44, # and slice 41 is the same as 40 tiled_volume = TiledVolume(self.data_setup.VOLUME_DESCRIPTION_FILE) tiled_volume.TEST_MODE = True roi = numpy.array([(40, 150, 100), (50, 550, 550)]) result_out = numpy.zeros(roi[1] - roi[0], dtype=tiled_volume.description.dtype) tiled_volume.read(roi, result_out) ref_path_comp = PathComponents(self.data_setup.REFERENCE_VOL_PATH) with h5py.File(ref_path_comp.externalPath, "r") as f: ref_data = f[ref_path_comp.internalPath][:] # Slices 5,6,7 are missing from the server data, and 'filled in' with slice 4 # Similarly, slice 1 is missing and filled in with slice 0. expected = ref_data[roiToSlice(*roi)] expected[5:8] = expected[4] expected[1] = expected[0] # numpy.save('/tmp/expected.npy', expected) # numpy.save('/tmp/result_out.npy', result_out) assert (expected == result_out).all()
def testCustomAxes(self): tiled_volume = TiledVolume( self.data_setup.TRANSPOSED_VOLUME_DESCRIPTION_FILE) tiled_volume.TEST_MODE = True roi = numpy.array([(10, 150, 100), (30, 550, 550)]) result_out = numpy.zeros(roi[1] - roi[0], dtype=tiled_volume.description.dtype) roi_t = (tuple(reversed(roi[0])), tuple(reversed(roi[1]))) result_out_t = result_out.transpose() tiled_volume.read(roi_t, result_out_t) ref_path_comp = PathComponents(self.data_setup.REFERENCE_VOL_PATH) with h5py.File(ref_path_comp.externalPath, "r") as f: ref_data = f[ref_path_comp.internalPath][:] expected = ref_data[roiToSlice(*roi)] # numpy.save('/tmp/expected.npy', expected) # numpy.save('/tmp/result_out.npy', result_out) assert (expected == result_out).all()
def testRemappedTiles(self): # The config above specifies that slices 45:47 get their data from slice 44, # and slice 41 is the same as 40 tiled_volume = TiledVolume( self.data_setup.VOLUME_DESCRIPTION_FILE ) tiled_volume.TEST_MODE = True roi = numpy.array( [(40, 150, 100), (50, 550, 550)] ) result_out = numpy.zeros( roi[1] - roi[0], dtype=tiled_volume.description.dtype ) tiled_volume.read( roi, result_out ) ref_path_comp = PathComponents(self.data_setup.REFERENCE_VOL_PATH) with h5py.File(ref_path_comp.externalPath, 'r') as f: ref_data = f[ref_path_comp.internalPath][:] # Slices 5,6,7 are missing from the server data, and 'filled in' with slice 4 # Similarly, slice 1 is missing and filled in with slice 0. expected = ref_data[roiToSlice(*roi)] expected[5:8] = expected[4] expected[1] = expected[0] #numpy.save('/tmp/expected.npy', expected) #numpy.save('/tmp/result_out.npy', result_out) assert (expected == result_out).all()