use of ome.xml.model.primitives.Timestamp in project bioformats by openmicroscopy.
the class DeltavisionReader method parseLogFile.
/**
* Extract metadata from associated log file, if it exists.
*/
private boolean parseLogFile(MetadataStore store) throws FormatException, IOException {
if (logFile == null || !new Location(logFile).exists()) {
logFile = null;
return false;
}
LOGGER.info("Parsing log file");
String[] lines = DataTools.readFile(logFile).split("[\r\n]");
String key, value = "", prefix = "";
int currentImage = 0;
List<String> channelNames = new ArrayList<String>();
List<Double> filters = new ArrayList<Double>();
for (String line : lines) {
int colon = line.indexOf(':');
if (colon >= 0 && colon < line.length() - 1 && !line.startsWith("Created")) {
key = line.substring(0, colon).trim();
value = line.substring(colon + 1).trim();
if (value.equals("") && !key.equals(""))
prefix = key;
addGlobalMeta(prefix + " " + key, value);
// Objective properties
if (key.equals("Objective")) {
// assume first word is the manufacturer's name
int space = value.indexOf(' ');
if (space != -1) {
String manufacturer = value.substring(0, space);
String extra = value.substring(space + 1);
String[] tokens = extra.split(",");
store.setObjectiveManufacturer(manufacturer, 0, 0);
String magnification = "", na = "";
if (tokens.length >= 1) {
int end = tokens[0].indexOf('X');
if (end > 0)
magnification = tokens[0].substring(0, end);
int start = tokens[0].indexOf('/');
if (start >= 0)
na = tokens[0].substring(start + 1);
}
try {
Double mag = new Double(magnification);
store.setObjectiveNominalMagnification(mag, 0, 0);
} catch (NumberFormatException e) {
LOGGER.warn("Could not parse magnification '{}'", magnification);
}
try {
store.setObjectiveLensNA(new Double(na), 0, 0);
} catch (NumberFormatException e) {
LOGGER.warn("Could not parse N.A. '{}'", na);
}
if (tokens.length >= 2) {
store.setObjectiveCorrection(getCorrection(tokens[1]), 0, 0);
}
// TODO: Token #2 is the microscope model name.
if (tokens.length > 3)
store.setObjectiveModel(tokens[3], 0, 0);
}
} else if (key.equalsIgnoreCase("Lens ID")) {
if (value.indexOf(',') != -1) {
value = value.substring(0, value.indexOf(','));
}
if (value.indexOf(' ') != -1) {
value = value.substring(value.indexOf(' ') + 1);
}
if (!value.equals("null")) {
String objectiveID = "Objective:" + value;
store.setObjectiveID(objectiveID, 0, 0);
for (int series = 0; series < getSeriesCount(); series++) {
store.setObjectiveSettingsID(objectiveID, series);
}
store.setObjectiveCorrection(getCorrection("Other"), 0, 0);
store.setObjectiveImmersion(getImmersion("Other"), 0, 0);
}
} else // Image properties
if (key.equals("Pixel Size")) {
String[] pixelSizes = value.split(" ");
for (int q = 0; q < pixelSizes.length; q++) {
Double size = null;
try {
size = new Double(pixelSizes[q].trim());
} catch (NumberFormatException e) {
LOGGER.warn("Could not parse pixel size '{}'", pixelSizes[q].trim());
}
if (q == 0) {
Length sizeX = FormatTools.getPhysicalSizeX(size);
if (sizeX != null) {
for (int series = 0; series < getSeriesCount(); series++) {
store.setPixelsPhysicalSizeX(sizeX, series);
}
}
}
if (q == 1) {
Length sizeY = FormatTools.getPhysicalSizeY(size);
if (sizeY != null) {
for (int series = 0; series < getSeriesCount(); series++) {
store.setPixelsPhysicalSizeY(sizeY, series);
}
}
}
if (q == 2) {
Length sizeZ = FormatTools.getPhysicalSizeZ(size);
if (sizeZ != null) {
for (int series = 0; series < getSeriesCount(); series++) {
store.setPixelsPhysicalSizeZ(sizeZ, series);
}
}
}
}
} else if (key.equals("Binning")) {
store.setDetectorType(getDetectorType("Other"), 0, 0);
String detectorID = MetadataTools.createLSID("Detector", 0, 0);
store.setDetectorID(detectorID, 0, 0);
for (int series = 0; series < getSeriesCount(); series++) {
for (int c = 0; c < getSizeC(); c++) {
store.setDetectorSettingsBinning(getBinning(value), series, c);
// link DetectorSettings to an actual Detector
store.setDetectorSettingsID(detectorID, series, c);
}
}
} else // Camera properties
if (key.equals("Type")) {
store.setDetectorModel(value, 0, 0);
} else if (key.equals("Gain")) {
value = value.replaceAll("X", "");
try {
String detectorID = MetadataTools.createLSID("Detector", 0, 0);
store.setDetectorID(detectorID, 0, 0);
for (int series = 0; series < getSeriesCount(); series++) {
for (int c = 0; c < getSizeC(); c++) {
store.setDetectorSettingsGain(new Double(value), series, c);
store.setDetectorSettingsID(detectorID, series, c);
}
}
} catch (NumberFormatException e) {
LOGGER.warn("Could not parse gain '{}'", value);
}
} else if (key.equals("Speed")) {
value = value.replaceAll("KHz", "");
try {
double khz = Double.parseDouble(value);
String detectorID = MetadataTools.createLSID("Detector", 0, 0);
store.setDetectorID(detectorID, 0, 0);
for (int series = 0; series < getSeriesCount(); series++) {
for (int c = 0; c < getSizeC(); c++) {
store.setDetectorSettingsReadOutRate(new Frequency(khz, UNITS.KILOHERTZ), series, c);
store.setDetectorSettingsID(detectorID, series, c);
}
}
} catch (NumberFormatException e) {
LOGGER.warn("Could not parse read-out rate '{}'", value);
}
} else if (key.equals("Temp Setting")) {
value = value.replaceAll("C", "").trim();
try {
// this is the camera temperature, not the environment temperature
// store.setImagingEnvironmentTemperature(value, 0);
} catch (NumberFormatException e) {
LOGGER.warn("Could not parse temperature '{}'", value);
}
} else // Plane properties
if (key.equals("EM filter")) {
if (!channelNames.contains(value)) {
channelNames.add(value);
}
} else if (key.equals("ND filter")) {
value = value.replaceAll("%", "");
try {
double nd = Double.parseDouble(value) / 100;
if (!filters.contains(nd)) {
filters.add(nd);
}
} catch (NumberFormatException exc) {
// so no need to log it explicitly
if (!value.equals("BLANK")) {
LOGGER.warn("Could not parse ND filter '{}'", value);
}
filters.add(null);
} catch (IllegalArgumentException e) {
LOGGER.debug("", e);
}
} else if (key.equals("Stage coordinates")) {
if (value.length() > 1) {
value = value.substring(1, value.length() - 1);
}
String[] coords = value.split(",");
for (int i = 0; i < coords.length; i++) {
Length p = null;
try {
final Double number = Double.valueOf(coords[i]);
p = new Length(number, UNITS.REFERENCEFRAME);
} catch (NumberFormatException e) {
LOGGER.warn("Could not parse stage coordinate '{}'", coords[i]);
}
if (currentImage < getImageCount() && getSeriesCount() == 1) {
// from the extended header.
if (i == 0) {
store.setPlanePositionX(p, 0, currentImage);
}
if (i == 1) {
store.setPlanePositionY(p, 0, currentImage);
}
if (i == 2) {
store.setPlanePositionZ(p, 0, currentImage);
}
}
}
currentImage++;
}
} else if (line.startsWith("Image"))
prefix = line;
else if (line.startsWith("Created")) {
if (line.length() > 8)
line = line.substring(8).trim();
String date = DateTools.formatDate(line, DATE_FORMATS);
if (date != null) {
for (int series = 0; series < getSeriesCount(); series++) {
store.setImageAcquisitionDate(new Timestamp(date), series);
}
} else {
LOGGER.warn("Could not parse date '{}'", line);
}
} else if (line.startsWith("#KEY")) {
line = line.substring(line.indexOf(" ")).trim();
int split = line.indexOf(":");
if (split < 0) {
split = line.indexOf(" ");
}
key = line.substring(0, split).trim();
value = line.substring(split + 1).trim();
addGlobalMeta(key, value);
} else if (line.endsWith(":")) {
prefix = line.substring(0, line.length() - 1);
} else if (!line.startsWith("#") && !line.replace("-", "").isEmpty() && !prefix.isEmpty()) {
addGlobalMetaList(prefix, line);
}
}
for (int series = 0; series < getSeriesCount(); series++) {
for (int c = 0; c < getEffectiveSizeC(); c++) {
if (c < channelNames.size()) {
store.setChannelName(channelNames.get(c), series, c);
}
if (c < filters.size()) {
ndFilters[c] = filters.get(c);
}
}
}
return true;
}
use of ome.xml.model.primitives.Timestamp in project bioformats by openmicroscopy.
the class FV1000Reader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
super.initFile(id);
parser.setCommentDelimiter(null);
isOIB = checkSuffix(id, OIB_SUFFIX);
if (isOIB) {
initPOIService();
}
// mappedOIF is used to distinguish between datasets that are being read
// directly (e.g. using ImageJ or showinf), and datasets that are being
// imported through omebf. In the latter case, the necessary directory
// structure is not preserved (only relative file names are stored in
// OMEIS), so we will need to use slightly different logic to build the
// list of associated files.
boolean mappedOIF = !isOIB && !new File(id).getAbsoluteFile().exists();
wavelengths = new ArrayList<Double>();
illuminations = new ArrayList<String>();
channels = new ArrayList<ChannelData>();
planes = new ArrayList<PlaneData>();
String oifName = null;
if (isOIB) {
oifName = mapOIBFiles();
} else {
// make sure we have the OIF file, not a TIFF
if (!checkSuffix(id, OIF_SUFFIX)) {
currentId = findOIFFile(id);
initFile(currentId);
}
oifName = currentId;
}
String oifPath = new Location(oifName).getAbsoluteFile().getAbsolutePath();
if (mappedOIF) {
oifPath = oifName.substring(0, oifName.lastIndexOf(File.separator) + 1);
}
String path = isOIB ? "" : oifPath.substring(0, oifPath.lastIndexOf(File.separator) + 1);
try {
RandomAccessInputStream s = getFile(oifName);
s.close();
} catch (IOException e) {
oifName = oifName.replaceAll(".oif", ".OIF");
}
// parse key/value pairs from the OIF file
code = new String[NUM_DIMENSIONS];
size = new String[NUM_DIMENSIONS];
pixelSize = new Double[NUM_DIMENSIONS];
previewNames = new ArrayList<String>();
SortedMap<Integer, String> previewFileNames = new TreeMap<Integer, String>();
boolean laserEnabled = true;
IniList f = getIniFile(oifName);
IniTable saveInfo = f.getTable("ProfileSaveInfo");
String[] saveKeys = saveInfo.keySet().toArray(new String[saveInfo.size()]);
for (String key : saveKeys) {
String value = saveInfo.get(key).toString();
value = sanitizeValue(value).trim();
if (key.startsWith("IniFileName") && key.indexOf("Thumb") == -1 && !isPreviewName(value)) {
filenames.put(new Integer(key.substring(11)), value);
} else if (key.startsWith("RoiFileName") && key.indexOf("Thumb") == -1 && !isPreviewName(value)) {
try {
roiFilenames.put(new Integer(key.substring(11)), value);
} catch (NumberFormatException e) {
}
} else if (key.equals("PtyFileNameS"))
ptyStart = value;
else if (key.equals("PtyFileNameE"))
ptyEnd = value;
else if (key.equals("PtyFileNameT2"))
ptyPattern = value;
else if (key.indexOf("Thumb") != -1) {
if (thumbId == null)
thumbId = value.trim();
} else if (key.startsWith("LutFileName")) {
lutNames.add(path + value);
} else if (isPreviewName(value)) {
try {
RandomAccessInputStream s = getFile(path + value.trim());
if (s != null) {
s.close();
Integer previewIndex = getPreviewNameIndex(key);
if (previewIndex != null) {
previewFileNames.put(previewIndex, path + value.trim());
} else {
previewNames.add(path + value.trim());
}
}
} catch (FormatException e) {
LOGGER.debug("Preview file not found", e);
} catch (IOException e) {
LOGGER.debug("Preview file not found", e);
}
}
}
// Store sorted list of preview names
previewNames.addAll(previewFileNames.values());
if (filenames.isEmpty())
addPtyFiles();
for (int i = 0; i < NUM_DIMENSIONS; i++) {
IniTable commonParams = f.getTable("Axis " + i + " Parameters Common");
code[i] = commonParams.get("AxisCode");
size[i] = commonParams.get("MaxSize");
double end = Double.parseDouble(commonParams.get("EndPosition"));
double start = Double.parseDouble(commonParams.get("StartPosition"));
pixelSize[i] = end - start;
}
IniTable referenceParams = f.getTable("Reference Image Parameter");
imageDepth = Integer.parseInt(referenceParams.get("ImageDepth"));
pixelSizeX = referenceParams.get("WidthConvertValue");
pixelSizeY = referenceParams.get("HeightConvertValue");
String ripValidBitCounts = referenceParams.get("ValidBitCounts");
if (ripValidBitCounts != null) {
validBits = Integer.parseInt(ripValidBitCounts);
}
int index = 0;
IniTable laser = f.getTable("Laser " + index + " Parameters");
while (laser != null) {
laserEnabled = laser.get("Laser Enable").equals("1");
if (laserEnabled) {
wavelengths.add(new Double(laser.get("LaserWavelength")));
}
creationDate = laser.get("ImageCaputreDate");
if (creationDate == null) {
creationDate = laser.get("ImageCaptureDate");
}
index++;
laser = f.getTable("Laser " + index + " Parameters");
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
index = 1;
IniTable guiChannel = f.getTable("GUI Channel " + index + " Parameters");
while (guiChannel != null) {
ChannelData channel = new ChannelData();
channel.gain = DataTools.parseDouble(guiChannel.get("AnalogPMTGain"));
channel.voltage = DataTools.parseDouble(guiChannel.get("AnalogPMTVoltage"));
channel.barrierFilter = channel.getFilter(guiChannel.get("BF Name"));
channel.active = Integer.parseInt(guiChannel.get("CH Activate")) != 0;
channel.name = guiChannel.get("CH Name");
channel.dyeName = guiChannel.get("DyeName");
channel.emissionFilter = channel.getFilter(guiChannel.get("EmissionDM Name"));
channel.emWave = DataTools.parseDouble(guiChannel.get("EmissionWavelength"));
channel.excitationFilter = channel.getFilter(guiChannel.get("ExcitationDM Name"));
channel.exWave = DataTools.parseDouble(guiChannel.get("ExcitationWavelength"));
channels.add(channel);
index++;
guiChannel = f.getTable("GUI Channel " + index + " Parameters");
}
index = 1;
IniTable channel = f.getTable("Channel " + index + " Parameters");
while (channel != null) {
String illumination = channel.get("LightType");
if (illumination != null)
illumination = illumination.toLowerCase();
if (illumination == null) {
// Ignored
} else if (illumination.indexOf("fluorescence") != -1) {
illumination = "Epifluorescence";
} else if (illumination.indexOf("transmitted") != -1) {
illumination = "Transmitted";
} else
illumination = null;
illuminations.add(illumination);
index++;
channel = f.getTable("Channel " + index + " Parameters");
}
HashMap<String, String> iniMap = f.flattenIntoHashMap();
metadata.putAll(iniMap);
}
LOGGER.info("Initializing helper readers");
if (previewNames.size() > 0) {
final List<String> v = new ArrayList<String>();
for (int i = 0; i < previewNames.size(); i++) {
String ss = previewNames.get(i);
ss = replaceExtension(ss, "pty", "tif");
if (ss.endsWith(".tif"))
v.add(ss);
}
previewNames = v;
if (previewNames.size() > 0) {
core.clear();
core.add(new CoreMetadata());
core.add(new CoreMetadata());
IFDList ifds = null;
CoreMetadata ms1 = core.get(1);
for (String previewName : previewNames) {
RandomAccessInputStream preview = getFile(previewName);
TiffParser tp = new TiffParser(preview);
ifds = tp.getIFDs();
preview.close();
tp = null;
ms1.imageCount += ifds.size();
}
ms1.sizeX = (int) ifds.get(0).getImageWidth();
ms1.sizeY = (int) ifds.get(0).getImageLength();
ms1.sizeZ = 1;
ms1.sizeT = 1;
ms1.sizeC = ms1.imageCount;
ms1.rgb = false;
int bits = ifds.get(0).getBitsPerSample()[0];
while ((bits % 8) != 0) bits++;
bits /= 8;
ms1.pixelType = FormatTools.pixelTypeFromBytes(bits, false, false);
ms1.dimensionOrder = "XYCZT";
ms1.indexed = false;
}
}
CoreMetadata ms0 = core.get(0);
ms0.imageCount = filenames.size();
tiffs = new ArrayList<String>(getImageCount());
thumbReader = new BMPReader();
if (thumbId != null) {
thumbId = replaceExtension(thumbId, "pty", "bmp");
thumbId = sanitizeFile(thumbId, path);
}
LOGGER.info("Reading additional metadata");
// open each INI file (.pty extension) and build list of TIFF files
String tiffPath = null;
ms0.dimensionOrder = "XY";
final Map<String, String> values = new HashMap<String, String>();
final List<String> baseKeys = new ArrayList<String>();
for (int i = 0, ii = 0; ii < getImageCount(); i++, ii++) {
String file = filenames.get(i);
while (file == null) file = filenames.get(++i);
file = sanitizeFile(file, path);
if (file.indexOf(File.separator) != -1) {
tiffPath = file.substring(0, file.lastIndexOf(File.separator));
} else
tiffPath = file;
Location ptyFile = new Location(file);
if (!isOIB && !ptyFile.exists()) {
LOGGER.warn("Could not find .pty file ({}); guessing at the " + "corresponding TIFF file.", file);
String tiff = replaceExtension(file, "pty", "tif");
Location tiffFile = new Location(tiff);
if (tiffFile.exists()) {
tiffs.add(ii, tiffFile.getAbsolutePath());
continue;
} else {
if (!tiffFile.getParentFile().exists()) {
String realOIFName = new Location(currentId).getName();
String basePath = tiffFile.getParentFile().getParent();
if (mappedOIF) {
tiffPath = basePath + File.separator + realOIFName + ".files";
ptyFile = new Location(tiffPath, ptyFile.getName());
file = ptyFile.getAbsolutePath();
} else {
Location newFile = new Location(basePath, realOIFName + ".files");
ptyFile = new Location(newFile, ptyFile.getName());
file = ptyFile.getAbsolutePath();
tiffPath = newFile.getAbsolutePath();
}
}
}
} else if (!isOIB) {
file = ptyFile.getAbsolutePath();
}
IniList pty = getIniFile(file);
IniTable fileInfo = pty.getTable("File Info");
file = sanitizeValue(fileInfo.get("DataName"));
if (!isPreviewName(file)) {
while (file.indexOf("GST") != -1) {
file = removeGST(file);
}
if (isOIB) {
file = tiffPath + File.separator + file;
} else
file = new Location(tiffPath, file).getAbsolutePath();
file = replaceExtension(file, "pty", "tif");
tiffs.add(ii, file);
}
PlaneData plane = new PlaneData();
for (int dim = 0; dim < NUM_DIMENSIONS; dim++) {
IniTable axis = pty.getTable("Axis " + dim + " Parameters");
if (axis == null)
break;
boolean addAxis = Integer.parseInt(axis.get("Number")) > 1;
if (dim == 2) {
if (addAxis && getDimensionOrder().indexOf('C') == -1) {
ms0.dimensionOrder += 'C';
}
} else if (dim == 3) {
if (addAxis && getDimensionOrder().indexOf('Z') == -1) {
ms0.dimensionOrder += 'Z';
}
final Double number = Double.valueOf(axis.get("AbsPositionValue"));
plane.positionZ = new Length(number, UNITS.REFERENCEFRAME);
} else if (dim == 4) {
if (addAxis && getDimensionOrder().indexOf('T') == -1) {
ms0.dimensionOrder += 'T';
}
// divide by 1000, as the position is in milliseconds
// and DeltaT is in seconds
plane.deltaT = Double.parseDouble(axis.get("AbsPositionValue")) / 1000;
} else if (dim == 7) {
try {
String xPos = axis.get("AbsPositionValueX");
if (xPos != null) {
final Double number = Double.valueOf(xPos);
plane.positionX = new Length(number, UNITS.REFERENCEFRAME);
}
} catch (NumberFormatException e) {
}
try {
String yPos = axis.get("AbsPositionValueY");
if (yPos != null) {
final Double number = Double.valueOf(yPos);
plane.positionY = new Length(number, UNITS.REFERENCEFRAME);
}
} catch (NumberFormatException e) {
}
}
}
ms0.bitsPerPixel = validBits;
planes.add(plane);
IniTable acquisition = pty.getTable("Acquisition Parameters Common");
if (acquisition != null) {
magnification = acquisition.get("Magnification");
lensNA = acquisition.get("ObjectiveLens NAValue");
objectiveName = acquisition.get("ObjectiveLens Name");
workingDistance = acquisition.get("ObjectiveLens WDValue");
pinholeSize = acquisition.get("PinholeDiameter");
String validBitCounts = acquisition.get("ValidBitCounts");
if (validBitCounts != null) {
ms0.bitsPerPixel = Integer.parseInt(validBitCounts);
}
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
for (IniTable table : pty) {
String[] keys = table.keySet().toArray(new String[table.size()]);
for (String key : keys) {
values.put("Image " + ii + " : " + key, table.get(key));
if (!baseKeys.contains(key))
baseKeys.add(key);
}
}
}
}
for (String key : baseKeys) {
if (key.equals("DataName") || key.indexOf("FileName") >= 0)
break;
boolean equal = true;
String first = values.get("Image 0 : " + key);
for (int i = 1; i < getImageCount(); i++) {
if (!first.equals(values.get("Image " + i + " : " + key))) {
equal = false;
break;
}
}
if (equal) {
addGlobalMeta(key, first);
} else {
for (int i = 0; i < getImageCount(); i++) {
String k = "Image " + i + " : " + key;
addGlobalMeta(k, values.get(k));
}
}
}
if (tiffs.size() != getImageCount()) {
ms0.imageCount = tiffs.size();
}
usedFiles = new ArrayList<String>();
if (tiffPath != null) {
usedFiles.add(isOIB ? id : oifName);
if (!isOIB) {
Location dir = new Location(tiffPath);
if (!mappedOIF && !dir.exists()) {
throw new FormatException("Required directory " + tiffPath + " was not found.");
}
String[] list = mappedOIF ? Location.getIdMap().keySet().toArray(new String[0]) : dir.list(true);
for (int i = 0; i < list.length; i++) {
if (mappedOIF)
usedFiles.add(list[i]);
else {
String p = new Location(tiffPath, list[i]).getAbsolutePath();
String check = p.toLowerCase();
if (!check.endsWith(".tif") && !check.endsWith(".pty") && !check.endsWith(".roi") && !check.endsWith(".lut") && !check.endsWith(".bmp")) {
continue;
}
usedFiles.add(p);
}
}
}
}
LOGGER.info("Populating metadata");
// calculate axis sizes
int realChannels = 0;
for (int i = 0; i < NUM_DIMENSIONS; i++) {
int ss = Integer.parseInt(size[i]);
if (pixelSize[i] == null)
pixelSize[i] = 1.0;
if (code[i].equals("X"))
ms0.sizeX = ss;
else if (code[i].equals("Y") && ss > 1)
ms0.sizeY = ss;
else if (code[i].equals("Z")) {
if (getSizeY() == 0) {
ms0.sizeY = ss;
} else {
ms0.sizeZ = ss;
// Z size stored in nm
pixelSizeZ = Math.abs((pixelSize[i].doubleValue() / (getSizeZ() - 1)) / 1000);
}
} else if (code[i].equals("T")) {
if (getSizeY() == 0) {
ms0.sizeY = ss;
} else {
ms0.sizeT = ss;
pixelSizeT = Math.abs((pixelSize[i].doubleValue() / (getSizeT() - 1)) / 1000);
}
} else if (ss > 0) {
if (getSizeC() == 0)
ms0.sizeC = ss;
else
ms0.sizeC *= ss;
if (code[i].equals("C"))
realChannels = ss;
}
}
if (getSizeZ() == 0)
ms0.sizeZ = 1;
if (getSizeC() == 0)
ms0.sizeC = 1;
if (getSizeT() == 0)
ms0.sizeT = 1;
if (getImageCount() == getSizeC() && getSizeY() == 1) {
ms0.imageCount *= getSizeZ() * getSizeT();
} else if (getImageCount() == getSizeC()) {
ms0.sizeZ = 1;
ms0.sizeT = 1;
}
if (getSizeZ() * getSizeT() * getSizeC() != getImageCount()) {
int diff = (getSizeZ() * getSizeC() * getSizeT()) - getImageCount();
if (diff == previewNames.size() || diff < 0) {
diff /= getSizeC();
if (getSizeT() > 1 && getSizeZ() == 1)
ms0.sizeT -= diff;
else if (getSizeZ() > 1 && getSizeT() == 1)
ms0.sizeZ -= diff;
} else
ms0.imageCount += diff;
}
if (getSizeC() > 1 && getSizeZ() == 1 && getSizeT() == 1) {
if (getDimensionOrder().indexOf('C') == -1)
ms0.dimensionOrder += 'C';
}
if (getDimensionOrder().indexOf('Z') == -1)
ms0.dimensionOrder += 'Z';
if (getDimensionOrder().indexOf('C') == -1)
ms0.dimensionOrder += 'C';
if (getDimensionOrder().indexOf('T') == -1)
ms0.dimensionOrder += 'T';
ms0.pixelType = FormatTools.pixelTypeFromBytes(imageDepth, false, false);
try {
RandomAccessInputStream thumb = getFile(thumbId);
byte[] b = new byte[(int) thumb.length()];
thumb.read(b);
thumb.close();
Location.mapFile("thumbnail.bmp", new ByteArrayHandle(b));
thumbReader.setId("thumbnail.bmp");
for (int i = 0; i < getSeriesCount(); i++) {
core.get(i).thumbSizeX = thumbReader.getSizeX();
core.get(i).thumbSizeY = thumbReader.getSizeY();
}
thumbReader.close();
Location.mapFile("thumbnail.bmp", null);
} catch (IOException e) {
LOGGER.debug("Could not read thumbnail", e);
} catch (FormatException e) {
LOGGER.debug("Could not read thumbnail", e);
}
// initialize lookup table
lut = new short[getSizeC()][3][65536];
byte[] buffer = new byte[65536 * 4];
int count = (int) Math.min(getSizeC(), lutNames.size());
for (int c = 0; c < count; c++) {
Exception exc = null;
try {
RandomAccessInputStream stream = getFile(lutNames.get(c));
stream.seek(stream.length() - 65536 * 4);
stream.read(buffer);
stream.close();
for (int q = 0; q < buffer.length; q += 4) {
lut[c][0][q / 4] = (short) ((buffer[q + 2] & 0xff) * 257);
lut[c][1][q / 4] = (short) ((buffer[q + 1] & 0xff) * 257);
lut[c][2][q / 4] = (short) ((buffer[q] & 0xff) * 257);
}
} catch (IOException e) {
exc = e;
} catch (FormatException e) {
exc = e;
}
if (exc != null) {
LOGGER.debug("Could not read LUT", exc);
lut = null;
break;
}
}
for (int i = 0; i < getSeriesCount(); i++) {
CoreMetadata ms = core.get(i);
ms.rgb = false;
ms.littleEndian = true;
ms.interleaved = false;
ms.metadataComplete = true;
ms.indexed = lut != null;
ms.falseColor = true;
int nFiles = i == 0 ? tiffs.size() : previewNames.size();
for (int file = 0; file < nFiles; file++) {
RandomAccessInputStream plane = getFile(i == 0 ? tiffs.get(file) : previewNames.get(file));
if (plane == null) {
ifds.add(null);
continue;
}
try {
TiffParser tp = new TiffParser(plane);
IFDList ifd = tp.getIFDs();
ifds.add(ifd);
} finally {
plane.close();
}
}
}
// populate MetadataStore
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this, true);
if (creationDate != null) {
creationDate = creationDate.replaceAll("'", "");
creationDate = DateTools.formatDate(creationDate, DATE_FORMAT);
}
for (int i = 0; i < getSeriesCount(); i++) {
// populate Image data
store.setImageName("Series " + (i + 1), i);
if (creationDate != null)
store.setImageAcquisitionDate(new Timestamp(creationDate), i);
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
populateMetadataStore(store, path);
}
}
use of ome.xml.model.primitives.Timestamp in project bioformats by openmicroscopy.
the class BaseZeissReader method fillMetadataPass7.
/**
* Store basic dimensions in model
* @param store
* @throws FormatException
* @throws IOException
*/
protected void fillMetadataPass7(MetadataStore store) throws FormatException, IOException {
for (int i = 0; i < getSeriesCount(); i++) {
long firstStamp = 0;
if (timestamps.size() > 0) {
String timestamp = timestamps.get(0);
store.setImageAcquisitionDate(new Timestamp(timestamp), i);
} else if (acquisitionDate != null) {
store.setImageAcquisitionDate(acquisitionDate, i);
}
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
// link Instrument and Image
String instrumentID = MetadataTools.createLSID("Instrument", 0);
store.setInstrumentID(instrumentID, 0);
String objectiveID = MetadataTools.createLSID("Objective", 0, 0);
store.setObjectiveID(objectiveID, 0, 0);
store.setObjectiveCorrection(getCorrection("Other"), 0, 0);
store.setObjectiveImmersion(getImmersion("Other"), 0, 0);
Integer[] channelKeys = channelName.keySet().toArray(new Integer[channelName.size()]);
Arrays.sort(channelKeys);
// link DetectorSettings to an actual Detector
for (int i = 0; i < getEffectiveSizeC(); i++) {
String detectorID = MetadataTools.createLSID("Detector", 0, i);
store.setDetectorID(detectorID, 0, i);
store.setDetectorType(getDetectorType("Other"), 0, i);
for (int s = 0; s < getSeriesCount(); s++) {
int c = i;
if (i < channelKeys.length) {
c = channelKeys[i];
}
store.setDetectorSettingsID(detectorID, s, i);
store.setDetectorSettingsGain(detectorGain.get(c), s, i);
store.setDetectorSettingsOffset(detectorOffset.get(c), s, i);
store.setChannelName(channelName.get(c), s, i);
store.setChannelEmissionWavelength(emWavelength.get(c), s, i);
store.setChannelExcitationWavelength(exWavelength.get(c), s, i);
if (channelColors != null && i < channelColors.length) {
int color = channelColors[i];
int red = color & 0xff;
int green = (color & 0xff00) >> 8;
int blue = (color & 0xff0000) >> 16;
store.setChannelColor(new Color(red, green, blue, 255), s, i);
}
}
}
for (int i = 0; i < getSeriesCount(); i++) {
store.setImageInstrumentRef(instrumentID, i);
store.setObjectiveSettingsID(objectiveID, i);
if (imageDescription != null) {
store.setImageDescription(imageDescription, i);
}
if (getSeriesCount() > 1) {
store.setImageName("Tile #" + (i + 1), i);
}
Length sizeX = FormatTools.getPhysicalSizeX(physicalSizeX);
Length sizeY = FormatTools.getPhysicalSizeY(physicalSizeY);
Length sizeZ = FormatTools.getPhysicalSizeZ(physicalSizeZ);
if (sizeX != null) {
store.setPixelsPhysicalSizeX(sizeX, i);
}
if (sizeY != null) {
store.setPixelsPhysicalSizeY(sizeY, i);
}
if (sizeZ != null) {
store.setPixelsPhysicalSizeZ(sizeZ, i);
}
Timestamp firstStamp = null;
if (timestamps.get(0) != null) {
firstStamp = new Timestamp(timestamps.get(0));
}
for (int plane = 0; plane < getImageCount(); plane++) {
int[] zct = getZCTCoords(plane);
int expIndex = zct[1];
if (channelKeys.length > 0) {
expIndex += channelKeys[0];
}
String exposure = exposureTime.get(expIndex);
if (exposure == null && exposureTime.size() == 1) {
exposure = exposureTime.values().iterator().next();
}
Double exp = 0d;
try {
exp = new Double(exposure);
} catch (NumberFormatException e) {
} catch (NullPointerException e) {
}
store.setPlaneExposureTime(new Time(exp, UNITS.SECOND), i, plane);
int posIndex = i * getImageCount() + plane;
if (posIndex < timestamps.size() && firstStamp != null) {
Timestamp timestamp = new Timestamp(timestamps.get(posIndex));
long difference = timestamp.asInstant().getMillis() - firstStamp.asInstant().getMillis();
double delta = (double) difference;
store.setPlaneDeltaT(new Time(delta, UNITS.MILLISECOND), i, plane);
}
if (stageX.get(posIndex) != null) {
store.setPlanePositionX(stageX.get(posIndex), i, plane);
}
if (stageY.get(posIndex) != null) {
store.setPlanePositionY(stageY.get(posIndex), i, plane);
}
}
}
for (int i = 0; i < getSeriesCount(); i++) {
for (int roi = 0; roi < roiIDs.size(); roi++) {
store.setImageROIRef(roiIDs.get(roi), i, roi);
}
}
}
}
use of ome.xml.model.primitives.Timestamp in project bioformats by openmicroscopy.
the class BioRadGelReader 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);
String check = in.readString(48);
if (check.indexOf("Intel Format") != -1) {
in.order(true);
}
in.seek(START_OFFSET);
boolean codeFound = false;
int skip = 0;
long baseFP = 0;
while (!codeFound) {
short code = in.readShort();
if (code == 0x81)
codeFound = true;
short length = in.readShort();
in.skipBytes(2 + 2 * length);
if (codeFound) {
baseFP = in.getFilePointer() + 2;
if (length > 1) {
in.seek(in.getFilePointer() - 2);
}
skip = in.readInt() - 32;
} else {
if (length == 1)
in.skipBytes(12);
else if (length == 2)
in.skipBytes(10);
}
}
diff = BASE_OFFSET - baseFP;
skip += diff;
double physicalWidth = 0d, physicalHeight = 0d;
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
if (baseFP + skip - 8187 > 0) {
in.seek(baseFP + skip - 8187);
String scannerName = in.readCString();
in.skipBytes(8);
in.readCString();
in.skipBytes(8);
String imageArea = in.readCString();
imageArea = imageArea.substring(imageArea.indexOf(':') + 1).trim();
int xIndex = imageArea.indexOf('x');
if (xIndex > 0) {
int space = imageArea.indexOf(' ');
if (space >= 0) {
String width = imageArea.substring(1, space);
int nextSpace = imageArea.indexOf(" ", xIndex + 2);
if (nextSpace > xIndex) {
String height = imageArea.substring(xIndex + 1, nextSpace);
physicalWidth = Double.parseDouble(width.trim()) * 1000;
physicalHeight = Double.parseDouble(height.trim()) * 1000;
}
}
}
}
}
in.seek(baseFP + skip - 298);
String date = in.readString(17);
date = DateTools.formatDate(date, "dd-MMM-yyyy HH:mm");
in.skipBytes(73);
String scannerName = in.readCString();
addGlobalMeta("Scanner name", scannerName);
in.seek(baseFP + skip);
CoreMetadata m = core.get(0);
m.sizeX = in.readShort() & 0xffff;
m.sizeY = in.readShort() & 0xffff;
if (getSizeX() * getSizeY() > in.length()) {
in.order(true);
in.seek(in.getFilePointer() - 4);
m.sizeX = in.readShort();
m.sizeY = in.readShort();
}
in.skipBytes(2);
int bpp = in.readShort();
m.pixelType = FormatTools.pixelTypeFromBytes(bpp, false, false);
offset = in.getFilePointer();
m.sizeZ = 1;
m.sizeC = 1;
m.sizeT = 1;
m.imageCount = 1;
m.dimensionOrder = "XYCZT";
m.rgb = false;
m.interleaved = false;
m.indexed = false;
m.littleEndian = in.isLittleEndian();
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this);
if (date != null) {
store.setImageAcquisitionDate(new Timestamp(date), 0);
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
Length sizeX = FormatTools.getPhysicalSizeX(physicalWidth / getSizeX());
Length sizeY = FormatTools.getPhysicalSizeY(physicalHeight / getSizeY());
if (sizeX != null) {
store.setPixelsPhysicalSizeX(sizeX, 0);
}
if (sizeY != null) {
store.setPixelsPhysicalSizeY(sizeY, 0);
}
}
}
use of ome.xml.model.primitives.Timestamp in project bioformats by openmicroscopy.
the class BioRadReader method parseNotes.
private boolean parseNotes(MetadataStore store) throws FormatException {
boolean multipleFiles = false;
int nextDetector = 0, nLasers = 0;
for (Note n : noteStrings) {
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
switch(n.type) {
case NOTE_TYPE_USER:
// TODO : this should be an overlay
addGlobalMetaList("Note", n.toString());
break;
case NOTE_TYPE_SCALEBAR:
// TODO : this should be an overlay
// the format of the text is:
// SCALEBAR = <length> <angle>
// where <length> is the length of the scalebar in microns,
// and <angle> is the angle in degrees
addGlobalMetaList("Note", n.toString());
break;
case NOTE_TYPE_ARROW:
// TODO : this should be an overlay
// the format of the text is:
// ARROW = <lx> <ly> <angle> <fill>
// where <lx> and <ly> define the arrow's bounding box,
// <angle> is the angle in degrees and <fill> is either "Fill" or
// "Outline"
addGlobalMetaList("Note", n.toString());
break;
case NOTE_TYPE_VARIABLE:
if (n.p.indexOf('=') >= 0) {
String key = n.p.substring(0, n.p.indexOf('=')).trim();
String value = n.p.substring(n.p.indexOf('=') + 1).trim();
addGlobalMeta(key, value);
if (key.equals("INFO_OBJECTIVE_NAME")) {
store.setObjectiveModel(value, 0, 0);
} else if (key.equals("INFO_OBJECTIVE_MAGNIFICATION")) {
Double mag = Double.parseDouble(value);
store.setObjectiveNominalMagnification(mag, 0, 0);
} else if (key.equals("LENS_MAGNIFICATION")) {
Double magnification = Double.parseDouble(value);
store.setObjectiveNominalMagnification(magnification, 0, 0);
} else if (key.startsWith("SETTING")) {
if (key.indexOf("_DET_") != -1) {
int index = key.indexOf("_DET_") + 5;
if (key.lastIndexOf("_") > index) {
String detectorID = MetadataTools.createLSID("Detector", 0, nextDetector);
store.setDetectorID(detectorID, 0, nextDetector);
store.setDetectorType(getDetectorType("Other"), 0, nextDetector);
if (key.endsWith("OFFSET")) {
if (nextDetector < offset.size()) {
offset.set(nextDetector, Double.parseDouble(value));
} else {
while (nextDetector > offset.size()) {
offset.add(null);
}
offset.add(new Double(value));
}
} else if (key.endsWith("GAIN")) {
if (nextDetector < gain.size()) {
gain.set(nextDetector, Double.parseDouble(value));
} else {
while (nextDetector > gain.size()) {
gain.add(null);
}
gain.add(new Double(value));
}
}
nextDetector++;
}
}
} else {
String[] values = value.split(" ");
if (values.length > 1) {
try {
int type = Integer.parseInt(values[0]);
if (type == 257 && values.length >= 3) {
// found length of axis in um
Double pixelSize = new Double(values[2]);
if (key.equals("AXIS_2")) {
Length size = FormatTools.getPhysicalSizeX(pixelSize);
if (size != null) {
store.setPixelsPhysicalSizeX(size, 0);
}
} else if (key.equals("AXIS_3")) {
Length size = FormatTools.getPhysicalSizeY(pixelSize);
if (size != null) {
store.setPixelsPhysicalSizeY(size, 0);
}
}
}
} catch (NumberFormatException e) {
}
}
}
} else if (n.p.startsWith("AXIS_2")) {
String[] values = n.p.split(" ");
Double pixelSize = new Double(values[3]);
Length size = FormatTools.getPhysicalSizeX(pixelSize);
if (size != null) {
store.setPixelsPhysicalSizeX(size, 0);
}
} else if (n.p.startsWith("AXIS_3")) {
String[] values = n.p.split(" ");
Double pixelSize = new Double(values[3]);
Length size = FormatTools.getPhysicalSizeY(pixelSize);
if (size != null) {
store.setPixelsPhysicalSizeY(size, 0);
}
} else {
addGlobalMetaList("Note", n.toString());
}
break;
case NOTE_TYPE_STRUCTURE:
int structureType = (n.x & 0xff00) >> 8;
int version = (n.x & 0xff);
String[] values = n.p.split(" ");
if (structureType == 1) {
switch(n.y) {
case 1:
for (int i = 0; i < STRUCTURE_LABELS_1.length; i++) {
addGlobalMeta(STRUCTURE_LABELS_1[i], values[i]);
}
Double mag = Double.parseDouble(values[11]);
store.setObjectiveNominalMagnification(mag, 0, 0);
Double sizeZ = new Double(values[14]);
Length size = FormatTools.getPhysicalSizeZ(sizeZ);
if (size != null) {
store.setPixelsPhysicalSizeZ(size, 0);
}
break;
case 2:
for (int i = 0; i < STRUCTURE_LABELS_2.length; i++) {
addGlobalMeta(STRUCTURE_LABELS_2[i], values[i]);
}
double x1 = Double.parseDouble(values[2]);
double x2 = Double.parseDouble(values[4]);
double width = x2 - x1;
width /= getSizeX();
double y1 = Double.parseDouble(values[3]);
double y2 = Double.parseDouble(values[5]);
double height = y2 - y1;
height /= getSizeY();
Length sizeX = FormatTools.getPhysicalSizeX(width);
Length sizeY = FormatTools.getPhysicalSizeY(height);
if (sizeX != null) {
store.setPixelsPhysicalSizeX(sizeX, 0);
}
if (sizeY != null) {
store.setPixelsPhysicalSizeY(sizeY, 0);
}
break;
case 3:
for (int i = 0; i < 3; i++) {
for (int j = 0; j < STRUCTURE_LABELS_3.length; j++) {
String v = j == STRUCTURE_LABELS_3.length - 1 ? values[12 + i] : values[i * 4 + j];
addGlobalMetaList(STRUCTURE_LABELS_3[j], v);
}
}
break;
case 4:
nLasers = Integer.parseInt(values[0]);
addGlobalMeta("Number of lasers", values[0]);
addGlobalMeta("Number of transmission detectors", values[1]);
addGlobalMeta("Number of PMTs", values[2]);
for (int i = 1; i <= 3; i++) {
int idx = (i + 1) * 3;
addGlobalMetaList("Shutter present for laser", values[i + 2]);
addGlobalMetaList("Neutral density filter for laser", values[idx]);
addGlobalMetaList("Excitation filter for laser", values[idx + 1]);
addGlobalMetaList("Use laser", values[idx + 2]);
}
for (int i = 0; i < nLasers; i++) {
addGlobalMetaList("Neutral density filter name - laser", values[15 + i]);
}
break;
case 5:
String prefix = "Excitation filter name - laser";
for (int i = 0; i < nLasers; i++) {
addGlobalMetaList(prefix, values[i]);
}
break;
case 6:
prefix = "Emission filter name - laser";
for (int i = 0; i < nLasers; i++) {
addGlobalMeta(prefix, values[i]);
}
break;
case 7:
for (int i = 0; i < 2; i++) {
prefix = "Mixer " + i + " - ";
for (int j = 0; j < STRUCTURE_LABELS_4.length; j++) {
addGlobalMeta(prefix + STRUCTURE_LABELS_4[j], values[i * 7 + j]);
}
}
addGlobalMeta("Mixer 0 - low signal on", values[14]);
addGlobalMeta("Mixer 1 - low signal on", values[15]);
break;
case 8:
case 9:
case 10:
addGlobalMeta("Laser name - laser " + (n.y - 7), values[0]);
break;
case 11:
for (int i = 0; i < 3; i++) {
prefix = "Transmission detector " + (i + 1) + " - ";
addGlobalMeta(prefix + "offset", values[i * 3]);
addGlobalMeta(prefix + "gain", values[i * 3 + 1]);
addGlobalMeta(prefix + "black level", values[i * 3 + 2]);
String detectorID = MetadataTools.createLSID("Detector", 0, i);
store.setDetectorID(detectorID, 0, i);
store.setDetectorOffset(new Double(values[i * 3]), 0, i);
store.setDetectorGain(new Double(values[i * 3 + 1]), 0, i);
store.setDetectorType(getDetectorType("Other"), 0, i);
}
break;
case 12:
for (int i = 0; i < 2; i++) {
prefix = "Part number for ";
for (int j = 0; j < STRUCTURE_LABELS_5.length; j++) {
addGlobalMetaList(prefix + STRUCTURE_LABELS_5[j], values[i * 4 + j]);
}
}
break;
case 13:
for (int i = 0; i < STRUCTURE_LABELS_6.length; i++) {
addGlobalMeta(STRUCTURE_LABELS_6[i], values[i]);
}
break;
case 14:
prefix = "Filter Block Name - filter block ";
addGlobalMetaList(prefix, values[0]);
addGlobalMetaList(prefix, values[1]);
break;
case 15:
for (int i = 0; i < 5; i++) {
addGlobalMetaList("Image bands status - band", values[i * 3]);
addGlobalMetaList("Image bands min - band", values[i * 3 + 1]);
addGlobalMetaList("Image bands max - band", values[i * 3 + 2]);
if (store instanceof IMinMaxStore) {
((IMinMaxStore) store).setChannelGlobalMinMax(i, Double.parseDouble(values[i * 3 + 1]), Double.parseDouble(values[i * 3 + 2]), 0);
}
}
break;
case 17:
int year = Integer.parseInt(values[5]) + 1900;
for (int i = 0; i < 5; i++) {
if (values[i].length() == 1)
values[i] = "0" + values[i];
}
// date is in yyyy-MM-dd'T'HH:mm:ss
String date = year + "-" + values[4] + "-" + values[3] + "T" + values[2] + ":" + values[1] + ":" + values[0];
addGlobalMeta("Acquisition date", date);
try {
store.setImageAcquisitionDate(new Timestamp(date), 0);
} catch (Exception e) {
LOGGER.debug("Failed to parse acquisition date", e);
}
break;
case 18:
addGlobalMeta("Mixer 3 - enhanced", values[0]);
for (int i = 1; i <= 3; i++) {
addGlobalMetaList("Mixer 3 - PMT percentage", values[i]);
addGlobalMetaList("Mixer 3 - Transmission percentage", values[i + 3]);
addGlobalMetaList("Mixer 3 - photon counting", values[i + 7]);
}
addGlobalMeta("Mixer 3 - low signal on", values[7]);
addGlobalMeta("Mixer 3 - mode", values[11]);
break;
case 19:
for (int i = 1; i <= 2; i++) {
prefix = "Mixer " + i + " - ";
String photon = prefix + "photon counting ";
addGlobalMetaList(photon, values[i * 4 - 4]);
addGlobalMetaList(photon, values[i * 4 - 3]);
addGlobalMetaList(photon, values[i * 4 - 2]);
addGlobalMeta(prefix + "mode", values[i * 4 - 1]);
}
break;
case 20:
addGlobalMeta("Display mode", values[0]);
addGlobalMeta("Course", values[1]);
addGlobalMeta("Time Course - experiment type", values[2]);
addGlobalMeta("Time Course - kd factor", values[3]);
String experimentID = MetadataTools.createLSID("Experiment", 0);
store.setExperimentID(experimentID, 0);
store.setExperimentType(getExperimentType(values[2]), 0);
break;
case 21:
addGlobalMeta("Time Course - ion name", values[0]);
break;
case 22:
addGlobalMeta("PIC file generated on Isoscan (lite)", values[0]);
for (int i = 1; i <= 3; i++) {
addGlobalMetaList("Photon counting used - PMT", values[i]);
addGlobalMetaList("Hot spot filter used - PMT", values[i + 3]);
addGlobalMetaList("Tx Selector used - TX", values[i + 6]);
}
break;
}
}
break;
default:
// notes for display only
addGlobalMetaList("Note", n.toString());
}
}
if (n.p.indexOf("AXIS") != -1) {
n.p = n.p.replaceAll("=", "");
final List<String> v = new ArrayList<String>();
StringTokenizer tokens = new StringTokenizer(n.p, " ");
while (tokens.hasMoreTokens()) {
String token = tokens.nextToken().trim();
if (token.length() > 0)
v.add(token);
}
String[] values = v.toArray(new String[v.size()]);
String key = values[0];
String noteType = values[1];
int axisType = Integer.parseInt(noteType);
if (axisType == 11 && values.length > 2) {
addGlobalMeta(key + " RGB type (X)", values[2]);
addGlobalMeta(key + " RGB type (Y)", values[3]);
CoreMetadata m = core.get(0);
if (key.equals("AXIS_4")) {
// this is a single section multi-channel dataset
m.sizeC = getImageCount();
m.sizeZ = 1;
m.sizeT = 1;
} else if (key.equals("AXIS_9")) {
multipleFiles = true;
m.sizeC = (int) Double.parseDouble(values[3]);
}
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM && values.length > 2) {
switch(axisType) {
case 1:
addGlobalMeta(key + " distance (X) in microns", values[2]);
addGlobalMeta(key + " distance (Y) in microns", values[3]);
break;
case 3:
addGlobalMeta(key + " angle (X) in degrees", values[2]);
addGlobalMeta(key + " angle (Y) in degrees", values[3]);
break;
case 4:
addGlobalMeta(key + " intensity (X)", values[2]);
addGlobalMeta(key + " intensity (Y)", values[3]);
break;
case 6:
addGlobalMeta(key + " ratio (X)", values[2]);
addGlobalMeta(key + " ratio (Y)", values[3]);
break;
case 7:
addGlobalMeta(key + " log ratio (X)", values[2]);
addGlobalMeta(key + " log ratio (Y)", values[3]);
break;
case 9:
addGlobalMeta(key + " noncalibrated intensity min", values[2]);
addGlobalMeta(key + " noncalibrated intensity max", values[3]);
addGlobalMeta(key + " calibrated intensity min", values[4]);
addGlobalMeta(key + " calibrated intensity max", values[5]);
break;
case 14:
addGlobalMeta(key + " time course type (X)", values[2]);
addGlobalMeta(key + " time course type (Y)", values[3]);
break;
case 15:
String prefix = " inverse sigmoid calibrated intensity ";
addGlobalMeta(key + prefix + "(min)", values[2]);
addGlobalMeta(key + prefix + "(max)", values[3]);
addGlobalMeta(key + prefix + "(beta)", values[4]);
addGlobalMeta(key + prefix + "(Kd)", values[5]);
break;
case 16:
prefix = " log inverse sigmoid calibrated intensity ";
addGlobalMeta(key + prefix + "(min)", values[2]);
addGlobalMeta(key + prefix + "(max)", values[3]);
addGlobalMeta(key + prefix + "(beta)", values[4]);
addGlobalMeta(key + prefix + "(Kd)", values[5]);
break;
}
}
}
}
return multipleFiles;
}
Aggregations