Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The reason why the converted DICOM displays as blank after converting from RAW format might be attributed to the following factors: #309

Closed
wangmingche opened this issue May 22, 2024 · 1 comment

Comments

@wangmingche
Copy link

escription
When converting a raw format file to DICOM using the provided program, the resulting output.dcm file appears as a blank/black image when viewed in a DICOM browser.

Environment
Go version: 1.22.0
dicom library version: github.com/suyashkumar/dicom v1.0.7
Steps to Reproduce
Prepare a raw format file.
Use the provided program to convert the raw file to DICOM.
View the resulting output.dcm file in a DICOM browser.
Expected Behavior
The converted DICOM image should display properly, showing the content of the original raw format file.

Actual Behavior
The converted DICOM image appears as a blank/black image when viewed in a DICOM browser.

`

    rawFile := "./Fppic_00001615_2024y04m04d18h00m10s_SNAGA39V30E954.raw"
rawData, err := ioutil.ReadFile(rawFile)
if err != nil {
	fmt.Printf("Failed to read RAW file: %v\n", err)
	return
}
fmt.Printf("rawData:%d\n",len(rawData))

//PixelDataInfo
    pixelDataInfo := dicom.PixelDataInfo{
	  IntentionallyUnprocessed: true,
	  UnprocessedValueData:     rawData,
  }

// 设置 DICOM 元数据
elements := []*dicom.Element{
	dicom.MustNewElement(tag.SOPClassUID, []string{"1.2.840.10008.5.1.4.1.1.2"}),
	//GenerateUID
	dicom.MustNewElement(tag.SOPInstanceUID, []string{"1.2.840.113619.2.55.3.279721844.297.1204122294.826.1"}),
	dicom.MustNewElement(tag.PatientName, []string{"ceshiwang"}),
	dicom.MustNewElement(tag.PatientID, []string{"123456"}),
	//dicom.MustNewElement(tag.StudyInstanceUID, Uuid),
	//dicom.MustNewElement(tag.SeriesInstanceUID, Uuid),
	dicom.MustNewElement(tag.StudyID, []string{"4007"}),
	dicom.MustNewElement(tag.Modality, []string{"CR"}),
	dicom.MustNewElement(tag.Manufacturer, []string{"DATU MEDICAL"}),
	dicom.MustNewElement(tag.Rows, []int{512}),
	dicom.MustNewElement(tag.Columns, []int{512}),
	dicom.MustNewElement(tag.BitsAllocated, []int{16}),
	dicom.MustNewElement(tag.BitsStored, []int{16}),
	dicom.MustNewElement(tag.HighBit, []int{15}),
	dicom.MustNewElement(tag.PixelRepresentation, []int{0}),
	dicom.MustNewElement(tag.PixelData,pixelDataInfo),
}
dicomDataSet := dicom.Dataset{Elements: elements}

var buffer bytes.Buffer
if err := dicom.Write(&buffer, dicomDataSet,dicom.DefaultMissingTransferSyntax()); err != nil {
	fmt.Printf("Failed to write DICOM file: %v\n", err)
	return
}
// 保存 DICOM 文件
dicomFile := "output.dcm"
if err := ioutil.WriteFile(dicomFile, buffer.Bytes(), 0644); err != nil {
	fmt.Printf("Failed to save DICOM file: %v\n", err)
	return
}

fmt.Printf("DICOM file saved: %s\n", dicomFile)

`

@suyashkumar
Copy link
Owner

Hi there, it's because we don't have autoscaling, but you can apply scaling on your own if you'd like, more details #301 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants