use of loci.formats.ChannelSeparator in project bioformats by openmicroscopy.
the class ReaderEqualityTest method createEqualWrappers.
@DataProvider(name = "equalWrappers")
public Object[][] createEqualWrappers() {
Location.mapId(TEST_FILE_A, TEST_FILE_A);
Location.mapId(TEST_FILE_B, TEST_FILE_B);
Object[][] wrappers = new Object[][] { { new ImageReader(), new ImageReader() }, { new ImageReader(), new ImageReader() }, { new MinMaxCalculator(new ChannelSeparator(new ChannelFiller())), new MinMaxCalculator(new ChannelSeparator(new ChannelFiller())) }, { new DimensionSwapper(new ChannelMerger()), new DimensionSwapper(new ChannelMerger()) } };
for (int i = 1; i < wrappers.length; i++) {
IFormatReader readerA = (IFormatReader) wrappers[i][0];
IFormatReader readerB = (IFormatReader) wrappers[i][1];
try {
readerA.setId(TEST_FILE_A);
readerB.setId(TEST_FILE_B);
} catch (FormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return wrappers;
}
use of loci.formats.ChannelSeparator in project bioformats by openmicroscopy.
the class ReaderEqualityTest method createUnequalWrappers.
@DataProvider(name = "unequalWrappers")
public Object[][] createUnequalWrappers() {
Object[][] wrappers = new Object[][] { { new ImageReader(), new ImageReader() }, { new ImageReader(), new ImageReader() }, { new MinMaxCalculator(new ChannelSeparator(new ChannelFiller())), new MinMaxCalculator(new ChannelSeparator()) }, { new DimensionSwapper(new ChannelMerger()), new DimensionSwapper(new ChannelMerger()) } };
for (int i = 0; i < wrappers.length; i++) {
IFormatReader readerA = (IFormatReader) wrappers[i][0];
IFormatReader readerB = (IFormatReader) wrappers[i][1];
try {
if (i != 1) {
readerA.setId(TEST_FILE_A);
} else {
readerA.setId(TEST_FILE_B);
}
if (i > 1) {
readerB.setId(TEST_FILE_B);
} else if (i == 1) {
readerB.setId(TEST_FILE_A);
}
} catch (FormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return wrappers;
}
use of loci.formats.ChannelSeparator in project bioformats by openmicroscopy.
the class WrapperTest method createWrappers.
@DataProvider(name = "wrappers")
public Object[][] createWrappers() {
Location.mapId(TEST_FILE, TEST_FILE);
Object[][] wrappers = new Object[][] { { new ChannelFiller() }, { new ChannelMerger() }, { new ChannelSeparator() }, { new DimensionSwapper() }, { new FileStitcher() }, { new ImageReader() }, { new MinMaxCalculator() }, { new Memoizer() } };
for (int i = 0; i < wrappers.length; i++) {
IFormatReader reader = (IFormatReader) wrappers[i][0];
try {
reader.setId(TEST_FILE);
} catch (FormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return wrappers;
}
use of loci.formats.ChannelSeparator in project bioformats by openmicroscopy.
the class BaseModelReaderTest method testSetId.
@Test
public void testSetId() throws Exception {
reader = new MinMaxCalculator(new ChannelSeparator(new ChannelFiller(new ImageReader())));
metadata = new OMEXMLMetadataImpl();
reader.setMetadataStore(metadata);
reader.setId(temporaryFile.getAbsolutePath());
}
use of loci.formats.ChannelSeparator in project bioformats by openmicroscopy.
the class NDPISReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
super.initFile(id);
Location parent = new Location(id).getAbsoluteFile().getParentFile();
String[] lines = DataTools.readFile(currentId).split("\r\n");
for (String line : lines) {
int eq = line.indexOf('=');
if (eq < 0) {
continue;
}
String key = line.substring(0, eq).trim();
String value = line.substring(eq + 1).trim();
if (key.equals("NoImages")) {
ndpiFiles = new String[Integer.parseInt(value)];
readers = new ChannelSeparator[ndpiFiles.length];
} else if (key.startsWith("Image")) {
int index = Integer.parseInt(key.replaceAll("Image", ""));
ndpiFiles[index] = new Location(parent, value).getAbsolutePath();
readers[index] = new ChannelSeparator(new NDPIReader());
readers[index].setFlattenedResolutions(hasFlattenedResolutions());
}
}
MetadataStore store = makeFilterMetadata();
readers[0].getReader().setMetadataStore(store);
readers[0].setId(ndpiFiles[0]);
core = new ArrayList<CoreMetadata>(readers[0].getCoreMetadataList());
for (int i = 0; i < core.size(); i++) {
CoreMetadata ms = core.get(i);
ms.sizeC = readers.length;
ms.rgb = false;
ms.imageCount = ms.sizeC * ms.sizeZ * ms.sizeT;
}
MetadataTools.populatePixels(store, this);
bandUsed = new int[ndpiFiles.length];
IFD ifd;
for (int c = 0; c < readers.length; c++) {
// populate channel names based on IFD entry
try (RandomAccessInputStream in = new RandomAccessInputStream(ndpiFiles[c])) {
TiffParser tp = new TiffParser(in);
ifd = tp.getIFDs().get(0);
}
String channelName = ifd.getIFDStringValue(TAG_CHANNEL);
Float wavelength = (Float) ifd.getIFDValue(TAG_EMISSION_WAVELENGTH);
store.setChannelName(channelName, 0, c);
store.setChannelEmissionWavelength(new Length(wavelength, UNITS.NANOMETER), 0, c);
bandUsed[c] = 0;
if (ifd.getSamplesPerPixel() >= 3) {
// 580 < wavelength <= 780 Red
if (380 < wavelength && wavelength <= 490)
bandUsed[c] = 2;
else if (490 < wavelength && wavelength <= 580)
bandUsed[c] = 1;
else if (580 < wavelength && wavelength <= 780)
bandUsed[c] = 0;
}
}
}
Aggregations