I'm trying to use the library to anonymize a dicom image.
In some cases it works fine, but in other cases the final image is corrupted. I mean, the pixels of the image are wrong and also the FileMetaInformationGroupLength
tag of final image has changed.
This also happen when I don't anonymize the image, I just read and write the image in a new file.
This is my code: //---------------------------------------------------------------------
string dir = @"C:\Users\Desktop\CT.dcm";
var dcmBytes = System.IO.File.ReadAllBytes(@dir);
try
{
var dcm = EvilDICOM.Core.DICOMObject.Read(dcmBytes);
var refName = new EvilDICOM.Core.Element.PersonName
{
FirstName = "",
Tag = EvilDICOM.Core.Helpers.TagHelper.PATIENT_NAME
};
dcm.ReplaceOrAdd(refName);
dcm.Write(@"C:\Users\Desktop\CT2.dcm");
}
catch(Exception ex)
{
throw new Exception("EXCEPTION: " + ex.Message);
}
//---------------------------------------------------------------------
Following is the original image with which I have the problem: https://www.dropbox.com/s/s5ase23jl9908jm/3DSlice1.dcm?dl=0
Following is the screenshot with the original image and the final image (the corrupted image). https://www.dropbox.com/s/12liy3gbw7dkb4d/Image_corrupted.PNG?dl=0
I don't know what is happening with the pixel data. But I have seen that the FileMetaInformationGroupLength
tag changes.
Original image is compressed with Transfer syntax 1.2.840.10008.1.2.4.70. The output image is encoded with 1.2.840.10008.1.2 which means uncompressed. You need to check if this change in transfer syntax is applied correctly while calling dcm.Write
.
Or may be that the transfer syntax is already changed while read operation.
In any case, make sure the change in transfer syntax is intended, it is done correctly and consistent with DICOM tags.
I never used Evil DICOM toolkit so I may not help you with code.