use of loci.formats.IFormatReader in project bioformats by openmicroscopy.
the class CropDialog method constructDialog.
@Override
protected GenericDialog constructDialog() {
final int seriesCount = process.getSeriesCount();
final IFormatReader r = process.getReader();
// construct dialog
final GenericDialog gd = new GenericDialog("Bio-Formats Crop Options");
for (int s = 0; s < seriesCount; s++) {
if (!options.isSeriesOn(s))
continue;
r.setSeries(s);
Region region = process.getCropRegion(s);
gd.addMessage(process.getSeriesLabel(s).replaceAll("_", " "));
gd.addNumericField("X_Coordinate_" + (s + 1), region.x, 0);
gd.addNumericField("Y_Coordinate_" + (s + 1), region.y, 0);
gd.addNumericField("Width_" + (s + 1), region.width, 0);
gd.addNumericField("Height_" + (s + 1), region.height, 0);
}
WindowTools.addScrollBars(gd);
return gd;
}
use of loci.formats.IFormatReader 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.IFormatReader in project bioformats by openmicroscopy.
the class MakeDatasetStructureTable method printTable.
/**
* Write the table to the file specified using setOutputFile(String[])
*/
public void printTable() {
ImageReader baseReader = new ImageReader();
IFormatReader[] allReaders = baseReader.getReaders();
Comparator<IFormatReader> comparator = new Comparator<IFormatReader>() {
@Override
public int compare(IFormatReader r1, IFormatReader r2) {
String s1 = r1.getFormat();
String s2 = r2.getFormat();
return s1.compareTo(s2);
}
};
Arrays.sort(allReaders, comparator);
printHeader();
for (IFormatReader reader : allReaders) {
try {
printFormatEntry(reader);
} catch (IllegalStateException e) {
}
}
printFooter();
}
use of loci.formats.IFormatReader in project bioformats by openmicroscopy.
the class HitachiReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
if (!checkSuffix(id, "txt")) {
String base = id;
if (base.indexOf('.') >= 0) {
base = base.substring(0, base.lastIndexOf("."));
}
id = base + ".txt";
initFile(id);
return;
}
super.initFile(id);
String data = DataTools.readFile(id);
IniParser parser = new IniParser();
parser.setBackslashContinuesLine(false);
IniList ini = parser.parseINI(new BufferedReader(new StringReader(data)));
IniTable image = ini.getTable("SemImageFile");
if (image == null) {
throw new FormatException("Could not find 'SemImageFile' table.");
}
for (String key : image.keySet()) {
addGlobalMeta(key, image.get(key));
}
String imageName = image.get("SampleName");
String pixelsFile = image.get("ImageName");
String date = image.get("Date");
String time = image.get("Time");
Location parent = new Location(id).getAbsoluteFile().getParentFile();
pixelsFile = new Location(parent, pixelsFile).getAbsolutePath();
ClassList<IFormatReader> classes = ImageReader.getDefaultReaderClasses();
Class<? extends IFormatReader>[] classArray = classes.getClasses();
ClassList<IFormatReader> newClasses = new ClassList<IFormatReader>(IFormatReader.class);
for (Class<? extends IFormatReader> c : classArray) {
if (!c.equals(HitachiReader.class)) {
newClasses.addClass(c);
}
}
helperReader = new ImageReader(newClasses);
helperReader.setId(pixelsFile);
core = new ArrayList<CoreMetadata>(helperReader.getCoreMetadataList());
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this, getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM);
store.setImageName(imageName, 0);
date = DateTools.formatDate(date + " " + time, DATE_FORMAT);
if (date != null) {
store.setImageAcquisitionDate(new Timestamp(date), 0);
}
populateOMEMetadata(image, store);
}
use of loci.formats.IFormatReader in project bioformats by openmicroscopy.
the class GetPhysicalMetadata method main.
public static void main(String[] args) throws Exception {
// parse command line arguments
if (args.length < 1) {
System.err.println("Usage: java GetMetadata imageFile [seriesNo]");
System.exit(1);
}
String id = args[0];
int series = args.length > 1 ? Integer.parseInt(args[1]) : 0;
// create OME-XML metadata store
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
IMetadata meta = service.createOMEXMLMetadata();
// 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);
printPixelDimensions(reader);
printPhysicalDimensions(meta, series);
}
Aggregations