public class N5DatasetDiscoverer extends Object
An N5DatasetDiscoverer specifies the types of N5MetadataParsers to
attempt, and an ExecutorService that enables parsing in parallel. The
parsers are passed to the constructor in a list. Group parsers are called
after all others are called, and should be used when a parsers result depends
on its children.
The discoverAndParseRecursive method returns a N5TreeNode
containing all child nodes, each of which contains parsed metadata. For each
group/dataset, the parsers will be called in order, and will return the first
non-empty result. As such parsers should be ordered from most- to
least-strict.
| Modifier and Type | Field and Description |
|---|---|
static N5MetadataParser<?>[] |
DEFAULT_PARSERS |
| Modifier and Type | Method and Description |
|---|---|
static List<N5MetadataParser<?>> |
defaultGroupParsers(org.janelia.saalfeldlab.n5.N5Reader n5)
Parser configuration depends on the n5 reader.
|
static List<N5MetadataParser<?>> |
defaultShallowGroupParsers(org.janelia.saalfeldlab.n5.N5Reader n5)
Parser configuration depends on the n5 reader.
|
static N5TreeNode |
discover(org.janelia.saalfeldlab.n5.N5Reader n5) |
static N5TreeNode |
discover(org.janelia.saalfeldlab.n5.N5Reader n5,
List<N5MetadataParser<?>> parsers) |
static N5TreeNode |
discover(org.janelia.saalfeldlab.n5.N5Reader n5,
List<N5MetadataParser<?>> parsers,
List<N5MetadataParser<?>> groupParsers) |
static N5TreeNode |
discover(org.janelia.saalfeldlab.n5.N5Reader n5,
String basePath) |
static N5TreeNode |
discover(org.janelia.saalfeldlab.n5.N5Reader n5,
String basePath,
List<N5MetadataParser<?>> parsers,
List<N5MetadataParser<?>> groupParsers) |
N5TreeNode |
discoverAndParseRecursive(N5TreeNode root) |
N5TreeNode |
discoverAndParseRecursive(N5TreeNode root,
Consumer<N5TreeNode> callback) |
N5TreeNode |
discoverAndParseRecursive(N5TreeNode root,
Predicate<String> filter,
Consumer<N5TreeNode> callback) |
N5TreeNode |
discoverAndParseRecursive(String base)
Recursively discovers and parses metadata for datasets that are children
of the given base path using
N5Reader.deepList(java.lang.String, java.util.function.Predicate<java.lang.String>). |
N5TreeNode |
discoverAndParseRecursive(String base,
Consumer<N5TreeNode> callback) |
static N5TreeNode |
discoverShallow(org.janelia.saalfeldlab.n5.N5Reader n5)
Discovers metadata present at the root without listing
|
static N5TreeNode |
discoverShallow(org.janelia.saalfeldlab.n5.N5Reader n5,
String dataset)
Discovers metadata present at the provided dataset without listing.
|
N5TreeNode |
discoverShallow(N5TreeNode base) |
N5TreeNode |
discoverShallow(N5TreeNode base,
Consumer<N5TreeNode> callback) |
N5TreeNode |
discoverShallow(String base) |
N5TreeNode |
discoverShallow(String base,
Consumer<N5TreeNode> callback) |
void |
filterRecursive(N5TreeNode node) |
static List<N5MetadataParser<?>> |
fromParsers(N5MetadataParser<?>[] parsers) |
N5TreeNode |
parse(N5TreeNode node) |
N5TreeNode |
parse(String dataset) |
static void |
parseMetadata(org.janelia.saalfeldlab.n5.N5Reader n5,
N5TreeNode node,
List<N5MetadataParser<?>> metadataParsers) |
static void |
parseMetadata(org.janelia.saalfeldlab.n5.N5Reader n5,
N5TreeNode node,
List<N5MetadataParser<?>> metadataParsers,
List<N5MetadataParser<?>> groupParsers)
Parses metadata for a node using the given parsers, stopping after the
first success.
|
void |
parseMetadataRecursive(N5TreeNode rootNode)
Parses metadata for the given node and all children in parallel using
this object's executor.
|
void |
parseMetadataRecursive(N5TreeNode rootNode,
Consumer<N5TreeNode> callback)
Parses metadata for the given node and all children in parallel using
this object's executor.
|
void |
parseMetadataRecursive(N5TreeNode rootNode,
Consumer<N5TreeNode> callback,
boolean skipParsingIfPresent)
Parses metadata for the given node and all children in parallel using this
object's executor.
|
static void |
parseMetadataShallow(org.janelia.saalfeldlab.n5.N5Reader n5,
N5TreeNode node,
List<N5MetadataParser<?>> metadataParsers,
List<N5MetadataParser<?>> groupParsers)
Parses metadata for a node using the given parsers, stopping after the first
success.
|
void |
sort(N5TreeNode node) |
static void |
sort(N5TreeNode node,
Comparator<? super String> comparator,
Consumer<N5TreeNode> callback) |
void |
sort(N5TreeNode node,
Consumer<N5TreeNode> callback) |
void |
sortAndTrimRecursive(N5TreeNode node) |
void |
sortAndTrimRecursive(N5TreeNode node,
Consumer<N5TreeNode> callback) |
static boolean |
trim(N5TreeNode node) |
static boolean |
trim(N5TreeNode node,
Consumer<N5TreeNode> callback)
Removes branches of the N5 container tree that do not contain any nodes
that can be opened (nodes with metadata).
|
public static final N5MetadataParser<?>[] DEFAULT_PARSERS
public N5DatasetDiscoverer(org.janelia.saalfeldlab.n5.N5Reader n5, ExecutorService executor)
public N5DatasetDiscoverer(org.janelia.saalfeldlab.n5.N5Reader n5, ExecutorService executor, List<N5MetadataParser<?>> metadataParsers, List<N5MetadataParser<?>> groupParsers)
public N5DatasetDiscoverer(org.janelia.saalfeldlab.n5.N5Reader n5, List<N5MetadataParser<?>> metadataParsers, List<N5MetadataParser<?>> groupParsers)
n5 - n5 readermetadataParsers - metadata parsersgroupParsers - group parserspublic N5DatasetDiscoverer(org.janelia.saalfeldlab.n5.N5Reader n5, ExecutorService executor, Predicate<N5TreeNode> filter, List<N5MetadataParser<?>> metadataParsers, List<N5MetadataParser<?>> groupParsers)
public N5DatasetDiscoverer(org.janelia.saalfeldlab.n5.N5Reader n5, ExecutorService executor, Optional<Comparator<? super String>> comparator, List<N5MetadataParser<?>> metadataParsers, List<N5MetadataParser<?>> groupParsers)
public N5DatasetDiscoverer(org.janelia.saalfeldlab.n5.N5Reader n5, ExecutorService executor, Optional<Comparator<? super String>> comparator, Predicate<N5TreeNode> filter, List<N5MetadataParser<?>> metadataParsers, List<N5MetadataParser<?>> groupParsers)
If the optional parameter comparator is specified, the groups and
datasets will be listed in the order determined by this comparator.
n5 - the n5 readerexecutor - the executorcomparator - optional string comparatorfilter - the dataset filtermetadataParsers - metadata parsersgroupParsers - group parserspublic N5DatasetDiscoverer(org.janelia.saalfeldlab.n5.N5Reader n5, ExecutorService executor, Optional<Comparator<? super String>> comparator, Predicate<N5TreeNode> filter, List<N5MetadataParser<?>> metadataParsers, List<N5MetadataParser<?>> groupParsers, List<N5MetadataParser<?>> shallowGroupParsers)
If the optional parameter comparator is specified, the groups and
datasets will be listed in the order determined by this comparator.
n5 - the n5 readerexecutor - the executorcomparator - optional string comparatorfilter - the dataset filtermetadataParsers - metadata parsersgroupParsers - group parsersshallowGroupParsers - shallow group parserspublic static void parseMetadata(org.janelia.saalfeldlab.n5.N5Reader n5, N5TreeNode node, List<N5MetadataParser<?>> metadataParsers) throws IOException
IOExceptionpublic static void parseMetadata(org.janelia.saalfeldlab.n5.N5Reader n5, N5TreeNode node, List<N5MetadataParser<?>> metadataParsers, List<N5MetadataParser<?>> groupParsers) throws IOException
n5 - the N5Readernode - the tree nodemetadataParsers - list of metadata parsersgroupParsers - list of group parsersIOException - the exceptionpublic static void parseMetadataShallow(org.janelia.saalfeldlab.n5.N5Reader n5, N5TreeNode node, List<N5MetadataParser<?>> metadataParsers, List<N5MetadataParser<?>> groupParsers)
The group parsers given are assumed to be shallow.
n5 - the N5Readernode - the tree nodemetadataParsers - list of metadata parsersgroupParsers - list of shallow group parserspublic static boolean trim(N5TreeNode node)
public static boolean trim(N5TreeNode node, Consumer<N5TreeNode> callback)
node - the nodecallback - the callback functiontrue if the branch contains a node that can be opened,
false otherwisepublic static void sort(N5TreeNode node, Comparator<? super String> comparator, Consumer<N5TreeNode> callback)
public void sort(N5TreeNode node, Consumer<N5TreeNode> callback)
public void sort(N5TreeNode node)
public N5TreeNode discoverShallow(String base)
public N5TreeNode discoverShallow(String base, Consumer<N5TreeNode> callback)
public N5TreeNode discoverShallow(N5TreeNode base)
public N5TreeNode discoverShallow(N5TreeNode base, Consumer<N5TreeNode> callback)
public N5TreeNode discoverAndParseRecursive(String base) throws IOException
N5Reader.deepList(java.lang.String, java.util.function.Predicate<java.lang.String>). Returns an
N5TreeNode that can be displayed as a JTree.base - the base pathIOException - the io exceptionpublic N5TreeNode discoverAndParseRecursive(String base, Consumer<N5TreeNode> callback) throws IOException
IOExceptionpublic N5TreeNode discoverAndParseRecursive(N5TreeNode root) throws IOException
IOExceptionpublic N5TreeNode discoverAndParseRecursive(N5TreeNode root, Consumer<N5TreeNode> callback) throws IOException
IOExceptionpublic N5TreeNode discoverAndParseRecursive(N5TreeNode root, Predicate<String> filter, Consumer<N5TreeNode> callback) throws IOException
IOExceptionpublic N5TreeNode parse(String dataset)
public N5TreeNode parse(N5TreeNode node)
public void sortAndTrimRecursive(N5TreeNode node)
public void sortAndTrimRecursive(N5TreeNode node, Consumer<N5TreeNode> callback)
public void filterRecursive(N5TreeNode node)
public void parseMetadataRecursive(N5TreeNode rootNode)
rootNode - the root nodepublic void parseMetadataRecursive(N5TreeNode rootNode, Consumer<N5TreeNode> callback)
rootNode - the root nodecallback - the callback functionpublic void parseMetadataRecursive(N5TreeNode rootNode, Consumer<N5TreeNode> callback, boolean skipParsingIfPresent)
The skipParsingIfPresent argument allows parsing to be skipped if metadata for this node are already present. This should generally be true.
rootNode - the root nodecallback - the callback functionskipParsingIfPresent - skip parsing the root node if metadata are already presentpublic static final List<N5MetadataParser<?>> fromParsers(N5MetadataParser<?>[] parsers)
public static N5TreeNode discover(org.janelia.saalfeldlab.n5.N5Reader n5, String basePath, List<N5MetadataParser<?>> parsers, List<N5MetadataParser<?>> groupParsers)
public static N5TreeNode discover(org.janelia.saalfeldlab.n5.N5Reader n5, List<N5MetadataParser<?>> parsers, List<N5MetadataParser<?>> groupParsers)
public static N5TreeNode discover(org.janelia.saalfeldlab.n5.N5Reader n5, List<N5MetadataParser<?>> parsers)
public static N5TreeNode discover(org.janelia.saalfeldlab.n5.N5Reader n5, String basePath)
public static N5TreeNode discover(org.janelia.saalfeldlab.n5.N5Reader n5)
public static N5TreeNode discoverShallow(org.janelia.saalfeldlab.n5.N5Reader n5, String dataset)
n5 - the readerdataset - the datasetpublic static N5TreeNode discoverShallow(org.janelia.saalfeldlab.n5.N5Reader n5)
n5 - the readerpublic static List<N5MetadataParser<?>> defaultGroupParsers(org.janelia.saalfeldlab.n5.N5Reader n5)
n5 - the n5 readerpublic static List<N5MetadataParser<?>> defaultShallowGroupParsers(org.janelia.saalfeldlab.n5.N5Reader n5)
n5 - the n5 readerCopyright © 2021–2026 Saalfeld Lab. All rights reserved.