Documentation ¶
Index ¶
- func NewNiiReader(options ...func(*nifti.NiiReader) error) (nifti.Reader, error)
- func NewNiiWriter(filePath string, options ...func(*nifti.NiiWriter)) (nifti.Writer, error)
- func WithReadHeaderFile(headerFile string) func(*nifti.NiiReader) error
- func WithReadHeaderReader(r *bytes.Reader) func(*nifti.NiiReader) error
- func WithReadImageFile(niiFile string) func(*nifti.NiiReader) error
- func WithReadImageReader(r *bytes.Reader) func(*nifti.NiiReader) error
- func WithReadInMemory(inMemory bool) func(*nifti.NiiReader) error
- func WithReadRetainHeader(retainHeader bool) func(*nifti.NiiReader) error
- func WithWriteCompression(withCompression bool) func(writer *nifti.NiiWriter)
- func WithWriteHeaderFile(writeHeaderFile bool) func(*nifti.NiiWriter)
- func WithWriteNIfTIData(data *nifti.Nii) func(writer *nifti.NiiWriter)
- func WithWriteNii1Header(header *nifti.Nii1Header) func(*nifti.NiiWriter)
- func WithWriteNii2Header(header *nifti.Nii2Header) func(*nifti.NiiWriter)
- func WithWriteVersion(version int) func(writer *nifti.NiiWriter)
- type SegmentCoordinate
- type Segmentation
- type SegmentationOption
- func WithAnnotations(annotations []SegmentCoordinate) SegmentationOption
- func WithImage(image *nifti.Nii) SegmentationOption
- func WithNii1Hdr(hdr *nifti.Nii1Header) SegmentationOption
- func WithNii2Hdr(hdr *nifti.Nii2Header) SegmentationOption
- func WithOutFile(outFile string) SegmentationOption
- func WithSegCompression(compression bool) SegmentationOption
- func WithSegmentRLE(segments []nifti.SegmentRLE) SegmentationOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNiiReader ¶
NewNiiReader returns a new NIfTI reader
Options:
- `WithReadInMemory(inMemory bool)` : Read the whole file into memory
- `WithReadRetainHeader(retainHeader bool)` : Whether to retain the header structure after parsing
- `WithReadHeaderFile(headerFile string)` : Specify a header file path in case of separate .hdr/.img file
- `WithReadImageFile(niiFile string)` : Specify an image file path
- `WithReadImageReader(r *bytes.Reader)` : Specify a header file reader in case of separate .hdr/.img file
- `WithReadHeaderReader(r *bytes.Reader)` : Specify an image file reader
func NewNiiWriter ¶
NewNiiWriter returns a new NIfTI writer. If no version is specified, the writer will default to write to NIfTI version 1
func WithReadHeaderFile ¶ added in v0.2.0
WithReadHeaderFile allows option to specify the separate header file in case of NIfTI pair .hdr/.img
func WithReadHeaderReader ¶ added in v0.2.0
WithReadHeaderReader allows option for users to specify the separate header file reader in case of NIfTI pair .hdr/.img
func WithReadImageFile ¶ added in v0.2.0
WithReadImageFile allows option to specify the NIfTI file (.nii.gz or .nii)
func WithReadImageReader ¶ added in v0.2.0
WithReadImageReader allows option for users to specify the NIfTI bytes reader (.nii.gz or .nii)
func WithReadInMemory ¶ added in v0.2.0
WithReadInMemory allows option to read the whole file into memory. The default is true. This is for future implementation. Currently, all file is read into memory before parsing
func WithReadRetainHeader ¶ added in v0.2.0
WithReadRetainHeader allows option to keep the header after parsing instead of just keeping the NIfTI data structure
func WithWriteCompression ¶ added in v0.2.0
WithWriteCompression 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 WithWriteHeaderFile ¶
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.
func WithWriteNIfTIData ¶ added in v0.2.0
WithWriteNIfTIData sets the option to allow user to provide predefined NIfTI-1 data structure.
func WithWriteNii1Header ¶ added in v0.2.0
func WithWriteNii1Header(header *nifti.Nii1Header) func(*nifti.NiiWriter)
WithWriteNii1Header 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 WithWriteNii2Header ¶ added in v0.2.0
func WithWriteNii2Header(header *nifti.Nii2Header) func(*nifti.NiiWriter)
WithWriteNii2Header sets the option to allow user to provide predefined NIfTI-2 header structure.
If no header provided, the header will be converted from the NIfTI image structure
func WithWriteVersion ¶ added in v0.2.0
WithWriteVersion sets the option to specify the exported NIfTI version (NIfTI-1 or 2). Default is NIfTI-1
Types ¶
type SegmentCoordinate ¶ added in v0.2.0
type SegmentCoordinate struct { Value any `json:"value"` X int64 `json:"x"` Y int64 `json:"y"` Z int64 `json:"z"` T int64 `json:"t"` }
SegmentCoordinate defines the structure for segmentation coordinate
type Segmentation ¶ added in v0.2.0
type Segmentation struct {
// contains filtered or unexported fields
}
func NewSegmentation ¶ added in v0.2.0
func NewSegmentation(opts ...SegmentationOption) *Segmentation
func (*Segmentation) AnnotationJsonToNii ¶ added in v0.2.0
func (s *Segmentation) AnnotationJsonToNii() error
AnnotationJsonToNii converts the annotation coordinates (x,y,z,t) array to a corresponding NIfTI file
func (*Segmentation) AnnotationNiiToJson ¶ added in v0.2.0
func (s *Segmentation) AnnotationNiiToJson() error
AnnotationNiiToJson converts the NIfTI file to a corresponding annotation coordinates (x,y,z,t) array
type SegmentationOption ¶ added in v0.2.0
type SegmentationOption func(s *Segmentation)
func WithAnnotations ¶ added in v0.2.0
func WithAnnotations(annotations []SegmentCoordinate) SegmentationOption
WithAnnotations allows users to specify the annotation coordinates to convert to NIfTI file
func WithImage ¶ added in v0.2.0
func WithImage(image *nifti.Nii) SegmentationOption
WithImage allows users to specify the NIfTI image structure to convert to (x,y,z,t) coordinate array
func WithNii1Hdr ¶ added in v0.2.0
func WithNii1Hdr(hdr *nifti.Nii1Header) SegmentationOption
WithNii1Hdr allows users to specify NIfTI-1 header to write the annotation file to
If both NIfTI-1 and NIfTI-2 header are specified. NIfTI-2 header takes precedence
func WithNii2Hdr ¶ added in v0.2.0
func WithNii2Hdr(hdr *nifti.Nii2Header) SegmentationOption
WithNii2Hdr allows users to specify NIfTI-1 header to write the annotation file to
If both NIfTI-1 and NIfTI-2 header are specified. NIfTI-2 header takes precedence
func WithOutFile ¶ added in v0.2.0
func WithOutFile(outFile string) SegmentationOption
WithOutFile allows user to specify the location to write the segmentation data to file
func WithSegCompression ¶ added in v0.2.0
func WithSegCompression(compression bool) SegmentationOption
WithSegCompression allows user to write the segmentation as compressed NIfTI file
func WithSegmentRLE ¶ added in v0.4.0
func WithSegmentRLE(segments []nifti.SegmentRLE) SegmentationOption
WithSegmentRLE allows users to specify the annotation as RLE-encoded array to convert to NIfTI file