Tiff files are ambiguous, tifffile relies on UIC2 tag
burgerdev opened this issue · 1 comments
burgerdev commented
From tifffile.TiffPage._process_tags:
# detect type of series
if planes == 1:
self.shape = self.shape[1:]
elif numpy.all(self.uic2tag.z_distance != 0):
self.axes = 'Z' + self.axes
elif numpy.all(numpy.diff(self.uic2tag.time_created) != 0):
self.axes = 'T' + self.axes
else:
self.axes = 'I' + self.axes
OpExportMultipageTiff
does not add the required tags, resulting in a failing unit test: the export op writes a zyx volume as untagged series, tifffile does not know what the pages are and calls the first axis 'I', OpTiffReader
tries to be smart and guesses 't' before 'z'.
$ nosetests2 testOpExportMultipageTiff
F
======================================================================
FAIL: testOpExportMultipageTiff.TestOpMultipageTiff.test_basic
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/burger/Private/Coding/hci/lazyflow/tests/testOpExportMultipageTiff.py", line 88, in test_basic
assert opReorderAxes.Output.meta.shape == self.testData.shape, "Exported files were of the wrong shape or number."
AssertionError: Exported files were of the wrong shape or number.
-------------------- >> begin captured logging << --------------------
lazyflow.operators: DEBUG: Loading default Operators...
lazyflow.operators: DEBUG: OpArrayPiperWithAccessCount OpCallWhenDirty OperatorWrapper OpArrayCache OpArrayPiper OpBaseVigraFilter OpDifferenceOfGaussians OpGaussianSmoothing OpHessianOfGaussianEigenvalues OpStructureTensorEigenvalues OpHessianOfGaussianEigenvaluesFirst OpHessianOfGaussian OpGaussianGradientMagnitude OpLaplacianOfGaussian OpMultiArraySlicer OpMultiArraySlicer2 OpMultiArrayStacker OpSingleChannelSelector OpSubRegion OpMultiArrayMerger OpMaxChannelIndicatorOperator OpPixelOperator OpMultiInputConcatenater OpWrapSlot OpTransposeSlots OpDtypeView OpSelectSubslot OpCacheFixer OpUnblockedArrayCache OpSplitRequestsBlockwise OpRefactoredBlockedArrayCache OLD_OpBlockedArrayCache OpSlicedBlockedArrayCache OpXToMulti OpXToMulti OpXToMulti OpPixelFeaturesPresmoothed OpPixelFeaturesInterpPresmoothed OpImageReader OpFeatureMatrixCache OpConcatenateFeatureMatrices OpTrainClassifierBlocked OpTrainPixelwiseClassifierBlocked OpTrainVectorwiseClassifierBlocked OpTrainClassifierFromFeatureVectors OpClassifierPredict OpPixelwiseClassifierPredict OpVectorwiseClassifierPredict OpAreas ListToMultiOperator OpAttributeSelector OpMetadataInjector OpMetadataSelector OpMetadataMerge OpOutputProvider OpValueCache OpPrecomputedInput OpDummyData OpZeroDefault
lazyflow.operators.opArrayCache.OpArrayCache: DEBUG: Configured OpArrayCache with shape=(1, 10, 64, 128, 2), blockShape=(1, 10, 64, 128, 2), dirtyShape=[1 1 1 1 1], origBlockShape=(1, 10, 64, 128, 2)
tests.testOpMultipageTiff: DEBUG: writing to: /tmp/tmpcx_QM4/multipage.tiff
lazyflow.operators.ioOperators.opExportMultipageTiff: DEBUG: Starting Multipage Export with slicing shape: [1, 1, 64, 128, 2]
lazyflow.operators.opArrayCache.OpArrayCache: DEBUG: OpArrayCache: Allocating cache (size: 163840bytes)
lazyflow.operators.opArrayCache.OpArrayCache: DEBUG: read 0-1 0-1 0-64 0-128 0-2 took 0.003423 sec.
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Roi: [(9, 0, 0, 0), (10, 64, 128, 2)]
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Reading page: (9,) = 9
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Roi: [(2, 0, 0, 0), (3, 64, 128, 2)]
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Reading page: (2,) = 2
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Roi: [(6, 0, 0, 0), (7, 64, 128, 2)]
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Reading page: (6,) = 6
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Roi: [(3, 0, 0, 0), (4, 64, 128, 2)]
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Reading page: (3,) = 3
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Roi: [(5, 0, 0, 0), (6, 64, 128, 2)]
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Reading page: (5,) = 5
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Roi: [(7, 0, 0, 0), (8, 64, 128, 2)]
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Reading page: (7,) = 7
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Roi: [(4, 0, 0, 0), (5, 64, 128, 2)]
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Reading page: (4,) = 4
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Roi: [(8, 0, 0, 0), (9, 64, 128, 2)]
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Reading page: (8,) = 8
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Roi: [(1, 0, 0, 0), (2, 64, 128, 2)]
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Roi: [(0, 0, 0, 0), (1, 64, 128, 2)]
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Reading page: (1,) = 1
lazyflow.operators.ioOperators.opTiffReader: DEBUG: Reading page: (0,) = 0
tests.testOpMultipageTiff: DEBUG: Expected shape=(1, 10, 64, 128, 2)
tests.testOpMultipageTiff: DEBUG: Read shape=(10, 1, 64, 128, 2)
--------------------- >> end captured logging << ---------------------
----------------------------------------------------------------------
Ran 1 test in 0.254s
FAILED (failures=1)
stuarteberg commented
Now fixed via 13d1f52. We export TIFFs in OME-TIFF format, and read that format as well.