From 6bb388f11260dd49f8224b0997e3ff69decc572a Mon Sep 17 00:00:00 2001 From: tripg Date: Sat, 5 Nov 2022 13:27:06 +0700 Subject: [PATCH] interface for both nifti1 and nifti2 2 --- nifti_test.go | 4 ++-- pkg/nifti/reader/nifti.go | 2 +- pkg/nifti/reader/reader.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nifti_test.go b/nifti_test.go index 2e7f96b1..9e1f4d54 100644 --- a/nifti_test.go +++ b/nifti_test.go @@ -2,8 +2,8 @@ package go2com import ( "fmt" - "github.com/okieraised/go2com/pkg/nifti/nifti1" "github.com/okieraised/go2com/pkg/nifti/nifti2" + "github.com/okieraised/go2com/pkg/nifti/reader" "github.com/stretchr/testify/assert" _ "image/jpeg" "testing" @@ -35,7 +35,7 @@ func TestNii1(t *testing.T) { //filePath = "/home/tripg/Documents/nifti/JHU_MNI_SS_T1.nii.gz" //filePath = "/home/tripg/Documents/nifti/avg152T1_LR_nifti2.nii.gz" - niiReader, err := nifti1.NewNii1Reader(filePath) + niiReader, err := reader.NewNiiReader(filePath) assert.NoError(err) err = niiReader.Parse() assert.NoError(err) diff --git a/pkg/nifti/reader/nifti.go b/pkg/nifti/reader/nifti.go index 4a1116ec..6fa07b88 100644 --- a/pkg/nifti/reader/nifti.go +++ b/pkg/nifti/reader/nifti.go @@ -370,7 +370,7 @@ func (n *Nii) getAffine() matrix.DMat44 { func (n *Nii) getImgShape() [4]int64 { dim := [4]int64{} - for index, _ := range n.Data.Dim { + for index, _ := range dim { dim[index] = n.Data.Dim[index+1] } return dim diff --git a/pkg/nifti/reader/reader.go b/pkg/nifti/reader/reader.go index cdfd5cc0..3331306f 100644 --- a/pkg/nifti/reader/reader.go +++ b/pkg/nifti/reader/reader.go @@ -112,7 +112,7 @@ func (r *niiReader) checkNiiVersion() error { return errors.New("invalid NIFTI file format") } } - return errors.New("cannot determine NIFTI file version") + return nil } func (r *niiReader) MatrixToOrientation(R matrix.DMat44) {