public override bool TryGetAttribute(DicomTag tag, out DicomAttribute attribute) { lock (SyncLock) { // the instance dataset should always override the prototype values from the sliceset return DataSet.TryGetAttribute(tag, out attribute) || Slice.TryGetAttribute(tag, out attribute); } }
public override bool TryGetAttribute(DicomTag tag, out DicomAttribute attribute) { lock (SyncLock) { if (NeedFullHeader(tag.TagValue)) GetFullHeader(); return base.TryGetAttribute(tag, out attribute); } }
public bool TryGetAttribute(uint tag, out DicomAttribute attribute) { if (this[tag] == null) { attribute = null; return false; } attribute = this[tag]; return true; }
public DicomEditorTag(DicomAttribute attribute, DicomEditorTag parentTag, int nestingLevel) { _attribute = attribute; _group = _attribute.Tag.Group; _element = _attribute.Tag.Element; _tagName = _attribute.Tag.Name; _parentTag = parentTag; _nestingLevel = nestingLevel; _postitionOrdinal = 0; }
public override bool TryGetAttribute(DicomTag tag, out DicomAttribute attribute) { lock (SyncLock) { if (_sop.IsStoredTag(tag)) { attribute = _sop[tag]; if (!attribute.IsEmpty) return true; } return base.TryGetAttribute(tag, out attribute); } }
/// <summary> /// Contructor from a <see cref="DicomCompressedPixelData"/> instance. /// </summary> /// <param name="compressedPixelData"></param> public DicomUncompressedPixelData(DicomCompressedPixelData compressedPixelData) : base(compressedPixelData) { if (BitsAllocated > 8) { _pd = new DicomAttributeOW(DicomTags.PixelData); } else { var pdTag = DicomTagDictionary.GetDicomTag(DicomTags.PixelData); var obTag = new DicomTag(DicomTags.PixelData, pdTag.Name, pdTag.VariableName, DicomVr.OBvr, pdTag.MultiVR, pdTag.VMLow, pdTag.VMHigh, pdTag.Retired); _pd = new DicomAttributeOB(obTag); } InitializeFrameData(this, _pd); }
private void InitializeFrameData(DicomUncompressedPixelData owner, DicomAttribute pixelDataAttribute) { var obAttrib = pixelDataAttribute as DicomAttributeOB; if (obAttrib != null && obAttrib.StreamLength > 0) { for (var n = 0; n < NumberOfFrames; ++n) { _fd.Add(new FrameDataOB(owner, obAttrib, n)); } } var owAttrib = pixelDataAttribute as DicomAttributeOW; if (owAttrib != null && owAttrib.StreamLength > 0) { for (var n = 0; n < NumberOfFrames; ++n) { _fd.Add(new FrameDataOW(owner, owAttrib, n)); } } }
/// <summary> /// Constructor from a <see cref="DicomMessageBase"/> instance. /// </summary> /// <param name="message"></param> public DicomUncompressedPixelData(DicomMessageBase message) : base(message) { _pd = message.DataSet[DicomTags.PixelData]; }
bool IDicomAttributeProvider.TryGetAttribute(uint dicomTag, out DicomAttribute dicomAttribute) { return _parentImageSop.TryGetFrameAttribute(_frameNumber, dicomTag, out dicomAttribute); }
public override bool TryGetAttribute(uint tag, out DicomAttribute attribute) { return _fusionHeaders.TryGetAttribute(tag, out attribute) || _realSopDataSource.TryGetAttribute(tag, out attribute); }
/// <summary> /// Creates an instance of <see cref="SetTagCommand"/> that can be used to update the specified dicom tag with the specified value /// </summary> /// <remarks> /// <see cref="BaseImageLevelUpdateCommand.File"/> must be set prior to <see cref="BaseImageLevelUpdateCommand.OnExecute"></see> /// </remarks> public SetTagCommand(DicomAttribute attribute, string newValue) : this(attribute.Tag.TagValue, String.Empty, newValue) { }
public override bool TryGetAttribute(uint tag, out DicomAttribute attribute) { lock (base.SyncLock) { if (_volumeReference.Volume.DataSet.TryGetAttribute(tag, out attribute)) return true; return _instanceDataSet.TryGetAttribute(tag, out attribute); } }
/// <summary> /// Initializes a <see cref="DicomUncompressedPixelData"/> from the attributes in a DICOM file/message. /// </summary> /// <param name="dicomMessage">A DICOM file/message from which to initialize the properties of the <see cref="DicomUncompressedPixelData"/>.</param> public DicomUncompressedPixelData(DicomMessageBase dicomMessage) : base(dicomMessage) { _pd = dicomMessage.DataSet[DicomTags.PixelData]; InitializeFrameData(this, _pd); }
public bool TryGetAttribute(DicomTag tag, out DicomAttribute attribute) { return TryGetAttribute(tag.TagValue, out attribute); }
/// <summary> /// Attempts to get the attribute specified by <paramref name="tag"/>. /// </summary> public override bool TryGetAttribute(uint tag, out DicomAttribute attribute) { lock (SyncLock) { Load(); if (_sourceMessage.DataSet.TryGetAttribute(tag, out attribute)) return true; return _sourceMessage.MetaInfo.TryGetAttribute(tag, out attribute); } }
/// <summary> /// Internal constructor used when copying an attribute from a pre-existing attribute instance. /// </summary> /// <param name="attrib">The attribute that is being copied.</param> internal DicomAttribute(DicomAttribute attrib) { Tag = attrib.Tag; _valueCount = attrib.Count; _length = attrib._length; }
public bool TryGetAttribute(uint tag, out DicomAttribute attribute) { lock (_syncRoot) { return _collection.TryGetAttribute(tag, out attribute); } }
public DicomEditorTag(DicomAttribute attribute) : this(attribute, null, 0) { }
public override bool TryGetAttribute(uint tag, out DicomAttribute attribute) { return _dataset.TryGetAttribute(tag, out attribute); }
/// <summary> /// Constructor from an <see cref="DicomAttributeCollection"/> instance. /// </summary> /// <param name="collection"></param> public DicomUncompressedPixelData(DicomAttributeCollection collection) : base(collection) { _pd = collection[DicomTags.PixelData]; }
public override bool TryGetAttribute(uint tag, out DicomAttribute attribute) { lock (SyncLock) { if (NeedFullHeader(tag)) LoadFullHeader(); return base.TryGetAttribute(tag, out attribute); } }
/// <summary> /// Contructor from a <see cref="DicomCompressedPixelData"/> instance. /// </summary> /// <param name="pd"></param> public DicomUncompressedPixelData(DicomCompressedPixelData pd) : base(pd) { if (BitsAllocated > 8) _pd = new DicomAttributeOW(DicomTags.PixelData); else { DicomTag pdTag = DicomTagDictionary.GetDicomTag(DicomTags.PixelData); _pd = new DicomAttributeOB( new DicomTag(DicomTags.PixelData, pdTag.Name, pdTag.VariableName, DicomVr.OBvr, pdTag.MultiVR, pdTag.VMLow, pdTag.VMHigh, pdTag.Retired)); } }
public void ConvertPaletteColorToRgb() { Platform.CheckTrue(PhotometricInterpretation.Equals("PALETTE COLOR"), "Photometric Interpretation Palette Color Check"); List<FrameData> frames = new List<FrameData>(); for (int i = 0; i < NumberOfFrames; i++) { byte[] currentFrame = GetFrame(i); byte[] newFrame = new byte[UncompressedFrameSize*3]; PaletteColorToRgb(BitsAllocated, IsSigned, currentFrame, newFrame, PaletteColorLut); frames.Add(new FrameDataBytes(this, newFrame, false)); } // change the Pixel Data attribute so we don't affect the original _pd = _pd.Tag.VR.CreateDicomAttribute(_pd.Tag); _fd.Clear(); _fd.AddRange(frames); SamplesPerPixel = 3; PhotometricInterpretation = "RGB"; PlanarConfiguration = 0; HasPaletteColorLut = false; }
public void ConvertPaletteColorToRgb() { Platform.CheckTrue(PhotometricInterpretation.Equals("PALETTE COLOR"),"Photometric Interpretation Palette Color Check"); List<byte[]> frames = new List<byte[]>(); for (int i=0; i < NumberOfFrames;i++) { byte[] currentFrame = GetFrame(i); byte[] newFrame = new byte[UncompressedFrameSize * 3]; PaletteColorToRgb(BitsAllocated, IsSigned, currentFrame, newFrame, PaletteColorLut); frames.Add(newFrame); } // Dereference the current pixel data _ms = null; _pd = null; foreach (byte[] frame in frames) AppendFrame(frame); SamplesPerPixel = 3; PhotometricInterpretation = "RGB"; PlanarConfiguration = 0; HasPaletteColorLut = false; }
/// <summary> /// Constructor from an <see cref="DicomAttributeCollection"/> instance. /// </summary> /// <param name="collection"></param> public DicomUncompressedPixelData(DicomAttributeCollection collection) : base(collection) { _pd = collection[DicomTags.PixelData]; InitializeFrameData(this, _pd); }
public bool TryGetAttribute(DicomTag tag, out DicomAttribute attribute) { return _collection.TryGetAttribute(tag, out attribute); }
private void InitializeFrameData(DicomUncompressedPixelData owner, DicomAttribute pixelDataAttribute) { var obAttrib = pixelDataAttribute as DicomAttributeOB; if (obAttrib != null && obAttrib.StreamLength > 0) { for (var n = 0; n < NumberOfFrames; ++n) _fd.Add(new FrameDataOB(owner, obAttrib, n)); } var owAttrib = pixelDataAttribute as DicomAttributeOW; if (owAttrib != null && owAttrib.StreamLength > 0) { for (var n = 0; n < NumberOfFrames; ++n) _fd.Add(new FrameDataOW(owner, owAttrib, n)); } }
public override sealed bool TryGetAttribute(uint tag, out DicomAttribute dicomAttribute) { return TryGetFrameAttribute(-1, tag, out dicomAttribute); }
/// <summary> /// Makes sure the new value can be encoded with the specific character set in the dicom file header. If necessary and if it's allowed, /// convert the dicom file to use unicode (ISO_IR 192). /// </summary> /// <param name="file"></param> /// <param name="attr"></param> /// <param name="desiredValue"></param> /// <exception cref="DicomCharacterSetException">Thrown if unicode is not allowed or (for some reason) the value cannot be encoded using unicode</exception> private void EnsureCharacterSetIsGood(DicomFile file, DicomAttribute attr, string desiredValue) { var encodedValue = attr.GetEncodedString(file.TransferSyntax, file.DataSet.SpecificCharacterSet); var diff = Diff(attr.Tag, encodedValue, desiredValue); if (diff < 0) { // it's all good return; } // The current specific character set does not support the new value. Try to encode it using unicode (if it's configured) if (!CanSaveInUnicode) { Platform.Log(LogLevel.Debug, "'{0}' cannot be encoded using current Character Set and Unicode is not allowed. Aborting..", desiredValue); //Throw DicomCharacterSetException var characterSetDescriptions = SpecificCharacterSetParser.GetCharacterSetInfoDescriptions(file.DataSet.SpecificCharacterSet); string instanceNumber = file.DataSet[DicomTags.InstanceNumber].ToString(); string instanceUid = file.DataSet[DicomTags.SopInstanceUid].ToString(); char badChar = diff >= desiredValue.Length ? desiredValue[desiredValue.Length - 1] : desiredValue[diff]; var error = string.Format("SOP {5}\n\nCannot set {0} to {1}. Character {2} is not covered by character set {3} [{4}].", UpdateEntry.TagPath.Tag.Name, desiredValue, badChar, file.DataSet.SpecificCharacterSet, StringUtilities.Combine(characterSetDescriptions, ","), string.Format("#{0} [{1}]", instanceNumber, instanceUid) ); Platform.Log(LogLevel.Error, error); throw new DicomCharacterSetException(UpdateEntry.TagPath.Tag.TagValue, file.DataSet.SpecificCharacterSet, desiredValue, error); } // The attribute value has been set, only need to set specific character set to unicode const string newSpecificCharacterSet = "ISO_IR 192"; // Before we commit the change, let's verify again if that's good. Platform.Log(LogLevel.Debug, "'{0}'cannot be encoded using current Character Set and Unicode is allowed. Checking for value consistency if switching to Unicode encoding", desiredValue); encodedValue = attr.GetEncodedString(file.TransferSyntax, newSpecificCharacterSet); diff = Diff(attr.Tag, encodedValue, desiredValue); if (diff >= 0) { // not ok? var characterSetDescriptions = SpecificCharacterSetParser.GetCharacterSetInfoDescriptions(file.DataSet.SpecificCharacterSet); string instanceNumber = file.DataSet[DicomTags.InstanceNumber].ToString(); string instanceUid = file.DataSet[DicomTags.SopInstanceUid].ToString(); char badChar = diff >= desiredValue.Length ? desiredValue[desiredValue.Length - 1] : desiredValue[diff]; var error = string.Format("SOP {5}\n\nCannot set {0} to {1}. Character {2} is not covered by character set {3} [{4}]. Attempt to use {6} did not solve the problem.", UpdateEntry.TagPath.Tag.Name, desiredValue, badChar, file.DataSet.SpecificCharacterSet, StringUtilities.Combine(characterSetDescriptions, ","), string.Format("#{0} [{1}]", instanceNumber, instanceUid), newSpecificCharacterSet ); Platform.Log(LogLevel.Error, error); throw new DicomCharacterSetException(UpdateEntry.TagPath.Tag.TagValue, file.DataSet.SpecificCharacterSet, desiredValue, error); } Platform.Log(LogLevel.Debug, "Specific Character Set for SOP {0} is now changed to unicode", file.MediaStorageSopInstanceUid); file.DataSet.SpecificCharacterSet = newSpecificCharacterSet; file.DataSet[DicomTags.SpecificCharacterSet].SetStringValue(newSpecificCharacterSet); }
/// <summary> /// Gets a specific DICOM attribute for the specified frame. /// </summary> /// <remarks> /// <see cref="DicomAttribute"/>s returned by this method should be considered /// read-only and should not be modified in any way. /// </remarks> /// <param name="frameNumber">The number of the frame for which the attribute is to be retrieved (1-based index).</param> /// <param name="tag">The DICOM tag to retrieve.</param> /// <param name="dicomAttribute">Returns the requested <see cref="DicomAttribute"/>, or NULL if it was not found.</param> /// <returns>Returns TRUE if the requested attribute was found; FALSE otherwise.</returns> public virtual bool TryGetFrameAttribute(int frameNumber, DicomTag tag, out DicomAttribute dicomAttribute) { dicomAttribute = GetFrameAttributeCore(frameNumber, tag); return dicomAttribute != null || DataSource.TryGetAttribute(tag, out dicomAttribute); }
/// <summary> /// Internal constructor used when copying an attribute from a pre-existing attribute instance. /// </summary> /// <param name="attrib">The attribute that is being copied.</param> internal DicomAttribute(DicomAttribute attrib) { Tag = attrib.Tag; _valueCount = attrib.Count; _length = attrib.StreamLength; }
public override bool TryGetAttribute(uint tag, out DicomAttribute attribute) { return _sopDataSource.TryGetAttribute(tag, out attribute); }