Giter Site home page Giter Site logo

dicomweb-go's Introduction

DICOMweb Go

license PkgGoDev Go Report Card Coverage Status GitHub Actions

Introduction

A DICOMweb client for Golang.

There are plenty of packages that allow you to read DICOM files in Go whereas not much for communicating with DICOM server.

Currently there are DICOM servers such as dcm4chee, Orthanc, etc., that support read/write DICOM by HTTP protocol, known as DICOMweb.

This package provides a simple DICOMweb client that allows you to query DICOM info (QIDO), retrieve DICOM files (WADO), and store DICOM files (STOW).

Documentation

Getting Started

Installation

go get github.com/toastcheng/dicomweb-go/dicomweb

Requirements

  • Go 1.12+

Quick Examples

note: for demonstration, the endpoint is set to a dcm4chee server hosted by dcmjs.org. Change it to your DICOM server instead.

Query all study

client := dicomweb.NewClient("https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs")

qido := dicomweb.QIDORequest{
    Type: dicomweb.Study,
}
resp, err := client.Query(qido)
if err != nil {
    log.Fatalf("faild to query: %v", err)
}

Query all series under specific study

client := dicomweb.NewClient(dicomweb.ClientOption{
    QIDOEndpoint: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
    WADOEndpoint: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
    STOWEndpoint: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
})

studyInstanceUID := "1.3.6.1.4.1.25403.345050719074.3824.20170126085406.1"
qido := dicomweb.QIDORequest{
    Type:              dicomweb.Series,
    StudyInstanceUID:  studyInstanceUID,

}
resp, err := client.Query(qido)
if err != nil {
    log.Fatalf("faild to query: %v", err)
}
log.Println(resp)
Retrieve the DICOM file
client := dicomweb.NewClient(dicomweb.ClientOption{
    QIDOEndpoint: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
    WADOEndpoint: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
    STOWEndpoint: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
})
studyInstanceUID := "1.3.6.1.4.1.25403.345050719074.3824.20170126085406.1"
seriesInstanceUID := "1.3.6.1.4.1.25403.345050719074.3824.20170126085406.2"
instanceUID := "1.3.6.1.4.1.25403.345050719074.3824.20170126085406.3"

wado := dicomweb.WADORequest{
    Type:              dicomweb.InstanceRaw,
    StudyInstanceUID:  studyInstanceUID,
    SeriesInstanceUID: seriesInstanceUID,
    SOPInstanceUID:    instanceUID,
    FrameID:           1,
}
parts, err := client.Retrieve(wado)
if err != nil {
    log.Fatalf("faild to query: %v", err)
}

for i, p := range parts {
    // save it into file like this:
    err := ioutil.WriteFile("/tmp/test_"+strconv.Itoa(i)+".dcm", p, 0666)
    if err != nil {
        log.Fatalf("faild to retrieve: %v", err)
    }
}
Store the DICOM file
client := dicomweb.NewClient(dicomweb.ClientOption{
    STOWEndpoint: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
})

parts := [][]byte{}
// read your data like this:
for i := 0; i < 10; i++ {
    fname := fmt.Sprintf("data_%d.dcm", i)
    b, err := ioutil.ReadFile(fname)
    if err != nil {
        log.Fatal(err)
    }
    parts = append(parts, b)
}

stow := dicomweb.STOWRequest{
    StudyInstanceUID: "1.2.840.113820.0.20200429.174041.3",
    Parts:            parts,
}
resp, err := c.Store(stow)
if err != nil {
    log.Fatalf("faild to query: %v", err)
}
log.Println(resp)

Contributing

This project is still in development, any contributions, issues and feature requests are welcome! Please check out the issues page.

License

dicomweb-go is available under the MIT license.

dicomweb-go's People

Contributors

loafoe avatar toastcheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dicomweb-go's Issues

Using another way to upload new Instance?

Hi, it's really nice to see this project. I am working on a medical project and use Golang. Now, I am using a HTTP client as usual. So I have a question. Why don't you use /instances/ like mentioned in the official doc instead of that, you are using /studies/ ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.