public class N5HDF5Reader extends Object implements org.janelia.saalfeldlab.n5.GsonN5Reader, Closeable
N5Reader implementation for HDF5 files.
Attributes are not generally read as JSON but use HDF5 types. That means that HDF5 files that were not generated with this library can be used properly and correctly. Structured attributes for which no appropriate HDF5 attribute type exists are parsed as JSON strings.
org.janelia.saalfeldlab.n5.N5Reader.Version| Modifier and Type | Field and Description |
|---|---|
protected int[] |
defaultBlockSize |
protected static org.janelia.saalfeldlab.n5.FileSystemKeyValueAccess |
FILE_SYSTEM_KEY_VALUE_ACCESS |
protected com.google.gson.Gson |
gson |
protected static String |
N5_JSON_ROOT_KEY |
protected org.janelia.saalfeldlab.n5.hdf5.N5HDF5Util.OpenDataSetCache |
openDataSetCache |
protected boolean |
overrideBlockSize |
protected ch.systemsx.cisd.hdf5.IHDF5Reader |
reader |
static org.janelia.saalfeldlab.n5.N5Reader.Version |
VERSION
SemVer version of this N5-HDF5 spec.
|
NO_VERSION, VERSION_KEY| Constructor and Description |
|---|
N5HDF5Reader(ch.systemsx.cisd.hdf5.IHDF5Reader reader,
boolean overrideBlockSize,
com.google.gson.GsonBuilder gsonBuilder,
int... defaultBlockSize)
Opens an
N5HDF5Reader for a given HDF5 file. |
N5HDF5Reader(ch.systemsx.cisd.hdf5.IHDF5Reader reader,
boolean overrideBlockSize,
int... defaultBlockSize)
Opens an
N5HDF5Reader for a given HDF5 file. |
N5HDF5Reader(ch.systemsx.cisd.hdf5.IHDF5Reader reader,
int... defaultBlockSize)
Opens an
N5HDF5Reader for a given HDF5 file. |
N5HDF5Reader(String hdf5Path,
boolean overrideBlockSize,
com.google.gson.GsonBuilder gsonBuilder,
int... defaultBlockSize)
Opens an
N5HDF5Reader for a given HDF5 file. |
N5HDF5Reader(String hdf5Path,
boolean overrideBlockSize,
int... defaultBlockSize)
Opens an
N5HDF5Reader for a given HDF5 file. |
N5HDF5Reader(String hdf5Path,
int... defaultBlockSize)
Opens an
N5HDF5Reader for a given HDF5 file. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
blockExists(String pathName,
org.janelia.saalfeldlab.n5.DatasetAttributes datasetAttributes,
long... gridPosition) |
void |
close() |
protected static boolean |
containsEscapeCharacters(String normalizedKey) |
protected static void |
cropBlockSize(long[] gridPosition,
long[] dimensions,
int[] blockSize,
int[] croppedBlockSize,
long[] offset)
Crops the dimensions of a
DataBlock at a given offset to fit into
an interval of given dimensions. |
boolean |
datasetExists(String pathName) |
boolean |
doesOverrideBlockSize() |
boolean |
exists(String pathName) |
<T> T |
getAttribute(String pathName,
String key,
Class<T> clazz) |
<T> T |
getAttribute(String pathName,
String key,
Type type) |
com.google.gson.JsonElement |
getAttributes(String pathName) |
String |
getAttributesKey() |
org.janelia.saalfeldlab.n5.DatasetAttributes |
getDatasetAttributes(String pathName)
Always returns
Compression.CompressionType#RAW because I could not yet find a
meaningful way to get information about the compression of a dataset. |
protected static org.janelia.saalfeldlab.n5.DataType |
getDataType(ch.systemsx.cisd.hdf5.HDF5DataSetInformation datasetInfo) |
int[] |
getDefaultBlockSizeCopy() |
File |
getFilename() |
com.google.gson.Gson |
getGson() |
URI |
getURI() |
String[] |
list(String pathName) |
Map<String,Class<?>> |
listAttributes(String pathName)
String attributes will be parsed as JSON and classified as
1) An Object[] if it is a JsonArray
2) A String if it is a JsonPrimitive
3) An Object if it is a JsonObject
|
protected static String |
normalizeHdf5PathLocation(String hdf5Path) |
<T> org.janelia.saalfeldlab.n5.DataBlock<T> |
readBlock(String pathName,
org.janelia.saalfeldlab.n5.DatasetAttributes datasetAttributes,
long... gridPosition) |
<T> org.janelia.saalfeldlab.n5.DataBlock<T> |
readChunk(String pathName,
org.janelia.saalfeldlab.n5.DatasetAttributes datasetAttributes,
long... gridPosition) |
protected static void |
reorder(int[] array) |
protected static void |
reorder(long[] array) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcreateDatasetAttributesdeepList, deepList, deepList, deepList, deepList, deepListDatasets, deepListDatasets, deepListDatasets, deepListDatasets, deepListHelper, getConvertedDatasetAttributes, getGroupSeparator, getVersion, groupPath, readChunks, readSerializedBlockprotected final com.google.gson.Gson gson
protected static final String N5_JSON_ROOT_KEY
protected static final org.janelia.saalfeldlab.n5.FileSystemKeyValueAccess FILE_SYSTEM_KEY_VALUE_ACCESS
public static final org.janelia.saalfeldlab.n5.N5Reader.Version VERSION
protected final ch.systemsx.cisd.hdf5.IHDF5Reader reader
protected final int[] defaultBlockSize
protected boolean overrideBlockSize
protected final org.janelia.saalfeldlab.n5.hdf5.N5HDF5Util.OpenDataSetCache openDataSetCache
public N5HDF5Reader(ch.systemsx.cisd.hdf5.IHDF5Reader reader,
boolean overrideBlockSize,
com.google.gson.GsonBuilder gsonBuilder,
int... defaultBlockSize)
throws org.janelia.saalfeldlab.n5.N5Exception
N5HDF5Reader for a given HDF5 file.reader - HDF5 readeroverrideBlockSize - true if you want this N5HDF5Reader to use the
defaultBlockSize instead of the chunk-size for reading
datasetsgsonBuilder - custom GsonBuilder to support custom attributesdefaultBlockSize - for all dimensions > defaultBlockSize.length, and for all
dimensions with defaultBlockSize[i] <= 0, the size of the
dataset will be usedorg.janelia.saalfeldlab.n5.N5Exceptionpublic N5HDF5Reader(ch.systemsx.cisd.hdf5.IHDF5Reader reader,
boolean overrideBlockSize,
int... defaultBlockSize)
N5HDF5Reader for a given HDF5 file.reader - HDF5 readeroverrideBlockSize - true if you want this N5HDF5Reader to use the
defaultBlockSize instead of the chunk-size for reading
datasetsdefaultBlockSize - for all dimensions > defaultBlockSize.length, and for all
dimensions with defaultBlockSize[i] <= 0, the size of the
dataset will be usedpublic N5HDF5Reader(ch.systemsx.cisd.hdf5.IHDF5Reader reader,
int... defaultBlockSize)
N5HDF5Reader for a given HDF5 file.reader - HDF5 readerdefaultBlockSize - for all dimensions > defaultBlockSize.length, and for all
dimensions with defaultBlockSize[i] <= 0, the size of the
dataset will be usedpublic N5HDF5Reader(String hdf5Path, boolean overrideBlockSize, com.google.gson.GsonBuilder gsonBuilder, int... defaultBlockSize)
N5HDF5Reader for a given HDF5 file.hdf5Path - HDF5 file nameoverrideBlockSize - true if you want this N5HDF5Reader to use the
defaultBlockSize instead of the chunk-size for reading
datasetsgsonBuilder - custom GsonBuilder to support custom attributesdefaultBlockSize - for all dimensions > defaultBlockSize.length, and for all
dimensions with defaultBlockSize[i] <= 0, the size of the
dataset will be usedpublic N5HDF5Reader(String hdf5Path, boolean overrideBlockSize, int... defaultBlockSize)
N5HDF5Reader for a given HDF5 file.hdf5Path - HDF5 file nameoverrideBlockSize - true if you want this N5HDF5Reader to use the
defaultBlockSize instead of the chunk-size for reading
datasetsdefaultBlockSize - for all dimensions > defaultBlockSize.length, and for all
dimensions with defaultBlockSize[i] <= 0, the size of the
dataset will be usedpublic N5HDF5Reader(String hdf5Path, int... defaultBlockSize)
N5HDF5Reader for a given HDF5 file.hdf5Path - HDF5 file namedefaultBlockSize - for all dimensions > defaultBlockSize.length, and for all
dimensions with defaultBlockSize[i] <= 0, the size of the
dataset will be usedpublic com.google.gson.Gson getGson()
getGson in interface org.janelia.saalfeldlab.n5.GsonN5Readerpublic String getAttributesKey()
getAttributesKey in interface org.janelia.saalfeldlab.n5.GsonN5Readerpublic boolean exists(String pathName)
exists in interface org.janelia.saalfeldlab.n5.N5Readerpublic String[] list(String pathName) throws org.janelia.saalfeldlab.n5.N5Exception
list in interface org.janelia.saalfeldlab.n5.N5Readerorg.janelia.saalfeldlab.n5.N5Exceptionprotected static boolean containsEscapeCharacters(String normalizedKey)
public <T> T getAttribute(String pathName, String key, Type type) throws org.janelia.saalfeldlab.n5.N5Exception
getAttribute in interface org.janelia.saalfeldlab.n5.GsonN5ReadergetAttribute in interface org.janelia.saalfeldlab.n5.N5Readerorg.janelia.saalfeldlab.n5.N5Exceptionpublic URI getURI()
getURI in interface org.janelia.saalfeldlab.n5.N5Readerpublic <T> T getAttribute(String pathName, String key, Class<T> clazz) throws org.janelia.saalfeldlab.n5.N5Exception
getAttribute in interface org.janelia.saalfeldlab.n5.GsonN5ReadergetAttribute in interface org.janelia.saalfeldlab.n5.N5Readerorg.janelia.saalfeldlab.n5.N5Exceptionpublic com.google.gson.JsonElement getAttributes(String pathName) throws org.janelia.saalfeldlab.n5.N5Exception
getAttributes in interface org.janelia.saalfeldlab.n5.GsonN5Readerorg.janelia.saalfeldlab.n5.N5Exceptionprotected static org.janelia.saalfeldlab.n5.DataType getDataType(ch.systemsx.cisd.hdf5.HDF5DataSetInformation datasetInfo)
protected static void reorder(long[] array)
protected static void reorder(int[] array)
protected static void cropBlockSize(long[] gridPosition,
long[] dimensions,
int[] blockSize,
int[] croppedBlockSize,
long[] offset)
DataBlock at a given offset to fit into
an interval of given dimensions. Fills long and int version of cropped
block size. Also calculates the grid raster position assuming that the
offset is divisible by block size without remainder.gridPosition - the coordinate of the blockdimensions - the dataset dimensionsblockSize - the block sizecroppedBlockSize - the cropped block size to be filledoffset - the offset to be filledpublic org.janelia.saalfeldlab.n5.DatasetAttributes getDatasetAttributes(String pathName)
Compression.CompressionType#RAW because I could not yet find a
meaningful way to get information about the compression of a dataset.getDatasetAttributes in interface org.janelia.saalfeldlab.n5.GsonN5ReadergetDatasetAttributes in interface org.janelia.saalfeldlab.n5.N5ReaderpathName - the group or dataset pathpublic <T> org.janelia.saalfeldlab.n5.DataBlock<T> readChunk(String pathName, org.janelia.saalfeldlab.n5.DatasetAttributes datasetAttributes, long... gridPosition) throws org.janelia.saalfeldlab.n5.N5Exception
readChunk in interface org.janelia.saalfeldlab.n5.N5Readerorg.janelia.saalfeldlab.n5.N5Exceptionpublic <T> org.janelia.saalfeldlab.n5.DataBlock<T> readBlock(String pathName, org.janelia.saalfeldlab.n5.DatasetAttributes datasetAttributes, long... gridPosition) throws org.janelia.saalfeldlab.n5.N5Exception
readBlock in interface org.janelia.saalfeldlab.n5.N5Readerorg.janelia.saalfeldlab.n5.N5Exceptionpublic boolean blockExists(String pathName, org.janelia.saalfeldlab.n5.DatasetAttributes datasetAttributes, long... gridPosition) throws org.janelia.saalfeldlab.n5.N5Exception
blockExists in interface org.janelia.saalfeldlab.n5.N5Readerorg.janelia.saalfeldlab.n5.N5Exceptionpublic boolean datasetExists(String pathName)
datasetExists in interface org.janelia.saalfeldlab.n5.N5Readerpublic Map<String,Class<?>> listAttributes(String pathName) throws org.janelia.saalfeldlab.n5.N5Exception
listAttributes in interface org.janelia.saalfeldlab.n5.GsonN5ReaderlistAttributes in interface org.janelia.saalfeldlab.n5.N5Readerorg.janelia.saalfeldlab.n5.N5Exceptionpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface org.janelia.saalfeldlab.n5.N5Readerpublic File getFilename()
public int[] getDefaultBlockSizeCopy()
public boolean doesOverrideBlockSize()
true if this reader overrides block size found in an
HDF5 dataset, false otherwiseCopyright © 2017–2026 Saalfeld Lab. All rights reserved.