A DICOM SOP Instance.

Note that there should no longer be any need to derive from this class; the Sop, ImageSop and Frame classes are now just simple Bridge classes (see Bridge Design Pattern) to ISopDataSource and ISopFrameData. See the remarks for ISopDataSource for more information.

Also, for more information on 'transient references' and the lifetime of Sops, see ISopReference.

Inheritance: IDisposable, IDicomAttributeProvider, ISopInstanceData, ISeriesData, IStudyData, IPatientData
Ejemplo n.º 1
0
		private static IEnumerable<IClipboardItem> CreateClipboardItems(StudyTree studyTree, Sop keyObjectSelectionDocument)
		{
			Platform.CheckTrue(keyObjectSelectionDocument.SopClassUid == SopClass.KeyObjectSelectionDocumentStorageUid, "SOP Class must be Key Object Selection Document Storage");

			var dummyContext = new KeyImageInformation(); // just need an instance of creating items
			var factory = new PresentationImageFactory(studyTree);
			foreach (var image in factory.CreateImages(keyObjectSelectionDocument))
			{
				var presentationStateInstanceUid = string.Empty;

				// set the deserialize interactive flag on the presentation state
				var dicomPresentationImage = image as IDicomPresentationImage;
				if (dicomPresentationImage != null)
				{
					var presentationState = dicomPresentationImage.PresentationState as DicomSoftcopyPresentationState;
					if (presentationState != null)
					{
						presentationState.DeserializeOptions |= DicomSoftcopyPresentationStateDeserializeOptions.InteractiveAnnotations;
						presentationStateInstanceUid = presentationState.PresentationSopInstanceUid;
					}
				}

				var item = dummyContext.CreateKeyImageItem(image, true);
				item.AssignSourceInfo(Guid.NewGuid(), keyObjectSelectionDocument.SopInstanceUid, presentationStateInstanceUid);
				yield return item;
			}
		}
Ejemplo n.º 2
0
		public SopDataSourceStudyItem(Sop sop)
		{
			Platform.CheckTrue(sop.DataSource is ILocalSopDataSource, "Sop must be local");
			{
				_filename = ((ILocalSopDataSource) sop.DataSource).Filename;
				_sopReference = sop.CreateTransientReference();
			}
		}
Ejemplo n.º 3
0
		public SopDataSourceStudyItem(Sop sop)
		{
			if (sop.DataSource is ILocalSopDataSource)
			{
				_filename = ((ILocalSopDataSource) sop.DataSource).Filename;
				_sopReference = sop.CreateTransientReference();
			}
		}
Ejemplo n.º 4
0
		public SopDataSourceStudyItem(ILocalSopDataSource sopDataSource)
		{
			_filename = sopDataSource.Filename;
			using (Sop sop = new Sop(sopDataSource))
			{
				_sopReference = sop.CreateTransientReference();
			}
		}
Ejemplo n.º 5
0
 public void Dispose()
 {
     if (_sop != null)
     {
         _sop.OnReferenceDisposed();
         _sop = null;
     }
 }
Ejemplo n.º 6
0
 internal void SetSop(Sop sop)
 {
     if (sop == null)
     {
         _sop = null;
     }
     else if (_sop == null)
     {
         _sop = sop;
     }
 }
Ejemplo n.º 7
0
		/// <summary>
		/// Compares two <see cref="ImageSop"/>s based on series number.
		/// </summary>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <returns></returns>
		public override int Compare(Sop x, Sop y)
		{
			int seriesNumber1 = x.SeriesNumber;
			int seriesNumber2 = y.SeriesNumber;

			if (seriesNumber1 < seriesNumber2)
				return this.ReturnValue;
			else if (seriesNumber1 > seriesNumber2)
				return -this.ReturnValue;
			else
				return 0;
		}
Ejemplo n.º 8
0
        private void AddPatient(Sop sop)
        {
            if (_patients[sop.PatientId] != null)
            {
                return;
            }

            Patient patient = new Patient();

            patient.SetSop(sop);

            _patients.Add(patient);
        }
Ejemplo n.º 9
0
        internal void SetSop(Sop sop)
        {
            if (sop == null)
            {
                _sop = null;
            }
            else if (_sop == null)
            {
                _sop = sop;
            }

            ParentStudy.SetSop(sop);
        }
