本文整理汇总了C#中DicomAttributeCollection类的典型用法代码示例。如果您正苦于以下问题:C# DicomAttributeCollection类的具体用法?C# DicomAttributeCollection怎么用?C# DicomAttributeCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DicomAttributeCollection类属于命名空间,在下文中一共展示了DicomAttributeCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssertTagValueChanged
public void AssertTagValueChanged(uint tag, string valueToSet, string originalCharacterSet, string expectedNewCharacterSet)
{
DicomAttributeCollection dataset = new DicomAttributeCollection();
SetupDataSet(dataset, originalCharacterSet);
DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset);
Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString());
SetTagCommand cmd = new SetTagCommand(tag, valueToSet);
Assert.AreEqual(cmd.CanSaveInUnicode, UnicodeAllowed, "SetTagCommand.CanSaveInUnicode returns an incorrect value");
Assert.IsTrue(cmd.Apply(file), "SetTagCommand.Apply failed");
var filename = string.Format("Test-{0}.dcm", DicomTagDictionary.GetDicomTag(tag).Name);
Assert.IsTrue(file.Save(filename), "Unable to save dicom file");
file = new DicomFile(filename);
file.Load();
if (valueToSet == null)
Assert.AreEqual(string.Empty, file.DataSet[tag].ToString());
else
Assert.AreEqual(valueToSet, file.DataSet[tag].ToString());
Assert.IsTrue(file.DataSet[DicomTags.SpecificCharacterSet].ToString().Equals(expectedNewCharacterSet));
Delete(filename);
}
示例2: TestIsValidMultiFrameOverlay
public void TestIsValidMultiFrameOverlay()
{
const int size = 3;
var dataset = new DicomAttributeCollection();
SetOverlay(dataset, 0, new bool[size*size], OverlayType.R, new Point(0, 0), size, size, null, false, false);
SetOverlay(dataset, 1, new bool[size*size], OverlayType.R, new Point(0, 0), size, size, 1, false, false);
SetOverlay(dataset, 2, new bool[size*size*5], OverlayType.R, new Point(0, 0), size, size, 5, false, false);
SetOverlay(dataset, 3, new bool[size*size], OverlayType.R, new Point(0, 0), size, size, 1, 3, false, false);
SetOverlay(dataset, 4, new bool[size*size*5], OverlayType.R, new Point(0, 0), size, size, 5, 2, false, false);
var module = new OverlayPlaneModuleIod(dataset);
Assert.IsTrue(module[0].IsValidMultiFrameOverlay(1), "Single Frame Overlay / 1 Frame in Image");
Assert.IsTrue(module[0].IsValidMultiFrameOverlay(2), "Single Frame Overlay / 2 Frames in Image");
Assert.IsTrue(module[1].IsValidMultiFrameOverlay(1), "1 Frame in Overlay (origin null==1) / 1 Frame in Image");
Assert.IsTrue(module[1].IsValidMultiFrameOverlay(2), "1 Frame in Overlay (origin null==1) / 2 Frames in Image");
Assert.IsFalse(module[2].IsValidMultiFrameOverlay(4), "5 Frames in Overlay (origin null==1) / 4 Frames in Image");
Assert.IsTrue(module[2].IsValidMultiFrameOverlay(5), "5 Frames in Overlay (origin null==1) / 5 Frames in Image");
Assert.IsTrue(module[2].IsValidMultiFrameOverlay(6), "5 Frames in Overlay (origin null==1) / 6 Frames in Image");
Assert.IsFalse(module[3].IsValidMultiFrameOverlay(2), "1 Frames in Overlay (origin 3) / 2 Frames in Image");
Assert.IsTrue(module[3].IsValidMultiFrameOverlay(3), "1 Frames in Overlay (origin 3) / 3 Frames in Image");
Assert.IsTrue(module[3].IsValidMultiFrameOverlay(4), "1 Frames in Overlay (origin 3) / 4 Frames in Image");
Assert.IsFalse(module[4].IsValidMultiFrameOverlay(5), "5 Frames in Overlay (origin 2) / 5 Frames in Image");
Assert.IsTrue(module[4].IsValidMultiFrameOverlay(6), "5 Frames in Overlay (origin 2) / 6 Frames in Image");
Assert.IsTrue(module[4].IsValidMultiFrameOverlay(7), "5 Frames in Overlay (origin 2) / 7 Frames in Image");
}
示例3: TestFormatNil
public void TestFormatNil()
{
var dataset = new DicomAttributeCollection();
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null), "1");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null, false), "2");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription), "3");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription, false), "4");
dataset[DicomTags.PatientBreedCodeSequence].SetNullValue();
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null), "5");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null, false), "6");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription), "7");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription, false), "8");
dataset[DicomTags.PatientBreedDescription].SetNullValue();
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null), "9");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null, false), "10");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription), "11");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription, false), "12");
dataset[DicomTags.PatientBreedCodeSequence].SetEmptyValue();
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null), "13");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null, false), "14");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription), "15");
Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription, false), "16");
}
示例4: OBAttributeOddLengthTests
public void OBAttributeOddLengthTests()
{
using(var ms = new MemoryStream())
{
var writer = new DicomStreamWriter(ms);
var ds = new DicomAttributeCollection();
var rawdata = new byte[] {0x0, 0x1, 0x2};
ds[DicomTags.EncapsulatedDocument].Values = rawdata;
writer.Write(TransferSyntax.ImplicitVrLittleEndian, ds, DicomWriteOptions.Default);
ms.Position = 0;
var output = ms.ToArray();
var expectedOutput = new byte[]
{
0x42, 0x00, 0x11, 0x00,
0x04, 0x00, 0x00, 0x00,
0x0, 0x1, 0x2, 0x0 /* pad */
};
Assert.AreEqual(output, expectedOutput);
}
}
示例5: _queryButton_Click
private void _queryButton_Click(object sender, EventArgs e)
{
var scu = new StudyRootFindScu();
var query = new DicomAttributeCollection();
scu.AssociationRejected += scu_AssociationRejected;
scu.AssociationAccepted += scu_AssociationAccepted;
scu.AssociationReleased += scu_AssociationReleased;
scu.AssociationAborted += scu_AssociationAborted;
scu.NetworkError += scu_NetworkError;
query[DicomTags.QueryRetrieveLevel].SetStringValue("STUDY");
query[DicomTags.PatientId].SetStringValue("");
query[DicomTags.PatientsName].SetStringValue("");
query[DicomTags.AccessionNumber].SetStringValue("");
query[DicomTags.StudyDescription].SetStringValue("");
query[DicomTags.StudyDate].SetStringValue("");
query[DicomTags.StudyInstanceUid].SetStringValue("");
if (_studyDateTextBox.Text != "")
{
query[DicomTags.StudyDate].SetStringValue(_studyDateTextBox.Text +"-" + DateTime.Today.ToString("yyyyMMdd"));
}
_results = null;
_results = scu.Find(_aeTitleTextbox.Text, _calledAETitleTextbox.Text, _hostnameTextbox.Text, int.Parse(_portTextbox.Text), query);
scu.Dispose();
}
示例6: SelectAllSeries
public void SelectAllSeries()
{
Study study = CreateTestStudy1();
var criteria = new DicomAttributeCollection();
var filters = new SeriesPropertyFilters(criteria);
var results = filters.FilterResults(study.GetSeries().Cast<Series>());
Assert.AreEqual(4, results.Count());
}
示例7: PatientNode
/// <summary>
/// Constructs a new <see cref="PatientNode"/> using actual values from attributes in the given <see cref="DicomAttributeCollection"/>.
/// </summary>
/// <param name="dicomDataSet">The data set from which to initialize this node.</param>
public PatientNode(DicomAttributeCollection dicomDataSet)
{
_studies = new StudyNodeCollection(this);
_patientId = dicomDataSet[DicomTags.PatientId].GetString(0, "");
_name = dicomDataSet[DicomTags.PatientsName].GetString(0, "");
_birthdate = DicomConverter.GetDateTime(dicomDataSet[DicomTags.PatientsBirthDate].GetDateTime(0), dicomDataSet[DicomTags.PatientsBirthTime].GetDateTime(0));
_sex = DicomConverter.GetSex(dicomDataSet[DicomTags.PatientsSex].GetString(0, ""));
}
示例8: SetupMRWithUNVR
public void SetupMRWithUNVR(DicomAttributeCollection theSet)
{
SetupMR(theSet);
theSet[DicomTags.LossyImageCompressionMethod].SetStringValue("ISO_15444_1");
ConvertAttributeToUN(theSet, DicomTags.LossyImageCompressionMethod);
}
示例9: PixelDataInfo
public PixelDataInfo(DicomAttributeCollection dataset)
{
dataset.LoadDicomFields(this);
AspectRatio = PixelAspectRatio.FromString(dataset[DicomTags.PixelAspectRatio].ToString()) ?? new PixelAspectRatio(0, 0);
PixelSpacing = PixelSpacing.FromString(dataset[DicomTags.PixelSpacing].ToString()) ?? new PixelSpacing(0, 0);
ImagerPixelSpacing = PixelSpacing.FromString(dataset[DicomTags.ImagerPixelSpacing].ToString()) ?? new PixelSpacing(0, 0);
}
示例10: SelectBySeriesUid_Multiple
public void SelectBySeriesUid_Multiple()
{
Study study = CreateTestStudy1();
var criteria = new DicomAttributeCollection();
criteria[DicomTags.SeriesInstanceUid].SetStringValue("1.2.3.2\\1.2.3.3");
var filters = new SeriesPropertyFilters(criteria);
var results = filters.FilterResults(study.GetSeries().Cast<Series>());
Assert.AreEqual(2, results.Count());
}
示例11: PopulateInstance
/// <summary>
/// Populate at the IMAGE level a response message.
/// </summary>
/// <param name="request"></param>
/// <param name="response"></param>
/// <param name="tagList"></param>
/// <param name="theInstanceStream"></param>
private void PopulateInstance(DicomAttributeCollection request, DicomMessage response, List<uint> tagList,
InstanceXml theInstanceStream)
{
DicomAttributeCollection dataSet = response.DataSet;
dataSet[DicomTags.RetrieveAeTitle].SetStringValue(Partition.AeTitle);
dataSet[DicomTags.InstanceAvailability].SetStringValue("ONLINE");
DicomAttributeCollection sourceDataSet = theInstanceStream.Collection;
if (false == sourceDataSet.Contains(DicomTags.SpecificCharacterSet))
{
dataSet[DicomTags.SpecificCharacterSet].SetStringValue(sourceDataSet[DicomTags.SpecificCharacterSet].ToString());
dataSet.SpecificCharacterSet = sourceDataSet[DicomTags.SpecificCharacterSet].ToString(); // this will ensure the data is encoded using the specified character set
}
foreach (uint tag in tagList)
{
try
{
switch (tag)
{
case DicomTags.PatientId:
dataSet[DicomTags.PatientId].SetStringValue(request[DicomTags.PatientId].ToString());
break;
case DicomTags.StudyInstanceUid:
dataSet[DicomTags.StudyInstanceUid].SetStringValue(
request[DicomTags.StudyInstanceUid].ToString());
break;
case DicomTags.SeriesInstanceUid:
dataSet[DicomTags.SeriesInstanceUid].SetStringValue(
request[DicomTags.SeriesInstanceUid].ToString());
break;
case DicomTags.QueryRetrieveLevel:
dataSet[DicomTags.QueryRetrieveLevel].SetStringValue("IMAGE");
break;
default:
if (sourceDataSet.Contains(tag))
dataSet[tag] = sourceDataSet[tag].Copy();
else
dataSet[tag].SetNullValue();
break;
// Meta tags that should have not been in the RQ, but we've already set
case DicomTags.RetrieveAeTitle:
case DicomTags.InstanceAvailability:
case DicomTags.SpecificCharacterSet:
break;
}
}
catch (Exception e)
{
Platform.Log(LogLevel.Warn, e, "Unexpected error setting tag {0} in C-FIND-RSP",
dataSet[tag].Tag.ToString());
dataSet[tag].SetNullValue();
}
}
}
示例12: SetupMRSeries
public IList<DicomAttributeCollection> SetupMRSeries(int seriesCount, int instancesPerSeries, string studyInstanceUid)
{
List<DicomAttributeCollection> instanceList = new List<DicomAttributeCollection>();
DicomAttributeCollection baseCollection = new DicomAttributeCollection();
SetupMR(baseCollection);
baseCollection[DicomTags.StudyInstanceUid].SetStringValue(studyInstanceUid);
int acquisitionNumber = 1;
int instanceNumber = 100;
float positionX = -61.7564f;
float positionY = -212.04848f;
float positionZ = -99.6208f;
float orientation1 = 0.861f;
float orientation2 = 0.492f;
float orientation3 = 0.126f;
float orientation4 = -0.2965f;
for (int i = 0; i < seriesCount; i++)
{
string seriesInstanceUid = DicomUid.GenerateUid().UID;
for (int j = 0; j < instancesPerSeries; j++)
{
string sopInstanceUid = DicomUid.GenerateUid().UID;
DicomAttributeCollection instanceCollection = baseCollection.Copy();
instanceCollection[DicomTags.SopInstanceUid].SetStringValue(sopInstanceUid);
instanceCollection[DicomTags.SeriesInstanceUid].SetStringValue(seriesInstanceUid);
instanceCollection[DicomTags.SeriesNumber].SetStringValue((i + 1).ToString());
instanceCollection[DicomTags.SeriesDescription].SetStringValue("Series" + (i + 1).ToString());
instanceCollection[DicomTags.AcquisitionNumber].SetStringValue(acquisitionNumber++.ToString());
instanceCollection[DicomTags.InstanceNumber].SetStringValue(instanceNumber++.ToString());
instanceCollection[DicomTags.ImagePositionPatient].SetFloat32(0, positionX);
instanceCollection[DicomTags.ImagePositionPatient].SetFloat32(1, positionY);
instanceCollection[DicomTags.ImagePositionPatient].SetFloat32(2, positionZ);
positionY += 0.1f;
instanceCollection[DicomTags.ImageOrientationPatient].SetFloat32(0, orientation1);
instanceCollection[DicomTags.ImageOrientationPatient].SetFloat32(1, orientation2);
instanceCollection[DicomTags.ImageOrientationPatient].SetFloat32(2, orientation3);
instanceCollection[DicomTags.ImageOrientationPatient].SetFloat32(2, orientation4);
orientation2 += 0.01f;
instanceList.Add(instanceCollection);
}
}
return instanceList;
}
示例13: UpdateAttributeCollection
/// <summary>
/// Update an <see cref="DicomAttributeCollection"/> with pixel data related tags.
/// </summary>
/// <param name="dataset">The collection to update.</param>
public override void UpdateAttributeCollection(DicomAttributeCollection dataset)
{
if (dataset.Contains(DicomTags.NumberOfFrames) || NumberOfFrames > 1)
dataset[DicomTags.NumberOfFrames].SetInt32(0, NumberOfFrames);
if (dataset.Contains(DicomTags.PlanarConfiguration))
dataset[DicomTags.PlanarConfiguration].SetInt32(0, PlanarConfiguration);
if (dataset.Contains(DicomTags.LossyImageCompression) || LossyImageCompression.Length > 0)
dataset[DicomTags.LossyImageCompression].SetString(0, LossyImageCompression);
if (dataset.Contains(DicomTags.LossyImageCompressionRatio) || (LossyImageCompressionRatio != 1.0f && LossyImageCompressionRatio != 0.0f))
dataset[DicomTags.LossyImageCompressionRatio].SetFloat32(0, LossyImageCompressionRatio);
if (dataset.Contains(DicomTags.LossyImageCompressionMethod) || LossyImageCompressionMethod.Length > 0)
dataset[DicomTags.LossyImageCompressionMethod].SetString(0, LossyImageCompressionMethod);
if (dataset.Contains(DicomTags.DerivationDescription) || DerivationDescription.Length > 0)
{
string currentValue = dataset[DicomTags.DerivationDescription].ToString();
dataset[DicomTags.DerivationDescription].SetStringValue(DerivationDescription);
if (!currentValue.Equals(DerivationDescription))
{
DicomSequenceItem item = new DicomSequenceItem();
CodeSequenceMacro macro = new CodeSequenceMacro(item);
macro.CodeMeaning = "Lossy Compression";
macro.CodeValue = "113040";
macro.CodingSchemeDesignator = "DCM";
macro.ContextGroupVersion = new DateTime(2005, 8, 22);
macro.ContextIdentifier = "7203";
macro.MappingResource = "DCMR";
dataset[DicomTags.DerivationCodeSequence].AddSequenceItem(item);
}
}
if (dataset.Contains(DicomTags.RescaleSlope) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M)
dataset[DicomTags.RescaleSlope].SetString(0, RescaleSlope);
if (dataset.Contains(DicomTags.RescaleIntercept) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M)
dataset[DicomTags.RescaleIntercept].SetString(0, RescaleIntercept);
if (dataset.Contains(DicomTags.WindowCenter) || LinearVoiLuts.Count > 0)
Window.SetWindowCenterAndWidth(dataset, LinearVoiLuts);
//Remove the palette color lut, if the pixels were translated to RGB
if (dataset.Contains(DicomTags.RedPaletteColorLookupTableData)
&& dataset.Contains(DicomTags.BluePaletteColorLookupTableData)
&& dataset.Contains(DicomTags.GreenPaletteColorLookupTableData)
&& !HasPaletteColorLut)
{
dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableDescriptor);
dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableData);
dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableDescriptor);
dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableData);
dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableDescriptor);
dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableData);
}
dataset.SaveDicomFields(this);
dataset[DicomTags.PixelData] = _sq;
}
示例14: SelectBySeriesDescription_Equals
public void SelectBySeriesDescription_Equals()
{
Study study = CreateTestStudy1();
var criteria = new DicomAttributeCollection();
criteria[DicomTags.SeriesDescription].SetString(0, "Series1");
var filters = new SeriesPropertyFilters(criteria);
var results = filters.FilterResults(study.GetSeries().Cast<Series>());
Assert.AreEqual(1, results.Count());
}
示例15: SelectAllSops
public void SelectAllSops()
{
Study study = CreateTestStudy1();
var sops = study.GetSeries().First().GetSopInstances().Cast<SopInstance>().ToList();
var criteria = new DicomAttributeCollection();
var filters = new SopInstancePropertyFilters(criteria);
var results = filters.FilterResults(sops);
Assert.AreEqual(5, results.Count());
}