def testBasic(self): graph = Graph() op = OpCachedTiledVolumeReader(graph=graph) op.DescriptionFilePath.setValue( self.data_setup.VOLUME_DESCRIPTION_FILE) op._opReader.tiled_volume.TEST_MODE = True roi = numpy.array([(10, 150, 100), (30, 550, 550)]) cached_result_out = op.CachedOutput(*roi).wait() uncached_result_out = op.UncachedOutput(*roi).wait() specified_result_out = op.CachedOutput(*roi).wait() # We expect a channel dimension to be added automatically... assert (cached_result_out.shape == roi[1] - roi[0]).all() 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) # We can't expect the pixels to match exactly because compression was used to create the tiles... assert (expected == cached_result_out).all() assert (expected == uncached_result_out).all() assert (expected == specified_result_out).all()
def _attemptOpenAsTiledVolume(self, filePath): fileExtension = os.path.splitext(filePath)[1].lower() fileExtension = fileExtension.lstrip('.') # Remove leading dot if fileExtension in OpInputDataReader.tiledExts: opReader = OpCachedTiledVolumeReader(parent=self) try: # This will raise a SchemaError if this is the wrong type of json config. opReader.DescriptionFilePath.setValue( filePath ) return ([opReader], opReader.SpecifiedOutput) except JsonConfigParser.SchemaError: opReader.cleanUp() return ([], None)
def _attemptOpenAsTiledVolume(self, filePath): fileExtension = os.path.splitext(filePath)[1].lower() fileExtension = fileExtension.lstrip('.') # Remove leading dot if fileExtension in OpInputDataReader.tiledExts: opReader = OpCachedTiledVolumeReader(parent=self) try: # This will raise a SchemaError if this is the wrong type of json config. opReader.DescriptionFilePath.setValue(filePath) return ([opReader], opReader.SpecifiedOutput) except JsonConfigParser.SchemaError: opReader.cleanUp() return ([], None)