fo-dicom
fo-dicom copied to clipboard
structuredReport with utf-8 enconding
Hi I want to add items to structuredReport with utf-8 enconding.
var strReport = new DicomStructuredReport(file.Dataset);
var titleContentItem = new DicomContentItem(
new DicomCodeItem(model.Title, "companyName", "Title"),
DicomRelationship.Contains,
new DicomCodeItem(model.Title, "companyName", "Title"));
strReport.Add(titleContentItem);
How can I save model.Title
with utf-8 enconding?
And when my text is too long I get this error value exceeds maximum length of 16 characters
Agree, there is no parameter for Encoding, fo-dicom always assumes DicomEncoding.Default. Have to add an overload, that passes through some encoding
The exception is fine, because DICOM defines the tag CodeValue (0008,0100) to be of Value Representation SH, which is a Shortstring with 16 characters maximum.
Currently as a solution I want to save the base64 form of my text.
in which field of StructuredReport can I save more characters?
Code Scheme designator (0008,0102, SH) identifies who desfined the codes, the Code Value (0008,0100, SH) then has to be a short unique code (typically not human readable), and the Code Meaning (0008,0104, LO) is then a human readable descriptive value. It is LO, that means 64 charachters. That should be enought?
Some famous example of such codes is for example this:
Coding Scheme Designator | Code Value | Code Meaning |
---|---|---|
SRT | R-10224 | medio-lateral |
SRT | R-10226 | medio-lateral oblique |
SRT | R-10228 | latero-medial |
SRT | R-10230 | latero-medial oblique |
you can also read here: https://dicom.innolitics.com/ciods/rt-dose/rt-series/00400260/00080104
Ah, you edited the question meanwhile. I am only familiar with structured reports in terms of CAD (mammo findings). So I know about the codes and values. But I have no experience with long texts.
Thanks for your answer. I think my problem is something else. look at the below image
Is StructuredReport files I need a part like this. How can I generate this part in an dicom file?
update: I know I should use DicomTag.SequenceDelimitationItem, but I don't know how to use it in fa-dicom.
Hi, I facet with same problem and created custom implementation of IOManager.
`///
/// <inheritdoc />
protected override IPath PathImpl => DesktopPath.Instance;
/// <inheritdoc />
protected override IFileReference CreateFileReferenceImpl(string fileName)
{
return new DesktopFileReference(fileName);
}
/// <inheritdoc />
protected override IDirectoryReference CreateDirectoryReferenceImpl(string directoryName)
{
return new DesktopDirectoryReference(directoryName);
}
}`
Also you should register this implementation IOManager.SetImplementation(new CustomIOManager());
and set tag SpecificCharacterSet _dicomFile.Dataset.AddOrUpdate(DicomTag.SpecificCharacterSet, "ISO_IR 192");
//https://dcm4chee-arc-cs.readthedocs.io/en/latest/charsets.html
With latest version the IOManager became obsolete and the handling of Encodings has becomme better.
Now you should be able to do something like that:
// setting the encoding as SpecificCharacterSet in dataset is important, so that then applications reading this file know that they have to decode as UTF8
file.Dataset.AddOrUpdate(DicomTag.SpecificCharacterSet, DicomEncoding.GetCharset(Encoding.UTF8));
// then when adding texts to the dataset or to nested datasets, the encoding of the parent/root dataset is used. Only if there is no specific encoding, then DicomEncoding.Default is used.
var strReport = new DicomStructuredReport(file.Dataset);
var titleContentItem = new DicomContentItem(
new DicomCodeItem(model.Title, "companyName", "Title"),
DicomRelationship.Contains,
new DicomCodeItem(model.Title, "companyName", "Title"));
strReport.Add(titleContentItem);
Please verify, that this now works as expected.
Closing due to inactivity. If you still observe a problem with latest version of fo-dicom, then please reopen this issue and provide actual informations.