Comments (6)
Anonymization is built into Evil DICOM (http://rexcardan.github.io/Evil-DICOM/articles/anonymization.html). I am not sure what is happening in your image bytes. Do you have an anonymized file you could send so I could debug myself. Its almost impossible to just look at your code and figure it out.
from evil-dicom.
Thanks for your answer!
I send you the image in which I have the problem.
https://www.dropbox.com/s/s5ase23jl9908jm/3DSlice1.dcm?dl=0
I also send you an screenshot with the original image and the final image (the corrupted image).
https://www.dropbox.com/s/12liy3gbw7dkb4d/Image_corrupted.PNG?dl=0
I dont know what is happening with the pixel data, but I have observed that the FileMetaInformationGroupLength tag changes.
Thank you in advance!
from evil-dicom.
I did notice one problem. These are compressed images. When EvilDICOM writes out, for right or wrong, it encodes the file assuming no compression. You can overcome this by setting the TransferSyntaxUID manually in the DICOMWriteSettings:
var writeSettings = DICOMWriteSettings.Default();
//Set writing syntax to current syntax
writeSettings.TransferSyntax = TransferSyntaxHelper.GetSyntax(dcm.GetSelector().TransferSyntaxUID.Data);
dcm.Write(@"C:\Users\REXNFX\Desktop\3DSlice1mod2.dcm", writeSettings);
What is weird is that it still shows up as scrambled in MicroDICOM, but shows up fine in other DICOM viewers. I am not sure why that is. I have compared the data written to original and it is the same except the patient name. Here is my verification code:
var path = @"C:\Users\REXNFX\Desktop\3DSlice1.dcm";
var dcm = DICOMObject.Read(path);
//Keep original before we start modding
var copy = DICOMObject.Read(path);
var refName = new EvilDICOM.Core.Element.PersonName
{
Data = "",
Tag = EvilDICOM.Core.Helpers.TagHelper.PATIENT_NAME
};
dcm.ReplaceOrAdd(refName);
//This is compressed to JPEG-LS. We need to set manually on write
var writeSettings = DICOMWriteSettings.Default();
//Set writing syntax to current syntax
writeSettings.TransferSyntax = TransferSyntaxHelper.GetSyntax(dcm.GetSelector().TransferSyntaxUID.Data);
dcm.Write(@"C:\Users\REXNFX\Desktop\3DSlice1mod2.dcm", writeSettings);
dcm = DICOMObject.Read(@"C:\Users\REXNFX\Desktop\3DSlice1mod2.dcm");
//CHECK ELEMENT COUNT
AssertAreEqual(dcm.AllElements.Count, copy.AllElements.Count);
//CHECK ELEMENT DATA
for (int i = 0; i < dcm.AllElements.Count; i++)
{
if (!dcm.AllElements[i].Tag.CompleteID.EndsWith("0000")) //Exclude headers
AssertAreEqual(dcm.AllElements[i].DData_, copy.AllElements[i].DData_, dcm.AllElements[i].Tag.CompleteID);
}
//CHECK PIXELS
var origPixels = copy.GetSelector().PixelData.Data_;
var writePixels = dcm.GetSelector().PixelData.Data_;
for (int i = 0; i < origPixels.Count; i++)
{
if (origPixels[i] != writePixels[i])
{
Console.WriteLine(i);
}
}
Console.Read();
from evil-dicom.
My AssertAreEqualCode looks like this:
private static void AssertAreEqual<T>(T val1, T val2, string message = "")
{
if (typeof(T) == typeof(DICOMObject))
{
var dynVal1 = val1 as dynamic;
var dynVal2 = val2 as dynamic;
for (int i = 0; i < dynVal1.AllElements.Count; i++)
{
if (!dynVal1.AllElements[i].Tag.CompleteID.EndsWith("0000")) //Exclude headers
AssertAreEqual(dynVal1.AllElements[i].DData_, dynVal2.AllElements[i].DData_, dynVal2.AllElements[i].Tag.CompleteID);
}
}
else if (typeof(T) == typeof(ICollection) || typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(List<>))
{
var dynVal1 = val1 as dynamic;
var dynVal2 = val2 as dynamic;
for (int i = 0; i < dynVal1.Count; i++)
{
if (dynVal1[0] != null && dynVal1[0].GetType() == typeof(DICOMObject))
{
var dcm1 = (DICOMObject)dynVal1[i];
var dcm2 = (DICOMObject)dynVal2[i];
AssertAreEqual(dcm1, dcm2, message);
}
else if (dynVal1[i]!=null&& !dynVal1[i].Equals(dynVal2[i])) { Console.WriteLine($"{message} item {i} not equal => {dynVal1[i]} != {dynVal2[i]}"); }
}
}
else if (!val1.Equals(val2))
{
Console.WriteLine($"{message} not eqaul => {val1} != {val2}");
}
}
from evil-dicom.
Thank you!! I will try by setting the TransferSyntaxUID when write the image! I hope it works!
from evil-dicom.
Thanks! I have implemented the code by setting the TransferSyntaxUID manually and it works fine!
from evil-dicom.
Related Issues (20)
- Feature Request: Single Association Mass CStore request
- Feature Request: Get (300A,000C) RTPlanGeometry Dicom tag HOT 1
- DICOM to BEV Transformation
- SendCStore skips important RS-DICOM-Tag (0008,0106) for Eclipse-Import
- Dicom File Larger than 2 GB HOT 7
- DICOMSCP error when a contour has many points HOT 1
- A typo in method bool IsInBounds(Vector3 pt) in RT package
- Anonymization fails for RP-files HOT 1
- Possible leak in DICOMSCU HOT 2
- MaskImageFast Error
- Unable to read Primary Fluence Mode Sequence
- CMove from ARIA to Self - CT Images (EvilDICOM v2.0.6.5) HOT 2
- ReadIndefiniteBigEndian uses LittleEndian for EndOfSequenceItem
- Queue.Anonymize() throws System.InvalidOoperationException HOT 2
- Progress and Roadmap of Evil-DICOM
- Meta/Header information not being written
- Unable to retrieve tag BeamDeliveryDurationLimit (300A,005C) HOT 1
- Is there any tool for writing Dicom-RT structure easily?
- How to delete one structure from loaded DICOM StructureSet
- RTDose CStore error when sending to MIM 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 evil-dicom.