question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

imagej_metadata failed with ValueError

See original GitHub issue

When opening a TiffFile the method imagej_metadata raises this exception:

imagej_metadata failed with ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Line: 15365 @ tifffile.py:

if not bytecounts:

Maybe replace with something like:

if not bytecounts.size > 0:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cgohlkecommented, Feb 3, 2022

Fixed in v2022.2.2.

0reactions
FirefoxMetzgercommented, Feb 4, 2022

I just tried this on my end with a problematic file, and I can confirm that this fixes the problem.

Before (tifffile 2022.11.2):

>>> import tifffile
>>> foo = tifffile.TiffFile("Substack (1-1023).tif") 
<tifffile.TiffPage 0 @8> imagej_metadata failed with ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
>>> foo.imagej_metadata
{'ImageJ': '1.53e', 'images': 1023, 'slices': 1023, 'unit': 'micron', 'finterval': 0.06870408356189728, 'loop': False}

After (tifffile 2022.02.2):

>>> import tifffile
>>> foo = tifffile.TiffFile("Substack (1-1023).tif")
>>> foo.imagej_metadata
{'ImageJ': '1.53e', 'images': 1023, 'slices': 1023, 'unit': 'micron', 'finterval': 0.06870408356189728, 'loop': False, 'Info': ' BitsPerPixel = 8\n DimensionOrder = XYCZT\n IsInterleaved = false\n IsRGB = false\n LittleEndian = true\n PixelType = uint8\n Series 4 Name = Series006\n SizeC = 1\n SizeT = 1765\n SizeX = 512\n SizeY = 350\n SizeZ = 1\nImage name = Series006\nImage|ATLConfocalSettingDefinition|ActiveCS_SubModeForRLD = 1000\n [... lets avoid flooding the thread ... ]\nImage|ChannelDescription|DataType = 0\nImage|ChannelDescription|IsLUTInverted = 0\nImage|ChannelDescription|LUTName = Green\nImage|ChannelDescription|Max = 2.550000e+002\nImage|ChannelDescription|Min = 0.000000e+000\nImage|ChannelDescription|Resolution = 8\nImage|ChannelScalingInfo|Automatic = 0\nImage|ChannelScalingInfo|BlackValue = 0\nImage|ChannelScalingInfo|GammaValue = 1\nImage|ChannelScalingInfo|WhiteValue = 1\nImage|DimensionDescription|BitInc = 0\nImage|DimensionDescription|BytesInc = 179200\nImage|DimensionDescription|DimID = 4\nImage|DimensionDescription|Length = 1.211940e+002\nImage|DimensionDescription|NumberOfElements = 1765\nImage|DimensionDescription|Origin = 0.000000e+000\nImage|DimensionDescription|Unit = s\nImage|TimeStampList|NumberOfTimeStamps = 1765\nLocation = D:\\Zebrafish\\190205_nanoKTP_kif5a\\190205_nanoKTP_kif5a.lif\n', 'Labels': ['t:2/1765 - Series006', 't:3/1765 - Series006', 't:4/1765 - Series006',[... lets avoid flooding the thread ... ] 't:1023/1765 - Series006', 't:1024/1765 - Series006']}
>>> 
Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError when getting tiff tags · Issue #2006 · python-pillow ...
What did you do? I tried to extract metadata from a .tif file. What did you expect to happen? get the metadata. What...
Read more >
Replace/add Tiff image tags using Pillow from one file to another
But there are some tags which are tags like ImageJMetaData , which ... on two gif images returns the error ValueError: image has...
Read more >
Tests/test_file_tiff_metadata.py · squarecapadmin/Pillow
assertEqual(loaded.tag[ImageJMetaData], bindata) self. ... try: info = dict(info) except ValueError: self.fail("Should not be struct value error there.
Read more >
Reading pixel size from image file with python - Usage & Issues
ValueError: Cannot read Bioformats from non-local file system. ... doesn't use the ImageJ metadata to get metadata for it's own object.
Read more >
imageio Documentation - Read the Docs
[{bool, int, float, str}] If truthy, this function will raise an error if the ... index=None it should set a more sensible default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found