use of loci.formats.in.SDTReader in project bioformats by openmicroscopy.
the class ExtractSDTData method main.
public static void main(String[] args) throws Exception {
if (args.length < 1) {
System.out.println("Usage: java ExtractSDTData file.sdt");
System.exit(1);
}
String id = args[0];
String tid = id.substring(0, id.indexOf('.'));
SDTReader r = new SDTReader();
r.setId(id);
int bins = r.getTimeBinCount();
int chan = r.getChannelCount();
int w = r.getSizeX();
int h = r.getSizeY();
System.out.println("Data is " + w + " x " + h + ", bins=" + bins + ", channels=" + chan);
byte[][] data = new byte[chan][h * w * bins * 2];
for (int c = 0; c < chan; c++) {
System.out.println("Reading channel #" + c + "...");
r.openBytes(c, data[c]);
int i = 0;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
String oid = tid + "-c" + c + "-row" + y + "-col" + x;
System.out.println(oid);
PrintWriter out = new PrintWriter(new FileWriter(oid));
for (int b = 0; b < bins; b++) {
i += 2;
int v0 = data[c][i];
int v1 = data[c][i + 1];
int v = (v0 << 8) & v1;
out.println(b + " " + v);
}
out.close();
}
}
}
}
use of loci.formats.in.SDTReader in project bioformats by openmicroscopy.
the class LociPrefs method makeImageReader.
// -- Utility methods --
/**
* Creates an image reader according to the current configuration settings,
* including which format readers are currently enabled, as well as
* format-specific configuration settings.
*/
public static ImageReader makeImageReader() {
ClassList<IFormatReader> defaultClasses = ImageReader.getDefaultReaderClasses();
Class<? extends IFormatReader>[] c = defaultClasses.getClasses();
// include only enabled classes
ClassList<IFormatReader> enabledClasses = new ClassList<IFormatReader>(IFormatReader.class);
for (int i = 0; i < c.length; i++) {
boolean on = LociPrefs.isReaderEnabled(c[i]);
if (on)
enabledClasses.addClass(c[i]);
}
ImageReader reader = new ImageReader(enabledClasses);
MetadataOptions options = reader.getMetadataOptions();
if (options instanceof DynamicMetadataOptions) {
((DynamicMetadataOptions) options).setBoolean(ZeissCZIReader.ALLOW_AUTOSTITCHING_KEY, allowCZIAutostitch());
((DynamicMetadataOptions) options).setBoolean(ZeissCZIReader.INCLUDE_ATTACHMENTS_KEY, includeCZIAttachments());
((DynamicMetadataOptions) options).setBoolean(NativeND2Reader.USE_CHUNKMAP_KEY, useND2Chunkmap());
((DynamicMetadataOptions) options).setBoolean(LIFReader.OLD_PHYSICAL_SIZE_KEY, isLeicaLIFPhysicalSizeBackwardsCompatible());
((DynamicMetadataOptions) options).setBoolean(CellSensReader.FAIL_ON_MISSING_KEY, isCellsensFailOnMissing());
reader.setMetadataOptions(options);
}
// toggle reader-specific options
boolean nd2Nikon = LociPrefs.isND2Nikon();
boolean pictQTJava = LociPrefs.isPictQTJava();
boolean qtQTJava = LociPrefs.isQTQTJava();
boolean sdtIntensity = LociPrefs.isSDTIntensity();
boolean tiffImageIO = LociPrefs.isTiffImageIO();
IFormatReader[] r = reader.getReaders();
for (int i = 0; i < r.length; i++) {
if (r[i] instanceof ND2Reader) {
ND2Reader nd2 = (ND2Reader) r[i];
nd2.setLegacy(nd2Nikon);
} else if (r[i] instanceof PictReader) {
PictReader pict = (PictReader) r[i];
pict.setLegacy(pictQTJava);
} else if (r[i] instanceof QTReader) {
QTReader qt = (QTReader) r[i];
qt.setLegacy(qtQTJava);
} else if (r[i] instanceof SDTReader) {
SDTReader sdt = (SDTReader) r[i];
sdt.setIntensity(sdtIntensity);
} else if (r[i] instanceof TiffDelegateReader) {
TiffDelegateReader tiff = (TiffDelegateReader) r[i];
tiff.setLegacy(tiffImageIO);
}
}
return reader;
}
Aggregations