-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for NIfTI and refactored DICOM reader (#29)
Co-authored-by: phuctt <[email protected]>
- Loading branch information
1 parent
060f629
commit ce17fc3
Showing
65 changed files
with
2,565 additions
and
2,032 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,4 @@ | |
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
test_data | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
package go2com | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"github.com/okieraised/go2com/internal/utils" | ||
"github.com/okieraised/go2com/pkg/dicom/dcm_io" | ||
"github.com/stretchr/testify/assert" | ||
_ "image/jpeg" | ||
"os" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func Test_ReaderProfiling(t *testing.T) { | ||
assert := assert.New(t) | ||
f, err := os.Open("./test_data/01.dcm") | ||
assert.NoError(err) | ||
|
||
fInfo, err := f.Stat() | ||
assert.NoError(err) | ||
|
||
fn := func() { | ||
dcmReader := dcm_io.NewDICOMReader(bufio.NewReader(f), dcm_io.WithSkipPixelData(false), dcm_io.WithSkipDataset(false), dcm_io.WithSetFileSize(fInfo.Size())) | ||
err = dcmReader.Parse() | ||
assert.NoError(err) | ||
} | ||
|
||
err = utils.CPUProfilingFunc(fn, "./cpu1.pprof") | ||
assert.NoError(err) | ||
} | ||
|
||
func Test_NewParser1(t *testing.T) { | ||
assert := assert.New(t) | ||
filePaths, err := utils.ReadDirRecursively("/home/tripg/workspace/dicom/test_data") | ||
assert.NoError(err) | ||
for _, fPath := range filePaths { | ||
fmt.Println("process:", fPath) | ||
|
||
f, err := os.Open(fPath) | ||
assert.NoError(err) | ||
|
||
fInfo, err := f.Stat() | ||
assert.NoError(err) | ||
|
||
dcmReader := dcm_io.NewDICOMReader(bufio.NewReader(f), dcm_io.WithSetFileSize(fInfo.Size())) | ||
|
||
err = dcmReader.Parse() | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
assert.NoError(err) | ||
} | ||
} | ||
|
||
func Test_NewParser2(t *testing.T) { | ||
assert := assert.New(t) | ||
filePaths, err := utils.ReadDirRecursively("/home/tripg/workspace/dicom/test_full") | ||
assert.NoError(err) | ||
for _, fPath := range filePaths { | ||
fmt.Println("process:", fPath) | ||
f, err := os.Open(fPath) | ||
assert.NoError(err) | ||
|
||
fInfo, err := f.Stat() | ||
assert.NoError(err) | ||
|
||
dcmReader := dcm_io.NewDICOMReader(bufio.NewReader(f), dcm_io.WithSetFileSize(fInfo.Size())) | ||
|
||
err = dcmReader.Parse() | ||
if err != nil { | ||
if strings.Contains(err.Error(), "not in valid dicom format") { | ||
continue | ||
} | ||
} | ||
assert.NoError(err) | ||
} | ||
} | ||
|
||
func Test_NewParser3(t *testing.T) { | ||
assert := assert.New(t) | ||
filePaths, err := utils.ReadDirRecursively("/home/tripg/workspace/dicom/mammo_dicoms") | ||
assert.NoError(err) | ||
for _, fPath := range filePaths { | ||
fmt.Println("process:", fPath) | ||
|
||
f, err := os.Open(fPath) | ||
assert.NoError(err) | ||
|
||
fInfo, err := f.Stat() | ||
assert.NoError(err) | ||
|
||
dcmReader := dcm_io.NewDICOMReader(bufio.NewReader(f), dcm_io.WithSetFileSize(fInfo.Size())) | ||
|
||
err = dcmReader.Parse() | ||
assert.NoError(err) | ||
|
||
_ = dcmReader.ExportDatasetTags(false) | ||
} | ||
} | ||
|
||
func Test_NewParser4(t *testing.T) { | ||
assert := assert.New(t) | ||
fPath := "/home/tripg/workspace/dicom/mammo_dicoms/1.2.840.113619.2.255.10452022879169.3670200508103440.2701.dicom" | ||
f, err := os.Open(fPath) | ||
assert.NoError(err) | ||
|
||
fInfo, err := f.Stat() | ||
assert.NoError(err) | ||
|
||
parser := dcm_io.NewDICOMReader(bufio.NewReader(f), dcm_io.WithSkipPixelData(true), dcm_io.WithSkipDataset(true), dcm_io.WithSetFileSize(fInfo.Size())) | ||
err = parser.Parse() | ||
assert.NoError(err) | ||
|
||
for _, elem := range parser.GetDataset().Elements { | ||
fmt.Println(elem) | ||
} | ||
} | ||
|
||
func Test_NewParser5(t *testing.T) { | ||
assert := assert.New(t) | ||
fPath := "/home/tripg/workspace/10142022/ALI_Technologies/UltraPACS/studies/w0019837/view0001" | ||
f, err := os.Open(fPath) | ||
assert.NoError(err) | ||
|
||
fInfo, err := f.Stat() | ||
assert.NoError(err) | ||
|
||
parser := dcm_io.NewDICOMReader(bufio.NewReader(f), dcm_io.WithSkipPixelData(false), dcm_io.WithSkipDataset(false), dcm_io.WithSetFileSize(fInfo.Size())) | ||
err = parser.Parse() | ||
assert.NoError(err) | ||
|
||
} | ||
|
||
func Test_NewParser6(t *testing.T) { | ||
assert := assert.New(t) | ||
f, err := os.Open("/home/tripg/workspace/10142022/ALI_Technologies/UltraPACS/studies/w0055053/view0013") | ||
//f, err = os.Open("/home/tripg/workspace/10142022/Acuson/Sequoia/EXAMS/EXAM0000/CLIPS/CLIP0031") | ||
f, err = os.Open("/home/tripg/workspace/10142022/Hamamatsu/Dog_15x15_20x.dcm") | ||
//f, err = os.Open("/home/tripg/workspace/dicom2/PrivateGEImplicitVRBigEndianTransferSyntax16Bits.dcm") | ||
assert.NoError(err) | ||
|
||
fInfo, err := f.Stat() | ||
assert.NoError(err) | ||
|
||
parser := dcm_io.NewDICOMReader(bufio.NewReader(f), dcm_io.WithSkipPixelData(false), dcm_io.WithSkipDataset(false), dcm_io.WithSetFileSize(fInfo.Size())) | ||
err = parser.Parse() | ||
assert.NoError(err) | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/okieraised/go2com" | ||
"log" | ||
"os" | ||
) | ||
|
||
func main() { | ||
go2com.InitTagDict() | ||
file, err := os.Open("./test_data/01.dcm") | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
defer file.Close() | ||
info, err := file.Stat() | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
fileSize := info.Size() | ||
|
||
parser, err := go2com.NewParser(file, fileSize, true, false) | ||
if err != nil { | ||
log.Fatal(err) | ||
return | ||
} | ||
err = parser.Parse() | ||
if err != nil { | ||
log.Fatal(err) | ||
return | ||
} | ||
for _, elem := range parser.GetDataset().Elements { | ||
fmt.Println(elem) | ||
} | ||
//go2com.InitTagDict() | ||
//file, err := os.Open("./test_data/01.dcm") | ||
//if err != nil { | ||
// fmt.Println(err) | ||
// return | ||
//} | ||
//defer file.Close() | ||
//info, err := file.Stat() | ||
//if err != nil { | ||
// fmt.Println(err) | ||
// return | ||
//} | ||
//fileSize := info.Size() | ||
// | ||
//parser, err := go2com.NewParser(file, fileSize, true, false) | ||
//if err != nil { | ||
// log.Fatal(err) | ||
// return | ||
//} | ||
//err = parser.Parse() | ||
//if err != nil { | ||
// log.Fatal(err) | ||
// return | ||
//} | ||
//for _, elem := range parser.GetDataset().Elements { | ||
// fmt.Println(elem) | ||
//} | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.