def test_export(self): """ hostname: The dvid server host h5filename: The h5 file to compare against h5group: The hdf5 group, also used as the uuid of the dvid dataset h5dataset: The dataset name, also used as the name of the dvid dataset start, stop: The bounds of the cutout volume to retrieve from the server. C ORDER FOR THIS TEST BECAUSE we use transpose_axes=True. """ # Retrieve from server graph = Graph() opExport = OpExportDvidVolume( transpose_axes=True, graph=graph ) data = numpy.indices( (10, 100, 200, 4) ) assert data.shape == (4, 10, 100, 200, 4) data = data.astype( numpy.uint8 ) data = vigra.taggedView( data, vigra.defaultAxistags('tzyxc') ) # Reverse data order for dvid export opExport.Input.setValue( data ) opExport.NodeDataUrl.setValue( 'http://localhost:8000/api/node/{uuid}/{dataname}'.format( uuid=self.data_uuid, dataname=self.data_name ) ) # Export! opExport.run_export() # Retrieve from file with h5py.File(self.test_filepath, 'r') as f: exported_data = f['all_nodes'][self.data_uuid][self.data_name][:] # Compare. assert ( data.view(numpy.ndarray) == exported_data.transpose() ).all(),\ "Exported data is not correct"
def test_export(self): # For now, we require block-aligned POST data = numpy.random.randint(0,255, (32, 128, 256, 1) ).astype(numpy.uint8) data = numpy.asfortranarray(data, numpy.uint8) assert data.shape == (32, 128, 256, 1) data = data.astype( numpy.uint8 ) data = vigra.taggedView( data, vigra.defaultAxistags('zyxc') ) # Retrieve from server graph = Graph() opPiper = OpArrayPiper(graph=graph) opPiper.Input.setValue( data ) opExport = OpExportDvidVolume( transpose_axes=True, graph=graph ) # Reverse data order for dvid export opExport.Input.connect( opPiper.Output ) opExport.NodeDataUrl.setValue( 'http://localhost:8000/api/node/{uuid}/{dataname}'.format( uuid=self.data_uuid, dataname=self.data_name ) ) # Export! opExport.run_export() # Read back. (transposed, because of transposed_axes, above) accessor = VoxelsAccessor(TEST_DVID_SERVER, self.data_uuid, self.data_name) read_data = accessor[:] # Compare. assert ( data.view(numpy.ndarray) == read_data.transpose() ).all(), \ "Exported data is not correct"
def test_export(self): # For now, we require block-aligned POST data = numpy.random.randint(0, 255, (32, 128, 256, 1)).astype(numpy.uint8) data = numpy.asfortranarray(data, numpy.uint8) assert data.shape == (32, 128, 256, 1) data = data.astype(numpy.uint8) data = vigra.taggedView(data, vigra.defaultAxistags("zyxc")) # Retrieve from server graph = Graph() opPiper = OpArrayPiper(graph=graph) opPiper.Input.setValue(data) opExport = OpExportDvidVolume(transpose_axes=True, graph=graph) # Reverse data order for dvid export opExport.Input.connect(opPiper.Output) opExport.NodeDataUrl.setValue( "http://localhost:8000/api/node/{uuid}/{dataname}".format( uuid=self.data_uuid, dataname=self.data_name)) # Export! opExport.run_export() # Read back. (transposed, because of transposed_axes, above) accessor = VoxelsAccessor(TEST_DVID_SERVER, self.data_uuid, self.data_name) read_data = accessor[:] # Compare. assert (data.view(numpy.ndarray) == read_data.transpose() ).all(), "Exported data is not correct"
def test_export(self): """ hostname: The dvid server host h5filename: The h5 file to compare against h5group: The hdf5 group, also used as the uuid of the dvid dataset h5dataset: The dataset name, also used as the name of the dvid dataset start, stop: The bounds of the cutout volume to retrieve from the server. C ORDER FOR THIS TEST BECAUSE we use transpose_axes=True. """ data = numpy.indices( (10, 100, 200, 4) ) assert data.shape == (4, 10, 100, 200, 4) data = data.astype( numpy.uint8 ) data = vigra.taggedView( data, vigra.defaultAxistags('tzyxc') ) # Retrieve from server graph = Graph() opPiper = OpArrayPiper(graph=graph) opPiper.Input.setValue( data ) opExport = OpExportDvidVolume( transpose_axes=True, graph=graph ) # Reverse data order for dvid export opExport.Input.connect( opPiper.Output ) opExport.NodeDataUrl.setValue( 'http://localhost:8000/api/node/{uuid}/{dataname}'.format( uuid=self.data_uuid, dataname=self.data_name ) ) # Export! opExport.run_export() # Retrieve from file with h5py.File(self.test_filepath, 'r') as f: exported_data = f['all_nodes'][self.data_uuid][self.data_name][:] # Compare. assert ( data.view(numpy.ndarray) == exported_data.transpose() ).all(),\ "Exported data is not correct"
def _export_dvid(self): self.progressSignal(0) export_path = self.ExportPath.value opExport = OpExportDvidVolume( transpose_axes=True, parent=self ) try: opExport.Input.connect( self.Input ) opExport.NodeDataUrl.setValue( export_path ) # Run the export in this thread opExport.run_export() finally: opExport.cleanUp() self.progressSignal(100)
def test_export_with_offset(self): """ For now, the offset and data must both be block-aligned for DVID. """ data = numpy.random.randint(0, 255, (32, 128, 256, 1)).astype(numpy.uint8) data = numpy.asfortranarray(data, numpy.uint8) assert data.shape == (32, 128, 256, 1) data = vigra.taggedView(data, vigra.defaultAxistags("zyxc")) # Retrieve from server graph = Graph() opPiper = OpArrayPiper(graph=graph) opPiper.Input.setValue(data) opExport = OpExportDvidVolume(transpose_axes=True, graph=graph) # Reverse data order for dvid export opExport.Input.connect(opPiper.Output) opExport.NodeDataUrl.setValue( "http://localhost:8000/api/node/{uuid}/{dataname}".format( uuid=self.data_uuid, dataname=self.data_name)) offset = (32, 64, 128, 0) opExport.OffsetCoord.setValue(offset) # Export! opExport.run_export() # Read back. (transposed, because of transposed_axes, above) accessor = VoxelsAccessor(TEST_DVID_SERVER, self.data_uuid, self.data_name) read_data = accessor[:] # The offset should have caused larger extents in the saved data. assert (read_data.transpose().shape == numpy.add( data.shape, offset)).all(), "Wrong shape: {}".format( exported_data.transpose().shape) # Compare. offset_slicing = tuple(slice(s, None) for s in offset) assert (data.view( numpy.ndarray) == read_data.transpose()[offset_slicing] ).all(), "Exported data is not correct"
def test_export_with_offset(self): """ hostname: The dvid server host h5filename: The h5 file to compare against h5group: The hdf5 group, also used as the uuid of the dvid dataset h5dataset: The dataset name, also used as the name of the dvid dataset start, stop: The bounds of the cutout volume to retrieve from the server. C ORDER FOR THIS TEST BECAUSE we use transpose_axes=True. """ data = numpy.indices( (10, 100, 200, 4) ) assert data.shape == (4, 10, 100, 200, 4) data = data.astype( numpy.uint8 ) data = vigra.taggedView( data, vigra.defaultAxistags('tzyxc') ) # Retrieve from server graph = Graph() opPiper = OpArrayPiper(graph=graph) opPiper.Input.setValue( data ) opExport = OpExportDvidVolume( transpose_axes=True, graph=graph ) # Reverse data order for dvid export opExport.Input.connect( opPiper.Output ) opExport.NodeDataUrl.setValue( 'http://localhost:8000/api/node/{uuid}/{dataname}'.format( uuid=self.data_uuid, dataname=self.data_name ) ) offset = (0, 5, 500, 0, 0) opExport.OffsetCoord.setValue( offset ) # Export! opExport.run_export() # Retrieve from file with h5py.File(self.test_filepath, 'r') as f: exported_data = f['all_nodes'][self.data_uuid][self.data_name][:] # The offset should have caused larger extents in the saved data. assert (exported_data.transpose().shape == numpy.add( data.shape, offset )).all(), \ "Wrong shape: {}".format(exported_data.transpose().shape) # Compare. offset_slicing = tuple(slice(s,None) for s in offset) assert ( data.view(numpy.ndarray) == exported_data.transpose()[offset_slicing] ).all(),\ "Exported data is not correct"
def test_export_with_offset(self): """ For now, the offset and data must both be block-aligned for DVID. """ data = numpy.random.randint(0, 255, (32, 128, 256, 1)).astype(numpy.uint8) data = numpy.asfortranarray(data, numpy.uint8) assert data.shape == (32, 128, 256, 1) data = vigra.taggedView(data, vigra.defaultAxistags("zyxc")) # Retrieve from server graph = Graph() opPiper = OpArrayPiper(graph=graph) opPiper.Input.setValue(data) opExport = OpExportDvidVolume(transpose_axes=True, graph=graph) # Reverse data order for dvid export opExport.Input.connect(opPiper.Output) opExport.NodeDataUrl.setValue( "http://localhost:8000/api/node/{uuid}/{dataname}".format(uuid=self.data_uuid, dataname=self.data_name) ) offset = (32, 64, 128, 0) opExport.OffsetCoord.setValue(offset) # Export! opExport.run_export() # Read back. (transposed, because of transposed_axes, above) accessor = VoxelsAccessor(TEST_DVID_SERVER, self.data_uuid, self.data_name) read_data = accessor[:] # The offset should have caused larger extents in the saved data. assert (read_data.transpose().shape == numpy.add(data.shape, offset)).all(), "Wrong shape: {}".format( exported_data.transpose().shape ) # Compare. offset_slicing = tuple(slice(s, None) for s in offset) assert (data.view(numpy.ndarray) == read_data.transpose()[offset_slicing]).all(), "Exported data is not correct"
def _export_dvid(self): self.progressSignal(0) export_path = self.ExportPath.value opExport = OpExportDvidVolume(transpose_axes=True, parent=self) try: opExport.Input.connect(self.Input) opExport.NodeDataUrl.setValue(export_path) # Run the export in this thread opExport.run_export() finally: opExport.cleanUp() self.progressSignal(100)
def _onSpecifyClicked(self): # FIXME don't hardcode hostname list browser = ContentsBrowser(["localhost:8000"], mode="specify_new", parent=self) if browser.exec_() == ContentsBrowser.Accepted: hostname, dataset_index, data_name, node_uuid = browser.get_selection( ) url = "http://{hostname}/api/node/{node_uuid}/{data_name}".format( **locals()) self._urlSlot.setValue(url) self.urlLabel.setText(url) if __name__ == "__main__": from PyQt4.QtGui import QApplication from lazyflow.graph import Graph from lazyflow.operators.ioOperators import OpExportDvidVolume op = OpExportDvidVolume(transpose_axes=True, graph=Graph()) app = QApplication([]) w = DvidVolumeExportOptionsWidget(None) w.initSlot(op.NodeDataUrl) w.show() app.exec_() print "New Dataset URL: {}".format(op.NodeDataUrl.value)