Documentation ¶
Overview ¶
Package dvid provides types, constants, and functions that have no other dependencies and can be used by all packages within DVID. This includes core data structures, command string handling, and command packaging. Since these elements are used at multiple DVID layers, we separate them here and allow reuse in layer-specific types through embedding.
Index ¶
- Constants
- func DecodeSerializationFormat(s SerializationFormat) (compress Compression, checksum Checksum)
- func Deserialize(s Serialization, object interface{}) (err error)
- func ElapsedTime(mode ModeFlag, startTime time.Time, p ...interface{})
- func Error(p ...interface{})
- func Fmt(mode ModeFlag, p ...interface{})
- func ImageData(img image.Image) (data []uint8, stride int32, err error)
- func ImageFromFile(filename string) (img image.Image, format string, err error)
- func ImageFromPost(r *http.Request, key string) (img image.Image, format string, err error)
- func ImageGrayFromData(data []uint8, nx, ny int) (img *image.Gray)
- func ListDataShapes() (shapes []string)
- func Log(mode ModeFlag, p ...interface{})
- func PrintNonZero(message string, value []byte)
- func Prompt(message, defaultValue string) string
- func ReadJSONFile(filename string) (value map[string]interface{}, err error)
- func SetErrorLoggingFile(out io.Writer)
- func WaitToComplete(wg *sync.WaitGroup, mode ModeFlag, startTime time.Time, p ...interface{})
- func WriteImageHttp(w http.ResponseWriter, img image.Image, formatStr string) (err error)
- func WriteJSONFile(filename string, value interface{}) error
- type BlockCoord
- type Checksum
- type Command
- type Compression
- type Config
- type DataShape
- type DataShapeString
- type Geometry
- func NewSlice(shape DataShape, offset VoxelCoord, size Point2d) (slice Geometry, err error)
- func NewSliceArb(origin, topRight, bottomLeft VoxelCoord) Geometry
- func NewSliceFromStrings(shapeStr, offsetStr, sizeStr string) (slice Geometry, err error)
- func NewSliceXY(origin VoxelCoord, size Point2d) Geometry
- func NewSliceXZ(origin VoxelCoord, size Point2d) Geometry
- func NewSliceYZ(origin VoxelCoord, size Point2d) Geometry
- type LocalID
- type ModeFlag
- type Point2d
- type Point3d
- type PointStr
- type Response
- type Serializable
- type Serialization
- type SerializationFormat
- type SliceArb
- func (s *SliceArb) BottomLeft() VoxelCoord
- func (s *SliceArb) DataShape() DataShape
- func (s *SliceArb) Depth() int32
- func (s *SliceArb) EndVoxel() VoxelCoord
- func (s *SliceArb) Height() int32
- func (s *SliceArb) NumVoxels() int64
- func (s *SliceArb) Origin() VoxelCoord
- func (s *SliceArb) Size() Point3d
- func (s *SliceArb) String() string
- func (s *SliceArb) TopRight() VoxelCoord
- func (s *SliceArb) Width() int32
- type SliceData
- type SliceXY
- type SliceXZ
- type SliceYZ
- type Subvolume
- func (s *Subvolume) BottomLeft() VoxelCoord
- func (s *Subvolume) DataShape() DataShape
- func (s *Subvolume) Depth() int32
- func (s *Subvolume) EndVoxel() VoxelCoord
- func (s *Subvolume) Height() int32
- func (s *Subvolume) NumVoxels() int64
- func (s *Subvolume) Origin() VoxelCoord
- func (s *Subvolume) Size() Point3d
- func (s *Subvolume) String() string
- func (s *Subvolume) TopRight() VoxelCoord
- func (s *Subvolume) Width() int32
- type Vector3d
- type VectorStr
- type Volume
- type VoxelCoord
- func (c VoxelCoord) Add(x VoxelCoord) (result VoxelCoord)
- func (c VoxelCoord) AddSize(s Point3d) (result VoxelCoord)
- func (c VoxelCoord) BlockCoord(blockSize Point3d) (bc BlockCoord)
- func (c VoxelCoord) BlockVoxel(blockSize Point3d) (bc VoxelCoord)
- func (c VoxelCoord) Distance(x VoxelCoord) int32
- func (c VoxelCoord) Div(x VoxelCoord) (result VoxelCoord)
- func (c VoxelCoord) Max(x VoxelCoord) (result VoxelCoord)
- func (c VoxelCoord) Min(x VoxelCoord) (result VoxelCoord)
- func (c VoxelCoord) Mod(x VoxelCoord) (result VoxelCoord)
- func (c *VoxelCoord) Prompt(message, defaultValue string)
- func (c VoxelCoord) String() string
- func (c VoxelCoord) Sub(x VoxelCoord) (result VoxelCoord)
- func (c VoxelCoord) ToBlockIndex(blockSize Point3d) (index int)
- type VoxelResolution
- type VoxelResolutionUnits
Constants ¶
const ( KeyUuid = "uuid" KeyPlane = "plane" )
Keys for setting various arguments within the command line via "key=value" strings.
const ( Kilo = 1 << 10 Mega = 1 << 20 Giga = 1 << 30 Tera = 1 << 40 )
const DefaultJPEGQuality = 80
DefaultJPEGQuality is the quality of images returned if requesting JPEG images and an explicit Quality amount is omitted.
Variables ¶
This section is empty.
Functions ¶
func DecodeSerializationFormat ¶
func DecodeSerializationFormat(s SerializationFormat) (compress Compression, checksum Checksum)
func Deserialize ¶
func Deserialize(s Serialization, object interface{}) (err error)
Deserializes a Go object using Gob encoding
func ElapsedTime ¶
ElapsedTime prints the time elapsed from the start time with Printf arguments afterwards. Example: ElapsedTime(dvid.Debug, startTime, "Time since launch of %s", funcName)
func Error ¶
func Error(p ...interface{})
Error prints a message to the Error Log File, which is useful to mark potential issues but not ones that should crash the DVID server. Basically, you should opt to crash the server if a mistake can propagate and corrupt data. If not, you can use this function. Note that Error logging to a file only occurs if DVID is running as a server, otherwise this function will print to stdout.
func Fmt ¶
func Fmt(mode ModeFlag, p ...interface{})
Fmt prints a message via fmt.Print() depending on the Mode of DVID.
func ImageData ¶
ImageData returns the underlying pixel data for an image or an error if the image doesn't have the requisite []uint8 pixel data.
func ImageFromFile ¶
ImageFromFile returns an image and its format name given a file name.
func ImageFromPost ¶
ImageFromPost returns and image and its format name given a key to a POST request. The image should be the first file in a POSTed form.
func ImageGrayFromData ¶
ImageGrayFromData returns a Gray image given data and image size.
func ListDataShapes ¶
func ListDataShapes() (shapes []string)
ListDataShapes returns a slice of shape names
func Log ¶
func Log(mode ModeFlag, p ...interface{})
Log prints a message via log.Print() depending on the Mode of DVID.
func PrintNonZero ¶
PrintNonZero prints the number of non-zero bytes in a slice of bytes.
func Prompt ¶
Prompt returns a string entered by the user after displaying message. If the user just hits ENTER (or enters an empty string), then the defaultValue is returned.
func ReadJSONFile ¶
ReadJSONFile returns a map[string]interface{} with decoded JSON from a file. If a file is not organized as a JSON object, an error will be returned.
func SetErrorLoggingFile ¶
SetErrorLoggingFile creates an error logger to the given file for this DVID process.
func WaitToComplete ¶
Wait for WaitGroup then print message including time for operation. The last arguments are fmt.Printf arguments and should not include the newline since one is added in this function.
func WriteImageHttp ¶
WriteImageHttp writes an image to a HTTP response writer using a format and optional compression strength specified in a string, e.g., "png", "jpg:80".
func WriteJSONFile ¶
WriteJSONFile writes an arbitrary but exportable Go object to a JSON file.
Types ¶
type BlockCoord ¶
type BlockCoord [3]int32
BlockCoord is the (X,Y,Z) of a Block.
func (BlockCoord) Add ¶
func (c BlockCoord) Add(x BlockCoord) (result BlockCoord)
func (BlockCoord) Max ¶
func (c BlockCoord) Max(x BlockCoord) (result BlockCoord)
BoundMin returns a block coordinate where each of its elements are not smaller than the corresponding element in x.
func (BlockCoord) Min ¶
func (c BlockCoord) Min(x BlockCoord) (result BlockCoord)
BoundMax returns a block coordinate where each of its elements are not greater than the corresponding element in x.
func (BlockCoord) String ¶
func (c BlockCoord) String() string
func (BlockCoord) Sub ¶
func (c BlockCoord) Sub(x BlockCoord) (result BlockCoord)
type Checksum ¶
type Checksum uint8
Checksum is the type of checksum employed for error checking stored data
type Command ¶
type Command []string
Command supports command-line interaction with DVID. The first item in the string slice is the command, which may be "help" or the name of DVID data name ("grayscale8"). If the first item is the name of a data type, the second item will have a type-specific command like "get". The other arguments are command arguments or optional settings of the form "<key>=<value>".
func (Command) CommandArgs ¶
CommandArgs sets a variadic argument set of string pointers to data command arguments, ignoring setting arguments of the form "<key>=<value>". If there aren't enough arguments to set a target, the target is set to the empty string. It returns an 'overflow' slice that has all arguments beyond those needed for targets.
Example: Given the command string "add param1 param2 42 data/*.png"
var s1, s2, s3, s4 string filenames := CommandArgs(0, &s1, &s2, &s3, &s4) fmt.Println(filenames) fmt.Println(s1) fmt.Println(s2, s3) fmt.Println(s4) Would print out: ["data/foo-1.png", "data/foo-2.png", "data/foo-3.png"] add param1 param2 42
func (Command) Name ¶
Name returns the first argument of the command (in lower case) which is assumed to be the name of the command.
func (Command) Parameter ¶
Parameter scans a command for any "key=value" argument and returns the value of the passed 'key'.
func (Command) TypeCommand ¶
TypeCommand returns the name of a type-specific command (in lower case).
type Compression ¶
type Compression uint8
Compression is the format of compression for storing data
const ( Uncompressed Compression = 0 Snappy = 1 << iota )
func DeserializeData ¶
func DeserializeData(s Serialization, uncompress bool) (data []byte, compress Compression, err error)
DeserializeData deserializes a slice of bytes using stored compression, checksum. If uncompress parameter is false, the data is not uncompressed.
func (Compression) String ¶
func (compress Compression) String() string
type Config ¶
type Config map[string]interface{}
Config is a map of keyword to arbitrary data to specify configurations via keyword.
type DataShape ¶
type DataShape byte
DataShape describes the way data is positioned in 3d space
const ( // XY describes a rectangle of voxels that share a z-coord. XY DataShape = iota // XZ describes a rectangle of voxels that share a y-coord. XZ // YZ describes a rectangle of voxels that share a x-coord. YZ // Arb describes a rectangle of voxels with arbitrary 3d orientation. Arb // Vol describes a Subvolume of voxels Vol )
type DataShapeString ¶
type DataShapeString string
String for specifying a slice orientation or subvolume
func (DataShapeString) DataShape ¶
func (s DataShapeString) DataShape() (shape DataShape, err error)
DataShape returns the data shape constant associated with the string.
type Geometry ¶
type Geometry interface { // DataShape describes the shape of the data. DataShape() DataShape // Origin returns the offset to the voxel at the top left corner of the data. Origin() VoxelCoord // Size returns the size as a Point3d that shows the extent in each dimension. Size() Point3d // Width is defined as size along different axis per shape: // x for Vol, XY, and XZ shapes // y for the YZ shape. Width() int32 // Height is defined as size along different axis per shape: // y for Vol, XY shapes // z for XZ, YZ Height() int32 // Depth is defined as 1 for XY, XZ, YZ, and Arb shapes. Depth returns // the size along z for Vol shapes. Depth() int32 // NumVoxels returns the number of voxels within this space. NumVoxels() int64 // EndVoxel returns the last voxel coordinate usually traversed so that // iteration from Origin->EndVoxel will visit all the voxels. EndVoxel() VoxelCoord String() string }
Geometry describes the shape, size, and position of data in the DVID volume.
func NewSlice ¶
func NewSlice(shape DataShape, offset VoxelCoord, size Point2d) (slice Geometry, err error)
NewSlice returns a Geometry object for a XY, XZ, or YZ slice given the data's orientation, offset, and size.
func NewSliceArb ¶
func NewSliceArb(origin, topRight, bottomLeft VoxelCoord) Geometry
func NewSliceFromStrings ¶
NewSliceFromStrings returns a Geometry object for a XY, XZ, or YZ slice given string representations of shape ("xy"), offset ("0,10,20"), and size ("250,250").
func NewSliceXY ¶
func NewSliceXY(origin VoxelCoord, size Point2d) Geometry
func NewSliceXZ ¶
func NewSliceXZ(origin VoxelCoord, size Point2d) Geometry
func NewSliceYZ ¶
func NewSliceYZ(origin VoxelCoord, size Point2d) Geometry
type LocalID ¶
type LocalID uint16
LocalID is a unique id for some data in a DVID instance. This unique id is presumably a much smaller representation than the actual data (e.g., a version UUID or dataset description) and can be represented with fewer bytes in keys.
func GetLocalID ¶
GetLocalID parses a slice of bytes into a LocalID.
type ModeFlag ¶
type ModeFlag uint
var Mode ModeFlag
Mode is a global variable set to the run modes of this DVID process.
type PointStr ¶
type PointStr string
PointStr is a n-dimensional coordinate in string format "x,y,z,..." where each coordinate is a 32-bit integer.
func (PointStr) VoxelCoord ¶
func (s PointStr) VoxelCoord() (coord VoxelCoord, err error)
type Response ¶
Response provides a few string fields to pass information back from a remote operation.
type Serializable ¶
type Serializable interface { Serialize() (Serialization, error) Deserialize(Serialization) error }
Serializable can be serialized to and deserialized from bytes.
type Serialization ¶
type Serialization []byte
Serialization should be a slice of bytes.
func Serialize ¶
func Serialize(object interface{}, compress Compression, checksum Checksum) (s Serialization, err error)
Serializes an arbitrary Go object using Gob encoding and optional compression, checksum
func SerializeData ¶
func SerializeData(data []byte, compress Compression, checksum Checksum) (s Serialization, err error)
Serialize a slice of bytes using optional compression, checksum
type SerializationFormat ¶
type SerializationFormat uint8
SerializationFormat is a single byte combining both compression and checksum methods.
func EncodeSerializationFormat ¶
func EncodeSerializationFormat(compress Compression, checksum Checksum) SerializationFormat
type SliceArb ¶
type SliceArb struct {
// contains filtered or unexported fields
}
SliceArb is an arbitray slice in 3d space.
func (*SliceArb) BottomLeft ¶
func (s *SliceArb) BottomLeft() VoxelCoord
func (*SliceArb) EndVoxel ¶
func (s *SliceArb) EndVoxel() VoxelCoord
func (*SliceArb) Origin ¶
func (s *SliceArb) Origin() VoxelCoord
func (*SliceArb) TopRight ¶
func (s *SliceArb) TopRight() VoxelCoord
type SliceData ¶
type SliceData struct {
// contains filtered or unexported fields
}
SliceData specifies a rectangle in 3d space that is orthogonal to an axis.
func (*SliceData) EndVoxel ¶
func (s *SliceData) EndVoxel() VoxelCoord
func (*SliceData) Origin ¶
func (s *SliceData) Origin() VoxelCoord
type SliceXY ¶
type SliceXY struct {
SliceData
}
SliceXY is a slice in the XY plane.
func (*SliceXY) BottomLeft ¶
func (s *SliceXY) BottomLeft() VoxelCoord
func (*SliceXY) TopRight ¶
func (s *SliceXY) TopRight() VoxelCoord
type SliceXZ ¶
type SliceXZ struct {
SliceData
}
SliceXZ is a slice in the XZ plane.
func (*SliceXZ) BottomLeft ¶
func (s *SliceXZ) BottomLeft() VoxelCoord
func (*SliceXZ) TopRight ¶
func (s *SliceXZ) TopRight() VoxelCoord
type SliceYZ ¶
type SliceYZ struct {
SliceData
}
SliceYZ is a slice in the YZ plane.
func (*SliceYZ) BottomLeft ¶
func (s *SliceYZ) BottomLeft() VoxelCoord
func (*SliceYZ) TopRight ¶
func (s *SliceYZ) TopRight() VoxelCoord
type Subvolume ¶
type Subvolume struct {
// contains filtered or unexported fields
}
Subvolume describes the Geometry for a rectangular box of voxels. The "Sub" prefix emphasizes that the data is usually a smaller portion of the volume held by the DVID datastore. Note that the 3d coordinate system is a Right-Hand system and works with OpenGL. The origin is considered the top left corner of an XY slice. X increases as you move from left to right. Y increases as you move down from the origin. Z increases as you add more slices deeper than the current slice.
func NewSubvolume ¶
func NewSubvolume(origin VoxelCoord, size Point3d) *Subvolume
NewSubvolume returns a Subvolume given a subvolume's origin and size.
func NewSubvolumeFromStrings ¶
NewSubvolumeFromStrings returns a Subvolume given string representations of origin ("0,10,20") and size ("250,250,250").
func (*Subvolume) BottomLeft ¶
func (s *Subvolume) BottomLeft() VoxelCoord
func (*Subvolume) EndVoxel ¶
func (s *Subvolume) EndVoxel() VoxelCoord
func (*Subvolume) Origin ¶
func (s *Subvolume) Origin() VoxelCoord
func (*Subvolume) TopRight ¶
func (s *Subvolume) TopRight() VoxelCoord
type VectorStr ¶
type VectorStr string
VectorStr is a n-dimensional coordinate in string format "x,y,z,...."" where each coordinate is a 32-bit float.
type Volume ¶
type Volume struct { // Volume extents VolumeMax VoxelCoord // Relative resolution of voxels in volume VoxelRes VoxelResolution // Units of resolution, e.g., "nanometers" VoxelResUnits VoxelResolutionUnits }
Volume defines the extent and resolution of a volume.
type VoxelCoord ¶
type VoxelCoord [3]int32
VoxelCoord is the (X,Y,Z) of a Voxel.
func (VoxelCoord) Add ¶
func (c VoxelCoord) Add(x VoxelCoord) (result VoxelCoord)
func (VoxelCoord) AddSize ¶
func (c VoxelCoord) AddSize(s Point3d) (result VoxelCoord)
AddSize returns a voxel coordinate that is moved by the s vector minus one. If s is the size of a box, this has the effect of returning the maximum voxel coordinate still within the box.
func (VoxelCoord) BlockCoord ¶
func (c VoxelCoord) BlockCoord(blockSize Point3d) (bc BlockCoord)
BlockCoord returns the coordinate of the block containing the voxel coordinate.
func (VoxelCoord) BlockVoxel ¶
func (c VoxelCoord) BlockVoxel(blockSize Point3d) (bc VoxelCoord)
BlockVoxel returns the voxel coordinate within a containing block for the given voxel coordinate.
func (VoxelCoord) Distance ¶
func (c VoxelCoord) Distance(x VoxelCoord) int32
Distance returns the integer distance (rounding down) between two voxel coordinates.
func (VoxelCoord) Div ¶
func (c VoxelCoord) Div(x VoxelCoord) (result VoxelCoord)
func (VoxelCoord) Max ¶
func (c VoxelCoord) Max(x VoxelCoord) (result VoxelCoord)
BoundMin returns a voxel coordinate where each of its elements are not smaller than the corresponding element in x.
func (VoxelCoord) Min ¶
func (c VoxelCoord) Min(x VoxelCoord) (result VoxelCoord)
BoundMax returns a voxel coordinate where each of its elements are not greater than the corresponding element in x.
func (VoxelCoord) Mod ¶
func (c VoxelCoord) Mod(x VoxelCoord) (result VoxelCoord)
func (*VoxelCoord) Prompt ¶
func (c *VoxelCoord) Prompt(message, defaultValue string)
Prompt asks the user to enter components of a voxel coordinate with empty entries returning the numerical equivalent of defaultValue.
func (VoxelCoord) String ¶
func (c VoxelCoord) String() string
func (VoxelCoord) Sub ¶
func (c VoxelCoord) Sub(x VoxelCoord) (result VoxelCoord)
func (VoxelCoord) ToBlockIndex ¶
func (c VoxelCoord) ToBlockIndex(blockSize Point3d) (index int)
ToBlockIndex returns an index into a block's data that corresponds to a given voxel coordinate. Note that the index is NOT multiplied by BytesPerVoxel but gives the element number, since we also want to set dirty flags.
type VoxelResolution ¶
type VoxelResolution [3]float32
VoxelResolution holds the relative resolutions along each dimension. Since voxel resolutions should be fixed for the lifetime of a datastore, we assume there is one base unit of resolution (e.g., nanometers) and all resolutions are based on that.
func (*VoxelResolution) Prompt ¶
func (res *VoxelResolution) Prompt(message, defaultValue string)
Prompt asks the user to enter components of a voxel's resolution with empty entries returning the numerical equivalent of defaultValue.
type VoxelResolutionUnits ¶
type VoxelResolutionUnits string
The description of the units of voxel resolution, e.g., "nanometer".