本文整理汇总了C#中DicomAttributeCollection.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# DicomAttributeCollection.Contains方法的具体用法?C# DicomAttributeCollection.Contains怎么用?C# DicomAttributeCollection.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DicomAttributeCollection
的用法示例。
在下文中一共展示了DicomAttributeCollection.Contains方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: DicomFile
/// <summary>
/// Create a DicomFile instance from existing MetaInfo and DataSet.
/// </summary>
/// <param name="filename">The name for the file.</param>
/// <param name="metaInfo">A <see cref="DicomAttributeCollection"/> for the MetaInfo (group 0x0002 attributes).</param>
/// <param name="dataSet">A <see cref="DicomAttributeCollection"/> for the DataSet.</param>
public DicomFile(String filename, DicomAttributeCollection metaInfo, DicomAttributeCollection dataSet)
{
MetaInfo = metaInfo;
DataSet = dataSet;
_filename = filename;
if (!MetaInfo.Contains(DicomTags.ImplementationVersionName))
ImplementationVersionName = DicomImplementation.Version;
if (!MetaInfo.Contains(DicomTags.ImplementationClassUid))
ImplementationClassUid = DicomImplementation.ClassUID.UID;
// If the meta info doesn't already specify the transfer syntax, give it the default transfer syntax of ELE
if (string.IsNullOrEmpty(MetaInfo[DicomTags.TransferSyntaxUid].ToString()))
MetaInfo[DicomTags.TransferSyntaxUid].SetStringValue(TransferSyntax.ExplicitVrLittleEndian.UidString);
if (!MetaInfo.Contains(DicomTags.FileMetaInformationVersion))
MetaInfo[DicomTags.FileMetaInformationVersion].Values = new byte[] { 0x00, 0x01 };
}
示例3: UpdateAttributeCollection
/// <summary>
/// Update a <see cref="DicomAttributeCollection"/> with the pixel data contained
/// within this object and also update pixel data related tags.
/// </summary>
/// <remarks>
/// This method will replace the pixel data attribute in <paramref name="dataset"/>
/// and update other pixel data related tags within the collection.
/// </remarks>
/// <param name="dataset">The collection to update.</param>
public override void UpdateAttributeCollection(DicomAttributeCollection dataset)
{
dataset.SaveDicomFields(this);
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.LossyImageCompressionRatio))
dataset[DicomTags.LossyImageCompressionRatio].SetFloat32(0, LossyImageCompressionRatio);
if (dataset.Contains(DicomTags.LossyImageCompressionMethod))
dataset[DicomTags.LossyImageCompressionMethod].SetString(0, LossyImageCompressionMethod);
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);
dataset[DicomTags.PixelData] = _pd;
//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);
}
UpdatePixelDataAttribute();
}
示例4: SearchAttributeSet
private bool SearchAttributeSet(DicomAttributeCollection set, string filename, SearchTypes searchType)
{
if (searchType == SearchTypes.PrivateSequence)
{
foreach (DicomAttribute attrib in set)
{
if (attrib.Tag.IsPrivate && attrib.Tag.VR.Equals(DicomVr.SQvr))
{
Platform.Log(LogLevel.Info, "Found file with private SQ: {0}", filename);
return true;
}
if (!attrib.Tag.VR.Equals(DicomVr.SQvr) || attrib.IsNull) continue;
// Recursive search
foreach (DicomSequenceItem item in (DicomSequenceItem[]) attrib.Values)
{
SearchAttributeSet(item, filename, searchType);
}
}
}
else if (searchType == SearchTypes.Overlay)
{
foreach (DicomAttribute attrib in set)
{
if ((attrib.Tag.TagValue & 0xFF000000) == 0x60000000)
{
Platform.Log(LogLevel.Info, "Found embedded overlay in file: {0}", filename);
return true;
}
if (attrib.Tag.TagValue > 0x70000000)
return false;
}
}
else if (searchType == SearchTypes.PaletteColor)
{
if (set.Contains(DicomTags.PhotometricInterpretation))
{
if (set[DicomTags.PhotometricInterpretation].ToString().Equals("PALETTE COLOR"))
return true;
}
return false;
}
return false;
}
示例5: SetupKoForImage
public void SetupKoForImage(DicomAttributeCollection theSet, DicomAttributeCollection source)
{
theSet[DicomTags.SpecificCharacterSet] = source[DicomTags.SpecificCharacterSet].Copy();
theSet[DicomTags.ImageType].SetStringValue("ORIGINAL\\PRIMARY\\OTHER\\M\\FFE");
theSet[DicomTags.InstanceCreationDate].SetStringValue(DateParser.ToDicomString(DateTime.Now));
theSet[DicomTags.InstanceCreationTime].SetStringValue(TimeParser.ToDicomString(DateTime.Now));
theSet[DicomTags.SopClassUid].SetStringValue(SopClass.KeyObjectSelectionDocumentStorageUid);
theSet[DicomTags.SopInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);
theSet[DicomTags.StudyDate] = source[DicomTags.StudyDate].Copy();
theSet[DicomTags.StudyTime] = source[DicomTags.StudyTime].Copy();
theSet[DicomTags.SeriesDate].SetStringValue(DateParser.ToDicomString(DateTime.Now));
theSet[DicomTags.SeriesTime].SetStringValue(TimeParser.ToDicomString(DateTime.Now));
theSet[DicomTags.ContentDate].SetStringValue(DateParser.ToDicomString(DateTime.Now));
theSet[DicomTags.ContentTime].SetStringValue(TimeParser.ToDicomString(DateTime.Now));
theSet[DicomTags.AccessionNumber] = source[DicomTags.AccessionNumber].Copy();
theSet[DicomTags.Modality].SetStringValue("KO");
theSet[DicomTags.Manufacturer].SetStringValue("ClearCanvas");
theSet[DicomTags.ManufacturersModelName].SetNullValue();
theSet[DicomTags.InstitutionName] = source[DicomTags.InstitutionName].Copy();
theSet[DicomTags.ReferringPhysiciansName] = source[DicomTags.ReferringPhysiciansName].Copy();
theSet[DicomTags.StudyDescription] = source[DicomTags.StudyDescription].Copy();
theSet[DicomTags.SeriesDescription].SetStringValue("Teaching Series");
theSet[DicomTags.PatientsName] = source[DicomTags.PatientsName].Copy();
theSet[DicomTags.PatientId] = source[DicomTags.PatientId].Copy();
theSet[DicomTags.PatientsBirthDate] = source[DicomTags.PatientsBirthDate].Copy();
theSet[DicomTags.PatientsSex] = source[DicomTags.PatientsSex].Copy();
theSet[DicomTags.PatientsWeight] = source[DicomTags.PatientsWeight].Copy();
theSet[DicomTags.StudyInstanceUid] = source[DicomTags.StudyInstanceUid].Copy();
theSet[DicomTags.SeriesInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);
theSet[DicomTags.StudyId] = source[DicomTags.StudyId].Copy();
theSet[DicomTags.SeriesNumber].SetStringValue("99");
theSet[DicomTags.InstanceNumber].SetStringValue("1");
theSet[DicomTags.ValueType].SetStringValue("CONTAINER");
DicomSequenceItem item = new DicomSequenceItem();
theSet[DicomTags.ConceptNameCodeSequence].AddSequenceItem(item);
item[DicomTags.CodeValue].SetStringValue("113004");
item[DicomTags.CodingSchemeDesignator].SetStringValue("DCM");
item[DicomTags.CodeMeaning].SetStringValue("For Teaching");
theSet[DicomTags.ContinuityOfContent].SetStringValue("SEPARATE");
item = new DicomSequenceItem();
theSet[DicomTags.CurrentRequestedProcedureEvidenceSequence].AddSequenceItem(item);
DicomSequenceItem refSeriesItem = new DicomSequenceItem();
item[DicomTags.ReferencedSeriesSequence].AddSequenceItem(refSeriesItem);
refSeriesItem[DicomTags.SeriesInstanceUid] = source[DicomTags.SeriesInstanceUid].Copy();
DicomSequenceItem refSopItem = new DicomSequenceItem();
refSeriesItem[DicomTags.ReferencedSopSequence].AddSequenceItem(refSopItem);
refSopItem[DicomTags.ReferencedSopClassUid].SetStringValue(source[DicomTags.SopClassUid].ToString());
refSopItem[DicomTags.ReferencedSopInstanceUid].SetStringValue(source[DicomTags.SopInstanceUid].ToString());
item[DicomTags.StudyInstanceUid] = source[DicomTags.StudyInstanceUid].Copy();
item[DicomTags.RequestedProcedureId].SetStringValue("MR2R1234");
item[DicomTags.ScheduledProcedureStepId].SetStringValue("MR2S1234");
theSet[DicomTags.IdenticalDocumentsSequence].AddSequenceItem(new DicomSequenceItem(item.Copy(),true,true,true));
DicomSequenceItem contentItem = new DicomSequenceItem();
theSet[DicomTags.ContentSequence].AddSequenceItem(contentItem);
contentItem[DicomTags.RelationshipType].SetStringValue("CONTAINS");
contentItem[DicomTags.ValueType].SetStringValue("IMAGE");
refSopItem = new DicomSequenceItem();
contentItem[DicomTags.ReferencedSopSequence].AddSequenceItem(refSopItem);
refSopItem[DicomTags.ReferencedSopClassUid].SetStringValue(source[DicomTags.SopClassUid].ToString());
refSopItem[DicomTags.ReferencedSopInstanceUid].SetStringValue(source[DicomTags.SopInstanceUid].ToString());
if (source.Contains(DicomTags.NumberOfFrames))
refSopItem[DicomTags.ReferencedFrameNumber].SetStringValue("1");
else
refSopItem[DicomTags.ReferencedFrameNumber].SetNullValue();
refSopItem[DicomTags.ReferencedSegmentNumber].SetNullValue();
contentItem = new DicomSequenceItem();
theSet[DicomTags.ContentSequence].AddSequenceItem(contentItem);
contentItem[DicomTags.RelationshipType].SetStringValue("CONTAINS");
contentItem[DicomTags.TextValue].SetStringValue("Teaching Images");
item = new DicomSequenceItem();
contentItem[DicomTags.ConceptNameCodeSequence].AddSequenceItem(item);
item[DicomTags.CodeValue].SetStringValue("113012");
item[DicomTags.CodingSchemeDesignator].SetStringValue("DCM");
item[DicomTags.CodeMeaning].SetStringValue("Key Object Description");
}
示例6: DicomPixelData
/// <summary>
/// Constructor.
/// </summary>
/// <param name="collection"></param>
protected DicomPixelData(DicomAttributeCollection collection)
{
collection.LoadDicomFields(this);
SopClass = SopClass.GetSopClass(collection[DicomTags.SopClassUid].GetString(0, string.Empty));
if (collection.Contains(DicomTags.NumberOfFrames))
NumberOfFrames = collection[DicomTags.NumberOfFrames].GetInt32(0, 1);
if (collection.Contains(DicomTags.PlanarConfiguration))
PlanarConfiguration = collection[DicomTags.PlanarConfiguration].GetUInt16(0, 1);
if (collection.Contains(DicomTags.LossyImageCompression))
LossyImageCompression = collection[DicomTags.LossyImageCompression].GetString(0, string.Empty);
if (collection.Contains(DicomTags.LossyImageCompressionRatio))
LossyImageCompressionRatio = collection[DicomTags.LossyImageCompressionRatio].GetFloat32(0, 1.0f);
if (collection.Contains(DicomTags.LossyImageCompressionMethod))
LossyImageCompressionMethod = collection[DicomTags.LossyImageCompressionMethod].GetString(0, string.Empty);
if (collection.Contains(DicomTags.DerivationDescription))
DerivationDescription = collection[DicomTags.DerivationDescription].GetString(0, string.Empty);
if (collection.Contains(DicomTags.RescaleSlope))
RescaleSlope = collection[DicomTags.RescaleSlope].ToString();
if (collection.Contains(DicomTags.RescaleIntercept))
RescaleIntercept = collection[DicomTags.RescaleIntercept].ToString();
if (collection.Contains(DicomTags.ModalityLutSequence))
{
DicomAttribute attrib = collection[DicomTags.ModalityLutSequence];
_hasDataModalityLut = !attrib.IsEmpty && !attrib.IsNull;
}
_linearVoiLuts = Window.GetWindowCenterAndWidth(collection);
if (collection.Contains(DicomTags.VoiLutSequence))
{
DicomAttribute attrib = collection[DicomTags.VoiLutSequence];
_hasDataVoiLuts = !attrib.IsEmpty && !attrib.IsNull;
}
if (PhotometricInterpretation.Equals(Iod.PhotometricInterpretation.PaletteColor.Code) && collection.Contains(DicomTags.RedPaletteColorLookupTableDescriptor))
{
_paletteColorLut = PaletteColorLut.Create(collection);
_hasPaletteColorLut = true;
}
}
示例7: Query
protected static IList<DicomAttributeCollection> Query(IApplicationEntity server, DicomAttributeCollection requestCollection)
{
//special case code for ModalitiesInStudy. An IStudyFinder must accept a multi-valued
//string for ModalitiesInStudy (e.g. "MR\\CT") and process it appropriately for the
//datasource that is being queried. In this case (Dicom) does not allow multiple
//query keys, so we have to execute one query per modality specified in the
//ModalitiesInStudy query item.
List<string> modalityFilters = new List<string>();
if (requestCollection.Contains(DicomTags.ModalitiesInStudy))
{
string modalityFilterString = requestCollection[DicomTags.ModalitiesInStudy].ToString();
if (!String.IsNullOrEmpty(modalityFilterString))
modalityFilters.AddRange(modalityFilterString.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries));
if (modalityFilters.Count == 0)
modalityFilters.Add(""); //make sure there is at least one filter, the default.
}
SortedList<string, DicomAttributeCollection> resultsByStudy = new SortedList<string, DicomAttributeCollection>();
string combinedFilter = requestCollection[DicomTags.ModalitiesInStudy];
try
{
foreach (string modalityFilter in modalityFilters)
{
using (StudyRootFindScu scu = new StudyRootFindScu())
{
requestCollection[DicomTags.ModalitiesInStudy].SetStringValue(modalityFilter);
IList<DicomAttributeCollection> results = scu.Find(
DicomServer.AETitle, server.AETitle, server.ScpParameters.HostName, server.ScpParameters.Port, requestCollection);
scu.Join(new TimeSpan(0, 0, 0, 0, 1000));
if(scu.Status == ScuOperationStatus.Canceled)
{
String message = String.Format(SR.MessageFormatRemoteServerCancelledFind,
scu.FailureDescription ?? "no failure description provided");
throw new DicomException(message);
}
if (scu.Status == ScuOperationStatus.ConnectFailed)
{
String message = String.Format(SR.MessageFormatConnectionFailed,
scu.FailureDescription ?? "no failure description provided");
throw new DicomException(message);
}
else if (scu.Status == ScuOperationStatus.AssociationRejected)
{
String message = String.Format(SR.MessageFormatAssociationRejected,
scu.FailureDescription ?? "no failure description provided");
throw new DicomException(message);
}
if (scu.Status == ScuOperationStatus.Failed)
{
String message = String.Format(SR.MessageFormatQueryOperationFailed,
scu.FailureDescription ?? "no failure description provided");
throw new DicomException(message);
}
if (scu.Status == ScuOperationStatus.TimeoutExpired)
{
String message = String.Format(SR.MessageFormatConnectTimeoutExpired,
scu.FailureDescription ?? "no failure description provided");
throw new DicomException(message);
}
if (scu.Status == ScuOperationStatus.NetworkError)
{
throw new DicomException(SR.MessageUnexpectedNetworkError);
}
if (scu.Status == ScuOperationStatus.UnexpectedMessage)
{
throw new DicomException(SR.MessageUnexpectedMessage);
}
//if this function returns true, it means that studies came back whose
//modalities did not match the filter, meaning that filtering on
//ModalitiesInStudy is not supported by that server.
if (FilterResultsByModality(results, resultsByStudy, modalityFilter))
break;
}
}
return new List<DicomAttributeCollection>(resultsByStudy.Values);
}
finally
{
//for consistencies sake, put the original filter back.
requestCollection[DicomTags.ModalitiesInStudy].SetStringValue(combinedFilter);
}
}
示例8: LoadSourceImageInfo
private static IList<SourceImageInfo> LoadSourceImageInfo(DicomAttributeCollection collection)
{
if (collection.Contains(DicomTags.SourceImageSequence))
{
DicomAttributeSQ sq = collection[DicomTags.SourceImageSequence] as DicomAttributeSQ;
IList<SourceImageInfo> list = new List<SourceImageInfo>();
foreach(DicomSequenceItem item in sq.Values as DicomSequenceItem[])
{
list.Add(new SourceImageInfo()
{SopInstanceUid = item[DicomTags.ReferencedSopInstanceUid].ToString()});
}
return list;
}
return null;
}
示例9: ValidateRemovedTags
private static void ValidateRemovedTags(DicomAttributeCollection dataset)
{
if (dataset.Contains(DicomTags.InstanceCreatorUid))
throw new Exception("InstanceCreatorUid");
if (dataset.Contains(DicomTags.StorageMediaFileSetUid))
throw new Exception("StorageMediaFileSetUid");
if (dataset.Contains(DicomTags.RequestAttributesSequence))
throw new Exception("RequestAttributesSequence");
DicomSequenceItem item = ((DicomSequenceItem[])dataset[DicomTags.ReferencedImageSequence].Values)[0];
if (item.Contains(DicomTags.InstanceCreatorUid))
throw new Exception("InstanceCreatorUid");
if (item.Contains(DicomTags.RequestAttributesSequence))
throw new Exception("RequestAttributesSequence");
}