use of loci.formats.IFormatReader 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.IFormatReader in project bioformats by openmicroscopy.
the class PrintLensNA method main.
public static void main(String[] args) throws DependencyException, FormatException, IOException, ServiceException {
// parse command line arguments
if (args.length < 1) {
System.err.println("Usage: java PrintLensNA imageFile");
System.exit(1);
}
String id = args[0];
// configure reader
IFormatReader reader = new ImageReader();
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
IMetadata meta = service.createOMEXMLMetadata();
reader.setMetadataStore(meta);
System.out.println("Initializing file: " + id);
// parse metadata
reader.setId(id);
// output metadata values
int instrumentCount = meta.getInstrumentCount();
System.out.println("There are " + instrumentCount + " instrument(s) associated with this file");
for (int i = 0; i < instrumentCount; i++) {
int objectiveCount = meta.getObjectiveCount(i);
System.out.println();
System.out.println("Instrument #" + i + " [" + meta.getInstrumentID(i) + "]: " + objectiveCount + " objective(s) found");
for (int o = 0; o < objectiveCount; o++) {
Double lensNA = meta.getObjectiveLensNA(i, o);
System.out.println("\tObjective #" + o + " [" + meta.getObjectiveID(i, o) + "]: LensNA=" + lensNA);
}
}
}
use of loci.formats.IFormatReader in project bioformats by openmicroscopy.
the class PrintTimestamps method main.
public static void main(String[] args) throws Exception {
// parse command line arguments
if (args.length < 1) {
System.err.println("Usage: java PrintTimestamps imageFile [seriesNo]");
System.exit(1);
}
String id = args[0];
int series = args.length > 1 ? Integer.parseInt(args[1]) : 0;
// enable debugging
// FormatReader.debug = true;
// create OME-XML metadata store of the latest schema version
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
IMetadata meta = service.createOMEXMLMetadata();
// or if you want a specific schema version, you can use:
// IMetadata meta = service.createOMEXMLMetadata(null, "2009-02");
// meta.createRoot();
// create format reader
IFormatReader reader = new ImageReader();
reader.setMetadataStore(meta);
// initialize file
System.out.println("Initializing " + id);
reader.setId(id);
int seriesCount = reader.getSeriesCount();
if (series < seriesCount)
reader.setSeries(series);
series = reader.getSeries();
System.out.println("\tImage series = " + series + " of " + seriesCount);
printDimensions(reader);
printGlobalTiming(meta, series);
printTimingPerTimepoint(meta, series);
printTimingPerPlane(meta, series);
}
use of loci.formats.IFormatReader in project bioformats by openmicroscopy.
the class CropDialog method harvestResults.
@Override
protected boolean harvestResults(GenericDialog gd) {
final int seriesCount = process.getSeriesCount();
final IFormatReader r = process.getReader();
for (int s = 0; s < seriesCount; s++) {
if (!options.isSeriesOn(s))
continue;
r.setSeries(s);
Region region = new Region();
region.x = (int) gd.getNextNumber();
region.y = (int) gd.getNextNumber();
region.width = (int) gd.getNextNumber();
region.height = (int) gd.getNextNumber();
if (region.x < 0)
region.x = 0;
if (region.y < 0)
region.y = 0;
if (region.x >= r.getSizeX())
region.x = r.getSizeX() - region.width - 1;
if (region.y >= r.getSizeY())
region.y = r.getSizeY() - region.height - 1;
if (region.width < 1)
region.width = 1;
if (region.height < 1)
region.height = 1;
if (region.width + region.x > r.getSizeX()) {
region.width = r.getSizeX() - region.x;
}
if (region.height + region.y > r.getSizeY()) {
region.height = r.getSizeY() - region.y;
}
options.setCropRegion(s, region);
}
return true;
}
use of loci.formats.IFormatReader in project bioformats by openmicroscopy.
the class ImagePlusReader method readImage.
private ImagePlus readImage(int s, boolean thumbnail) throws FormatException, IOException {
final ImporterOptions options = process.getOptions();
final int zCount = process.getZCount(s);
final int cCount = process.getCCount(s);
final int tCount = process.getTCount(s);
final List<LUT> luts = new ArrayList<LUT>();
// create image stack
final ImageStack stack;
if (options.isVirtual())
stack = createVirtualStack(process, s, luts);
else
stack = readPlanes(process, s, luts, thumbnail);
notifyListeners(new StatusEvent(1, 1, "Creating image"));
// create title
final String seriesName = process.getOMEMetadata().getImageName(s);
final String file = process.getCurrentFile();
final IFormatReader reader = process.getReader();
final String title = constructImageTitle(reader, file, seriesName, options.isGroupFiles());
// create image
final ImagePlus imp;
if (stack.isVirtual()) {
VirtualImagePlus vip = new VirtualImagePlus(title, stack);
vip.setReader(reader);
imp = vip;
saveLUTs(imp, luts);
} else
imp = createImage(title, stack, luts);
// if concatenating images only store metadata on first series
if (!options.isConcatenate() || s == 0) {
final String metadata = process.getOriginalMetadata().toString();
imp.setProperty("Info", metadata);
}
imp.setProperty(PROP_SERIES, s);
// retrieve the spatial calibration information, if available
final FileInfo fi = createFileInfo();
new Calibrator(process).applyCalibration(imp);
imp.setFileInfo(fi);
imp.setDimensions(cCount, zCount, tCount);
// open as a hyperstack, as appropriate
final boolean hyper = !options.isViewStandard();
imp.setOpenAsHyperStack(hyper);
return imp;
}
Aggregations