Skip to content

Commit

Permalink
Metamorph: prevent NumberFormatException when trying to read waveleng…
Browse files Browse the repository at this point in the history
…th in nm

Fixes #4273.
  • Loading branch information
melissalinkert committed Feb 18, 2025
1 parent ea96bf4 commit 4d06b6b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion components/formats-gpl/src/loci/formats/in/MetamorphHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
import ome.units.UNITS;
import ome.units.quantity.Length;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.xml.sax.Attributes;

/**
Expand All @@ -45,6 +48,9 @@
*/
public class MetamorphHandler extends BaseHandler {

private static final Logger LOGGER =
LoggerFactory.getLogger(MetamorphHandler.class);

// -- Fields --

private Hashtable metadata;
Expand Down Expand Up @@ -256,7 +262,15 @@ else if (key.equals("stage-position-y")) {
}
}
if (key.equals("wavelength")) {
wavelengths.add(Integer.parseInt(value));
// usually this key represents an integer wavelength in nm
// sometimes it can be a more descriptive string with no
// usable value in nm
try {
wavelengths.add(Integer.parseInt(value));
}
catch (NumberFormatException e) {
LOGGER.debug("Could not parse wavelength value from {}", value);
}
}
else if (key.equals("acquisition-time-local")) {
date = value;
Expand Down

0 comments on commit 4d06b6b

Please sign in to comment.