amsundaram06
 Basic Member Posts:22
 |
| 2008-08-12 02:16 AM |
|
I'm developing a medical photography system which the software part is in .NET. I require to export the BMP files to DICOM.Is it suitable for my need? I want to make a DICOM file, add the patient data and photos to the file and finally writing it to the disk. Would you please advice me how tho this ? Any sample code?
Actually I am using X-Ray Radiofluoroscopic Image modality is RF my image size is 720x540.. help me to convert to dicom...
|
|
|
|
|
dblanchard
 Senior Member Posts:185
 |
| 2008-08-12 02:35 AM |
|
If your bitmap is uncompressed you should be able to use the DicomFile class in the ClearCanvas.Dicom project. There are a lot of details involved, you need to know number of bytes per pixel and other things. here is a sample of a DX (digital x-ray) 1536 x 1920, 12 bits.
using ClearCanvas.Dicom;
private void WriteDicomFile() { int width = 1536; int height = 1920; short bitsPerPixel = 12; short bytesPerPixel = 2;
byte[] imageBuffer = new byte[width * height * bytesPerPixel]; // TODO: put bitmap data in imageBuffer DicomFile dicomFile = new DicomFile(); dicomFile.MediaStorageSopClassUid = SopClass.DigitalXRayImageStorageForPresentation.Uid; dicomFile.DataSet[DicomTags.SopClassUid].SetStringValue(SopClass.DigitalXRayImageStorageForPresentation.Uid); dicomFile.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian; dicomFile.ImplementationClassUid = "2.16.840.1.00000000000"; //TODO: fill it with appropriate value dicomFile.ImplementationVersionName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); dicomFile.SourceApplicationEntityTitle = "MyApp";
// Uids need to be set and unique DicomUid sopInstanceUid = DicomUid.GenerateUid(); dicomFile.MediaStorageSopInstanceUid = sopInstanceUid.UID; dicomFile.DataSet[DicomTags.SopInstanceUid].SetStringValue(sopInstanceUid.UID);
dicomFile.DataSet[DicomTags.StudyInstanceUid].SetStringValue(DicomUid.GenerateUid().UID); dicomFile.DataSet[DicomTags.SeriesInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);
dicomFile.DataSet[DicomTags.Modality].SetStringValue("DX"); dicomFile.DataSet[DicomTags.SpecificCharacterSet].SetString(0, "ISO_IR 100"); dicomFile.DataSet[DicomTags.SoftwareVersions].SetString(0, dicomFile.ImplementationVersionName); dicomFile.DataSet[DicomTags.StationName].SetStringValue(Environment.MachineName); dicomFile.DataSet[DicomTags.Manufacturer].SetStringValue(""); dicomFile.DataSet[DicomTags.ManufacturersModelName].SetStringValue("");
// Pixel Data dicomFile.DataSet[DicomTags.ImageType].SetStringValue(@"ORIGINAL\PRIMARY"); dicomFile.DataSet[DicomTags.Columns].SetInt32(0, width); dicomFile.DataSet[DicomTags.Rows].SetInt32(0, height); dicomFile.DataSet[DicomTags.BitsStored].SetInt16(0, bitsPerPixel); dicomFile.DataSet[DicomTags.BitsAllocated].SetInt16(0, 16); dicomFile.DataSet[DicomTags.HighBit].SetInt16(0, 15); dicomFile.DataSet[DicomTags.PixelData].Values = imageBuffer;
/* * imagesRow, seriesRow, studiesRow, and patientsRow are rows from our database //Image info dicomFile.DataSet[DicomTags.InstanceCreationDate].SetDateTime(0, imagesRow.CreateDate); dicomFile.DataSet[DicomTags.InstanceCreationTime].SetDateTime(0, imagesRow.CreateDate); dicomFile.DataSet[DicomTags.AcquisitionDate].SetDateTime(0, imagesRow.CreateDate); dicomFile.DataSet[DicomTags.AcquisitionTime].SetDateTime(0, imagesRow.CreateDate); dicomFile.DataSet[DicomTags.ContentDate].SetDateTime(0, imagesRow.CreateDate); dicomFile.DataSet[DicomTags.ContentTime].SetDateTime(0, imagesRow.CreateDate); dicomFile.DataSet[DicomTags.InstanceNumber].SetInt32(0, imagesRow.InstanceNumber); dicomFile.DataSet[DicomTags.AcquisitionNumber].SetInt32(0, imagesRow.AcquisitionNumber);
// Series Info DicomDataSet.SeriesRow seriesRow = imagesRow.SeriesRow; dicomFile.DataSet[DicomTags.SeriesInstanceUid].SetStringValue(seriesRow.SeriesInstanceUid); dicomFile.DataSet[DicomTags.SeriesDate].SetDateTime(0, seriesRow.CreateDate); dicomFile.DataSet[DicomTags.SeriesTime].SetDateTime(0, seriesRow.CreateDate); dicomFile.DataSet[DicomTags.SeriesDescription].SetStringValue(seriesRow.SeriesDescription); dicomFile.DataSet[DicomTags.SeriesNumber].SetInt32(0, seriesRow.SeriesNumber);
//Studies Info DicomDataSet.StudiesRow studiesRow = imagesRow.SeriesRow.StudiesRow; dicomFile.DataSet[DicomTags.StudyInstanceUid].SetStringValue(studiesRow.StudyInstanceUid); dicomFile.DataSet[DicomTags.StudyDate].SetDateTime(0, studiesRow.CreateDate); dicomFile.DataSet[DicomTags.StudyTime].SetDateTime(0, studiesRow.CreateDate); dicomFile.DataSet[DicomTags.StudyDescription].SetStringValue(studiesRow.StudyDescription); DicomDataSet.PatientsRow patientsRow = imagesRow.SeriesRow.StudiesRow.PatientsRow; dicomFile.DataSet[DicomTags.PatientsName].SetStringValue(patientsRow.PatientName); dicomFile.DataSet[DicomTags.PatientId].SetStringValue(patientsRow.PatientId); if (!patientsRow.IsPatientBirthDateNull()) { dicomFile.DataSet[DicomTags.PatientsBirthDate].SetDateTime(0, patientsRow.PatientBirthDate); dicomFile.DataSet[DicomTags.PatientsBirthTime].SetDateTime(0, patientsRow.PatientBirthDate); } dicomFile.DataSet[DicomTags.PatientsSex].SetStringValue(PatientSexConverter.QuickConvertToDicomValue(patientsRow.PatientSexId, patientsRow).ToString()); dicomFile.DataSet[DicomTags.PatientsAge].SetStringValue(AgeConverter.QuickConvertToDicomValue(patientsRow.CreateDate, patientsRow).ToString());
*/ dicomFile.Save("c:\\tempFile.dcm"); }
|
|
|
|
|
amsundaram06
 Basic Member Posts:22
 |
