Comments (2)
You are getting this error because the dicom file which you are trying to parse has no preamble (128 bytes zeros) and magic bytes ('D', 'I', 'C', 'M'). If you'd like to have detailed information about the dicom format and file structure please have a look at (https://dicom.nema.org/dicom/2013/output/chtml/part10/chapter_7.html).
Regarding the problem, you can try to insert the preamble and magic at the beginning of your file and then parse it.
You can apply the following snippet, but it's important to note that this is not the best solution. You may need to consider better solution in different cases.
package main
import (
"bytes"
"fmt"
"log"
"os"
"github.com/suyashkumar/dicom"
)
func main() {
dcmMagic := make([]byte, 128)
dcmMagic = append(dcmMagic, []byte{'D', 'I', 'C', 'M'}...)
buf, _ := os.ReadFile("test-dicom.dcm")
rd := bytes.NewReader(append(dcmMagic, buf...))
ds, err := dicom.Parse(rd, rd.Size(), nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(ds)
}
from dicom.
Thanks for helping out the community @itp-atakan! Sounds like maybe this isn't an issue? Note that we have a compatability mode that tries to read the dataset without the magic word:
Line 149 in 9612756
from dicom.
Related Issues (20)
- Add option to not hold entire dataset in memory at once HOT 2
- If the passed in Reader is _also_ an io.Seeker, consider trying to use Seek() on Skip
- Consider a Read - Modify some Elements - Write Pipeline API
- Consider updating type system to use Go generics HOT 1
- Value representation "Application Entity" is not correclly serialized
- fatal exit without defer HOT 2
- Explore Lint based or reflection based tests for struct equality changes
- Add additional struct `Equals` test cases
- What's the right import statement to use this? HOT 2
- Write() fails for encapsulated pixel data unless ValueLength explicitly set to tag.VLUndefinedLength HOT 1
- Question: Is it possible to get to individual Pixels in dicom image? HOT 3
- Use this project in C# HOT 1
- Memory usage (sometimes 15x from the size of dicom file) HOT 1
- Check for Signed Integers in Native Pixel Data HOT 1
- Support Negative Integers in Native Pixel Data
- dicom.Write: The Pixel data only supports OW type
- File with dicom seg throws an error - writing dicom file: unsupported BitsPerSample value
- Converting DICOM to Image results into "blacked" image HOT 4
- using dicom.Parse function ,unexpected EOF HOT 1
- Write element with sequence item or nested sequence HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dicom.