Пример #1
0
        /// <summary>
        /// Gets the VOI data LUTs for specified frame.
        /// </summary>
        /// <param name="frameNumber"></param>
        /// <returns></returns>
        internal IList <VoiDataLut> GetFrameVoiDataLuts(int frameNumber)
        {
            Platform.CheckPositive(frameNumber, "frameNumber");

            lock (_syncLock)
            {
                var cacheKey = VoiDataLutsCacheKey.RootKey;
                var dataset  = (IDicomAttributeProvider)DataSource;

                // attempt to find the VOI LUT Sequence in a functional group pertaining to the requested frame
                FunctionalGroupDescriptor functionalGroupDescriptor;
                if (_functionalGroups != null && _functionalGroups.TryGetValue(DicomTags.VoiLutSequence, out functionalGroupDescriptor))
                {
                    bool perFrame;
                    var  functionalGroup = MultiFrameFunctionalGroupsModuleIod.GetFunctionalGroup(functionalGroupDescriptor, DataSource, frameNumber, out perFrame);
                    var  item            = functionalGroup != null ? functionalGroup.SingleItem : null;

                    DicomAttribute dicomAttribute;
                    if (item != null && item.TryGetAttribute(DicomTags.VoiLutSequence, out dicomAttribute))
                    {
                        cacheKey = perFrame ? VoiDataLutsCacheKey.GetFrameKey(frameNumber) : VoiDataLutsCacheKey.SharedKey;
                        dataset  = item;
                    }
                }

                IList <VoiDataLut> dataLuts;
                if (!_frameVoiDataLuts.TryGetValue(cacheKey, out dataLuts))
                {
                    _frameVoiDataLuts.Add(cacheKey, dataLuts = CreateVoiDataLuts(dataset));
                }
                return(dataLuts);
            }
        }
Пример #2
0
        private DicomAttribute GetFrameAttributeCore(int frameNumber, uint tag)
        {
            FunctionalGroupDescriptor functionalGroupDescriptor;

            if (frameNumber > 0 && _functionalGroups != null && _functionalGroups.TryGetValue(tag, out functionalGroupDescriptor))
            {
                DicomAttribute dicomAttribute;
                var            functionalGroup = MultiFrameFunctionalGroupsModuleIod.GetFunctionalGroup(functionalGroupDescriptor, DataSource, frameNumber);
                var            item            = functionalGroup != null ? functionalGroup.SingleItem : null;
                if (item != null && item.TryGetAttribute(tag, out dicomAttribute))
                {
                    return(dicomAttribute);
                }
            }
            return(null);
        }
        /// <summary>
        /// Gets the functional group sequence item for a particular tag in the data set (i.e. the parent sequence item containing the requested tag).
        /// </summary>
        /// <remarks>
        /// <para>
        /// If the requested tag is the root sequence tag of a functional group (e.g. <see cref="DicomTags.PatientOrientationInFrameSequence"/>),
        /// the returned sequence item will be the functional group sequence item for the frame in which the requested attribute can be found.
        /// </para>
        /// <para>
        /// If the requested tag is a nested tag of a functional group and the root sequence tag allows only one sequence item
        /// (e.g. <see cref="DicomTags.PatientOrientation"/> as a nested tag of <see cref="DicomTags.PatientOrientationInFrameSequence"/>),
        /// the returned sequence item will be the single sequence item in the root sequence attribute.
        /// </para>
        /// <para>
        /// It is not possible to directly access a nested tag of a functional group if the root sequence tag allows multiple sequence items
        /// (e.g. <see cref="DicomTags.RadiopharmaceuticalAgentNumber"/> as a nested tag of <see cref="DicomTags.RadiopharmaceuticalUsageSequence"/>).
        /// To do so, access the <see cref="DicomTags.RadiopharmaceuticalUsageSequence"/> and handle the sequence items individually.
        /// </para>
        /// </remarks>
        /// <param name="frameNumber">DICOM frame number (first frame is 1).</param>
        /// <param name="tag">DICOM tag of the attribute.</param>
        /// <param name="isFrameSpecific">Indicates whether or not the returned functional group is specific to the requested frame.</param>
        /// <returns>The requested functional group sequence item.</returns>
        public DicomSequenceItem GetFrameFunctionalGroupItem(int frameNumber, uint tag, out bool isFrameSpecific)
        {
            FunctionalGroupDescriptor functionalGroupDescriptor;

            if (frameNumber > 0 && _tagMap != null && _tagMap.TryGetValue(tag, out functionalGroupDescriptor))
            {
                FrameFunctionalGroupValue functionalGroupResult;
                var key = new FrameFunctionalGroupKey(functionalGroupDescriptor, frameNumber);
                if (!_cache.TryGetValue(key, out functionalGroupResult))
                {
                    _cache[key] = functionalGroupResult = new FrameFunctionalGroupValue(MultiFrameFunctionalGroupsModuleIod.GetFunctionalGroup(functionalGroupDescriptor, _dataSet, frameNumber, out isFrameSpecific), isFrameSpecific);
                }
                else
                {
                    isFrameSpecific = functionalGroupResult.IsFrameSpecific;
                }

                var functionalGroup = functionalGroupResult.FunctionalGroupMacro;
                if (functionalGroup == null)
                {
                    return(null);
                }

                // if the requested tag is the root sequence tag, return the entire per-frame/shared functional group sequence item as the result
                // otherwise, return the singleton sequence item that contains the requested nested tag (or null if the containing sequence item is not a singleton)
                return(functionalGroup.DefinedTags.Contains(tag) ? functionalGroup.DicomSequenceItem : functionalGroup.SingleItem);
            }
            isFrameSpecific = false;
            return(null);
        }