Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #7175 (closed)

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

Bug: ImageStack.getProcessor missing calibration table for virtual ImagePluses

Reported by: crueden-x Owned by: mlinkert
Priority: minor Milestone: Unscheduled
Component: Bio-Formats Version: n.a.
Keywords: n.a. Cc:
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: 0.0d
Sprint: n.a.

Description (last modified by crueden-x)

When calling imp.getImageStack().getProcessor(i) for i>1 on an ImagePlus? imp, there is a discrepancy between the behavior depending on how Bio-Formats opened that ImagePlus?. If the ImagePlus? is virtual, the returned processor has no associated calibration table. But if the ImagePlus? is non-virtual, or i==1, then the calibration table is present.

This results in the method ImageProcessor?.getPixelValue(int, int) failing to return a properly calibrated value in the problem cases.

As a result, ImporterTest?.testDatasetSwapDims() currently fails when testing signed data (INT8 and INT16) with virtual stacks.

Here is an example program that illustrates the problem:

//
// BFBug.java
//

import ij.IJ;
import ij.ImageJ;
import ij.ImagePlus;
import ij.WindowManager;
import ij.io.Opener;
import ij.process.ImageProcessor;
import loci.plugins.BF;
import loci.plugins.in.ImporterOptions;

public class BFBug {

	public static void main(final String[] args) throws Exception {
		new ImageJ();

		final boolean useBioFormats = true;
		final ImagePlus imp, vImp;

		if (useBioFormats) {
			final String id = "int16&pixelType=int16" +
				"&sizeX=44&sizeY=108&sizeZ=2&sizeC=3&sizeT=1.fake";
			final ImporterOptions options = new ImporterOptions();
			options.setId(id);

			options.setVirtual(true);
			vImp = BF.openImagePlus(options)[0];
			vImp.show();

			options.setVirtual(false);
			imp = BF.openImagePlus(options)[0];
			imp.show();
		}
		else {
			// TIFF was converted from fake id above
			final String path = "/Users/curtis/Desktop/int16.tif";

			IJ.run("TIFF Virtual Stack...", "open=" + path);
			vImp = WindowManager.getCurrentImage();

			imp = new Opener().openImage(path);
			imp.show();
		}

		final ImageProcessor proc1 = imp.getStack().getProcessor(1);
		final ImageProcessor vProc1 = vImp.getStack().getProcessor(1);
		final float[] cal1 = proc1.getCalibrationTable();
		final float[] vCal1 = vProc1.getCalibrationTable();
		System.out.println("cal1=" + cal1 + ", vCal1=" + vCal1);

		final ImageProcessor proc2 = imp.getStack().getProcessor(2);
		final ImageProcessor vProc2 = vImp.getStack().getProcessor(2);
		final int p = (int) proc2.getPixelValue(0, 0);
		final int vp = (int) vProc2.getPixelValue(0, 0);
		final int rawP = proc2.get(0, 0);
		final int vRawP = vProc2.get(0, 0);
		final float[] cal2 = proc2.getCalibrationTable();
		final float[] vCal2 = vProc2.getCalibrationTable();
		if (p != vp) {
			System.out.println("MISMATCH: p=" + p + ", vp=" + vp +
				", rawP=" + rawP + ", vRawP=" + vRawP +
				", cal2=" + cal2 + ", vCal2=" + vCal2);
		}
		else System.out.println("IT'S ALL GOOD");
	}

}

Change History (5)

comment:1 Changed 7 years ago by crueden-x

  • Description modified (diff)

comment:2 Changed 7 years ago by Curtis Rueden <ctrueden@…>

(In [7084f38c43d509fe139b4a95e23b7eebe28e395f/bioformats.git]) Temporarily disable testing of virtual stacks.

This avoids a bug in Bio-Formats; see #7175 for details.

comment:3 Changed 7 years ago by Curtis Rueden <ctrueden@…>

(In [7084f38c43d509fe139b4a95e23b7eebe28e395f/bioformats.git]) Temporarily disable testing of virtual stacks.

This avoids a bug in Bio-Formats; see #7175 for details.

comment:4 Changed 7 years ago by Melissa Linkert <melissa@…>

  • Remaining Time set to 0
  • Resolution set to fixed
  • Status changed from new to closed

(In [5d7e9adfdd006e6593e241529cff19c05efe6a48/bioformats.git]) Make sure that BFVirtualStack sets the calibration table.

Previously, the calibration table was only set for the first
ImageProcessor?; subsequent ImageProcessors? would have a null calibration
table. This was particularly problematic for signed data, which relies
on the calibration table to scale the pixel values correctly.

Closes #7175.

comment:5 Changed 7 years ago by Melissa Linkert <melissa@…>

(In [5d7e9adfdd006e6593e241529cff19c05efe6a48/bioformats.git]) Make sure that BFVirtualStack sets the calibration table.

Previously, the calibration table was only set for the first
ImageProcessor?; subsequent ImageProcessors? would have a null calibration
table. This was particularly problematic for signed data, which relies
on the calibration table to scale the pixel values correctly.

Closes #7175.

Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.76381 sec.)

We're Hiring!