| 2008-08-12 06:47 AM |
|
Thank you Dblanchard... |
|
|
|
|
stewart
 Senior Member Posts:2128
 |
| 2008-09-11 02:39 PM |
|
Hi, I just added a plugin to the new ClearCanvas Community plugin repository that does this, if you're interested. It's pretty simplistic at the moment, as it only outputs the images in RGB format. -Stewart |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
stewart
 Senior Member Posts:2128
 |
| 2008-09-11 03:55 PM |
|
Sorry all, I jumped the gun. The plugin repository isn't quite ready yet. -Stewart |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
norman
 Senior Member Posts:813
 |
| 2008-09-11 03:57 PM |
|
We hope to get it online in the next few days. Watch for it! N. |
|
|
|
|
amsundaram06
 Basic Member Posts:22
 |
| 2008-09-19 04:47 AM |
|
How can i assign FileMetaInformationversion with my dicom file... |
|
|
|
|
norman
 Senior Member Posts:813
 |
| 2008-09-19 01:59 PM |
|
You can now download the "Import from Bitmap" plugin from the community plugins repository. That will allow you to import non-DICOM images and convert them to DICOM.
N.
|
|
|
|
|
steve
 Senior Member Posts:1932
 |
| 2008-09-19 04:27 PM |
|
You can set the File Meta Information Version tag in a DICOM file something like this:
DicomFile test;
test = new DicomFile("test");
byte[] metaInfoVersion = new byte[2];
metaInfoVersion[0] = 0;
metaInfoVersion[1] = 1;
test.MetaInfo[DicomTags.FileMetaInformationVersion].Values = metaInfoVersion;
Steve |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
amsundaram06
 Basic Member Posts:22
 |
