public class PrairieMetadata extends Object
Modifier and Type | Class and Description |
---|---|
class |
PrairieMetadata.Frame
A Prairie
<Frame> , beneath a <Sequence> . |
class |
PrairieMetadata.PFile
A Prairie
<File> beneath a <Frame> . |
class |
PrairieMetadata.Sequence
A Prairie
<Sequence> . |
static interface |
PrairieMetadata.Value
A value in a Prairie metadata dictionary.
|
static class |
PrairieMetadata.ValueItem
A leaf value with an actual
PrairieMetadata.ValueItem.value() as well as an optional
PrairieMetadata.ValueItem.description() . |
static class |
PrairieMetadata.ValueTable
A table of values.
|
Modifier and Type | Field and Description |
---|---|
private HashSet<Integer> |
activeChannels
Set of active channel indices.
|
private PrairieMetadata.ValueTable |
config
Key/value pairs from CFG and/or ENV files.
|
private int |
cycleMax
Maximum cycle value.
|
private int |
cycleMin
Minimum cycle value.
|
private String |
date
The date of the acquisition.
|
private PrairieMetadata.Sequence |
firstSequence
The first actual
<Sequence> element. |
private PrairieMetadata.ValueTable |
scanValues
Table of key/value pairs at the top level.
|
private HashMap<Integer,PrairieMetadata.Sequence> |
sequences
<Sequence> elements, keyed on each sequence's cycle . |
private Double |
waitTime
The wait time of the acquisition.
|
Constructor and Description |
---|
PrairieMetadata(Document xml,
Document cfg,
Document env)
Creates a new Prairie metadata by parsing the given XML, CFG and/or ENV
documents.
|
Modifier and Type | Method and Description |
---|---|
private String |
attr(Element el,
String name)
Gets the attribute value with the given name, or null if not defined.
|
private boolean |
b(String value)
Converts the given string to a
boolean . |
private void |
checkElement(Element el,
String name)
Checks that the given element has the specified name.
|
private Double |
d(String value)
Converts the given string to a
Double , or null if
incompatible. |
private Element |
el(NodeList nodes,
int index)
Gets the
index th element from the given list of nodes. |
int[] |
getActiveChannels()
Gets the list of active channel indices, in sorted order.
|
Integer |
getBitDepth()
Gets the
bitDepth recorded in the configuration. |
PrairieMetadata.ValueTable |
getConfig()
Gets the map of configuration key/value pairs.
|
PrairieMetadata.Value |
getConfig(String key)
Gets the
value of the given configuration key . |
int |
getCycleCount()
Gets the number of recorded cycles.
|
int |
getCycleMax()
Gets the maximum cycle value.
|
int |
getCycleMin()
Gets the minimum cycle value.
|
String |
getDate()
Gets the date of the acquisition.
|
PrairieMetadata.PFile |
getFile(int cycle,
int index,
int channel)
Gets the
Frame at the given (cycle , index ,
channel ). |
private Element |
getFirstChild(Element el,
String name)
Gets the first child element with the given name.
|
PrairieMetadata.Sequence |
getFirstSequence()
Gets the first
Sequence . |
PrairieMetadata.Frame |
getFrame(int cycle,
int index)
Gets the
Frame at the given (cycle and index ). |
Double |
getLaserPower()
Gets the first
laserPower recorded in the configuration. |
PrairieMetadata.Sequence |
getSequence(int cycle)
Gets the
Sequence at the given cycle . |
ArrayList<PrairieMetadata.Sequence> |
getSequences()
Gets all
Sequences , ordered by cycle . |
PrairieMetadata.Value |
getValue(String key)
Gets the
value of the given key , at the top-level
<PVScan> element. |
PrairieMetadata.ValueTable |
getValues()
Gets the table of
PVScan key/value pairs. |
Double |
getWaitTime()
Gets the
waitTime recorded in the configuration. |
private Integer |
i(String value)
Converts the given string to an
Integer , or null if incompatible. |
boolean |
isInvertX()
Gets whether the stage position X coordinates are inverted (i.e.,
left-to-right).
|
boolean |
isInvertY()
Gets whether the stage position Y coordinates are inverted (i.e.,
bottom-to-top).
|
private void |
parseCFG(Document doc)
Parses metadata from Prairie CFG file.
|
private void |
parseChannels()
Parses details of the activated channels into the
activeChannels
data structure from the "channel" entry of the configuration. |
private void |
parseENV(Document doc)
Parses metadata from Prairie ENV file.
|
private void |
parseKeys(Element el,
PrairieMetadata.ValueTable table)
Parses
<Key> elements beneath the given element, into the specified
table. |
private void |
parsePVStateShard(Element el,
PrairieMetadata.ValueTable table)
Parses the
<PVStateShard> element beneath the given element, into
the specified table. |
private void |
parseXML(Document doc)
Parses metadata from Prairie XML file.
|
private String |
token(String s,
String regex,
int i)
Gets the
i th token of the given string, split according to the
specific regular expression. |
private String |
value(PrairieMetadata.Value value)
Returns
value.value() , or null if value is null. |
private String |
value(PrairieMetadata.Value value,
int index)
Returns
value.get(index).value() , or null if value or
value.get(index) is null. |
private String |
value(PrairieMetadata.Value value,
String key)
Returns
value.get(key).value() , or null if value or
value.get(key) is null. |
private <K extends Comparable<? super K>,V> |
valuesByKey(Map<K,V> map)
Gets the values of the given map, sorted by key.
|
private final HashMap<Integer,PrairieMetadata.Sequence> sequences
<Sequence>
elements, keyed on each sequence's cycle
.private final PrairieMetadata.ValueTable scanValues
private PrairieMetadata.Sequence firstSequence
<Sequence>
element.private int cycleMin
private int cycleMax
private String date
private Double waitTime
private final PrairieMetadata.ValueTable config
public PrairieMetadata(Document xml, Document cfg, Document env)
xml
- The XML document to parse, or null if none available.cfg
- The CFG document to parse, or null if none available.env
- The ENV document to parse, or null if none available.public Double getWaitTime()
waitTime
recorded in the configuration.public int[] getActiveChannels()
These indices correspond to the configuration's channel
keys
flagged as True
.
public boolean isInvertX()
public boolean isInvertY()
public Integer getBitDepth()
bitDepth
recorded in the configuration.public Double getLaserPower()
laserPower
recorded in the configuration.public PrairieMetadata.Value getConfig(String key)
value
of the given configuration key
.public PrairieMetadata.ValueTable getConfig()
public String getDate()
public int getCycleMin()
cycle
attribute
found, and hence will not necessarily equal 1
(though in practice
it usually does).public int getCycleMax()
cycle
attribute
found, and hence will not necessarily equal sequences#size()
(though in practice it usually does).public int getCycleCount()
getCycleMax()
- getCycleMin()
+ 1.public PrairieMetadata.Sequence getFirstSequence()
Sequence
.public PrairieMetadata.Sequence getSequence(int cycle)
Sequence
at the given cycle
.public ArrayList<PrairieMetadata.Sequence> getSequences()
Sequences
, ordered by cycle
.public PrairieMetadata.Frame getFrame(int cycle, int index)
Frame
at the given (cycle
and index
).public PrairieMetadata.PFile getFile(int cycle, int index, int channel)
Frame
at the given (cycle
, index
,
channel
).public PrairieMetadata.Value getValue(String key)
value
of the given key
, at the top-level
<PVScan>
element.public PrairieMetadata.ValueTable getValues()
PVScan
key/value pairs.private void parseXML(Document doc)
private void parseCFG(Document doc)
private void parseENV(Document doc)
private void parseKeys(Element el, PrairieMetadata.ValueTable table)
<Key>
elements beneath the given element, into the specified
table. These <Key>
elements are only present in data from
PrairieView versions prior to 5.2.private void parsePVStateShard(Element el, PrairieMetadata.ValueTable table)
<PVStateShard>
element beneath the given element, into
the specified table. These <PVStateShard>
elements are only present
in data from PrairieView versions 5.2 and later.private void parseChannels()
activeChannels
data structure from the "channel" entry of the configuration.private void checkElement(Element el, String name)
IllegalArgumentException
- if the name does not match.private Element getFirstChild(Element el, String name)
private Element el(NodeList nodes, int index)
index
th element from the given list of nodes.private String attr(Element el, String name)
private String value(PrairieMetadata.Value value)
value.value()
, or null if value
is null.private String value(PrairieMetadata.Value value, String key)
value.get(key).value()
, or null if value
or
value.get(key)
is null.private String value(PrairieMetadata.Value value, int index)
value.get(index).value()
, or null if value
or
value.get(index)
is null.private boolean b(String value)
boolean
.private String token(String s, String regex, int i)
i
th token of the given string, split according to the
specific regular expression.private <K extends Comparable<? super K>,V> ArrayList<V> valuesByKey(Map<K,V> map)
Copyright © 2016 Open Microscopy Environment