use of loci.formats.FormatException in project bioformats by openmicroscopy.
the class DimensionSwapperTest method createDimSwapper.
@DataProvider(name = "swapper")
public Object[][] createDimSwapper() {
Location.mapId(TEST_FILE, TEST_FILE);
DimensionSwapper swapper = new DimensionSwapper();
try {
swapper.setId(TEST_FILE);
} catch (FormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
swapper.setOutputOrder(OUTPUT_ORDER);
return new Object[][] { { swapper } };
}
use of loci.formats.FormatException in project bioformats by openmicroscopy.
the class LosslessJPEG2000Test method setUp.
@BeforeMethod
public void setUp() throws Exception {
File temp8 = File.createTempFile("test", ".jp2");
File temp16 = File.createTempFile("test", ".jp2");
temp8.deleteOnExit();
temp16.deleteOnExit();
Location.mapId(FILE_8, temp8.getAbsolutePath());
Location.mapId(FILE_16, temp16.getAbsolutePath());
IMetadata metadata8;
try {
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
metadata8 = service.createOMEXMLMetadata();
} catch (DependencyException exc) {
throw new FormatException("Could not create OME-XML store.", exc);
} catch (ServiceException exc) {
throw new FormatException("Could not create OME-XML store.", exc);
}
MetadataTools.populateMetadata(metadata8, 0, "foo", false, "XYCZT", "uint8", 1, 1, 1, 1, 1, 1);
IFormatWriter writer8 = new JPEG2000Writer();
writer8.setMetadataRetrieve(metadata8);
writer8.setId(FILE_8);
writer8.saveBytes(0, PIXELS_8);
writer8.close();
IMetadata metadata16;
try {
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
metadata16 = service.createOMEXMLMetadata();
} catch (DependencyException exc) {
throw new FormatException("Could not create OME-XML store.", exc);
} catch (ServiceException exc) {
throw new FormatException("Could not create OME-XML store.", exc);
}
MetadataTools.populateMetadata(metadata16, 0, "foo", false, "XYCZT", "uint16", 1, 1, 1, 1, 1, 1);
IFormatWriter writer16 = new JPEG2000Writer();
writer16.setMetadataRetrieve(metadata16);
writer16.setId(FILE_16);
writer16.saveBytes(0, PIXELS_16);
writer16.close();
}
use of loci.formats.FormatException in project bioformats by openmicroscopy.
the class ImporterTest method colorizeSubcaseTester.
private void colorizeSubcaseTester(int pixType, int sizeC, int rgb, boolean indexed, boolean falseColor, int lutLen) {
if ((pixType != FormatTools.UINT8) && (pixType != FormatTools.UINT16))
throw new IllegalArgumentException("Invalid pixelType: not UINT8 or UINT16 (" + pixType + ")");
if (sizeC % rgb != 0)
throw new IllegalArgumentException("Bad combo of sizeC and rgb: " + sizeC + " " + rgb);
int channelsPerPlane = rgb;
if (channelsPerPlane > 7)
throw new IllegalArgumentException("Bad sizeC; channelsPerPlane > 7 : " + channelsPerPlane);
int sizeX = 60, sizeY = 30, sizeZ = 1, sizeT = 1, numSeries = 1;
String path = constructFakeFilename("colorColorized", pixType, sizeX, sizeY, sizeZ, sizeC, sizeT, numSeries, indexed, rgb, falseColor, lutLen);
LOGGER.debug("colorizeSubcaseTester: {}", path);
ImagePlus[] imps = null;
try {
ImporterOptions options = new ImporterOptions();
options.setAutoscale(false);
options.setColorMode(ImporterOptions.COLOR_MODE_COLORIZED);
options.setId(path);
imps = BF.openImagePlus(options);
} catch (IOException e) {
fail(e.getMessage());
} catch (FormatException e) {
fail(e.getMessage());
}
impsCountTest(imps, 1);
ImagePlus imp = imps[0];
if (lutLen == -1)
lutLen = 3;
int expectedSizeC = effectiveC(sizeC, rgb, lutLen, indexed, falseColor);
xyzctTest(imp, sizeX, sizeY, sizeZ, expectedSizeC, sizeT);
if (imp.isComposite()) {
CompositeImage ci = (CompositeImage) imp;
assertTrue(ci.hasCustomLuts());
assertEquals(CompositeImage.COLOR, ci.getMode());
// TODO - falseColor stuff needs to be impl
if (!falseColor)
colorTests(ci, expectedSizeC, DEFAULT_COLOR_ORDER);
} else {
LOGGER.debug(" Not a composite image");
}
}
use of loci.formats.FormatException in project bioformats by openmicroscopy.
the class ImporterTest method outputStackOrderTester.
/**
* tests BF's options.setStackOrder()
*/
private void outputStackOrderTester(boolean virtual, int pixType, ChannelOrder order, int x, int y, int z, int c, int t) {
String bfChOrder = bfChanOrd(order);
String chOrder = order.toString();
String path = constructFakeFilename("stack", pixType, x, y, z, c, t, -1, false, -1, false, -1);
ImagePlus[] imps = null;
try {
ImporterOptions options = new ImporterOptions();
options.setAutoscale(false);
options.setVirtual(virtual);
options.setId(path);
options.setStackOrder(bfChOrder);
imps = BF.openImagePlus(options);
} catch (IOException e) {
fail(e.getMessage());
} catch (FormatException e) {
fail(e.getMessage());
}
impsCountTest(imps, 1);
ImagePlus imp = imps[0];
xyzctTest(imp, x, y, z, c, t);
stackTest(imp, z * c * t);
stackInSpecificOrderTest(imp, chOrder);
}
use of loci.formats.FormatException in project bioformats by openmicroscopy.
the class ImporterTest method colorCustomTester.
/**
* tests BF's options.setColorMode(custom)
*/
private void colorCustomTester(boolean virtual, int pixType, boolean indexed, int channels, int chanPerPlane, boolean falseColor, int numSeries) {
int sizeX = 55, sizeY = 71, sizeZ = 3, sizeT = 4;
String path = constructFakeFilename("colorCustom", pixType, sizeX, sizeY, sizeZ, channels, sizeT, numSeries, indexed, chanPerPlane, falseColor, -1);
LOGGER.debug("colorCustomTester: {}", path);
ImagePlus[] imps = null;
try {
ImporterOptions options = new ImporterOptions();
options.setAutoscale(false);
options.setVirtual(virtual);
options.setColorMode(ImporterOptions.COLOR_MODE_CUSTOM);
int maxChannels = (channels <= 7) ? channels : 7;
for (int s = 0; s < numSeries; s++) for (int c = 0; c < maxChannels; c++) options.setCustomColor(s, c, CUSTOM_COLOR_ORDER[c]);
options.setId(path);
imps = BF.openImagePlus(options);
} catch (IOException e) {
fail(e.getMessage());
} catch (FormatException e) {
fail(e.getMessage());
}
impsCountTest(imps, 1);
ImagePlus imp = imps[0];
int lutLen = 3;
int expectedSizeC = effectiveC(channels, chanPerPlane, lutLen, indexed, falseColor);
xyzctTest(imp, sizeX, sizeY, sizeZ, expectedSizeC, sizeT);
if ((expectedSizeC >= 2) && (expectedSizeC <= 7)) {
assertTrue(imp.isComposite());
CompositeImage ci = (CompositeImage) imp;
assertTrue(ci.hasCustomLuts());
assertEquals(CompositeImage.COLOR, ci.getMode());
colorTests(ci, expectedSizeC, CUSTOM_COLOR_ORDER);
} else // expectedSizeC < 2 or > 7 - we should have gotten back a regular ImagePlus
{
assertFalse(imp.isComposite());
imagePlusLutTest(imp, indexed, falseColor, CUSTOM_COLOR_ORDER[0]);
}
stackInCztOrderTest(imp, sizeZ, expectedSizeC, sizeT, indexed, falseColor);
// TODO : i've done no pixel testing
}
Aggregations