Bfconvert throwing loci.formats.FormatException for a czi file

Sample image and/or macro code

Background

Running:

bfconvert -noflat img1.czi img1-%s-%c-%z.ome.tif

The output is:

ZeissCZIReader initializing img1.czi
[Zeiss CZI] -> img1-%s-%c-%z.ome.tif [OME-TIFF]
Switching to BigTIFF (by file size)
Tile size = 1024 x 1024
Series 0: converted 1/1 planes (100%)
Tile size = 1024 x 1024
Series 0: converted 1/1 planes (100%)
Tile size = 1024 x 1024
Series 0: converted 1/1 planes (100%)
Tile size = 1024 x 1024
Series 0: converted 1/1 planes (100%)
Series 0: converted 1/1 planes (100%)
Series 0: converted 1/1 planes (100%)
Series 0: converted 1/1 planes (100%)
Tile size = 1024 x 1024
Exception in thread “main” loci.formats.FormatException: (w:1024 + x:36864) must be <= 37670
at loci.formats.FormatWriter.checkParams(FormatWriter.java:464)
at loci.formats.out.TiffWriter.saveBytes(TiffWriter.java:229)
at loci.formats.out.OMETiffWriter.saveBytes(OMETiffWriter.java:218)
at loci.formats.out.PyramidOMETiffWriter.saveBytes(PyramidOMETiffWriter.java:89)
at loci.formats.tools.ImageConverter.convertTilePlane(ImageConverter.java:923)
at loci.formats.tools.ImageConverter.convertPlane(ImageConverter.java:791)
at loci.formats.tools.ImageConverter.testConvert(ImageConverter.java:719)
at loci.formats.tools.ImageConverter.main(ImageConverter.java:1096)

Challenges

  • What software packages and/or plugins have you tried?

bfconvert -version
Version: 6.5.0
Build date: 30 April 2020
VCS revision: ed992ebc2cb07d04fcb49485540af0babd1baa05

HI @serban,

thanks for sharing the sample file. The error you are receiving is another occurrence of the bfconvert issue for multi-series files reported in Bfconvert throwing an error for an *.vsi file and which will be addressed in the next Bio-Formats release by https://github.com/ome/bioformats/pull/3553.

Similarly to the previous post, your best immediate workaround is to use a downgraded version of Bio-Formats 6.3.1 for converting multi-series images.

Best,
Sebastien

Thank you @s.besson for your answer,

I’ve downloaded bftools 6.3.1 and gave it a try but I still have the same error :

I:\ImageDataSets\SlideScanner\bftools\bftools>bfconvert -pyramid-resolutions 2 -pyramid-scale 3 -series 0 -tilex 512 -tiley 512 -noflat -bigtiff JPEG-90pct.vsi JPEG-90.ome.tiff
JPEG-90pct.vsi
CellSensReader initializing JPEG-90pct.vsi
[CellSens VSI] -> JPEG-90.ome.tiff [OME-TIFF]
Tile size = 512 x 512
        Converted 1/1 planes (100%)
Tile size = 512 x 512
Exception in thread "main" loci.formats.FormatException: (w:512 + x:3584) must be <= 3892
        at loci.formats.FormatWriter.checkParams(FormatWriter.java:463)
        at loci.formats.out.TiffWriter.saveBytes(TiffWriter.java:220)
        at loci.formats.out.OMETiffWriter.saveBytes(OMETiffWriter.java:218)
        at loci.formats.out.PyramidOMETiffWriter.saveBytes(PyramidOMETiffWriter.java:89)
        at loci.formats.tools.ImageConverter.convertTilePlane(ImageConverter.java:913)
        at loci.formats.tools.ImageConverter.convertPlane(ImageConverter.java:781)
        at loci.formats.tools.ImageConverter.testConvert(ImageConverter.java:709)
        at loci.formats.tools.ImageConverter.main(ImageConverter.java:1086)

Best,

R

Hi @romainGuiet, are the files you are using already multi resolution images? Are you trying to generate extra pyramid levels or simply convert the existing ones?

Hi @dgault,
I’m sorry I just realized I answered in the wrong thread, it started there: Bfconvert error with *.vsi file?

Yes it’s already a multi resolution vsi

I would like to use the full resolution image and generates a new pyramidal image, or if possible simply convert to ome.tiff by keeping the existing multi-resolution

Ok, what looks to have happened is that if the number of resolutions requested is the same as or smaller than the number existing in the file, then the converter will try to use the existing ones. However in this case you wanted a different scale which lead to the odd size mismatch. This is a bug which I will log and try to resolve in a future release of the converter. Until then there are work arounds for it.

Converting using the existing resolutions is straight forward:
bfconvert -tilex 512 -tiley 512 -noflat -bigtiff JPEG-90pct.vsi JPEG-90.ome.tiff

To generate new resolutions you will need to either set the number of resolutions to be greater than those already available in the file, or you the same downsampling as the existing file.

So you can increase the number of resolutions:
bfconvert -pyramid-resolutions 4 -pyramid-scale 3 -series 0 -tilex 512 -tiley 512 -noflat -bigtiff JPEG-90pct.vsi JPEG-90.ome.tiff JPEG-90pct.vsi

Or keep the downsampling the same (in which case it will use the existing resolutions rather than generating them):
bfconvert -pyramid-resolutions 2 -pyramid-scale 2 -series 0 -tilex 512 -tiley 512 -noflat -bigtiff JPEG-90pct.vsi JPEG-90.ome.tiff JPEG-90pct.vsi

1 Like