nifti

package module
v0.0.0-...-dbd70bb Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: MIT Imports: 9 Imported by: 1

README

NIFTI

A simple NIFTI io lib write in pure Golang. Only provide the most basic read/write functions. See examples for the usage.

Forked from henghuang/nifti to handle large files

INSTALLATION

go get github.com/KyungWonPark/nifti

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Nifti1Header

type Nifti1Header struct {
	SizeofHdr    int32    /*!< MUST be 348           */ /* int32 sizeof_hdr;      */
	DataType     [10]byte /*!< ++UNUSED++            */ /* char data_type[10];  */
	DbName       [18]byte /*!< ++UNUSED++            */ /* char db_name[18];    */
	Extents      int32    /*!< ++UNUSED++            */ /* int32 extents;         */
	SessionError int16    /*!< ++UNUSED++            */ /* short session_error; */
	Regular      byte     /*!< ++UNUSED++            */ /* char regular;        */
	DimInfo      byte     /*!< MRI slice ordering.   */ /* char hkey_un0;       */

	/*--- was image_dimension substruct ---*/
	Dim      [8]int16 /*!< Data array dimensions.*/ /* short dim[8];        */
	IntentP1 float32  /*!< 1st intent parameter. */ /* short unused8;       */
	/* short unused9;       */
	IntentP2 float32 /*!< 2nd intent parameter. */ /* short unused10;      */
	/* short unused11;      */
	IntentP3 float32 /*!< 3rd intent parameter. */ /* short unused12;      */
	/* short unused13;      */
	IntentCode    int16      /*!< NIFTI_INTENT_* code.  */ /* short unused14;      */
	Datatype      int16      /*!< Defines data type!    */ /* short datatype;      */
	Bitpix        int16      /*!< Number bits/voxel.    */ /* short bitpix;        */
	SliceStart    int16      /*!< First slice index.    */ /* short dim_un0;       */
	Pixdim        [8]float32 /*!< Grid spacings.        */ /* float32 pixdim[8];     */
	VoxOffset     float32    /*!< Offset into .nii file */ /* float32 vox_offset;    */
	SclSlope      float32    /*!< Data scaling: slope.  */ /* float32 funused1;      */
	SclInter      float32    /*!< Data scaling: offset. */ /* float32 funused2;      */
	SliceEnd      int16      /*!< Last slice index.     */ /* float32 funused3;      */
	SliceCode     byte       /*!< Slice timing order.   */
	XyztUnits     byte       /*!< Units of pixdim[1..4] */
	CalMax        float32    /*!< Max display intensity */ /* float32 cal_max;       */
	CalMin        float32    /*!< Min display intensity */ /* float32 cal_min;       */
	SliceDuration float32    /*!< Time for 1 slice.     */ /* float32 compressed;    */
	Toffset       float32    /*!< Time axis shift.      */ /* float32 verified;      */
	Glmax         int32      /*!< ++UNUSED++            */ /* int32 glmax;           */
	Glmin         int32      /*!< ++UNUSED++            */ /* int32 glmin;           */

	/*--- was data_history substruct ---*/
	Descrip [80]byte /*!< any text you like.    */ /* char descrip[80];    */
	AuxFile [24]byte /*!< auxiliary filename.   */ /* char aux_file[24];   */

	QformCode int16 /*!< NIFTI_XFORM_* code.   */ /*-- all ANALYZE 7.5 ---*/
	SformCode int16 /*!< NIFTI_XFORM_* code.   */ /*   fields below here  */
	/*   are replaced       */
	QuaternB float32 /*!< Quaternion b param.   */
	QuaternC float32 /*!< Quaternion c param.   */
	QuaternD float32 /*!< Quaternion d param.   */
	QoffsetX float32 /*!< Quaternion x shift.   */
	QoffsetY float32 /*!< Quaternion y shift.   */
	QoffsetZ float32 /*!< Quaternion z shift.   */

	SrowX [4]float32 /*!< 1st row affine transform.   */
	SrowY [4]float32 /*!< 2nd row affine transform.   */
	SrowZ [4]float32 /*!< 3rd row affine transform.   */

	IntentName [16]byte /*!< 'name' or meaning of data.  */

	Magic [4]byte /*!< MUST be "ni1\0" or "n+1\0". */


} /**** 348 bytes total ****/

func (*Nifti1Header) LoadHeader

func (header *Nifti1Header) LoadHeader(filepath string)

type Nifti1Image

type Nifti1Image struct {
	// contains filtered or unexported fields
}

func NewImg

func NewImg(dimX, dimY, dimZ, dimT int) *Nifti1Image

create new image

func (*Nifti1Image) GetAt

func (img *Nifti1Image) GetAt(x, y, z, t uint32) float32

x,y,z,t,start at zero

func (*Nifti1Image) GetDims

func (img *Nifti1Image) GetDims() [4]int

Return [x,y,z,t]

func (*Nifti1Image) GetHeader

func (img *Nifti1Image) GetHeader() Nifti1Header

func (*Nifti1Image) GetSlice

func (img *Nifti1Image) GetSlice(z, t uint32) [][]float32

func (*Nifti1Image) GetTimeSeries

func (img *Nifti1Image) GetTimeSeries(x, y, z uint32) []float32

func (*Nifti1Image) LoadImage

func (img *Nifti1Image) LoadImage(filepath string, rdata bool)

filepath ,read data? header.VoxOffset, header.Bitpix,header.Dim are very important

func (*Nifti1Image) Save

func (img *Nifti1Image) Save(filename string)

write nii

func (*Nifti1Image) SetAt

func (img *Nifti1Image) SetAt(x, y, z, t uint32, elem float32)

func (*Nifti1Image) SetHeaderDim

func (img *Nifti1Image) SetHeaderDim(dimX, dimY, dimZ, dimT int)

func (*Nifti1Image) SetHeaderDim2

func (img *Nifti1Image) SetHeaderDim2(dimX, dimY, dimZ, dimT int)

func (*Nifti1Image) SetNewHeader

func (img *Nifti1Image) SetNewHeader(newHeader Nifti1Header)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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