nii_io

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidDatatype

func IsValidDatatype(datatype int32) bool

IsValidDatatype checks whether the datatype is valid for NIFTI format

func NewNiiWriter

func NewNiiWriter(filePath string, options ...func(*niiWriter)) (*niiWriter, error)

NewNiiWriter returns a new write for export

func WithCompression

func WithCompression(withCompression bool) func(writer *niiWriter)

WithCompression sets the option to write compressed NIfTI image to a single file (.nii.gz)

If true, the whole file will be compressed. Default is false.

func WithHeader

func WithHeader(header *Nii1Header) func(*niiWriter)

WithHeader sets the option to allow user to provide predefined NIfTI-1 header structure.

If no header provided, the header will be converted from the NIfTI image structure

func WithHeaderCompression

func WithHeaderCompression(headerCompression bool) func(*niiWriter)

WithHeaderCompression sets the option to write compressed NIfTI header structure to file (.hdr.gz)

If true, the header will be compressed. It only works when WithWriteHeaderFile is provided with option `true`. Default is false.

func WithHeaderFile

func WithHeaderFile(headerFile string) func(*niiReader) error

WithHeaderFile allows option to specify the separate header file

func WithInMemory

func WithInMemory(inMemory bool) func(*niiReader) error

WithInMemory allows option to read the whole file into memory

func WithNIfTIData

func WithNIfTIData(data *Nii) func(writer *niiWriter)

WithNIfTIData sets the option to allow user to provide predefined NIfTI-1 data structure.

func WithRetainHeader

func WithRetainHeader(retainHeader bool) func(*niiReader) error

WithRetainHeader allows option to keep the header after parsing instead of just keeping the NIfTI data structure

func WithWriteHeaderFile

func WithWriteHeaderFile(writeHeaderFile bool) func(*niiWriter)

WithWriteHeaderFile sets the option to write NIfTI image to a header/image (.hdr/.img) file pair

If true, output will be two files for the header and the image. Default is false.

Types

type NiiReader

type NiiReader interface {
	// Parse returns the input NIFTI as header and image data
	Parse() error
	// GetOrientation returns the image orientation
	GetOrientation() [3]string
	// GetSliceCode returns the slice code
	GetSliceCode() string
	// GetDatatype returns the datatype of the NIFTI image
	GetDatatype() string
	// GetSFormCode returns the SForm code string
	GetSFormCode() string
	// GetQFormCode returns the QForm code string
	GetQFormCode() string
	// GetImgShape returns the image shape [x, y, z, t]
	GetImgShape() [4]int64
	// GetAt returns the value at [x, y, z, t] as float64
	GetAt(x, y, z, t int64) float64
	// GetBinaryOrder returns the binary order of the NIFTI image
	GetBinaryOrder() binary.ByteOrder
	// GetUnitsOfMeasurements returns the spatial and temporal units of the NIFTI image
	GetUnitsOfMeasurements() ([2]string, error)
	// GetTimeSeries returns the time series of value at [x, y, z]
	GetTimeSeries(x, y, z int64) ([]float64, error)
	// GetSlice returns the X-Y slice at [z, t]
	GetSlice(z, t int64) ([][]float64, error)
	// GetVolume returns the image data as 3-D matrix
	GetVolume(t int64) ([][][]float64, error)
	// GetAffine returns the affine matrix of the NIFTI image
	GetAffine() matrix.DMat44
	// QuaternToMatrix converts the quarternions parameters to matrix
	QuaternToMatrix() matrix.DMat44
	// GetNiiData returns the raw NIFTI header and image data
	GetNiiData() *Nii
}

func NewNiiReader

func NewNiiReader(filePath string, options ...func(*niiReader) error) (NiiReader, error)

NewNiiReader receives a path to the NIFTI file and returns a new reader to parse the file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL