You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Unable to replace ContourImageSequence. This exception is thrown:
System.InvalidOperationException: 'Unable to create DICOM element of type SQ with values of type Dicom.DicomSequence'
To Reproduce
The below attempts to replace the ContourImageSequence with itself (which I assume excludes any errors that may be attributable to user generation of the sequence). To be clear, it fails when I try to AddOrUpdate with a user-generated sequence as well.
// Get Sequence
var contourSequence = SSTemplate.Dataset.GetSequence(DicomTag.ReferencedFrameOfReferenceSequence).Items[0]
.GetSequence(DicomTag.RTReferencedStudySequence).Items[0]
.GetSequence(DicomTag.RTReferencedSeriesSequence).Items[0]
.GetSequence(DicomTag.ContourImageSequence);
// Set Sequence - this fails, even when replacing it with itself!
SSTemplate.Dataset.GetSequence(DicomTag.ReferencedFrameOfReferenceSequence).Items[0]
.GetSequence(DicomTag.RTReferencedStudySequence).Items[0]
.GetSequence(DicomTag.RTReferencedSeriesSequence).Items[0].
AddOrUpdate(DicomTag.ContourImageSequence, contourSequence);
Expected behavior
I expect this to work?
Environment
Fellow Oak DICOM version: 4.0.8
OS: Windows 10 x64
Platform: .NET Framework 4.8
The text was updated successfully, but these errors were encountered:
The AddOrUpdate method is a facade for the various constructors. If you take a look at the constructor of DicomSequence then you see that it takes a list of DicomDatasets as parameter. public DicomSequence(DicomTag tag, params DicomDataset[] items)
so you could either call AddOrUpdate(DicomTag.ContourImageSequence, contourSequence.Items.ToArray());
or - because the variable contourSequence also contains the DicomTag - you can just call AddOrUpdate(contourSequence);
In terms of my present issue sending only the contourSequence to the method has resolved the exception. In future I wonder if it might be more user-friendly to adjust the constructor to catch this during compile... DicomSequence presents an IEnumerable<DicomDataset> interface, which is presumably why it's accepted as a DicomDataset[]... it's not super obvious to beginners like me why it should work as a DicomItem but not IEnumerable<DicomDataset>.
At any rate, thanks again and I appreciate the quick response!
Describe the bug
Unable to replace ContourImageSequence. This exception is thrown:
System.InvalidOperationException: 'Unable to create DICOM element of type SQ with values of type Dicom.DicomSequence'
To Reproduce
The below attempts to replace the ContourImageSequence with itself (which I assume excludes any errors that may be attributable to user generation of the sequence). To be clear, it fails when I try to AddOrUpdate with a user-generated sequence as well.
// Get Sequence
var contourSequence = SSTemplate.Dataset.GetSequence(DicomTag.ReferencedFrameOfReferenceSequence).Items[0]
.GetSequence(DicomTag.RTReferencedStudySequence).Items[0]
.GetSequence(DicomTag.RTReferencedSeriesSequence).Items[0]
.GetSequence(DicomTag.ContourImageSequence);
// Set Sequence - this fails, even when replacing it with itself!
SSTemplate.Dataset.GetSequence(DicomTag.ReferencedFrameOfReferenceSequence).Items[0]
.GetSequence(DicomTag.RTReferencedStudySequence).Items[0]
.GetSequence(DicomTag.RTReferencedSeriesSequence).Items[0].
AddOrUpdate(DicomTag.ContourImageSequence, contourSequence);
Expected behavior
I expect this to work?
Environment
Fellow Oak DICOM version: 4.0.8
OS: Windows 10 x64
Platform: .NET Framework 4.8
The text was updated successfully, but these errors were encountered: