I wanted to report on a great Dicom library I came across today. It is called ClearCanvas See www.clearcanvas.ca
It is unbelievable how accessible thay made dicom file access and dicom file viewing.
I wanted to modify some dicom file programmatically in VS 2005. You can do this very easily with the Clearcanvas SDK. The SDK is vary well documented and it took me about 30 minutes to get code going to change a patient Id in a dicom image, somthing I was not able to do very easily with other open source dicom libraries.
The library is also documented very well, with sample code, and the site has a good forum.
Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ClearCanvas.Dicom;
namespace CCDicom
{
public partial class DicomAttibuteViewer : Form
{
public DicomAttibuteViewer()
{
InitializeComponent();
}
private void btGo_Click(object sender, EventArgs e)
{
DicomFile _df = new DicomFile(@"C:\user\DotNet\OpenDicom\DicomSampleFiles\00000014.dcm");
_df.Load(DicomReadOptions.Default);
DicomAttributeCollection _ds = _df.DataSet;
foreach (DicomAttribute _da in _ds)
{
if (_da.Tag.Group == 16 && _da.Tag.Element == 32)
{
// Patient ID
_da.SetString(0, "mypatientid");
}
if (_da.Tag.Group == 10)
{
}
this.listBox1.Items.Add(_da.Tag +"->" + _da.ToString());
}
_df.Save(@"c:\user\DotNet\OpenDicom\DicomSampleFiles\erik1.dcm");
}
}
}