Ejemplo n.º 10
0
        internal void SetSop(Sop sop)
        {
            if (sop == null)
            {
                _sop = null;
            }
            else if (_sop == null)
            {
                _sop = sop;
            }

            this.ParentPatient.SetSop(sop);
        }
Ejemplo n.º 11
0
        private void AddStudy(Sop sop)
        {
            if (_studies.ContainsKey(sop.StudyInstanceUid))
            {
                return;
            }

            Patient patient = _patients[sop.PatientId];
            Study   study   = new Study(patient);

            study.SetSop(sop);
            patient.Studies.Add(study);

            _studies[study.StudyInstanceUid] = study;
        }
Ejemplo n.º 12
0
		private static IEnumerable<IComparable> GetCompareValues(Sop sop)
		{
            //Group be common study level attributes
            yield return sop.StudyInstanceUid;

            //Group by common series level attributes
            //This sorts "FOR PRESENTATION" images to the beginning (except in reverse, of course).
            if (!sop.IsImage)
                yield return 1;
            else
                yield return ((ImageSop)sop).PresentationIntentType == "FOR PRESENTATION" ? 0 : 1;

            yield return sop.SeriesNumber;
            yield return sop.SeriesDescription;
            yield return sop.SeriesInstanceUid;

			yield return sop.InstanceNumber;
			yield return sop[DicomTags.AcquisitionNumber].GetInt32(0, 0);
		}
