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 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 = OpStackLoader( 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.stack ) 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 _export_multipage_tiff_sequence(self): self.progressSignal(0) export_path_base, export_path_ext = os.path.splitext( self.ExportPath.value ) export_path_pattern = export_path_base + ".tiff" try: opExport = OpExportMultipageTiffSequence( parent=self ) opExport.FilepathPattern.setValue( export_path_pattern ) opExport.Input.connect( self.Input ) opExport.progressSignal.subscribe( self.progressSignal ) if self.CoordinateOffset.ready(): step_axis = opExport.get_nonsingleton_axes()[0] step_axis_index = self.Input.meta.getAxisKeys().index(step_axis) step_axis_offset = self.CoordinateOffset.value[step_axis_index] opExport.SliceIndexOffset.setValue( step_axis_offset ) # Run the export opExport.run_export() finally: opExport.cleanUp() self.progressSignal(100)