use of org.janelia.saalfeldlab.n5.N5DatasetDiscoverer in project bigwarp by saalfeldlab.
the class BigWarpInit method loadN5Source.
public static Source<?> loadN5Source(final String n5Root, final String n5Dataset) {
final N5Reader n5;
try {
n5 = new N5Factory().openReader(n5Root);
} catch (IOException e) {
e.printStackTrace();
return null;
}
final N5MetadataParser<?>[] PARSERS = new N5MetadataParser[] { new ImagePlusLegacyMetadataParser(), new N5CosemMetadataParser(), new N5SingleScaleMetadataParser(), new CanonicalMetadataParser(), new N5GenericSingleScaleMetadataParser() };
final N5MetadataParser<?>[] GROUP_PARSERS = new N5MetadataParser[] { new N5CosemMultiScaleMetadata.CosemMultiScaleParser(), new N5ViewerMultiscaleMetadataParser(), new CanonicalMetadataParser() };
N5Metadata meta = null;
try {
final N5DatasetDiscoverer discoverer = new N5DatasetDiscoverer(n5, N5DatasetDiscoverer.fromParsers(PARSERS), N5DatasetDiscoverer.fromParsers(GROUP_PARSERS));
final N5TreeNode node = discoverer.discoverAndParseRecursive(n5Dataset);
meta = node.getMetadata();
} catch (IOException e) {
}
if (meta instanceof MultiscaleMetadata) {
return openAsSourceMulti(n5, (MultiscaleMetadata<?>) meta, true);
} else {
return openAsSource(n5, meta, true);
}
}
Aggregations