def test_Writer(self): opData = OpArrayCache(graph=self.graph) opData.blockShape.setValue(self.testData.shape) opData.Input.setValue(self.testData) opExport = OpExportMultipageTiffSequence(graph=self.graph) opExport.FilepathPattern.setValue(self._stack_filepattern) opExport.Input.connect(opData.Output) opExport.SliceIndexOffset.setValue(22) # Run the export opExport.run_export() globstring = self._stack_filepattern.format(slice_index=999) globstring = globstring.replace('999', '*') opReader = OpTiffSequenceReader(graph=self.graph) opReader.GlobString.setValue(globstring) # (The OpStackLoader produces txyzc order.) opReorderAxes = OpReorderAxes(graph=self.graph) opReorderAxes.AxisOrder.setValue(self._axisorder) opReorderAxes.Input.connect(opReader.Output) readData = opReorderAxes.Output[:].wait() logger.debug("Expected shape={}".format(self.testData.shape)) logger.debug("Read shape={}".format(readData.shape)) assert opReorderAxes.Output.meta.shape == self.testData.shape, "Exported files were of the wrong shape or number." assert (opReorderAxes.Output[:].wait() == self.testData.view( numpy.ndarray)).all(), "Exported data was not correct" opReorderAxes.cleanUp() opReader.cleanUp()
def __init__(self, *args, **kwargs): super( OpSplitBodyCarving, self ).__init__( *args, **kwargs ) self._opParseAnnotations = OpParseAnnotations( parent=self ) self._opParseAnnotations.AnnotationFilepath.connect( self.AnnotationFilepath ) self._opParseAnnotations.BodyLabels.connect( self.RavelerLabels ) self.AnnotationLocations.connect( self._opParseAnnotations.AnnotationLocations ) self.AnnotationBodyIds.connect( self._opParseAnnotations.AnnotationBodyIds ) self.Annotations.connect( self._opParseAnnotations.Annotations ) self._opSelectRavelerObject = OpSelectLabel( parent=self ) self._opSelectRavelerObject.SelectedLabel.connect( self.CurrentRavelerLabel ) self._opSelectRavelerObject.Input.connect( self.RavelerLabels ) self.CurrentRavelerObject.connect( self._opSelectRavelerObject.Output ) # LUTs of all fragments of the current Raveler body are combined into a single LUT self._opFragmentSetLut = OpFragmentSetLut( parent=self ) self._opFragmentSetLut.MST.connect( self._opMstCache.Output ) self._opFragmentSetLut.RavelerLabel.connect( self.CurrentRavelerLabel ) self._opFragmentSetLut.CurrentEditingFragment.connect( self.CurrentEditingFragment ) self._opFragmentSetLut.Trigger.connect( self.Trigger ) # The combined LUT is cached to avoid recomputing it for every orthoview. self._opFragmentSetLutCache = OpArrayCache( parent=self ) self._opFragmentSetLutCache.blockShape.setValue( (1e10,) ) # Something big (always get the whole thing) # Display-only: Show the annotations as crosshairs self._opCrosshairs = OpCrosshairMarkers( parent=self ) self._opCrosshairs.CrosshairRadius.setValue( 5 ) self._opCrosshairs.Input.connect( self.RavelerLabels ) self._opCrosshairs.PointList.connect( self.AnnotationLocations ) self.AnnotationCrosshairs.connect( self._opCrosshairs.Output )
def test_basic(self): opData = OpArrayCache(graph=self.graph) opData.blockShape.setValue(self.testData.shape) opData.Input.setValue(self.testData) filepath = os.path.join(self._tmpdir, 'multipage.tiff') logger.debug("writing to: {}".format(filepath)) opExport = OpExportMultipageTiff(graph=self.graph) opExport.Filepath.setValue(filepath) opExport.Input.connect(opData.Output) # Run the export opExport.run_export() opReader = OpInputDataReader(graph=self.graph) opReader.FilePath.setValue(filepath) # The reader assumes xyzc order. # We have to transpose the data before we compare. opReorderAxes = OpReorderAxes(graph=self.graph) opReorderAxes.AxisOrder.setValue(self._axisorder) opReorderAxes.Input.connect(opReader.Output) readData = opReorderAxes.Output[:].wait() logger.debug("Expected shape={}".format(self.testData.shape)) logger.debug("Read shape={}".format(readData.shape)) assert opReorderAxes.Output.meta.shape == self.testData.shape, "Exported files were of the wrong shape or number." assert (opReorderAxes.Output[:].wait() == self.testData.view( numpy.ndarray)).all(), "Exported data was not correct" # Cleanup opReorderAxes.cleanUp() opReader.cleanUp()
def test_basic(self): graph = lazyflow.graph.Graph() data = numpy.indices((100, 100), dtype=numpy.uint8).sum(0) data = vigra.taggedView(data, vigra.defaultAxistags('xy')) opDataProvider = OpArrayCache(graph=graph) opDataProvider.Input.setValue(data) op = OpZeroDefault(graph=graph) op.MetaInput.setValue(data) # Zero by default output_data = op.Output[:].wait() assert (output_data == 0).all() # Connecting a real input triggers dirty notification dirty_notification_count = [0] def handleDirty(*args): dirty_notification_count[0] += 1 op.Output.notifyDirty(handleDirty) op.Input.connect(opDataProvider.Output) assert dirty_notification_count[0] == 1 # Output should provide real data if available assert (op.Output[:].wait() == data.view(numpy.ndarray)).all() # Output provides zeros again when the data is no longer available op.Input.disconnect() output_data = op.Output[:].wait() assert (output_data == 0).all()
def testBasic_MultipageTiffSequence(self): data = 255 * numpy.random.random((5, 10, 50, 100, 3)) data = data.astype(numpy.uint8) data = vigra.taggedView(data, vigra.defaultAxistags('tzyxc')) # Must run this through an operator # Can't use opExport.setValue() because because OpStackWriter can't work with ValueRequests graph = Graph() opData = OpArrayCache(graph=graph) opData.blockShape.setValue(data.shape) opData.Input.setValue(data) filepattern = self._tmpdir + '/test_export_x{x_start}-{x_stop}_y{y_start}-{y_stop}_t{slice_index}' opExport = OpExportSlot(graph=graph) opExport.Input.connect(opData.Output) opExport.OutputFormat.setValue('multipage tiff sequence') opExport.OutputFilenameFormat.setValue(filepattern) opExport.CoordinateOffset.setValue((7, 10, 20, 30, 0)) opExport.run_export() export_pattern = opExport.ExportPath.value globstring = export_pattern.format(slice_index=999) globstring = globstring.replace('999', '*') opReader = OpTiffSequenceReader(graph=graph) opReorderAxes = OpReorderAxes(graph=graph) try: opReader.GlobString.setValue(globstring) # (The OpStackLoader produces txyzc order.) opReorderAxes.AxisOrder.setValue('tzyxc') opReorderAxes.Input.connect(opReader.Output) assert opReorderAxes.Output.meta.shape == data.shape, "Exported files were of the wrong shape or number." assert (opReorderAxes.Output[:].wait() == data.view( numpy.ndarray)).all(), "Exported data was not correct" finally: opReorderAxes.cleanUp() opReader.cleanUp()
def test_basic(self): opSource = OpArrayPiper(graph=self.graph) opSource.Input.setValue(self.testData) opData = OpArrayCache(graph=self.graph) opData.blockShape.setValue(self.testData.shape) opData.Input.connect(opSource.Output) filepath = os.path.join(self._tmpdir, 'multipage.tiff') logger.debug("writing to: {}".format(filepath)) opExport = OpExportMultipageTiff(graph=self.graph) opExport.Filepath.setValue(filepath) opExport.Input.connect(opData.Output) # Run the export opExport.run_export() opReader = OpTiffReader(graph=self.graph) try: opReader.Filepath.setValue(filepath) # Re-order before comparing opReorderAxes = OpReorderAxes(graph=self.graph) try: opReorderAxes.AxisOrder.setValue(self._axisorder) opReorderAxes.Input.connect(opReader.Output) readData = opReorderAxes.Output[:].wait() logger.debug("Expected shape={}".format(self.testData.shape)) logger.debug("Read shape={}".format(readData.shape)) assert opReorderAxes.Output.meta.shape == self.testData.shape, \ "Exported files were of the wrong shape or number." assert (opReorderAxes.Output[:].wait() == self.testData.view( numpy.ndarray )).all(), \ "Exported data was not correct" finally: opReorderAxes.cleanUp() finally: opReader.cleanUp()