use of loci.formats.DimensionSwapper in project bioformats by openmicroscopy.
the class ImportProcess method initializeStack.
/**
* Performed following ImportStep.STACK notification.
*/
private void initializeStack() throws FormatException, IOException {
IFormatReader r = baseReader;
if (options.isGroupFiles()) {
r = fileStitcher = new FileStitcher(baseReader);
// overwrite base filename with file pattern
String id = options.getId();
fileStitcher.setId(id);
fileStitcher.setUsingPatternIds(true);
fileStitcher.setCanChangePattern(false);
}
r.setId(options.getId());
if (options.isGroupFiles()) {
options.setId(fileStitcher.getFilePattern().getPattern());
}
final byte[][] lut8 = r.get8BitLookupTable();
final int sizeC = r.getSizeC();
r = channelFiller = new ChannelFiller(r);
if (channelFiller.isFilled()) {
BF.warn(options.isQuiet(), getIdName() + ": index values will be lost");
}
r = channelSeparator = new ChannelSeparator(r);
r = dimensionSwapper = new DimensionSwapper(r);
if (options.isAutoscale() || FormatTools.isFloatingPoint(r)) {
r = minMaxCalculator = new MinMaxCalculator(r);
}
if (options.doStitchTiles()) {
r = tileStitcher = new TileStitcher(r);
}
r = virtualReader = new VirtualReader(r);
reader = new ImageProcessorReader(r);
if (options != null && !options.showROIs()) {
baseReader.getMetadataOptions().setMetadataLevel(MetadataLevel.NO_OVERLAYS);
}
setId();
computeSeriesLabels(reader);
}
use of loci.formats.DimensionSwapper 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.DimensionSwapper in project bioformats by openmicroscopy.
the class ImageInfo method configureReaderPreInit.
public void configureReaderPreInit() throws FormatException, IOException {
if (omexml) {
reader.setOriginalMetadataPopulated(originalMetadata);
try {
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
reader.setMetadataStore(service.createOMEXMLMetadata(null, omexmlVersion));
} catch (DependencyException de) {
throw new MissingLibraryException(OMEXMLServiceImpl.NO_OME_XML_MSG, de);
} catch (ServiceException se) {
throw new FormatException(se);
}
}
// check file format
if (reader instanceof ImageReader) {
// determine format
ImageReader ir = (ImageReader) reader;
if (new Location(id).exists()) {
LOGGER.info("Checking file format [{}]", ir.getFormat(id));
}
} else {
// verify format
LOGGER.info("Checking {} format [{}]", reader.getFormat(), reader.isThisType(id) ? "yes" : "no");
}
LOGGER.info("Initializing reader");
if (stitch) {
reader = new FileStitcher(reader, true);
Location f = new Location(id);
String pat = null;
if (!f.exists()) {
((FileStitcher) reader).setUsingPatternIds(true);
pat = id;
} else {
pat = FilePattern.findPattern(f);
}
if (pat != null)
id = pat;
}
if (expand)
reader = new ChannelFiller(reader);
if (separate)
reader = new ChannelSeparator(reader);
if (merge)
reader = new ChannelMerger(reader);
if (cache) {
if (cachedir != null) {
reader = new Memoizer(reader, 0, new File(cachedir));
} else {
reader = new Memoizer(reader, 0);
}
}
minMaxCalc = null;
if (minmax || autoscale)
reader = minMaxCalc = new MinMaxCalculator(reader);
dimSwapper = null;
if (swapOrder != null || shuffleOrder != null) {
reader = dimSwapper = new DimensionSwapper(reader);
}
reader = biReader = new BufferedImageReader(reader);
reader.close();
reader.setNormalized(normalize);
reader.setMetadataFiltered(filter);
reader.setGroupFiles(group);
options.setMetadataLevel(doMeta ? MetadataLevel.ALL : MetadataLevel.MINIMUM);
options.setValidate(validate);
reader.setMetadataOptions(options);
reader.setFlattenedResolutions(flat);
}
use of loci.formats.DimensionSwapper 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.DimensionSwapper 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;
}
Aggregations