Ejemplo n.º 13
0
        private void AddSeries(Sop sop)
        {
            Series series;

            if (_series.ContainsKey(sop.SeriesInstanceUid))
            {
                series = _series[sop.SeriesInstanceUid];
            }
            else
            {
                Study study = _studies[sop.StudyInstanceUid];
                series = new Series(study);
                series.SetSop(sop);
                study.Series.Add(series);

                _series[series.SeriesInstanceUid] = series;
            }

            sop.ParentSeries = series;
            series.Sops.Add(sop);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Adds a <see cref="Sop"/> to the <see cref="StudyTree"/>.
        /// </summary>
        public bool AddSop(Sop sop)
        {
            Platform.CheckForNullReference(sop, "sop");

            //disable
            //if (!this.SopValidationDisabled)
            //    sop.Validate();

            if (_sops.ContainsKey(sop.SopInstanceUid))
            {
                sop.Dispose();
                return(false);
            }

            AddPatient(sop);
            AddStudy(sop);
            AddSeries(sop);
            _sops[sop.SopInstanceUid] = sop;

            return(true);
        }
Ejemplo n.º 15
0
		internal void SetSop(Sop sop)
		{
			if (sop == null)
				_sop = null;
			else if (_sop == null)
				_sop = sop;

			this.ParentPatient.SetSop(sop);
		}
Ejemplo n.º 16
0
		protected SopInstanceReferenceBase(Sop sop)
			: this(sop.StudyInstanceUid, sop.SeriesInstanceUid, sop.SopClassUid, sop.SopInstanceUid, sop.DataSource[DicomTags.SourceApplicationEntityTitle].ToString()) {}
Ejemplo n.º 17
0
		public SopInstanceReference(Sop sop)
			: base(sop) {}
Ejemplo n.º 18
0
		/// <summary>
		/// Creates the presentation images for a given image SOP.
		/// </summary>
		/// <param name="sop">The image SOP from which presentation images are to be created.</param>
		/// <returns>A list of created presentation images.</returns>
		public virtual List<IPresentationImage> CreateImages(Sop sop)
		{
			if (sop.IsImage)
				return CreateImages((ImageSop)sop);
			
			if (sop.SopClassUid == SopClass.KeyObjectSelectionDocumentStorageUid)
				return CreateImages(new KeyObjectSelectionDocumentIod(sop.DataSource));

			return new List<IPresentationImage>();
		}
Ejemplo n.º 19
0
		internal void SetSop(Sop sop)
		{
			if (sop == null)
				_sop = null;
			else if (_sop == null)
				_sop = sop;
		}
		private static bool IsAttenuationCorrected(Sop sop)
		{
			var correctionTypes = DicomStringHelper.GetStringArray(sop[DicomTags.CorrectedImage].ToString().ToUpperInvariant());
			return (Array.FindIndex(correctionTypes, s => s == _attenuationCorrectionCode) >= 0);
		}
Ejemplo n.º 21
0
		public KeyImageInformation(StudyTree studyTree, Sop keyObjectSelectionDocument)
			: base(CreateClipboardItems(studyTree, keyObjectSelectionDocument))
		{
			var koDeserializer = new KeyImageDeserializer(keyObjectSelectionDocument);
			var description = koDeserializer.DeserializeDescriptions().OfType<KeyObjectDescriptionContentItem>().FirstOrDefault();
			var author = koDeserializer.DeserializeObserverContexts().OfType<PersonObserverContextContentItem>().FirstOrDefault();

			_parentStudyInstanceUid = keyObjectSelectionDocument.StudyInstanceUid;
			_documentInstanceUid = keyObjectSelectionDocument.SopInstanceUid;
			_author = author != null ? author.PersonObserverName : string.Empty;
			_description = description != null ? description.Description : string.Empty;
			_documentTitle = koDeserializer.DocumentTitle ?? KeyObjectSelectionDocumentTitleContextGroup.OfInterest;
			_seriesDescription = keyObjectSelectionDocument.SeriesDescription;
			_seriesNumber = keyObjectSelectionDocument.SeriesNumber;
			_contentDateTime = DateTimeParser.ParseDateAndTime(null, keyObjectSelectionDocument.ContentDate, keyObjectSelectionDocument.ContentTime);
			_name = string.Format(SR.FormatOriginalKeyImageSelection, keyObjectSelectionDocument.SeriesNumber, keyObjectSelectionDocument.SeriesDescription, Format.DateTime(_contentDateTime));
		}
Ejemplo n.º 22
0
		public SopArgumentHint(Sop sop) : this(sop.DataSource) {}
Ejemplo n.º 23
0
			public void Dispose()
			{
				if (_sop != null)
				{
					_sop.OnReferenceDisposed();
					_sop = null;
				}
			}
Ejemplo n.º 24
0
			public SopReference(Sop sop)
			{
				_sop = sop;
				_sop.OnReferenceCreated();
			}
Ejemplo n.º 25
0
		/// <summary>
		/// Constructs a new instance of <see cref="KeyImageDeserializer"/>.
		/// </summary>
		/// <remarks>
		/// <para>Due to the relatively new nature of key object support in the ClearCanvas Framework, this API may be more prone to changes in the next release.</para>
		/// </remarks>
		public KeyImageDeserializer(Sop sourceSop)
		{
			_document = new KeyObjectSelectionDocumentIod(sourceSop);
		}
Ejemplo n.º 26
0
		internal void SetSop(Sop sop)
		{
			if (sop == null)
				_sop = null;
			else if (_sop == null)
				_sop = sop;

			ParentStudy.SetSop(sop);
		}
Ejemplo n.º 27
0
 /// <summary>
 /// Creates a <see cref="Sop"/> from the given <see cref="ISopDataSource"/>.
 /// </summary>
 protected virtual Sop CreateSop(ISopDataSource dataSource)
 {
     return(Sop.Create(dataSource));
 }
        private SegmentationMenuInfo MenuInfoFromDocumentAndSeg(SegmentationDocument segmentationDocument, Seg seg, Sop sop)
        {
            if (seg.SegmentImageData != null &&
                seg.SegmentImageData.SegmentFrameData != null &&
                seg.SegmentImageData.SegmentFrameData.Count > 0)
            {
                return new SegmentationMenuInfo
                           {
                               DisplayLabel = seg.DisplayLabel,
                               DisplayImageSeriesUid = seg.ImageSeriesUid,
                               SegmentationNumber = seg.SegmentationNumber,
                               SegmentationDocumentUid = segmentationDocument.SopInstanceUid,
                               SeriesNumber = segmentationDocument.SeriesNumber,
                               ImagePositionPatient = seg.SegmentImageData.SegmentFrameData[0].ImagePositionPatient,
                               ImageOrientationPatient =
                                   seg.SegmentImageData.SegmentFrameData[0].ImageOrientationPatient,
                               FrameOfReferenceUid = seg.SegmentImageData.FrameOfReferenceUid,
                               PatientId = sop.PatientId,
                               PatientsName = sop.PatientsName,
                               StudyAccessionNumber = sop.AccessionNumber,
                               StudyDate = sop.StudyDate,
                               StudyTime = sop.StudyTime,
                               StudyDescription = sop.StudyDescription,
                               StudyInstanceUid = sop.StudyInstanceUid
                           };
            }

            return null;
        }
Ejemplo n.º 29
0
		private void AddStudy(Sop sop)
		{
			if (_studies.ContainsKey(sop.StudyInstanceUid))
				return;

			Patient patient = _patients[sop.PatientId];
			Study study = new Study(patient);
			study.SetSop(sop);
			patient.Studies.Add(study);

			_studies[study.StudyInstanceUid] = study;
		}
Ejemplo n.º 30
0
		private void AddSeries(Sop sop)
		{
			Series series;
			if (_series.ContainsKey(sop.SeriesInstanceUid))
			{
				series = _series[sop.SeriesInstanceUid];
			}
			else
			{
				Study study = _studies[sop.StudyInstanceUid];
				series = new Series(study);
				series.SetSop(sop);
				study.Series.Add(series);

				_series[series.SeriesInstanceUid] = series;
			}

			sop.ParentSeries = series;
			series.Sops.Add(sop);
		}
Ejemplo n.º 31
0
		internal virtual bool ShouldAddSop(Sop sop)
		{
			return false;
		}
Ejemplo n.º 32
0
		/// <summary>
		/// Compares 2 <see cref="Sop"/>s based on Instance Number.
		/// </summary>
		public override int Compare(Sop x, Sop y)
		{
			return Compare(GetCompareValues(x), GetCompareValues(y));
		}
Ejemplo n.º 33
0
 public SopReference(Sop sop)
 {
     _sop = sop;
     _sop.OnReferenceCreated();
 }
Ejemplo n.º 34
0
        //Add this when we actually support it.
		internal virtual bool Update(Sop sop)
		{
            throw new NotSupportedException();
		}
Ejemplo n.º 35
0
		/// <summary>
		/// Adds a <see cref="Sop"/> to the <see cref="StudyTree"/>.
		/// </summary>
		public bool AddSop(Sop sop)
		{
			Platform.CheckForNullReference(sop, "sop");

			if (!this.SopValidationDisabled)
				sop.Validate();

			if (_sops.ContainsKey(sop.SopInstanceUid))
			{
				sop.Dispose();
				return false;
			}

			AddPatient(sop);
			AddStudy(sop);
			AddSeries(sop);
			_sops[sop.SopInstanceUid] = sop;
		
			return true;
		}
Ejemplo n.º 36
0
		private void AddPatient(Sop sop)
		{
			if (_patients[sop.PatientId] != null)
				return;

			Patient patient = new Patient();
			patient.SetSop(sop);

			_patients.Add(patient);
		}
Ejemplo n.º 37
0
            public PlaceholderPresentationImage(Sop sop)
                : base(new GrayscaleImageGraphic(1, 1))
            {
                _sopReference = sop.CreateTransientReference();

                var sopClass = SopClass.GetSopClass(sop.SopClassUid);
                var sopClassDescription = sopClass != null ? sopClass.Name : SR.LabelUnknown;
                CompositeImageGraphic.Graphics.Add(new ErrorMessageGraphic { Text = string.Format(SR.MessageUnsupportedImageType, sopClassDescription), Color = Color.WhiteSmoke });
                Platform.Log(LogLevel.Warn, "Unsupported SOP Class \"{0} ({1})\" (SOP Instance {2})", sopClassDescription, sop.SopClassUid, sop.SopInstanceUid);
            }
 private void AddSegmentationMenuInfo(SegmentationDocument segmentationDocument, Seg seg, Sop sop)
 {
     if (
         !_segmentationMenuInfos.ContainsKey(
             segmentationDocument.SopInstanceUid + seg.SegmentationNumber))
     {
         SegmentationMenuInfo info =
             MenuInfoFromDocumentAndSeg(segmentationDocument, seg, sop);
         if (info != null)
             _segmentationMenuInfos.Add(
                 segmentationDocument.SopInstanceUid + seg.SegmentationNumber,
                 info);
     }
 }