| 2008-09-21 07:16 AM |
|
Hi steve
ΐ] Ύ] Ώ] i got error while using ur code. i which way i use that charactoer in my code(i think is it Unicode). |
|
|
|
|
f_mammoth
 Basic Member Posts:26
 |
| 2008-09-21 10:32 PM |
|
so,how to show it?
|
|
|
|
|
steve
 Senior Member Posts:1932
 |
| 2008-09-22 10:20 AM |
|
I just edited my previous post. Norman did an upgrade to the forum software over the weekend, and it appears like it changed the way some some code is represented. Can you recheck my previous post? Thanks, Steve |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
amsundaram06
 Basic Member Posts:22
 |
| 2008-09-22 11:12 AM |
|
Hi, How can i generate multiframe dicom file. Is it posible with cctoolkit? if posible give me an example? regards, S |
|
|
|
|
steve
 Senior Member Posts:1932
 |
| 2008-09-23 09:53 AM |
|
S, In the unit tests for the DICOM library (within the library itself), there's a routine for creating a multi-frame DICOM image. It's in Tests\AbstractTest.cs, and its the SetupMultiframeXA() method. Steve |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
wiki
 Advanced Member Posts:33
 |
| 2008-09-24 11:27 AM |
|
Hi, Actually i am converting bmp(RGB) file to dicom. In the pixel representation of dicom file there is tags PixelAspectRatio in which way i will specify the value for this tag. regards, Wiki |
|
|
|
|
steve
 Senior Member Posts:1932
 |
| 2008-09-24 12:27 PM |
|
Pixel aspect ratio is an integer string, so you can just do something like this: theSet[DicomTags.PixelAspectRatio].SetStringValue("0.8\\0.8"); The above would be added to the SetupMultiframeXA() code I mentioned above. Steve |
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
amsundaram06
 Basic Member Posts:22
 |
| 2008-09-30 02:34 AM |
|
Hi Steve, I had followed the SetupMultiframeXA() function but i have one doubt i which way i will assign my frames pixel data inside the dataset. regards , S |
|
|
|
|
steve
 Senior Member Posts:1932
 |
| 2008-09-30 11:03 AM |
|
I probably should have suggested another alternate with this. As you probably noticed with SetupMultiframeXA() routine, you have to set all frames of the pixel data at one time, using the method shown. This is the optimum (fastest) way for setting the pixel data. Another alternative is to use the DicomUncompressedPixelData class, which was developed for dealing with compression. It has methods for adding frames, and then assigning them into the root message. Here's some sample code:
DicomFile file = new DicomFile("filename");
DicomUncompressedPixelData pd = new DicomUncompressedPixelData(file );
byte[] frame = new byte[frameLength];
pd.AppendFrame(frame);
pd.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian;
pd.UpdateMessage(file);
This is a bit more straightforward way for appending frames individually to a DICOM file. The same basic form can be used for adding to a DicomMessage or attribute collection.
Steve
|
|
| Real-time support available to Clinical Edition and Team Edition customers |
|
|
pL
 New Member Posts:2
 |
| 2008-10-03 02:20 AM |
|
Hello everyone, I'm writting tiff->dcm converter using ccsdk. And have a problem with writting string tags with cyrillic symbols. All char symbols with value higher 128 are shown as '?' in output dcm. I've tried to set diffrend character sets, but it didn't help. I've watched dcm file with a text editor, and saw that question marks are also present there. So it is not an error of wievers. I am using c#, vsnet 2005,and ccsdk 1.2. What i do wrong? ps i couldnt start a new thread, sorry for this. |
|
|
|
|
amsundaram06
 Basic Member Posts:22
 |
| 2008-10-13 04:19 AM |
|
thanks steve. |
|
|
|
|