本文整理汇总了C#中IDicomAttributeProvider.TryGetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IDicomAttributeProvider.TryGetAttribute方法的具体用法?C# IDicomAttributeProvider.TryGetAttribute怎么用?C# IDicomAttributeProvider.TryGetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDicomAttributeProvider
的用法示例。
在下文中一共展示了IDicomAttributeProvider.TryGetAttribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StudyInformation
public StudyInformation(IDicomAttributeProvider attributeProvider)
{
if (attributeProvider[DicomTags.StudyId]!=null)
StudyId = attributeProvider[DicomTags.StudyId].ToString();
if (attributeProvider[DicomTags.AccessionNumber]!=null)
AccessionNumber = attributeProvider[DicomTags.AccessionNumber].ToString();
if (attributeProvider[DicomTags.StudyDate] != null )
StudyDate = attributeProvider[DicomTags.StudyDate].ToString();
if (attributeProvider[DicomTags.ModalitiesInStudy] != null)
Modalities = attributeProvider[DicomTags.ModalitiesInStudy].ToString();
if (attributeProvider[DicomTags.StudyInstanceUid] != null)
StudyInstanceUid = attributeProvider[DicomTags.StudyInstanceUid].ToString();
if (attributeProvider[DicomTags.StudyDescription] != null)
StudyDescription = attributeProvider[DicomTags.StudyDescription].ToString();
if (attributeProvider[DicomTags.ReferringPhysiciansName] != null)
ReferringPhysician = attributeProvider[DicomTags.ReferringPhysiciansName].ToString();
PatientInfo = new PatientInformation(attributeProvider);
DicomAttribute seriesUidAttr;
if (attributeProvider.TryGetAttribute(DicomTags.SeriesInstanceUid, out seriesUidAttr))
{
SeriesInformation series = new SeriesInformation(attributeProvider);
Add(series);
}
}
示例2: AddSequenceItem
/// <summary>
/// Adds a sequence item to temporarydictionary with the current offset.
/// </summary>
/// <param name="recordType">Type of the record.</param>
/// <param name="dataSet">The data set.</param>
/// <param name="tags">The tags.</param>
/// <returns>The newly created DirectoryRecord</returns>
/// <remarks>Tags are a dictionary of tags and optional values - if the value is null, then it will get the value from the specified dataset</remarks>
private static DirectoryRecordSequenceItem AddSequenceItem(DirectoryRecordType recordType, IDicomAttributeProvider dataSet, IDictionary<uint, object> tags)
{
DirectoryRecordSequenceItem dicomSequenceItem = new DirectoryRecordSequenceItem();
dicomSequenceItem[DicomTags.OffsetOfTheNextDirectoryRecord].Values = 0;
dicomSequenceItem[DicomTags.RecordInUseFlag].Values = 0xFFFF;
dicomSequenceItem[DicomTags.OffsetOfReferencedLowerLevelDirectoryEntity].Values = 0;
string recordName;
DirectoryRecordTypeDictionary.TryGetName(recordType, out recordName);
dicomSequenceItem[DicomTags.DirectoryRecordType].Values = recordName;
DicomAttribute charSetAttrib;
if (dataSet.TryGetAttribute(DicomTags.SpecificCharacterSet, out charSetAttrib))
dicomSequenceItem[DicomTags.SpecificCharacterSet] = charSetAttrib.Copy();
foreach (uint dicomTag in tags.Keys)
{
try
{
DicomTag dicomTag2 = DicomTagDictionary.GetDicomTag(dicomTag);
DicomAttribute attrib;
if (tags[dicomTag] != null)
{
dicomSequenceItem[dicomTag].Values = tags[dicomTag];
}
else if (dataSet.TryGetAttribute(dicomTag, out attrib))
{
dicomSequenceItem[dicomTag].Values = attrib.Values;
}
else
{
Platform.Log(LogLevel.Info,
"Cannot find dicomTag {0} for record type {1}", dicomTag2 != null ? dicomTag2.ToString() : dicomTag.ToString(), recordType);
}
}
catch (Exception ex)
{
Platform.Log(LogLevel.Error, ex, "Exception adding dicomTag {0} to directory record for record type {1}", dicomTag, recordType);
}
}
return dicomSequenceItem;
}
示例3: GetDateTimeAttributeValues
/// <summary>
/// Gets the date/time value of either a DICOM DT attribute, or a concatenation of a DT attribute and a TM attribute, formatted as a DT string.
/// </summary>
/// <param name="dicomAttributeProvider">The source DICOM data set.</param>
/// <param name="dicomDateTimeTag">The DT tag.</param>
/// <param name="dicomDateTag">The DA tag.</param>
/// <param name="dicomTimeTag">The TM tag.</param>
/// <returns></returns>
public static string GetDateTimeAttributeValues(IDicomAttributeProvider dicomAttributeProvider, uint dicomDateTimeTag, uint dicomDateTag, uint dicomTimeTag)
{
DicomAttribute dicomAttribute;
// if the DT attribute is present, return that value
if (dicomDateTimeTag != 0 && dicomAttributeProvider.TryGetAttribute(dicomDateTimeTag, out dicomAttribute) && !dicomAttribute.IsEmpty)
return dicomAttribute.GetString(0, string.Empty);
// check for presence of DA attribute, and return that concatenated with the TM attribute value if it exists
if (dicomDateTag != 0 && dicomAttributeProvider.TryGetAttribute(dicomDateTag, out dicomAttribute))
{
var daString = dicomAttribute.GetString(0, string.Empty);
if (!string.IsNullOrEmpty(daString))
{
string tmString = null;
if (dicomTimeTag != 0 && dicomAttributeProvider.TryGetAttribute(dicomTimeTag, out dicomAttribute) && !dicomAttribute.IsEmpty)
tmString = dicomAttribute.GetString(0, string.Empty);
return GetDateTimeAttributeValues(daString, tmString);
}
}
return string.Empty;
}
示例4: GetTimeAttributeValues
/// <summary>
/// Gets the time value of a DICOM DT attribute or a TM attribute, formatted as a TM string.
/// </summary>
/// <param name="dicomAttributeProvider">The source DICOM data set.</param>
/// <param name="dicomDateTimeTag">The DT tag.</param>
/// <param name="dicomTimeTag">The TM tag.</param>
/// <returns></returns>
public static string GetTimeAttributeValues(IDicomAttributeProvider dicomAttributeProvider, uint dicomDateTimeTag, uint dicomTimeTag)
{
DicomAttribute dicomAttribute;
// if the DT attribute is present, use the time component of that
if (dicomDateTimeTag != 0 && dicomAttributeProvider.TryGetAttribute(dicomDateTimeTag, out dicomAttribute) && !dicomAttribute.IsEmpty)
{
var dtString = dicomAttribute.GetString(0, string.Empty);
if (!string.IsNullOrEmpty(dtString)) return GetTimeAttributeValues(dtString);
}
// if the TM attribute is present, return that value
if (dicomTimeTag != 0 && dicomAttributeProvider.TryGetAttribute(dicomTimeTag, out dicomAttribute))
return dicomAttribute.GetString(0, string.Empty);
return string.Empty;
}
示例5: AddDicomFileValues
public void AddDicomFileValues(IDicomAttributeProvider dicomAttributes)
{
uint[] dicomTags = new uint[]
{
DicomTags.ImageType,
DicomTags.SopClassUid,
DicomTags.SopInstanceUid,
DicomTags.StudyInstanceUid,
DicomTags.SamplesPerPixel,
DicomTags.PhotometricInterpretation,
DicomTags.NumberOfFrames,
DicomTags.Rows,
DicomTags.Columns,
DicomTags.BitsAllocated,
DicomTags.BitsStored,
DicomTags.HighBit,
DicomTags.PixelRepresentation,
DicomTags.SmallestImagePixelValue,
DicomTags.LargestImagePixelValue,
DicomTags.WindowCenter,
DicomTags.WindowWidth,
DicomTags.PixelData
};
foreach (uint dicomTag in dicomTags)
{
try
{
DicomAttribute dicomAttribute;
if (dicomAttributes.TryGetAttribute(dicomTag, out dicomAttribute))
DicomAttributeProvider[dicomTag].Values = dicomAttribute.Values;
}
catch (Exception ex)
{
Platform.Log(LogLevel.Error, ex, "Exception adding dicom tag value for uint: " + dicomTag);
throw;
}
}
}
示例6: TryGetAttributeSQ
private static bool TryGetAttributeSQ(IDicomAttributeProvider provider, uint tag, out DicomAttributeSQ dicomAttributeSQ)
{
DicomAttribute dicomAttribute;
if (provider.TryGetAttribute(tag, out dicomAttribute))
{
dicomAttributeSQ = dicomAttribute as DicomAttributeSQ;
return dicomAttributeSQ != null;
}
dicomAttributeSQ = null;
return false;
}
示例7: FormatString
private static string FormatString(IDicomAttributeProvider frame, uint dicomTag, string unused)
{
DicomAttribute attribute;
bool tagExists = frame.TryGetAttribute(dicomTag, out attribute) && !attribute.IsEmpty;
if (tagExists)
return attribute.ToString();
return "";
}
示例8: GetPixelSpacingAttributeInfo
private static string GetPixelSpacingAttributeInfo(IDicomAttributeProvider sopDataSource)
{
var modality = sopDataSource[DicomTags.Modality].ToString();
var imagerPixelSpacing = "*";
var pixelSpacing = "*";
var pixelSpacingCalibrationType = "*";
var pixelSpacingCalibrationDescription = "*";
var estimatedRadiographicMagnificationFactor = "*";
DicomAttribute attribute;
if (sopDataSource.TryGetAttribute(DicomTags.ImagerPixelSpacing, out attribute))
imagerPixelSpacing = attribute.ToString();
if (sopDataSource.TryGetAttribute(DicomTags.PixelSpacing, out attribute))
pixelSpacing = attribute.ToString();
if (sopDataSource.TryGetAttribute(DicomTags.PixelSpacingCalibrationType, out attribute))
pixelSpacingCalibrationType = attribute.ToString();
if (sopDataSource.TryGetAttribute(DicomTags.PixelSpacingCalibrationDescription, out attribute))
pixelSpacingCalibrationDescription = attribute.ToString();
if (sopDataSource.TryGetAttribute(DicomTags.EstimatedRadiographicMagnificationFactor, out attribute))
estimatedRadiographicMagnificationFactor = attribute.ToString();
return string.Format("[{0}] ImagerPixSpac={1} PixSpac={2} PixSpacCalType={3} PixSpacCalDesc={4} EstRadMagFac={5}", modality, imagerPixelSpacing, pixelSpacing, pixelSpacingCalibrationType, pixelSpacingCalibrationDescription, estimatedRadiographicMagnificationFactor);
}