Package loci.formats.services
Class JHDFServiceImpl
java.lang.Object
loci.common.services.AbstractService
loci.formats.services.JHDFServiceImpl
- All Implemented Interfaces:
loci.common.services.Service,JHDFService
Utility class for working with HDF files.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes and resets the service.voidcreateGroup(String path) Writes an array as sub-slice into an existing HDF5 datasetbooleanChecks if path in HDF5 file exists.intgetElementSize(String path) Retrieves the Element Size of a dataset in Byte.getFile()Retrieves the current initialized file path.Retrieves the all members of a group.int[]Retrieves the shape of a dataset.voidinitIntArray(String path, long[] dimensions, long bpp) Creates an HDF5 dataset in path consisting of integers specified by bytes per pixel bpp.ch.systemsx.cisd.base.mdarray.MDByteArrayreadByteArray(String path) Reads a multi-dimensional byte array from path.ch.systemsx.cisd.base.mdarray.MDByteArrayreadByteBlockArray(String path, int[] offset, int[] size) Reads a multi-dimensional sub-block byte array from path.ch.systemsx.cisd.hdf5.HDF5CompoundDataMap[]Reads Compound array of any typech.systemsx.cisd.base.mdarray.MDIntArrayreadIntArray(String path) Reads a multi-dimensional int array from path.ch.systemsx.cisd.base.mdarray.MDIntArrayreadIntBlockArray(String path, int[] offset, int[] size) Reads a multi-dimensional sub-block int array from path.ch.systemsx.cisd.base.mdarray.MDShortArrayreadShortBlockArray(String path, int[] offset, int[] size) Reads a multi-dimensional sub-block short array from path.String[]readStringArray(String path) Reads String array array from path.voidInitializes the service on a given file path.voidsetFileForWrite(String file) Initializes the service on a given file path.voidwriteArraySlice(String path, ch.systemsx.cisd.base.mdarray.MDByteArray image, long[] offset) Writes an array as sub-slice into an existing HDF5 datasetvoidwriteArraySlice(String path, ch.systemsx.cisd.base.mdarray.MDIntArray image, long[] offset) Writes an array as sub-slice into an existing HDF5 datasetvoidwriteArraySlice(String path, ch.systemsx.cisd.base.mdarray.MDShortArray image, long[] offset) Writes an array as sub-slice into an existing HDF5 datasetMethods inherited from class loci.common.services.AbstractService
checkClassDependency
-
Field Details
-
NO_JHDF_MSG
-
currentFile
-
hdfReader
private ch.systemsx.cisd.hdf5.IHDF5Reader hdfReaderRoot of the HDF5 file. -
hdfWriter
private ch.systemsx.cisd.hdf5.IHDF5Writer hdfWriterRoot of the HDF5 file.
-
-
Constructor Details
-
JHDFServiceImpl
public JHDFServiceImpl()Default constructor.
-
-
Method Details
-
setFile
Description copied from interface:JHDFServiceInitializes the service on a given file path.- Specified by:
setFilein interfaceJHDFService- Parameters:
file- Path to initialize the service with.- Throws:
IOException- If there is an error initializing the service withfile.
-
setFileForWrite
Description copied from interface:JHDFServiceInitializes the service on a given file path.- Specified by:
setFileForWritein interfaceJHDFService- Parameters:
file- Path to initialize the service with.- Throws:
IOException- If there is an error initializing the service withfile.
-
getFile
Description copied from interface:JHDFServiceRetrieves the current initialized file path.- Specified by:
getFilein interfaceJHDFService- Returns:
- Current initialized file path or
nullif the service has yet to be initialized or is closed.
-
getMember
Description copied from interface:JHDFServiceRetrieves the all members of a group.- Specified by:
getMemberin interfaceJHDFService- Parameters:
path- HDF path to the group.- Returns:
- List
of members.
-
getShape
Description copied from interface:JHDFServiceRetrieves the shape of a dataset.- Specified by:
getShapein interfaceJHDFService- Parameters:
path- HDF path to the dataset.- Returns:
- int[] of shapes.
-
readByteArray
Description copied from interface:JHDFServiceReads a multi-dimensional byte array from path.- Specified by:
readByteArrayin interfaceJHDFService- Parameters:
path- HDF path to the dataset.- Returns:
- MDByteArray array of bytes.
-
readIntArray
Description copied from interface:JHDFServiceReads a multi-dimensional int array from path.- Specified by:
readIntArrayin interfaceJHDFService- Parameters:
path- HDF path to the dataset.- Returns:
- MDIntArray array of int.
-
readIntBlockArray
public ch.systemsx.cisd.base.mdarray.MDIntArray readIntBlockArray(String path, int[] offset, int[] size) Description copied from interface:JHDFServiceReads a multi-dimensional sub-block int array from path.- Specified by:
readIntBlockArrayin interfaceJHDFService- Parameters:
path- HDF path to the dataset.offset- Offset of the block to read.size- Output size of the array.- Returns:
- MDIntArray array of int.
-
readByteBlockArray
public ch.systemsx.cisd.base.mdarray.MDByteArray readByteBlockArray(String path, int[] offset, int[] size) Description copied from interface:JHDFServiceReads a multi-dimensional sub-block byte array from path.- Specified by:
readByteBlockArrayin interfaceJHDFService- Parameters:
path- HDF path to the dataset.offset- Offset of the block to read.size- Output size of the array.- Returns:
- MDIntArray array of int.
-
readShortBlockArray
public ch.systemsx.cisd.base.mdarray.MDShortArray readShortBlockArray(String path, int[] offset, int[] size) Description copied from interface:JHDFServiceReads a multi-dimensional sub-block short array from path.- Specified by:
readShortBlockArrayin interfaceJHDFService- Parameters:
path- HDF path to the dataset.offset- Offset of the block to read.size- Output size of the array.- Returns:
- MDIntArray array of int.
-
readStringArray
Description copied from interface:JHDFServiceReads String array array from path.- Specified by:
readStringArrayin interfaceJHDFService- Parameters:
path- HDF path to the dataset.- Returns:
- String[] array.
-
readCompoundArrayDataMap
Description copied from interface:JHDFServiceReads Compound array of any type- Specified by:
readCompoundArrayDataMapin interfaceJHDFService- Parameters:
path- HDF path to the dataset.- Returns:
- HDF5CompoundDataMap[] compound array map.
-
getElementSize
Description copied from interface:JHDFServiceRetrieves the Element Size of a dataset in Byte.- Specified by:
getElementSizein interfaceJHDFService- Parameters:
path- HDF path to the group.- Returns:
- List
of members.
-
initIntArray
Description copied from interface:JHDFServiceCreates an HDF5 dataset in path consisting of integers specified by bytes per pixel bpp.- Specified by:
initIntArrayin interfaceJHDFService- Parameters:
path- path to HDF5 a dataset.bpp- bytes per pixel for the integer data type bpp \in {1,2,4} == {Byte, Short, Integer}
-
writeArraySlice
public void writeArraySlice(String path, ch.systemsx.cisd.base.mdarray.MDByteArray image, long[] offset) Description copied from interface:JHDFServiceWrites an array as sub-slice into an existing HDF5 dataset- Specified by:
writeArraySlicein interfaceJHDFService- Parameters:
path- path to the (existing) HDF5 dataset.image- the data stored as MDArray of pixel type Byteoffset- dimensions, where to start writing the image. The image will be written from offset to offset + image.dimensions()
-
writeArraySlice
public void writeArraySlice(String path, ch.systemsx.cisd.base.mdarray.MDShortArray image, long[] offset) Description copied from interface:JHDFServiceWrites an array as sub-slice into an existing HDF5 dataset- Specified by:
writeArraySlicein interfaceJHDFService- Parameters:
path- path to the (existing) HDF5 dataset.image- the data stored as MDArray of pixel type Shortoffset- dimensions, where to start writing the image. The image will be written from offset to offset + image.dimensions()
-
writeArraySlice
public void writeArraySlice(String path, ch.systemsx.cisd.base.mdarray.MDIntArray image, long[] offset) Description copied from interface:JHDFServiceWrites an array as sub-slice into an existing HDF5 dataset- Specified by:
writeArraySlicein interfaceJHDFService- Parameters:
path- path to the (existing) HDF5 dataset.image- the data stored as MDArray of pixel type intoffset- dimensions, where to start writing the image. The image will be written from offset to offset + image.dimensions()
-
createGroup
Description copied from interface:JHDFServiceWrites an array as sub-slice into an existing HDF5 dataset- Specified by:
createGroupin interfaceJHDFService- Parameters:
path- path of the HDF5 group.- Throws:
IOException
-
exists
Description copied from interface:JHDFServiceChecks if path in HDF5 file exists.- Specified by:
existsin interfaceJHDFService- Parameters:
path- path to HDF5 group or dataset.- Returns:
- boolean true if path exists in HDF5 file else false.
-
close
Description copied from interface:JHDFServiceCloses and resets the service.- Specified by:
closein interfaceJHDFService- Throws:
IOException- If there is an error closing the file.
-