Cropping a whole slide image that is too big to open

Hi, I’ve been imaging whole slides that are too big to open in ImageJ at full resolution. The images are .qptiff (i.e. pyramidal) format and I can open them with bio-formats at a lesser than full resolution. I can determine the region I want to analyze at a lesser resolution and what I would like to do is crop them without opening. I’ve been trying to use the bftools/bfcovert tool, but I’m not able to crop large regions, only small ones. What am I doing wrong? Why does there appear to be a size limit?

This is a screenshot of the bioformats window when I open the image to give an idea of the size:

Screen Shot 2019-12-10 at 4.44.05 PM

This is the output when I try to crop a large region:

~$ ./bftools/bfconvert -series 0 -crop 300,112,7000,7000 “/opt/Polaris/img_1.qptiff” “/opt/Polaris/img_1_crop.tif”
Picked up _JAVA_OPTIONS: -Xms32000m -Xmx32000m
/opt/Polaris/img_1.qptiff
VectraReader initializing /opt/Polaris/img_1.qptiff
Reading IFDs
Populating metadata
Populating OME metadata
[PerkinElmer Vectra/QPTIFF] -> /opt/Polaris/img_1_crop.tif [Tagged Image File Format]
Tile size = 512 x 512
Exception in thread “main” loci.formats.FormatException: (w:344 + x:6956) must be <= 7000
at loci.formats.FormatWriter.checkParams(FormatWriter.java:463)
at loci.formats.out.TiffWriter.saveBytes(TiffWriter.java:220)
at loci.formats.tools.ImageConverter.convertTilePlane(ImageConverter.java:878)
at loci.formats.tools.ImageConverter.convertPlane(ImageConverter.java:763)
at loci.formats.tools.ImageConverter.testConvert(ImageConverter.java:691)
at loci.formats.tools.ImageConverter.main(ImageConverter.java:1051)

If I do a smaller crop region it works ok:

$ ./bftools/bfconvert -series 0 -crop 300,112,4000,4000 “/opt/Polaris/img_1.qptiff” “/opt/Polaris/img_1_crop.tif”
Picked up _JAVA_OPTIONS: -Xms32000m -Xmx32000m
Output file /opt/Polaris/img_1_crop.tif exists.
/opt/Polaris/img_1.qptiff
VectraReader initializing /opt/Polaris/img_1.qptiff
Reading IFDs
Populating metadata
Populating OME metadata
[PerkinElmer Vectra/QPTIFF] -> /opt/Polaris/img_1_crop.tif [Tagged Image File Format]
Converted 2/4 planes (50%)
Converted 4/4 planes (100%)
[done]
3.123s elapsed (238.75+247.5ms per plane, 606ms overhead)

This is the version I’m using:

$ ./bftools/bfconvert -version
Picked up _JAVA_OPTIONS: -Xms32000m -Xmx32000m
Version: 6.3.0
Build date: 24 October 2019
VCS revision: 584ab98f489398e16e7ce8cdd7a5c80dab133cde

thanks in advance! I’m open to approaching this from a different direction is someone has a suggestion. -John

Hi John,
You could maybe try QuPath to crop regions from your slides:


In case you prefer doing it via the command line in the past I have done this using vips (https://jcupitt.github.io/libvips/API/current/).
Cheers,
Peter

1 Like

Hi @johnmc, that looks like a bug in the bfconvert tool. If you are able to upload the sample file to https://www.openmicroscopy.org/qa2/qa/upload/ we can hopefully fix it. Otherwise the ‘Crop on Import’ option in the Bio-Formats Importer in Fiji should still work.

ah, I didn’t notice that check box and went off into bftool land. Thank you!

It does work to use bio-formats in ImageJ:

IJ.run(“Bio-Formats Importer”, “open=/Volumes/Polaris/img_1.qptiff color_mode=Default crop rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT series_1 x_coordinate_1=200 y_coordinate_1=200 width_1=9000 height_1=10000”);

Let me know if you still want an example to troubleshoot bftools. thanks again! John

1 Like

3 posts were split to a new topic: Opening Perkin Elmer Vectra scanner (.qptiff)