/// <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;
            }
        }
		/// <summary>
		/// Constructs a serialization-capable DICOM softcopy presentation state object.
		/// </summary>
		/// <param name="presentationStateSopClass">The SOP class of this type of softcopy presentation state.</param>
		protected DicomSoftcopyPresentationState(SopClass presentationStateSopClass)
		{
			_presentationSopClass = presentationStateSopClass;
			_dicomFile = new DicomFile();

			_serialized = false;
			_sourceAETitle = string.Empty;
			_stationName = string.Empty;
			_institution = Institution.Empty;
			Manufacturer = "ClearCanvas Inc.";
			ManufacturersModelName = ProductInformation.GetName(false, false);
			DeviceSerialNumber = string.Empty;
			SoftwareVersions = ProductInformation.GetVersion(true, true, true, true);
			_presentationInstanceNumber = 1;
			_presentationSopInstanceUid = string.Empty;
			_presentationSeriesDateTime = Platform.Time;
			_presentationSeriesNumber = null;
			_presentationSeriesInstanceUid = string.Empty;
			_presentationLabel = "FOR_PRESENTATION";
		}
Example #3
0
		/// <summary>
		/// Checks whether or not the specified SOP Class indicates a supported image type.
		/// </summary>
		/// <param name="sopClass">The SOP Class to be checked.</param>
		/// <returns>True if the SOP Class is a supported image type; False otherwise.</returns>
		public static bool IsSupportedSopClass(SopClass sopClass)
		{
			return IsImageSop(sopClass);
		}
		private static DicomFile CreateInstance(int number, string description, SopClass sopClass, DicomAttributeCollection baseDataSet)
		{
			DateTime now = DateTime.Now;
			DicomUid sopInstanceUid = DicomUid.GenerateUid();
			DicomFile dicomFile = new DicomFile(string.Empty, new DicomAttributeCollection(), baseDataSet.Copy(true, true, true));

			//meta info
			dicomFile.MediaStorageSopInstanceUid = sopInstanceUid.UID;
			dicomFile.MediaStorageSopClassUid = sopClass.Uid;

			//Series
			dicomFile.DataSet[DicomTags.Modality].SetStringValue("OT");
			dicomFile.DataSet[DicomTags.SeriesInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);
			dicomFile.DataSet[DicomTags.SeriesNumber].SetInt32(0, number);
			dicomFile.DataSet[DicomTags.SeriesDescription].SetStringValue(description);

			//General Image
			dicomFile.DataSet[DicomTags.InstanceNumber].SetInt32(0, 1);

			//SC Image
			dicomFile.DataSet[DicomTags.DateOfSecondaryCapture].SetDateTime(0, now);
			dicomFile.DataSet[DicomTags.TimeOfSecondaryCapture].SetDateTime(0, now);

			//Sop Common
			dicomFile.DataSet[DicomTags.InstanceCreationDate].SetDateTime(0, now);
			dicomFile.DataSet[DicomTags.InstanceCreationTime].SetDateTime(0, now);
			dicomFile.DataSet[DicomTags.SopClassUid].SetStringValue(sopClass.Uid);
			dicomFile.DataSet[DicomTags.SopInstanceUid].SetStringValue(sopInstanceUid.UID);

			return dicomFile;
		}
Example #5
0
		// TODO (CR Jun 2012): Move to a more common place, like a SopClassExtensions class in IV.Common, or CC.Dicom?

		internal static bool IsImageSop(SopClass sopClass)
		{
			return _imageSopClasses.Contains(sopClass);
		}
		private static ISopDataSource CreateMockDataset(string modality, SopClass sopClass, SizeF? imagerPixelSpacing, SizeF? pixelSpacing, string pixelSpacingCalibrationType, string pixelSpacingCalibrationDescription, double? estimatedRadiographicMagnification)
		{
			var dicomFile = new DicomFile();
			var dataset = dicomFile.DataSet;
			dataset[DicomTags.PatientId].SetStringValue("PATIENT");
			dataset[DicomTags.PatientsName].SetStringValue("YOSHI");
			dataset[DicomTags.StudyId].SetStringValue("STUDY");
			dataset[DicomTags.SeriesDescription].SetStringValue("SERIES");
			dataset[DicomTags.StudyInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);
			dataset[DicomTags.SeriesInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);
			dataset[DicomTags.Modality].SetStringValue(modality);
			dataset[DicomTags.SopInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);
			dataset[DicomTags.SopClassUid].SetStringValue(sopClass.Uid);
			dataset[DicomTags.FrameOfReferenceUid].SetStringValue(DicomUid.GenerateUid().UID);
			dataset[DicomTags.PhotometricInterpretation].SetStringValue("MONOCHROME2");
			dataset[DicomTags.BitsStored].SetInt32(0, 16);
			dataset[DicomTags.BitsAllocated].SetInt32(0, 16);
			dataset[DicomTags.HighBit].SetInt32(0, 15);
			dataset[DicomTags.PixelRepresentation].SetInt32(0, 0);
			dataset[DicomTags.Rows].SetInt32(0, 100);
			dataset[DicomTags.Columns].SetInt32(0, 100);
			dataset[DicomTags.WindowCenter].SetInt32(0, 32768);
			dataset[DicomTags.WindowWidth].SetInt32(0, 65536);
			dataset[DicomTags.WindowCenterWidthExplanation].SetString(0, "Full Window");

			if (imagerPixelSpacing.HasValue)
			{
				dataset[DicomTags.ImagerPixelSpacing].SetFloat32(0, imagerPixelSpacing.Value.Height);
				dataset[DicomTags.ImagerPixelSpacing].SetFloat32(1, imagerPixelSpacing.Value.Width);
			}

			if (pixelSpacing.HasValue)
			{
				dataset[DicomTags.PixelSpacing].SetFloat32(0, pixelSpacing.Value.Height);
				dataset[DicomTags.PixelSpacing].SetFloat32(1, pixelSpacing.Value.Width);
			}

			if (!string.IsNullOrEmpty(pixelSpacingCalibrationType))
				dataset[DicomTags.PixelSpacingCalibrationType].SetStringValue(pixelSpacingCalibrationType);

			if (!string.IsNullOrEmpty(pixelSpacingCalibrationDescription))
				dataset[DicomTags.PixelSpacingCalibrationDescription].SetStringValue(pixelSpacingCalibrationDescription);

			if (estimatedRadiographicMagnification.HasValue)
				dataset[DicomTags.EstimatedRadiographicMagnificationFactor].SetFloat64(0, estimatedRadiographicMagnification.Value);

			return new TestDataSource(dicomFile);
		}
