use of loci.formats.CoreMetadata in project bioformats by openmicroscopy.
the class ImagicReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
if (!checkSuffix(id, "hed")) {
id = id.substring(0, id.lastIndexOf(".")) + ".hed";
}
super.initFile(id);
in = new RandomAccessInputStream(id);
pixels = id.substring(0, id.lastIndexOf(".")) + ".img";
pixelsFile = new RandomAccessInputStream(pixels);
CoreMetadata m = core.get(0);
m.littleEndian = true;
in.order(isLittleEndian());
pixelsFile.order(isLittleEndian());
int nImages = (int) (in.length() / 1024);
String imageName = null;
double physicalXSize = 0d;
double physicalYSize = 0d;
double physicalZSize = 0d;
for (int i = 0; i < nImages; i++) {
in.seek(i * 1024);
in.skipBytes(16);
int month = in.readInt();
int day = in.readInt();
int year = in.readInt();
int hour = in.readInt();
int minute = in.readInt();
int seconds = in.readInt();
in.skipBytes(8);
m.sizeY = in.readInt();
m.sizeX = in.readInt();
String type = in.readString(4);
if (type.equals("REAL")) {
m.pixelType = FormatTools.FLOAT;
} else if (type.equals("INTG")) {
m.pixelType = FormatTools.UINT16;
} else if (type.equals("PACK")) {
m.pixelType = FormatTools.UINT8;
} else if (type.equals("COMP")) {
throw new FormatException("Unsupported pixel type 'COMP'");
} else if (type.equals("RECO")) {
throw new FormatException("Unsupported pixel type 'RECO'");
}
int ixold = in.readInt();
int iyold = in.readInt();
float averageDensity = in.readFloat();
float sigma = in.readFloat();
in.skipBytes(8);
float maxDensity = in.readFloat();
float minDensity = in.readFloat();
in.skipBytes(4);
float defocus1 = in.readFloat();
float defocus2 = in.readFloat();
float defocusAngle = in.readFloat();
float startAngle = in.readFloat();
float endAngle = in.readFloat();
imageName = in.readString(80);
float ccc3d = in.readFloat();
int ref3d = in.readInt();
int micrographID = in.readInt();
int zShift = in.readInt();
float alpha = in.readFloat();
float beta = in.readFloat();
float gamma = in.readFloat();
in.skipBytes(8);
int nAliSum = in.readInt();
int pointGroup = in.readInt();
in.skipBytes(28);
int version = in.readInt();
int stamp = in.readInt();
in.skipBytes(120);
float angle = in.readFloat();
float voltage = in.readFloat();
float sphericalAberration = in.readFloat();
float partialCoherence = in.readFloat();
float ccc = in.readFloat();
float errar = in.readFloat();
float err3d = in.readFloat();
int ref = in.readInt();
float classNumber = in.readFloat();
in.skipBytes(4);
float representationQuality = in.readFloat();
float eqZShift = in.readFloat();
float xShift = in.readFloat();
float yShift = in.readFloat();
float numcls = in.readFloat();
float overallQuality = in.readFloat();
float equivalentAngle = in.readFloat();
float eqXShift = in.readFloat();
float eqYShift = in.readFloat();
float cmToVar = in.readFloat();
float informat = in.readFloat();
int nEigenvalues = in.readInt();
int nActiveImages = in.readInt();
physicalXSize = in.readFloat();
physicalYSize = in.readFloat();
physicalZSize = in.readFloat();
addGlobalMeta("IXOLD", ixold);
addGlobalMeta("IYOLD", iyold);
addGlobalMeta("Average density (AVDENS)", averageDensity);
addGlobalMeta("SIGMA", sigma);
addGlobalMeta("Maximum density (DENSMAX)", maxDensity);
addGlobalMeta("Minimum density (DENSMIN)", minDensity);
addGlobalMeta("DEFOCUS1", defocus1);
addGlobalMeta("DEFOCUS2", defocus2);
addGlobalMeta("Defocus angle (DEFANGLE)", defocusAngle);
addGlobalMeta("SINOSTRT", startAngle);
addGlobalMeta("SINOEND", endAngle);
addGlobalMeta("Image name", imageName);
addGlobalMeta("CCC3D", ccc3d);
addGlobalMeta("REF3D", ref3d);
addGlobalMeta("MIDENT", micrographID);
addGlobalMeta("EZSHIFT", zShift);
addGlobalMeta("EALPHA", alpha);
addGlobalMeta("EBETA", beta);
addGlobalMeta("EGAMMA", gamma);
addGlobalMeta("NALISUM", nAliSum);
addGlobalMeta("PGROUP", pointGroup);
addGlobalMeta("IMAGIC Version (IMAVERS)", version);
addGlobalMeta("REALTYPE", stamp);
addGlobalMeta("ANGLE", angle);
addGlobalMeta("VOLTAGE (in kV)", voltage);
addGlobalMeta("SPABERR (in mm)", sphericalAberration);
addGlobalMeta("PCOHER", partialCoherence);
addGlobalMeta("CCC", ccc);
addGlobalMeta("ERRAR", errar);
addGlobalMeta("ERR3D", err3d);
addGlobalMeta("REF", ref);
addGlobalMeta("CLASSNO", classNumber);
addGlobalMeta("REPQUAL", representationQuality);
addGlobalMeta("ZSHIFT", eqZShift);
addGlobalMeta("XSHIFT", xShift);
addGlobalMeta("YSHIFT", yShift);
addGlobalMeta("NUMCLS", numcls);
addGlobalMeta("OVQUAL", overallQuality);
addGlobalMeta("EANGLE", equivalentAngle);
addGlobalMeta("EXSHIFT", eqXShift);
addGlobalMeta("EYSHIFT", eqYShift);
addGlobalMeta("CMTOTVAR", cmToVar);
addGlobalMeta("INFORMAT", informat);
addGlobalMeta("NUMEIGEN", nEigenvalues);
addGlobalMeta("NIACTIVE", nActiveImages);
addGlobalMeta("RESOLX", physicalXSize);
addGlobalMeta("RESOLY", physicalYSize);
addGlobalMeta("RESOLZ", physicalZSize);
}
m.sizeZ = nImages;
m.sizeC = 1;
m.sizeT = 1;
m.imageCount = nImages;
m.dimensionOrder = "XYZCT";
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this);
store.setImageName(imageName.trim(), 0);
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
Length sizeX = FormatTools.getPhysicalSizeX(physicalXSize * 0.0001);
Length sizeY = FormatTools.getPhysicalSizeY(physicalYSize * 0.0001);
Length sizeZ = FormatTools.getPhysicalSizeZ(physicalZSize * 0.0001);
if (sizeX != null) {
store.setPixelsPhysicalSizeX(sizeX, 0);
}
if (sizeY != null) {
store.setPixelsPhysicalSizeY(sizeY, 0);
}
if (sizeZ != null) {
store.setPixelsPhysicalSizeZ(sizeZ, 0);
}
}
}
use of loci.formats.CoreMetadata in project bioformats by openmicroscopy.
the class ImprovisionTiffReader method initStandardMetadata.
// -- Internal BaseTiffReader API methods --
/* @see BaseTiffReader#initStandardMetadata() */
@Override
protected void initStandardMetadata() throws FormatException, IOException {
super.initStandardMetadata();
put("Improvision", "yes");
// parse key/value pairs in the comments
String[] comments = new String[ifds.size()];
String tz = null, tc = null, tt = null;
for (int plane = 0; plane < ifds.size(); plane++) {
String comment = ifds.get(plane).getComment();
comments[plane] = comment;
if (comment != null) {
String[] lines = comment.split("\n");
for (String line : lines) {
int equals = line.indexOf('=');
if (equals < 0)
continue;
String key = line.substring(0, equals);
String value = line.substring(equals + 1);
addGlobalMeta(key, value);
if (key.equals("TotalZPlanes"))
tz = value;
else if (key.equals("TotalChannels"))
tc = value;
else if (key.equals("TotalTimepoints"))
tt = value;
else if (key.equals("XCalibrationMicrons")) {
pixelSizeX = DataTools.parseDouble(value);
} else if (key.equals("YCalibrationMicrons")) {
pixelSizeY = DataTools.parseDouble(value);
} else if (key.equals("ZCalibrationMicrons")) {
pixelSizeZ = DataTools.parseDouble(value);
} else if (key.equals("WhiteColour")) {
String[] rgb = value.split(",");
if (rgb.length < 3) {
channelColors.add(null);
continue;
}
int red = 255;
try {
red = Integer.parseInt(rgb[0]);
} catch (NumberFormatException e) {
}
int green = 255;
try {
green = Integer.parseInt(rgb[1]);
} catch (NumberFormatException e) {
}
int blue = 255;
try {
blue = Integer.parseInt(rgb[2]);
} catch (NumberFormatException e) {
}
channelColors.add(new Color(red, green, blue, 255));
}
}
metadata.remove("Comment");
}
}
CoreMetadata m = core.get(0);
m.sizeT = 1;
if (getSizeZ() == 0)
m.sizeZ = 1;
if (getSizeC() == 0)
m.sizeC = 1;
if (tz != null)
m.sizeZ *= Integer.parseInt(tz);
if (tc != null)
m.sizeC *= Integer.parseInt(tc);
if (tt != null)
m.sizeT *= Integer.parseInt(tt);
if (getSizeZ() * getSizeC() * getSizeT() < getImageCount()) {
m.sizeC *= getImageCount();
} else
m.imageCount = getSizeZ() * getSizeT() * Integer.parseInt(tc);
// parse each of the comments to determine axis ordering
long[] stamps = new long[ifds.size()];
int[][] coords = new int[ifds.size()][3];
cNames = new String[getSizeC()];
boolean multipleFiles = false;
for (int i = 0; i < ifds.size(); i++) {
Arrays.fill(coords[i], -1);
String comment = comments[i];
// TODO : can use loci.common.IniParser to parse the comments
comment = comment.replaceAll("\r\n", "\n");
comment = comment.replaceAll("\r", "\n");
String channelName = null;
String[] lines = comment.split("\n");
for (String line : lines) {
int equals = line.indexOf('=');
if (equals < 0)
continue;
String key = line.substring(0, equals);
String value = line.substring(equals + 1);
if (key.equals("TimeStampMicroSeconds")) {
stamps[i] = Long.parseLong(value);
} else if (key.equals("ZPlane"))
coords[i][0] = Integer.parseInt(value);
else if (key.equals("ChannelNo")) {
coords[i][1] = Integer.parseInt(value);
int ndx = Integer.parseInt(value) - 1;
if (cNames[ndx] == null)
cNames[ndx] = channelName;
} else if (key.equals("TimepointName")) {
coords[i][2] = Integer.parseInt(value);
} else if (key.equals("ChannelName")) {
channelName = value;
} else if (key.equals("MultiFileTIFF")) {
multipleFiles = value.equalsIgnoreCase("yes");
}
if (getMetadataOptions().getMetadataLevel() == MetadataLevel.MINIMUM && coords[i][0] >= 0 && coords[i][1] >= 0 && coords[i][2] >= 0) {
break;
}
}
}
if (multipleFiles) {
// look for other TIFF files that belong to this dataset
String currentUUID = getUUID(currentId);
Location parent = new Location(currentId).getAbsoluteFile().getParentFile();
String[] list = parent.list(true);
Arrays.sort(list);
ArrayList<String> matchingFiles = new ArrayList<String>();
for (String f : list) {
String path = new Location(parent, f).getAbsolutePath();
if (isThisType(path) && getUUID(path).equals(currentUUID)) {
matchingFiles.add(path);
}
}
files = matchingFiles.toArray(new String[matchingFiles.size()]);
} else {
files = new String[] { currentId };
}
if (files.length * ifds.size() < getImageCount()) {
files = new String[] { currentId };
m.imageCount = ifds.size();
m.sizeZ = ifds.size();
m.sizeT = 1;
if (!isRGB()) {
m.sizeC = 1;
}
}
readers = new MinimalTiffReader[files.length];
for (int i = 0; i < readers.length; i++) {
readers[i] = new MinimalTiffReader();
readers[i].setId(files[i]);
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
// determine average time per plane
long sum = 0;
for (int i = 1; i < stamps.length; i++) {
long diff = stamps[i] - stamps[i - 1];
if (diff > 0)
sum += diff;
}
pixelSizeT = (int) (sum / getSizeT());
}
// determine dimension order
m.dimensionOrder = "XY";
if (isRGB())
m.dimensionOrder += 'C';
for (int i = 1; i < coords.length; i++) {
int zDiff = coords[i][0] - coords[i - 1][0];
int cDiff = coords[i][1] - coords[i - 1][1];
int tDiff = coords[i][2] - coords[i - 1][2];
if (zDiff > 0 && getDimensionOrder().indexOf('Z') < 0) {
m.dimensionOrder += 'Z';
}
if (cDiff > 0 && getDimensionOrder().indexOf('C') < 0) {
m.dimensionOrder += 'C';
}
if (tDiff > 0 && getDimensionOrder().indexOf('T') < 0) {
m.dimensionOrder += 'T';
}
if (m.dimensionOrder.length() == 5)
break;
}
if (getDimensionOrder().indexOf('Z') < 0)
m.dimensionOrder += 'Z';
if (getDimensionOrder().indexOf('C') < 0)
m.dimensionOrder += 'C';
if (getDimensionOrder().indexOf('T') < 0)
m.dimensionOrder += 'T';
}
use of loci.formats.CoreMetadata in project bioformats by openmicroscopy.
the class InveonReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
if (!checkSuffix(id, "hdr")) {
id += ".hdr";
}
super.initFile(id);
String headerData = DataTools.readFile(id);
String[] lines = headerData.split("\n");
String date = null;
String institution = null, investigator = null;
String model = null;
String description = null;
Double pixelSizeX = null;
Double pixelSizeY = null;
Double pixelSizeZ = null;
int frames = 0;
for (String line : lines) {
line = line.trim();
if (!line.startsWith("#")) {
int space = line.indexOf(' ');
if (space < 0) {
continue;
}
String key = line.substring(0, space);
String value = line.substring(space + 1);
if (key.equals("institution")) {
institution = value;
} else if (key.equals("investigator")) {
investigator = value;
} else if (key.equals("study")) {
description = value;
} else if (key.equals("model")) {
value = transformModel(value);
model = value;
} else if (key.equals("modality")) {
value = transformModality(value);
} else if (key.equals("modality_configuration")) {
value = transformModalityConfiguration(value);
} else if (key.equals("file_type")) {
value = transformFileType(value);
} else if (key.equals("acquisition_mode")) {
value = transformAcquisitionMode(value);
} else if (key.equals("bed_control")) {
value = transformBedControl(value);
} else if (key.equals("bed_motion")) {
value = transformBedMotion(value);
} else if (key.equals("registration_available")) {
value = transformRegistrationAvailable(value);
} else if (key.equals("normalization_applied")) {
value = transformNormalizationApplied(value);
} else if (key.equals("recon_algorithm")) {
value = transformReconAlgorithm(value);
} else if (key.equals("x_filter")) {
value = transformFilter(value);
} else if (key.equals("y_filter")) {
value = transformFilter(value);
} else if (key.equals("z_filter")) {
value = transformFilter(value);
} else if (key.equals("subject_orientation")) {
value = transformSubjectOrientation(value);
} else if (key.equals("subject_length_units")) {
value = transformSubjectLengthUnits(value);
} else if (key.equals("subject_weight_units")) {
value = transformSubjectWeightUnits(value);
} else if (key.equals("gantry_rotation")) {
value = transformGantryRotation(value);
} else if (key.equals("rotation_direction")) {
value = transformRotationDirection(value);
} else if (key.equals("ct_warping")) {
value = transformCTWarping(value);
} else if (key.equals("ct_projection_interpolation")) {
value = transformCTProjectionInterpolation(value);
} else if (key.equals("event_type")) {
value = transformEventType(value);
} else if (key.equals("projection") || key.equals("ct_projection_center_offset") || key.equals("ct_projection_horizontal_bed_offset")) {
space = value.indexOf(' ');
int index = Integer.parseInt(value.substring(0, space));
value = value.substring(space + 1);
key += " " + index;
} else if (key.equals("user")) {
space = value.indexOf(' ');
key = value.substring(0, space);
value = value.substring(space + 1);
} else if (key.equals("file_name")) {
// remove path from stored file name, if present
value = value.replace('/', File.separatorChar);
value = value.replace('\\', File.separatorChar);
value = value.substring(value.lastIndexOf(File.separator) + 1);
Location header = new Location(currentId).getAbsoluteFile();
datFile = new Location(header.getParent(), value).getAbsolutePath();
} else if (key.equals("time_frames")) {
int sizeT = Integer.parseInt(value);
for (int i = 0; i < core.size(); i++) {
core.get(i).sizeT = sizeT;
}
} else if (key.equals("total_frames")) {
frames = Integer.parseInt(value);
} else if (key.equals("number_of_bed_positions")) {
int nPos = (int) Math.min(frames, Integer.parseInt(value));
if (nPos > 1) {
CoreMetadata original = core.get(0);
core.clear();
for (int i = 0; i < nPos; i++) {
core.add(original);
}
}
} else if (key.equals("data_type")) {
setDataType(value);
} else if (key.equals("x_dimension")) {
int sizeX = Integer.parseInt(value);
for (int i = 0; i < core.size(); i++) {
core.get(i).sizeX = sizeX;
}
} else if (key.equals("y_dimension")) {
int sizeY = Integer.parseInt(value);
for (int i = 0; i < core.size(); i++) {
core.get(i).sizeY = sizeY;
}
} else if (key.equals("z_dimension")) {
int sizeZ = Integer.parseInt(value);
for (int i = 0; i < core.size(); i++) {
core.get(i).sizeZ = sizeZ;
}
} else if (key.equals("scan_time")) {
date = value;
} else if (key.equals("data_file_pointer")) {
String[] values = value.split(" ");
int[] ints = new int[values.length];
for (int i = 0; i < ints.length; i++) {
ints[i] = Integer.parseInt(values[i]);
}
byte[] b = DataTools.intsToBytes(ints, false);
dataPointers.add(DataTools.bytesToLong(b, false));
} else // pixel sizes stored in mm
if (key.equals("pixel_size_x")) {
pixelSizeX = new Double(value) * 1000;
} else if (key.equals("pixel_size_y")) {
pixelSizeY = new Double(value) * 1000;
} else if (key.equals("pixel_size_z")) {
pixelSizeZ = new Double(value) * 1000;
}
addGlobalMeta(key, value);
}
}
for (int i = 0; i < core.size(); i++) {
CoreMetadata ms = core.get(i);
if (ms.sizeZ == 0) {
ms.sizeZ = 1;
}
if (ms.sizeT == 0) {
ms.sizeT = 1;
}
ms.sizeC = 1;
ms.rgb = false;
ms.interleaved = false;
ms.indexed = false;
ms.dimensionOrder = "XYZCT";
ms.imageCount = ms.sizeZ * ms.sizeC * ms.sizeT;
}
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this);
String experimenter = null, instrument = null;
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
experimenter = MetadataTools.createLSID("Experimenter", 0);
store.setExperimenterID(experimenter, 0);
store.setExperimenterUserName(investigator, 0);
store.setExperimenterInstitution(institution, 0);
instrument = MetadataTools.createLSID("Instrument", 0);
store.setInstrumentID(instrument, 0);
store.setMicroscopeModel(model, 0);
}
for (int i = 0; i < core.size(); i++) {
if (date != null) {
String newDate = DateTools.formatDate(date, "EEE MMM dd HH:mm:ss yyyy");
if (newDate != null) {
store.setImageAcquisitionDate(new Timestamp(newDate), i);
}
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
if (experimenter != null) {
store.setImageExperimenterRef(experimenter, i);
}
if (instrument != null) {
store.setImageInstrumentRef(instrument, i);
}
store.setImageDescription(description, i);
Length sizeX = FormatTools.getPhysicalSizeX(pixelSizeX);
Length sizeY = FormatTools.getPhysicalSizeY(pixelSizeY);
Length sizeZ = FormatTools.getPhysicalSizeZ(pixelSizeZ);
if (sizeX != null) {
store.setPixelsPhysicalSizeX(sizeX, i);
}
if (sizeY != null) {
store.setPixelsPhysicalSizeY(sizeY, i);
}
if (sizeZ != null) {
store.setPixelsPhysicalSizeZ(sizeZ, i);
}
}
}
}
use of loci.formats.CoreMetadata in project bioformats by openmicroscopy.
the class InveonReader method setDataType.
private void setDataType(String value) {
int type = Integer.parseInt(value);
int pixelType = FormatTools.INT8;
boolean littleEndian = true;
switch(type) {
case 2:
pixelType = FormatTools.INT16;
break;
case 3:
pixelType = FormatTools.INT32;
break;
case 4:
pixelType = FormatTools.FLOAT;
break;
case 5:
pixelType = FormatTools.FLOAT;
littleEndian = false;
break;
case 6:
pixelType = FormatTools.INT16;
littleEndian = false;
break;
case 7:
pixelType = FormatTools.INT32;
littleEndian = false;
break;
}
for (int i = 0; i < core.size(); i++) {
CoreMetadata ms = core.get(i);
ms.pixelType = pixelType;
ms.littleEndian = littleEndian;
}
}
use of loci.formats.CoreMetadata in project bioformats by openmicroscopy.
the class IvisionReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
super.initFile(id);
in = new RandomAccessInputStream(id);
LOGGER.info("Populating metadata");
String version = in.readString(4);
addGlobalMeta("Version", version);
int fileFormat = in.read();
int dataType = in.read();
CoreMetadata m = core.get(0);
m.sizeC = 1;
switch(dataType) {
case 0:
m.pixelType = FormatTools.UINT8;
break;
case 1:
m.pixelType = FormatTools.INT16;
break;
case 2:
m.pixelType = FormatTools.INT32;
break;
case 3:
m.pixelType = FormatTools.FLOAT;
break;
case 4:
m.pixelType = FormatTools.UINT8;
m.sizeC = 3;
color16 = true;
break;
case 5:
m.pixelType = FormatTools.UINT8;
m.sizeC = 3;
hasPaddingByte = true;
break;
case 6:
m.pixelType = FormatTools.UINT16;
break;
case 7:
m.pixelType = FormatTools.FLOAT;
squareRoot = true;
break;
case 8:
m.pixelType = FormatTools.UINT16;
m.sizeC = 3;
break;
}
m.sizeX = in.readInt();
m.sizeY = in.readInt();
in.skipBytes(6);
m.sizeZ = in.readShort();
in.skipBytes(50);
m.sizeT = 1;
if (getSizeX() > 1 && getSizeY() > 1) {
lut = new byte[2048];
in.read(lut);
}
imageOffset = in.getFilePointer();
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
in.skipBytes(getSizeZ() * getSizeC() * getSizeT() * getSizeX() * getSizeY() * FormatTools.getBytesPerPixel(getPixelType()));
// look for block of XML data
LOGGER.info("Looking for XML metadata");
in.findString(false, "<?xml");
if (in.getFilePointer() < in.length()) {
in.seek(in.getFilePointer() - 5);
String xml = in.readString((int) (in.length() - in.getFilePointer()));
xml = xml.substring(xml.indexOf('<'), xml.lastIndexOf("plist>") + 6);
IvisionHandler handler = new IvisionHandler();
try {
XMLTools.parseXML(xml, handler);
} catch (IOException e) {
LOGGER.debug("", e);
}
} else
LOGGER.debug("XML metadata not found");
}
LOGGER.info("Populating core metadata");
m.rgb = getSizeC() > 1;
m.dimensionOrder = "XYCZT";
m.littleEndian = false;
m.interleaved = true;
m.indexed = false;
m.imageCount = getSizeZ() * getSizeT();
LOGGER.info("Populating MetadataStore");
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this, true);
if (creationDate != null) {
String date = DateTools.formatDate(creationDate, DATE_FORMAT);
if (date != null) {
store.setImageAcquisitionDate(new Timestamp(date), 0);
}
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
String instrumentID = MetadataTools.createLSID("Instrument", 0);
store.setInstrumentID(instrumentID, 0);
store.setImageInstrumentRef(instrumentID, 0);
if (deltaT != null) {
Double increment = 0d;
try {
increment = new Double(deltaT);
} catch (NumberFormatException e) {
LOGGER.debug("Failed to parse time increment", e);
}
if (increment != null) {
store.setPixelsTimeIncrement(new Time(increment, UNITS.SECOND), 0);
}
}
String objectiveID = MetadataTools.createLSID("Objective", 0, 0);
store.setObjectiveID(objectiveID, 0, 0);
store.setObjectiveSettingsID(objectiveID, 0);
store.setObjectiveCorrection(getCorrection("Other"), 0, 0);
store.setObjectiveImmersion(getImmersion("Other"), 0, 0);
if (lensNA != null)
store.setObjectiveLensNA(lensNA, 0, 0);
if (magnification != null) {
store.setObjectiveNominalMagnification(magnification, 0, 0);
}
if (refractiveIndex != null) {
store.setObjectiveSettingsRefractiveIndex(refractiveIndex, 0);
}
String detectorID = MetadataTools.createLSID("Detector", 0, 0);
store.setDetectorID(detectorID, 0, 0);
store.setDetectorSettingsID(detectorID, 0, 0);
store.setDetectorType(getDetectorType("Other"), 0, 0);
store.setDetectorSettingsBinning(getBinning(binX + "x" + binY), 0, 0);
if (gain != null) {
try {
store.setDetectorSettingsGain(new Double(gain), 0, 0);
} catch (NumberFormatException e) {
LOGGER.debug("Failed to parse detector gain", e);
}
}
}
}
Aggregations