Search in sources :

Example 11 with ChannelSeparator

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;
}
Also used : IFormatReader(loci.formats.IFormatReader) MinMaxCalculator(loci.formats.MinMaxCalculator) ChannelMerger(loci.formats.ChannelMerger) DimensionSwapper(loci.formats.DimensionSwapper) ChannelFiller(loci.formats.ChannelFiller) IOException(java.io.IOException) ImageReader(loci.formats.ImageReader) ChannelSeparator(loci.formats.ChannelSeparator) FormatException(loci.formats.FormatException) DataProvider(org.testng.annotations.DataProvider)

Example 12 with ChannelSeparator

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;
}
Also used : IFormatReader(loci.formats.IFormatReader) MinMaxCalculator(loci.formats.MinMaxCalculator) ChannelMerger(loci.formats.ChannelMerger) DimensionSwapper(loci.formats.DimensionSwapper) ChannelFiller(loci.formats.ChannelFiller) IOException(java.io.IOException) ImageReader(loci.formats.ImageReader) ChannelSeparator(loci.formats.ChannelSeparator) FormatException(loci.formats.FormatException) DataProvider(org.testng.annotations.DataProvider)

Example 13 with ChannelSeparator

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;
}
Also used : IFormatReader(loci.formats.IFormatReader) Memoizer(loci.formats.Memoizer) ChannelMerger(loci.formats.ChannelMerger) ChannelFiller(loci.formats.ChannelFiller) IOException(java.io.IOException) ChannelSeparator(loci.formats.ChannelSeparator) FormatException(loci.formats.FormatException) FileStitcher(loci.formats.FileStitcher) MinMaxCalculator(loci.formats.MinMaxCalculator) DimensionSwapper(loci.formats.DimensionSwapper) ImageReader(loci.formats.ImageReader) DataProvider(org.testng.annotations.DataProvider)

Example 14 with ChannelSeparator

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());
}
Also used : MinMaxCalculator(loci.formats.MinMaxCalculator) ChannelFiller(loci.formats.ChannelFiller) ImageReader(loci.formats.ImageReader) ChannelSeparator(loci.formats.ChannelSeparator) OMEXMLMetadataImpl(loci.formats.ome.OMEXMLMetadataImpl) Test(org.testng.annotations.Test)

Example 15 with ChannelSeparator

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;
        }
    }
}
Also used : IFD(loci.formats.tiff.IFD) CoreMetadata(loci.formats.CoreMetadata) ChannelSeparator(loci.formats.ChannelSeparator) MetadataStore(loci.formats.meta.MetadataStore) Length(ome.units.quantity.Length) TiffParser(loci.formats.tiff.TiffParser) RandomAccessInputStream(loci.common.RandomAccessInputStream) Location(loci.common.Location)

Aggregations

ChannelSeparator (loci.formats.ChannelSeparator)17 ChannelFiller (loci.formats.ChannelFiller)11 MinMaxCalculator (loci.formats.MinMaxCalculator)11 ImageReader (loci.formats.ImageReader)10 FormatException (loci.formats.FormatException)8 IOException (java.io.IOException)6 IFormatReader (loci.formats.IFormatReader)6 ChannelMerger (loci.formats.ChannelMerger)5 DimensionSwapper (loci.formats.DimensionSwapper)5 Test (org.testng.annotations.Test)5 Location (loci.common.Location)4 FileStitcher (loci.formats.FileStitcher)4 OMEXMLMetadataImpl (loci.formats.ome.OMEXMLMetadataImpl)4 MetadataStore (loci.formats.meta.MetadataStore)3 DataProvider (org.testng.annotations.DataProvider)3 RandomAccessInputStream (loci.common.RandomAccessInputStream)2 DependencyException (loci.common.services.DependencyException)2 ServiceException (loci.common.services.ServiceException)2 ServiceFactory (loci.common.services.ServiceFactory)2 CoreMetadata (loci.formats.CoreMetadata)2