Example #7
0
 public static SopClass RegisterSopClass(SopClass sopClass)
 {
     SopClass theSop;
     if (!_sopList.TryGetValue(sopClass.Uid, out theSop))
         _sopList.Add(sopClass.Uid, theSop = sopClass);
     return theSop;
 }
Example #8
0
 /// <summary>Retrieve a SopClass object associated with the Uid.</summary>
 public static SopClass GetSopClass(String uid)
 {
     SopClass theSop;
     if (!_sopList.TryGetValue(uid, out theSop))
     {
         var newSop = new SopClass(string.Format("Generated: '{0}'", uid), uid, SopClassCategory.Uncategorized);
         theSop = RegisterSopClass(newSop);
     }
     return theSop;
 }
		/// <summary>
		/// Constructs a deserialization-only DICOM softcopy presentation state object.
		/// </summary>
		/// <param name="psSopClass">The SOP class of this type of softcopy presentation state.</param>
		/// <param name="dataSource">An attribute collection containing the presentation state.</param>
		protected DicomSoftcopyPresentationState(SopClass psSopClass, DicomAttributeCollection dataSource)
			: this(psSopClass, new DicomFile("", CreateMetaInfo(dataSource), dataSource)) {}
		/// <summary>
		/// Constructs a deserialization-only DICOM softcopy presentation state object.
		/// </summary>
		/// <param name="psSopClass">The SOP class of this type of softcopy presentation state.</param>
		/// <param name="dicomFile">The presentation state file.</param>
		protected DicomSoftcopyPresentationState(SopClass psSopClass, DicomFile dicomFile)
		{
			if (dicomFile.MediaStorageSopClassUid != psSopClass.Uid)
			{
				string message = string.Format("The specified DICOM file is not of a compatible SOP Class. Expected: {0}; Found: {1}",
				                               psSopClass, SopClass.GetSopClass(dicomFile.MediaStorageSopClassUid));
				throw new ArgumentException(message, "dicomFile");
			}

			_presentationSopClass = psSopClass;
			_dicomFile = dicomFile;

			_serialized = true;
			_sourceAETitle = _dicomFile.SourceApplicationEntityTitle;
			_stationName = _dicomFile.DataSet[DicomTags.StationName].ToString();
			_institution = Institution.GetInstitution(_dicomFile);
			Manufacturer = _dicomFile.DataSet[DicomTags.Manufacturer].ToString();
			ManufacturersModelName = _dicomFile.DataSet[DicomTags.ManufacturersModelName].ToString();
			DeviceSerialNumber = _dicomFile.DataSet[DicomTags.DeviceSerialNumber].ToString();
			SoftwareVersions = _dicomFile.DataSet[DicomTags.SoftwareVersions].ToString();
			_presentationInstanceNumber = _dicomFile.DataSet[DicomTags.InstanceNumber].GetInt32(0, 0);
			_presentationSopInstanceUid = _dicomFile.DataSet[DicomTags.SopInstanceUid].ToString();
			_presentationSeriesDateTime = DateTimeParser.ParseDateAndTime(_dicomFile.DataSet, 0, DicomTags.SeriesDate, DicomTags.SeriesTime);
			_presentationSeriesNumber = GetNullableInt32(_dicomFile.DataSet[DicomTags.SeriesNumber], 0);
			_presentationSeriesInstanceUid = _dicomFile.DataSet[DicomTags.SeriesInstanceUid].ToString();
			_presentationLabel = _dicomFile.DataSet[DicomTags.ContentLabel].ToString();
		}
Example #11
0
 /// <summary>Retrieve a SopClass object associated with the Uid.</summary>
 public static SopClass GetSopClass(String uid)
 {
     SopClass theSop;
     if (!_sopList.TryGetValue(uid, out theSop))
     {
         theSop = new SopClass(string.Format("Generated: '{0}'", uid), uid, false); 
         _sopList.Add(uid, theSop);  
     }
     return theSop;
 }