dicom
dicom copied to clipboard
Write element with sequence item or nested sequence
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() { element_1, _ := dicom.NewElement(tag.Modality, []string{"SR"}) element_2, _ := dicom.NewElement(tag.PatientName, "Alice") element_3, _ := dicom.NewElement(tag.PatientID, "12345") seqItem := [][]*dicom.Element{ { element_2, element_3, }, } sequenceElement, _ := dicom.NewElement(tag.ConceptNameCodeSequence, seqItem) ds := dicom.Dataset{ Elements: []*dicom.Element{ sequenceElement, element_1, }, } 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
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"})
@ZengQingHong927 sounds like you got everything working? Let me know if not and additional help needed.