suyashkumar / dicom

⚡High Performance DICOM Medical Image Parser in Go.
MIT License
943 stars 137 forks source link

Write element with sequence item or nested sequence #308

Closed ZengQingHong927 closed 4 months ago

ZengQingHong927 commented 5 months ago

Hey all, I am new to the great library and being to implement a dicom application to connect to PACS. I refer to the godoc to create a dataset with sequence item. Finally, I print the dataset value and get the null. Thank you.

` import ( "fmt"

"github.com/suyashkumar/dicom"
"github.com/suyashkumar/dicom/pkg/tag"

)

func main() { element1, := dicom.NewElement(tag.Modality, []string{"SR"}) element2, := dicom.NewElement(tag.PatientName, "Alice") element3, := dicom.NewElement(tag.PatientID, "12345") seqItem := [][]dicom.Element{ { element_2, element3, }, } sequenceElement, := dicom.NewElement(tag.ConceptNameCodeSequence, seqItem) ds := dicom.Dataset{ Elements: []dicom.Element{ sequenceElement, element1, }, } for , v := range ds.Elements { data, _ := v.Value.MarshalJSON() fmt.Println(string(data)) } } `

The below is log [[null,null]] ["SR"]

System: MacOS 14.4.1 Go Version: 1.21.1 IDE: vscode

ZengQingHong927 commented 5 months ago

I found the bug that second parameter must be slice for NewElement function. element_2, _ := dicom.NewElement(tag.PatientName, []string{"Alice"}) element_3, _ := dicom.NewElement(tag.PatientID, []string{"12345"})

suyashkumar commented 4 months ago

@ZengQingHong927 sounds like you got everything working? Let me know if not and additional help needed.