public final class FormatTools extends Object
| Modifier and Type | Field and Description |
|---|---|
static String[] |
ALL_DOMAINS
List of all supported domains.
|
static String |
ASTRONOMY_DOMAIN
Identifies the astronomy domain.
|
static int |
CAN_GROUP |
static int |
CANNOT_GROUP |
static String |
CHANNEL_NAME |
static String |
CHANNEL_NUM |
static String[] |
COMPRESSION_SUFFIXES |
static int |
DOUBLE
Identifies the DOUBLE data type used to store pixel values.
|
static String |
EM_DOMAIN
Identifies the electron microscopy domain.
|
static String |
FLIM_DOMAIN
Identifies the fluorescence-lifetime domain.
|
static int |
FLOAT
Identifies the FLOAT data type used to store pixel values.
|
static String |
GEL_DOMAIN
Identifies the gel and blot imaging domain.
|
static String |
GRAPHICS_DOMAIN
Identifies the graphics domain.
|
static String |
HCS_DOMAIN
Identifies the high content screening domain.
|
static String |
HISTOLOGY_DOMAIN
Identifies the histology domain.
|
static int |
INT16
Identifies the INT16 data type used to store pixel values.
|
static int |
INT32
Identifies the INT32 data type used to store pixel values.
|
static int |
INT8
Identifies the INT8 data type used to store pixel values.
|
static String |
LM_DOMAIN
Identifies the light microscopy domain.
|
static String |
MEDICAL_DOMAIN
Identifies the medical imaging domain.
|
static int |
MUST_GROUP
File grouping options.
|
static String[] |
NON_GRAPHICS_DOMAINS
List of non-graphics domains.
|
static String[] |
NON_HCS_DOMAINS
List of non-HCS domains.
|
static String[] |
NON_SPECIAL_DOMAINS
List of domains that do not require special handling.
|
static String |
SEM_DOMAIN
Identifies the scanning electron microscopy domain.
|
static String |
SERIES_NAME |
static String |
SERIES_NUM
Patterns to be used when constructing a pattern for output filenames.
|
static String |
SPM_DOMAIN
Identifies the scanning probe microscopy domain.
|
static String |
T_NUM |
static int |
THUMBNAIL_DIMENSION
Default height and width for thumbnails.
|
static String |
TIMESTAMP |
static int |
UINT16
Identifies the UINT16 data type used to store pixel values.
|
static int |
UINT32
Identifies the UINT32 data type used to store pixel values.
|
static int |
UINT8
Identifies the UINT8 data type used to store pixel values.
|
static String |
UNKNOWN_DOMAIN
Identifies an unknown domain.
|
static String |
Z_NUM |
| Modifier and Type | Method and Description |
|---|---|
static void |
assertId(Object id,
boolean notNull,
int depth)
Asserts that the current file is either null, or not, according to the
given flag.
|
static void |
assertStream(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> stream,
boolean notNull,
int depth)
Asserts that the current file is either null, or not, according to the
given flag.
|
static void |
calibrate(net.imagej.axis.CalibratedAxis axis,
double scale,
double origin)
Applies the given scale and origin to the provided
CalibratedAxis ,
if it is a LinearAxis. |
static void |
calibrate(net.imagej.axis.CalibratedAxis axis,
double scale,
double origin,
String unit)
As
calibrate(CalibratedAxis, double, double) but also sets the
unit of the axis. |
static void |
calibrate(Metadata m,
int imageIndex,
double[] scale)
Applies the given scale value, and an origin of 0.0, to each
LinearAxis in the provided Metadata. |
static void |
calibrate(Metadata m,
int imageIndex,
double[] scale,
double[] origin)
Applies the given scale and origin values to each
LinearAxis in the
provided Metadata. |
static void |
checkBufferSize(int imageIndex,
Metadata m,
int len)
Checks that the given buffer length is long enough to hold planes of the
specified image index, using the provided Reader.
|
static void |
checkBufferSize(Metadata m,
int len,
net.imglib2.Interval bounds,
int imageIndex)
Checks that the given buffer size is large enough to hold an image with the
given planar lengths.
|
static void |
checkPlaneForReading(Metadata m,
int imageIndex,
long planeIndex,
int bufLength,
net.imglib2.Interval bounds)
As
checkPlaneForWriting(io.scif.Metadata, int, long, int, net.imglib2.Interval) but also asserts that the Metadata has a
non-null source attached. |
static void |
checkPlaneForWriting(Metadata m,
int imageIndex,
long planeIndex,
int bufLength,
net.imglib2.Interval bounds)
Convenience method for checking that the plane number, tile size and buffer
sizes are all valid for the given Metadata.
|
static void |
checkPlaneNumber(Metadata m,
int imageIndex,
long planeIndex)
Checks that the given plane number is valid for the given reader.
|
static boolean |
checkSuffix(String name,
String suffix)
Performs suffix matching for the given filename.
|
static boolean |
checkSuffix(String name,
String[] suffixList)
Performs suffix matching for the given filename.
|
static void |
checkTileSize(Metadata m,
net.imglib2.Interval bounds,
int imageIndex)
Checks that the given tile size is valid for the given reader.
|
static void |
convert(Reader input,
Writer output,
String outputFile)
Convenience method for writing all of the images and metadata obtained from
the specified Reader into the specified Writer.
|
static void |
convert(Reader input,
Writer output,
String outputFile,
SCIFIOConfig config)
As
convert(Reader, Writer, String), with configuration options. |
static net.imagej.axis.CalibratedAxis[] |
createAxes(net.imagej.axis.AxisType... axisTypes)
Creates an array, wrapping all provided AxisTypes as CalibratedAxis with
calibration = 1.0.
|
static net.imagej.axis.CalibratedAxis |
createAxis(net.imagej.axis.AxisType axisType)
Wraps the provided AxisType in a CalibratedAxis with calibration = 1.0.
|
static long[] |
defaultMinMax(ImageMetadata iMeta)
Helper method to get the default range for the specified
ImageMetadata. |
static long[] |
defaultMinMax(int pixelType)
Get the default range for the specified pixel type.
|
static long[] |
defaultMinMax(int bitsPerPixel,
boolean signed)
Get the default range for the specified bits per pixel.
|
static long[] |
defaultMinMax(int pixelType,
int bitsPerPixel)
Helper method to delegate to
defaultMinMax(int, boolean) or
defaultMinMax(int) based on the given parameters. |
static int |
getBitsPerPixel(int pixelType)
Retrieves how many bytes per pixel the current plane or section has.
|
static int |
getBytesPerPixel(int pixelType)
Retrieves how many bytes per pixel the current plane or section has.
|
static int |
getBytesPerPixel(String pixelType)
Retrieves the number of bytes per pixel in the current plane.
|
static String |
getFilename(int imageIndex,
int image,
Reader r,
String pattern) |
static String[] |
getFilenames(String pattern,
Reader r) |
static int |
getImagesPerFile(String pattern,
Reader r) |
static long |
getNonPlanarAxisPosition(Metadata m,
int imageIndex,
long planeIndex,
net.imagej.axis.AxisType type)
Returns the position of the specified
AxisType for the given image
and plane indices. |
static String |
getPixelTypeString(int pixelType)
Takes a pixel type value and gets a corresponding string representation.
|
static long |
getPlaneSize(Metadata m,
int imageIndex)
Returns the size in bytes of a tile defined by the given Metadata.
|
static long |
getPlaneSize(Metadata m,
net.imglib2.Interval bounds,
int imageIndex)
Returns the size in bytes of a plane with the given minima and maxima.
|
static long |
getPlaneSize(Metadata m,
int width,
int height,
int imageIndex)
Returns the size in bytes of a w * h tile.
|
static long |
getPlaneSize(Reader r,
int imageIndex)
Returns the size in bytes of a single plane read by the given Reader.
|
static long |
getRasterLength(long[] lengths)
Computes the number of raster values for a positional array with the given
lengths.
|
static double |
getScale(ImageMetadata imageMeta,
net.imagej.axis.AxisType axisType)
Gets the average scale over the specified axis of the given image metadata.
|
static double |
getScale(Metadata m,
int imageIndex,
net.imagej.axis.AxisType axisType)
Gets the average scale over the specified axis of the given image metadata.
|
static boolean |
isFloatingPoint(int pixelType)
Determines whether the given pixel type is floating point or integer.
|
static boolean |
isSigned(int pixelType)
Determines whether the given pixel type is signed or unsigned.
|
static long |
nextPlaneIndex(int imageIndex,
Metadata m,
long[] pos,
long[] offsets,
long[] cropLengths)
Computes the next plane index for a given position, using the current min
and max planar values.
|
static long |
nextPlaneIndex(int imageIndex,
Reader r,
long[] pos,
long[] offsets,
long[] cropLengths)
Computes the next plane index for a given position, using the current min
and max planar values.
|
static long |
nextPlaneIndex(long[] lengths,
long[] pos,
long[] offsets,
long[] cropLengths)
Computes the next plane index for a given position, using the current min
and max planar values.
|
static int |
pixelTypeFromBytes(int bytes,
boolean signed,
boolean fp)
Returns an appropriate pixel type given the number of bytes per pixel.
|
static int |
pixelTypeFromString(String pixelTypeAsString)
Takes a string value and maps it to one of the pixel type enumerations.
|
static long |
positionToRaster(int imageIndex,
Metadata m,
long[] planeIndices)
Computes a unique 1-D index corresponding to the given multidimensional
position.
|
static long |
positionToRaster(int imageIndex,
Reader reader,
long[] planeIndices)
Computes a unique 1-D index corresponding to the given multidimensional
position.
|
static long |
positionToRaster(long[] lengths,
long[] pos)
Computes a unique 1-D index corresponding to the given multidimensional
position.
|
static long[] |
rasterToPosition(int imageIndex,
long planeIndex,
Metadata m)
Computes a unique N-D position corresponding to the given rasterized index
value.
|
static long[] |
rasterToPosition(int imageIndex,
long planeIndex,
Metadata m,
List<net.imagej.axis.CalibratedAxis> expectedAxis)
Computes a unique N-D position corresponding to the given rasterized index
value.
|
static long[] |
rasterToPosition(int imageIndex,
long planeIndex,
Reader reader)
Computes a unique N-D position corresponding to the given rasterized index
value.
|
static long[] |
rasterToPosition(long[] lengths,
long raster)
Computes a unique N-D position corresponding to the given rasterized index
value.
|
static long[] |
rasterToPosition(long[] lengths,
long raster,
long[] pos)
Computes a unique N-D position corresponding to the given rasterized index
value.
|
static boolean |
validStream(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> handle,
int len,
boolean littleEndian)
Returns true if the given DataHandle contains at least 'len' bytes.
|
static boolean |
validStream(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> handle,
int len,
org.scijava.io.handle.DataHandle.ByteOrder order)
Returns true if the given DataHandle contains at least 'len' bytes.
|
public static final String[] COMPRESSION_SUFFIXES
public static final int THUMBNAIL_DIMENSION
public static final int INT8
public static final int UINT8
public static final int INT16
public static final int UINT16
public static final int INT32
public static final int UINT32
public static final int FLOAT
public static final int DOUBLE
public static final int MUST_GROUP
public static final int CAN_GROUP
public static final int CANNOT_GROUP
public static final String SERIES_NUM
public static final String SERIES_NAME
public static final String CHANNEL_NUM
public static final String CHANNEL_NAME
public static final String Z_NUM
public static final String T_NUM
public static final String TIMESTAMP
public static final String HCS_DOMAIN
public static final String LM_DOMAIN
public static final String EM_DOMAIN
public static final String SPM_DOMAIN
public static final String SEM_DOMAIN
public static final String FLIM_DOMAIN
public static final String MEDICAL_DOMAIN
public static final String HISTOLOGY_DOMAIN
public static final String GEL_DOMAIN
public static final String ASTRONOMY_DOMAIN
public static final String GRAPHICS_DOMAIN
public static final String UNKNOWN_DOMAIN
public static final String[] NON_GRAPHICS_DOMAINS
public static final String[] NON_HCS_DOMAINS
public static final String[] NON_SPECIAL_DOMAINS
GRAPHICS_DOMAIN and HCS_DOMAIN.public static final String[] ALL_DOMAINS
public static net.imagej.axis.CalibratedAxis createAxis(net.imagej.axis.AxisType axisType)
public static net.imagej.axis.CalibratedAxis[] createAxes(net.imagej.axis.AxisType... axisTypes)
public static void calibrate(Metadata m, int imageIndex, double[] scale)
LinearAxis in the provided Metadata.public static void calibrate(Metadata m, int imageIndex, double[] scale, double[] origin)
LinearAxis in the
provided Metadata.public static void calibrate(net.imagej.axis.CalibratedAxis axis, double scale, double origin)
CalibratedAxis ,
if it is a LinearAxis.IllegalArgumentException - if the axis is not a LinearAxis.public static void calibrate(net.imagej.axis.CalibratedAxis axis, double scale, double origin, String unit)
calibrate(CalibratedAxis, double, double) but also sets the
unit of the axis.CalibratedAxis.setUnit(String)public static double getScale(Metadata m, int imageIndex, net.imagej.axis.AxisType axisType)
public static double getScale(ImageMetadata imageMeta, net.imagej.axis.AxisType axisType)
public static long getNonPlanarAxisPosition(Metadata m, int imageIndex, long planeIndex, net.imagej.axis.AxisType type)
AxisType for the given image
and plane indices.public static long[] rasterToPosition(int imageIndex,
long planeIndex,
Metadata m,
List<net.imagej.axis.CalibratedAxis> expectedAxis)
imageIndex - image index within datasetplaneIndex - rasterized plane index to convert to axis indicesexpectedAxis - determines the size and order of the positions in the
returned array.public static long[] rasterToPosition(int imageIndex,
long planeIndex,
Reader reader)
imageIndex - image index within datasetplaneIndex - rasterized plane index to convert to axis indicesreader - reader used to open the datasetpublic static long[] rasterToPosition(int imageIndex,
long planeIndex,
Metadata m)
imageIndex - image index within datasetplaneIndex - rasterized plane index to convert to axis indicesm - metadata describing the datasetpublic static long[] rasterToPosition(long[] lengths,
long raster)
lengths - the maximum value at each positional dimensionraster - rasterized index valuepublic static long[] rasterToPosition(long[] lengths,
long raster,
long[] pos)
lengths - the maximum value at each positional dimensionraster - rasterized index valuepos - preallocated position array to populate with the resultpublic static long nextPlaneIndex(int imageIndex,
Reader r,
long[] pos,
long[] offsets,
long[] cropLengths)
imageIndex - image index within datasetr - reader used to open the datasetpos - current position in each dimensionoffsets - offsets in each dimension (potentially cropped)cropLengths - effective lengths in each dimension (potentially
cropped)public static long nextPlaneIndex(int imageIndex,
Metadata m,
long[] pos,
long[] offsets,
long[] cropLengths)
imageIndex - image index within datasetm - metadata describing the datasetpos - current position in each dimensionoffsets - offsets in each dimension (potentially cropped)cropLengths - effective lengths in each dimension (potentially
cropped)public static long nextPlaneIndex(long[] lengths,
long[] pos,
long[] offsets,
long[] cropLengths)
lengths - actual dimension lengthspos - current position in each dimensionoffsets - offsets in each dimension (potentially cropped)cropLengths - effective lengths in each dimension (potentially
cropped)public static long positionToRaster(int imageIndex,
Reader reader,
long[] planeIndices)
imageIndex - image index within datasetreader - reader used to open the datasetplaneIndices - position along each dimensional axispublic static long positionToRaster(int imageIndex,
Metadata m,
long[] planeIndices)
imageIndex - image index within datasetm - metadata describing the datasetplaneIndices - position along each dimensional axispublic static long positionToRaster(long[] lengths,
long[] pos)
lengths - the maximum value for each positional dimensionpos - position along each dimensional axispublic static long getRasterLength(long[] lengths)
public static void assertId(Object id, boolean notNull, int depth)
id - File name to test.notNull - True iff id should be non-null.depth - How far back in the stack the calling method is; this name is
reported as part of the exception message, if available. Use zero
to suppress output of the calling method name.public static void assertStream(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> stream, boolean notNull, int depth)
stream - Source to test.notNull - True iff id should be non-null.depth - How far back in the stack the calling method is; this name is
reported as part of the exception message, if available. Use zero
to suppress output of the calling method name.public static void checkPlaneForReading(Metadata m, int imageIndex, long planeIndex, int bufLength, net.imglib2.Interval bounds) throws FormatException
checkPlaneForWriting(io.scif.Metadata, int, long, int, net.imglib2.Interval) but also asserts that the Metadata has a
non-null source attached. If no exception is throwin, these parameters are
suitable for reading.FormatExceptionpublic static void checkPlaneForWriting(Metadata m, int imageIndex, long planeIndex, int bufLength, net.imglib2.Interval bounds) throws FormatException
FormatExceptionpublic static void checkPlaneNumber(Metadata m, int imageIndex, long planeIndex) throws FormatException
FormatExceptionpublic static void checkTileSize(Metadata m, net.imglib2.Interval bounds, int imageIndex) throws FormatException
FormatExceptionpublic static void checkBufferSize(int imageIndex,
Metadata m,
int len)
throws FormatException
FormatExceptionpublic static void checkBufferSize(Metadata m, int len, net.imglib2.Interval bounds, int imageIndex) throws FormatException
FormatException - if the buffer is too smallpublic static boolean validStream(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> handle, int len, boolean littleEndian) throws IOException
IOExceptionpublic static boolean validStream(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> handle, int len, org.scijava.io.handle.DataHandle.ByteOrder order) throws IOException
IOExceptionpublic static long getPlaneSize(Reader r, int imageIndex)
public static long getPlaneSize(Metadata m, int imageIndex)
public static long getPlaneSize(Metadata m, int width, int height, int imageIndex)
public static long getPlaneSize(Metadata m, net.imglib2.Interval bounds, int imageIndex)
public static int pixelTypeFromString(String pixelTypeAsString)
pixelTypeAsString - the pixel type as a string.public static String getPixelTypeString(int pixelType)
pixelType - the pixel type.public static int getBytesPerPixel(int pixelType)
pixelType - the pixel type as retrieved fromImageMetadata.getPixelType()public static int getBitsPerPixel(int pixelType)
pixelType - the pixel type as retrieved from
ImageMetadata.getPixelType().ImageMetadata.getPixelType()public static int getBytesPerPixel(String pixelType)
pixelType - the pixel type, as a String.pixelTypeFromString(String),
getBytesPerPixel(int)public static boolean isFloatingPoint(int pixelType)
pixelType - the pixel type as retrieved from
ImageMetadata.getPixelType().ImageMetadata.getPixelType()public static boolean isSigned(int pixelType)
pixelType - the pixel type as retrieved from
ImageMetadata.getPixelType().ImageMetadata.getPixelType()public static int pixelTypeFromBytes(int bytes,
boolean signed,
boolean fp)
throws FormatException
bytes - number of bytes per pixel.signed - whether or not the pixel type should be signed.fp - whether or not these are floating point pixels.FormatExceptionpublic static String getFilename(int imageIndex, int image, Reader r, String pattern) throws FormatException, IOException
FormatException - Never actually thrown.IOException - Never actually thrown.public static String[] getFilenames(String pattern, Reader r) throws FormatException, IOException
FormatExceptionIOExceptionpublic static int getImagesPerFile(String pattern, Reader r) throws FormatException, IOException
FormatExceptionIOExceptionpublic static void convert(Reader input, Writer output, String outputFile) throws FormatException, IOException
input - the pre-initialized Reader used for reading data.output - the uninitialized Writer used for writing data.outputFile - the full path name of the output file to be created.FormatException - if there is a general problem reading from or
writing to one of the files.IOException - if there is an I/O-related error.public static void convert(Reader input, Writer output, String outputFile, SCIFIOConfig config) throws FormatException, IOException
convert(Reader, Writer, String), with configuration options.input - the pre-initialized Reader used for reading data.output - the uninitialized Writer used for writing data.outputFile - the full path name of the output file to be created.config - SCIFIOConfig to use for the reading and writing.FormatException - if there is a general problem reading from or
writing to one of the files.IOException - if there is an I/O-related error.public static long[] defaultMinMax(int pixelType)
pixelType - the pixel type.IllegalArgumentException - if the pixel type is floating point or
invalid.public static long[] defaultMinMax(int bitsPerPixel,
boolean signed)
IllegalArgumentException - if the bits per pixel are non-positive.public static long[] defaultMinMax(int pixelType,
int bitsPerPixel)
defaultMinMax(int, boolean) or
defaultMinMax(int) based on the given parameters. If a valid
bitsPerPixel is available, that will be preferred over pixelType.public static long[] defaultMinMax(ImageMetadata iMeta)
ImageMetadata.public static boolean checkSuffix(String name, String suffix)
Copyright © 2011–2026 SCIFIO. All rights reserved.