Esempio n. 1
0
		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);
            }
			
		}
Esempio n. 2
0
		public static ModalityDataLut Create(IDicomAttributeProvider dicomAttributeProvider)
		{
			DicomAttributeSQ modalityLutSequence = (DicomAttributeSQ)dicomAttributeProvider[DicomTags.ModalityLutSequence];
			int pixelRepresentation = GetPixelRepresentation(dicomAttributeProvider);

			return Create(modalityLutSequence, pixelRepresentation);
		}
Esempio n. 3
0
        public static DicomAttribute GetAttribute(this DicomTagPath path, IDicomAttributeProvider attributes, bool create)
        {
            DicomAttribute attribute;
            var tags = new Queue<DicomTag>(path.TagsInPath);

            do
            {
                var tag = tags.Dequeue();
                attribute = attributes[tag];
                if (tags.Count == 0)
                    break;

                var sequenceItems = attribute.Values as DicomSequenceItem[];
                if (sequenceItems == null || sequenceItems.Length == 0)
                {
                    if (!create)
                        return null;

                    attribute.AddSequenceItem(new DicomSequenceItem());
                    sequenceItems = (DicomSequenceItem[]) attribute.Values;
                }

                attributes = sequenceItems[0];
            } while (tags.Count > 0);

            if (attribute.IsEmpty && create)
                attribute.SetNullValue();

            return attribute.IsEmpty ? null : attribute;
        }
		public ColorSoftcopyPresentationStateIod(IDicomAttributeProvider provider) {
			_dicomAttributeProvider = provider;

			this.Patient = new PatientModuleIod(_dicomAttributeProvider);
			this.ClinicalTrialSubject = new ClinicalTrialSubjectModuleIod(_dicomAttributeProvider);

			this.GeneralStudy = new GeneralStudyModuleIod(_dicomAttributeProvider);
			this.PatientStudy = new PatientStudyModuleIod(_dicomAttributeProvider);
			this.ClinicalTrialStudy = new ClinicalTrialStudyModuleIod(_dicomAttributeProvider);

			this.GeneralSeries = new GeneralSeriesModuleIod(_dicomAttributeProvider);
			this.ClinicalTrialSeries = new ClinicalTrialSeriesModuleIod(_dicomAttributeProvider);
			this.PresentationSeries = new PresentationSeriesModuleIod(_dicomAttributeProvider);

			this.GeneralEquipment = new GeneralEquipmentModuleIod(_dicomAttributeProvider);

			this.PresentationStateIdentification = new PresentationStateIdentificationModuleIod(_dicomAttributeProvider);
			this.PresentationStateRelationship = new PresentationStateRelationshipModuleIod(_dicomAttributeProvider);
			this.PresentationStateShutter = new PresentationStateShutterModuleIod(_dicomAttributeProvider);
			this.DisplayShutter = new DisplayShutterModuleIod(_dicomAttributeProvider);
			this.BitmapDisplayShutter = new BitmapDisplayShutterModuleIod(_dicomAttributeProvider);
			this.OverlayPlane = new OverlayPlaneModuleIod(_dicomAttributeProvider);
			this.OverlayActivation = new OverlayActivationModuleIod(_dicomAttributeProvider);
			this.DisplayedArea = new DisplayedAreaModuleIod(_dicomAttributeProvider);
			this.GraphicAnnotation = new GraphicAnnotationModuleIod(_dicomAttributeProvider);
			this.SpatialTransform = new SpatialTransformModuleIod(_dicomAttributeProvider);
			this.GraphicLayer = new GraphicLayerModuleIod(_dicomAttributeProvider);
			this.IccProfile = new IccProfileModuleIod(_dicomAttributeProvider);
			this.SopCommon = new SopCommonModuleIod(_dicomAttributeProvider);
		}
			public static VolumeSopDataSourcePrototype Create(IDicomAttributeProvider source, int bitsAllocated, int bitsStored, bool isSigned)
			{
				VolumeSopDataSourcePrototype prototype = new VolumeSopDataSourcePrototype();
				DicomAttributeCollection volumeDataSet = prototype._collection;

				// perform exact copy on the Patient Module
				foreach (uint tag in PatientModuleIod.DefinedTags)
					volumeDataSet[tag] = source[tag].Copy();

				// perform exact copy on the Clinical Trial Subject Module
				foreach (uint tag in ClinicalTrialSubjectModuleIod.DefinedTags)
					volumeDataSet[tag] = source[tag].Copy();

				// perform exact copy on the General Study Module
				foreach (uint tag in GeneralStudyModuleIod.DefinedTags)
					volumeDataSet[tag] = source[tag].Copy();

				// perform exact copy on the Patient Study Module
				foreach (uint tag in PatientStudyModuleIod.DefinedTags)
					volumeDataSet[tag] = source[tag].Copy();

				// perform exact copy on the Clinical Trial Study Module
				foreach (uint tag in ClinicalTrialStudyModuleIod.DefinedTags)
					volumeDataSet[tag] = source[tag].Copy();

				// TODO JY: flesh out these other modules.

				// generate and cache Series Module attributes that are common among all slicings
				volumeDataSet[DicomTags.Modality] = source[DicomTags.Modality].Copy();
				volumeDataSet[DicomTags.SeriesNumber].SetStringValue("0");
				volumeDataSet[DicomTags.SeriesDescription] = source[DicomTags.SeriesDescription].Copy();

				// generate General Equipment Module
				// these is a ticket to properly implement the GenEq module in all created instances.
				// the ticket is specific to KO and PR, but it should equally apply to these MPR SCs

				// generate SC Equipment Module
				volumeDataSet[DicomTags.ConversionType].SetStringValue("WSD");

				// generate General Image Module
				volumeDataSet[DicomTags.ImageType].SetStringValue(@"DERIVED\SECONDARY");
				volumeDataSet[DicomTags.PixelSpacing] = source[DicomTags.PixelSpacing].Copy();
				volumeDataSet[DicomTags.FrameOfReferenceUid] = source[DicomTags.FrameOfReferenceUid].Copy();

				// generate Image Pixel Module
				volumeDataSet[DicomTags.SamplesPerPixel] = source[DicomTags.SamplesPerPixel].Copy();
				volumeDataSet[DicomTags.PhotometricInterpretation] = source[DicomTags.PhotometricInterpretation].Copy();
				volumeDataSet[DicomTags.BitsAllocated].SetInt32(0, bitsAllocated);
				volumeDataSet[DicomTags.BitsStored].SetInt32(0, bitsStored);
				volumeDataSet[DicomTags.HighBit].SetInt32(0, bitsStored - 1);
				volumeDataSet[DicomTags.PixelRepresentation].SetInt32(0, isSigned ? 1 : 0);

				// generate SOP Common Module
				volumeDataSet[DicomTags.SopClassUid].SetStringValue(SopClass.SecondaryCaptureImageStorageUid);

				return prototype;
			}
		/// <summary>
		/// Initializes a new instance of <see cref="FunctionalGroupMapCache"/>.
		/// </summary>
		/// <param name="dataSet">The data set.</param>
		/// <param name="sopClassUid">Overrides the detected SOP class UID of the data set.</param>
		/// <exception cref="ArgumentNullException">Thrown if <paramref name="dataSet"/> is NULL.</exception>
		public FunctionalGroupMapCache(IDicomAttributeProvider dataSet, string sopClassUid)
		{
			Platform.CheckForNullReference(dataSet, "dataSet");

			if (string.IsNullOrEmpty(sopClassUid))
				sopClassUid = dataSet[DicomTags.SopClassUid].ToString();

			_dataSet = dataSet;
			_cache = new Dictionary<FrameFunctionalGroupKey, FrameFunctionalGroupValue>();
			_tagMap = new MultiFrameFunctionalGroupsModuleIod(dataSet).HasValues() ? FunctionalGroupDescriptor.GetFunctionalGroupMap(sopClassUid) : null;
		}
Esempio n. 7
0
		public static PaletteColorMap Create(IDicomAttributeProvider dataSource)
		{
			CodeClock clock = new CodeClock();
			clock.Start();

			PaletteColorLut paletteColorLut = PaletteColorLut.Create(dataSource);

			clock.Stop();
			PerformanceReportBroker.PublishReport("PaletteColorMap", "Create(IDicomAttributeProvider)", clock.Seconds);

			return new PaletteColorMap(paletteColorLut);
		}
Esempio n. 8
0
		/// <summary>
		/// Fills basic attributes in the General Equipment module.
		/// </summary>
		/// <param name="target">The destination attribute collection whose attributes are to be updated.</param>
		protected void FillGeneralEquipmentModule(IDicomAttributeProvider target)
		{
			var targetGeneralEquipment = new GeneralEquipmentModuleIod(target);
			targetGeneralEquipment.InitializeAttributes();
			targetGeneralEquipment.Manufacturer = Manufacturer ?? string.Empty; // Manufacturer here is Type 2
			targetGeneralEquipment.InstitutionName = Institution.Name;
			targetGeneralEquipment.InstitutionAddress = Institution.Address;
			targetGeneralEquipment.StationName = StationName;
			targetGeneralEquipment.InstitutionalDepartmentName = Institution.DepartmentName;
			targetGeneralEquipment.ManufacturersModelName = ManufacturersModelName;
			targetGeneralEquipment.DeviceSerialNumber = DeviceSerialNumber;
			targetGeneralEquipment.SoftwareVersions = SoftwareVersions;
		}
		internal VolumeSliceSopDataSource(IVolumeReference volumeReference, IVolumeSlicerParams slicerParams, IList<Vector3D> throughPoints)
		{
			Platform.CheckForNullReference(throughPoints, "throughPoints");
			Platform.CheckTrue(throughPoints.Count > 0, "At least one through point must be specified.");
			var volume = volumeReference.Volume;

			_volumeReference = volumeReference;
			_slicerParams = slicerParams;
			_resliceMatrix = new Matrix(slicerParams.SlicingPlaneRotation);
			_resliceMatrix[3, 0] = throughPoints[0].X;
			_resliceMatrix[3, 1] = throughPoints[0].Y;
			_resliceMatrix[3, 2] = throughPoints[0].Z;
			_throughPoints = new List<Vector3D>(throughPoints).AsReadOnly();

			// keep a direct reference to the prototype, so that attribute values are available even if the referenced volume is unloaded via memory management
			_prototypeDataSet = volume.DataSet;

			_instanceDataSet = new DicomAttributeCollection();

			// JY: ideally, each slicing plane is represented by a single multiframe SOP where the individual slices are the frames.
			// We need to support multi-valued Slice Location in the base viewer first.
			// When that is implemented, the SOPs should be created on the first frame of the slicing (i.e. one of the end slices)
			// and the Slice Location Vector will simply store the slice locations relative to that defined in these attributes.
			// Also, the rows and columns will have to be computed to be the MAX possible size (all frames must have same size)

			// assign Rows and Columns to reflect actual output size
			Size frameSize = GetSliceExtent(volume, slicerParams);
			_instanceDataSet[DicomTags.Columns].SetInt32(0, frameSize.Width);
			_instanceDataSet[DicomTags.Rows].SetInt32(0, frameSize.Height);

			// assign Image Orientation (Patient)
			Matrix resliceAxesPatientOrientation = _volumeReference.Volume.RotateToPatientOrientation(_resliceMatrix);
			_instanceDataSet[DicomTags.ImageOrientationPatient].SetFloat32(0, resliceAxesPatientOrientation[0, 0]);
			_instanceDataSet[DicomTags.ImageOrientationPatient].SetFloat32(1, resliceAxesPatientOrientation[0, 1]);
			_instanceDataSet[DicomTags.ImageOrientationPatient].SetFloat32(2, resliceAxesPatientOrientation[0, 2]);
			_instanceDataSet[DicomTags.ImageOrientationPatient].SetFloat32(3, resliceAxesPatientOrientation[1, 0]);
			_instanceDataSet[DicomTags.ImageOrientationPatient].SetFloat32(4, resliceAxesPatientOrientation[1, 1]);
			_instanceDataSet[DicomTags.ImageOrientationPatient].SetFloat32(5, resliceAxesPatientOrientation[1, 2]);

			// assign Image Position (Patient)
			Vector3D topLeftOfSlicePatient = GetTopLeftOfSlicePatient(frameSize, throughPoints[0], volume, slicerParams);
			_instanceDataSet[DicomTags.ImagePositionPatient].SetFloat32(0, topLeftOfSlicePatient.X);
			_instanceDataSet[DicomTags.ImagePositionPatient].SetFloat32(1, topLeftOfSlicePatient.Y);
			_instanceDataSet[DicomTags.ImagePositionPatient].SetFloat32(2, topLeftOfSlicePatient.Z);

			// assign Number of Frames
			_instanceDataSet[DicomTags.NumberOfFrames].SetInt32(0, throughPoints.Count);

			// assign a new SOP instance UID
			_instanceDataSet[DicomTags.SopInstanceUid].SetString(0, DicomUid.GenerateUid().UID);
		}
Esempio n. 10
0
		public SeriesInformation(IDicomAttributeProvider attributeProvider)
		{
			if (attributeProvider[DicomTags.SeriesInstanceUid] != null)
				SeriesInstanceUid = attributeProvider[DicomTags.SeriesInstanceUid].ToString();
			if (attributeProvider[DicomTags.SeriesDescription] != null)
				SeriesDescription = attributeProvider[DicomTags.SeriesDescription].ToString();
			if (attributeProvider[DicomTags.Modality] != null)
				Modality = attributeProvider[DicomTags.Modality].ToString();
            if (attributeProvider[DicomTags.SeriesNumber] != null)
                SeriesNumber = attributeProvider[DicomTags.SeriesNumber].ToString();

            if (attributeProvider[DicomTags.NumberOfSeriesRelatedInstances] != null)
                Int32.TryParse(attributeProvider[DicomTags.NumberOfSeriesRelatedInstances].ToString(), out _numberOfInstances);
		}
Esempio n. 11
0
        public RawDataIod(IDicomAttributeProvider dicomAttributeProvider)
		{
			_dicomAttributeProvider = dicomAttributeProvider;
			_patientModule = new PatientModuleIod(_dicomAttributeProvider);
			_clinicalTrialSubjectModule = new ClinicalTrialSubjectModuleIod(_dicomAttributeProvider);
			_generalStudyModule = new GeneralStudyModuleIod(_dicomAttributeProvider);
			_patientStudyModule = new PatientStudyModuleIod(_dicomAttributeProvider);
			_clinicalTrialStudyModule = new ClinicalTrialStudyModuleIod(_dicomAttributeProvider);
			_generalSeriesModule = new GeneralSeriesModuleIod(_dicomAttributeProvider);
			_clinicalTrialSeriesModule = new ClinicalTrialSeriesModuleIod(_dicomAttributeProvider);
			_generalEquipmentModule = new GeneralEquipmentModuleIod(_dicomAttributeProvider);
            _acquisitionContextModule = new AcquisitionContextModuleIod(_dicomAttributeProvider);
            _rawDataModule = new RawDataModule(_dicomAttributeProvider);
			_sopCommonModule = new SopCommonModuleIod(_dicomAttributeProvider);
		}
		public KeyObjectSelectionDocumentIod(IDicomAttributeProvider dicomAttributeProvider)
		{
			_dicomAttributeProvider = dicomAttributeProvider;
			_patientModule = new PatientModuleIod(_dicomAttributeProvider);
			_specimenIdentificationModule = new SpecimenIdentificationModuleIod(_dicomAttributeProvider);
			_clinicalTrialSubjectModule = new ClinicalTrialSubjectModuleIod(_dicomAttributeProvider);
			_generalStudyModule = new GeneralStudyModuleIod(_dicomAttributeProvider);
			_patientStudyModule = new PatientStudyModuleIod(_dicomAttributeProvider);
			_clinicalTrialStudyModule = new ClinicalTrialStudyModuleIod(_dicomAttributeProvider);
			_keyObjectDocumentSeriesModule = new KeyObjectDocumentSeriesModuleIod(_dicomAttributeProvider);
			_clinicalTrialSeriesModule = new ClinicalTrialSeriesModuleIod(_dicomAttributeProvider);
			_generalEquipmentModule = new GeneralEquipmentModuleIod(_dicomAttributeProvider);
			_keyObjectDocumentModule = new KeyObjectDocumentModuleIod(_dicomAttributeProvider);
			_srDocumentContentModule = new SrDocumentContentModuleIod(_dicomAttributeProvider);
			_sopCommonModule = new SopCommonModuleIod(_dicomAttributeProvider);
		}
Esempio n. 13
0
		/// <summary>
		/// Initializes a new instance of the <see cref="EncapsulatedPdfIod"/> class.
		/// </summary>
		/// <param name="dicomAttributeProvider">The DICOM attribute provider.</param>
		public EncapsulatedPdfIod(IDicomAttributeProvider dicomAttributeProvider)
		{
			_dicomAttributeProvider = dicomAttributeProvider;

			_patientModule = new PatientModuleIod(_dicomAttributeProvider);
			_clinicalTrialSubjectModule = new ClinicalTrialSubjectModuleIod(_dicomAttributeProvider);
			_generalStudyModule = new GeneralStudyModuleIod(_dicomAttributeProvider);
			_patientStudyModule = new PatientStudyModuleIod(_dicomAttributeProvider);
			_clinicalTrialStudyModule = new ClinicalTrialStudyModuleIod(_dicomAttributeProvider);
			_encapsulatedDocumentSeriesModule = new EncapsulatedDocumentSeriesModuleIod(_dicomAttributeProvider);
			_clinicalTrialSeriesModule = new ClinicalTrialSeriesModuleIod(_dicomAttributeProvider);
			_generalEquipmentModule = new GeneralEquipmentModuleIod(_dicomAttributeProvider);
			_scEquipmentModule = new ScEquipmentModuleIod(_dicomAttributeProvider);
			_encapsulatedDocumentModule = new EncapsulatedDocumentModuleIod(_dicomAttributeProvider);
			_sopCommonModule = new SopCommonModuleIod(_dicomAttributeProvider);
		}
Esempio n. 14
0
		internal VolumeSlice(IVolumeReference volumeReference, IVolumeSlicerParams slicerParams, Vector3D throughPoint)
		{
			Platform.CheckForNullReference(throughPoint, "throughPoint");
			var volume = volumeReference.Volume;

			_volumeReference = volumeReference;
			_slicerParams = slicerParams;
			_throughPoint = throughPoint;

			// keep a direct reference to the prototype, so that attribute values are available even if the referenced volume is unloaded via memory management
			_prototypeDataSet = volume.DataSet;

			// JY: ideally, each slicing plane is represented by a single multiframe SOP where the individual slices are the frames.
			// We need to support multi-valued Slice Location in the base viewer first.
			// When that is implemented, the SOPs should be created on the first frame of the slicing (i.e. one of the end slices)
			// and the Slice Location Vector will simply store the slice locations relative to that defined in these attributes.
			// Also, the rows and columns will have to be computed to be the MAX possible size (all frames must have same size)

			// compute Rows and Columns to reflect actual output size
			var frameSize = GetSliceExtent(volume, slicerParams);
			Colums = frameSize.Width;
			Rows = frameSize.Height;

			// compute Image Orientation (Patient)
			var matrix = new Matrix(slicerParams.SlicingPlaneRotation);
			matrix[3, 0] = _throughPoint.X;
			matrix[3, 1] = _throughPoint.Y;
			matrix[3, 2] = _throughPoint.Z;

			var resliceAxesPatientOrientation = _volumeReference.Volume.RotateToPatientOrientation(matrix);
			var orientation = new DicomAttributeDS(DicomTags.ImageOrientationPatient);
			orientation.SetFloat32(0, resliceAxesPatientOrientation[0, 0]);
			orientation.SetFloat32(1, resliceAxesPatientOrientation[0, 1]);
			orientation.SetFloat32(2, resliceAxesPatientOrientation[0, 2]);
			orientation.SetFloat32(3, resliceAxesPatientOrientation[1, 0]);
			orientation.SetFloat32(4, resliceAxesPatientOrientation[1, 1]);
			orientation.SetFloat32(5, resliceAxesPatientOrientation[1, 2]);
			ImageOrientationPatient = orientation.ToString();

			// compute Image Position (Patient)
			var topLeftOfSlicePatient = GetTopLeftOfSlicePatient(frameSize, _throughPoint, volume, slicerParams);
			var position = new DicomAttributeDS(DicomTags.ImagePositionPatient);
			position.SetFloat32(0, topLeftOfSlicePatient.X);
			position.SetFloat32(1, topLeftOfSlicePatient.Y);
			position.SetFloat32(2, topLeftOfSlicePatient.Z);
			ImagePositionPatient = position.ToString();
		}
Esempio n. 15
0
		public PatientInformation(IDicomAttributeProvider attributeProvider)
		{
			if (attributeProvider[DicomTags.PatientsName] != null)
				Name = attributeProvider[DicomTags.PatientsName].ToString();

			if (attributeProvider[DicomTags.PatientId] != null)
				PatientId = attributeProvider[DicomTags.PatientId].ToString();

			if (attributeProvider[DicomTags.PatientsAge] != null)
				Age = attributeProvider[DicomTags.PatientsAge].ToString();

			if (attributeProvider[DicomTags.PatientsBirthDate] != null)
				PatientsBirthdate = attributeProvider[DicomTags.PatientsBirthDate].ToString();

			if (attributeProvider[DicomTags.PatientsSex] != null)
				Sex = attributeProvider[DicomTags.PatientsSex].ToString();

			if (attributeProvider[DicomTags.IssuerOfPatientId] != null)
				IssuerOfPatientId = attributeProvider[DicomTags.IssuerOfPatientId].ToString();
		}
Esempio n. 16
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ScImageIod"/> class.
		/// </summary>
		/// <param name="dicomAttributeProvider">The DICOM attribute provider.</param>
		public ScImageIod(IDicomAttributeProvider dicomAttributeProvider)
		{
			_dicomAttributeProvider = dicomAttributeProvider;

			_patientModule = new PatientModuleIod(_dicomAttributeProvider);
			_clinicalTrialSubjectModule = new ClinicalTrialSubjectModuleIod(_dicomAttributeProvider);
			_generalStudyModule = new GeneralStudyModuleIod(_dicomAttributeProvider);
			_patientStudyModule = new PatientStudyModuleIod(_dicomAttributeProvider);
			_clinicalTrialStudyModule = new ClinicalTrialStudyModuleIod(_dicomAttributeProvider);
			_generalSeriesModule = new GeneralSeriesModuleIod(_dicomAttributeProvider);
			_clinicalTrialSeriesModule = new ClinicalTrialSeriesModuleIod(_dicomAttributeProvider);
			_generalEquipmentModule = new GeneralEquipmentModuleIod(_dicomAttributeProvider);
			_scEquipmentModule = new ScEquipmentModuleIod(_dicomAttributeProvider);
			_generalImageModule = new GeneralImageModuleIod(_dicomAttributeProvider);
			_imagePixelModule = new ImagePixelMacroIod(_dicomAttributeProvider);
			_deviceModule = new DeviceModuleIod(_dicomAttributeProvider);
			_scImageModule = new ScImageModuleIod(_dicomAttributeProvider);
			_overlayPlaneModule = new OverlayPlaneModuleIod(_dicomAttributeProvider);
			_modalityLutModule = new ModalityLutModuleIod(_dicomAttributeProvider);
			_voiLutModule = new VoiLutModuleIod(_dicomAttributeProvider);
			_iccProfileModule = new IccProfileModuleIod(_dicomAttributeProvider);
			_sopCommonModule = new SopCommonModuleIod(_dicomAttributeProvider);
		}
		/// <summary>
		/// Sets the image pixel module on the given dataset.
		/// </summary>
		/// <param name="dataset">The dataset.</param>
		/// <param name="pixelData">The pixel data.</param>
		/// <param name="rows">The number of rows per frame.</param>
		/// <param name="columns">The number of columns per frame.</param>
		/// <param name="frames">The number of frames.</param>
		/// <param name="bitsAllocated">The bits allocated per pixel.</param>
		/// <param name="bitsStored">The bits stored per pixel.</param>
		/// <param name="highBit">The position of the high bit in each pixel allocation.</param>
		/// <param name="isSigned">Whether or not pixels are signed.</param>
		/// <exception cref="ArgumentException">Thrown if input values are inconsistent.</exception>
		public static void SetImagePixels(IDicomAttributeProvider dataset, byte[] pixelData, int rows, int columns, int frames, int bitsAllocated, int bitsStored, int highBit, bool isSigned)
		{
			// sanity check
			Platform.CheckForNullReference(dataset, "dataset");
			Platform.CheckForNullReference(pixelData, "pixelData");
			Platform.CheckArgumentRange(bitsStored, 1, 16, "bitsStored");
			Platform.CheckTrue(highBit >= bitsStored - 1 && highBit <= 15, "highBit must be between bitsStored-1 and 15, inclusive");
			Platform.CheckTrue(bitsAllocated == 8 || bitsAllocated == 16, "bitsAllocated must be 8 or 16");
			Platform.CheckTrue(rows*columns*frames*(bitsAllocated/8) == pixelData.Length, "pixelData must have length equal to rows*columns*frames*bitsAllocated/8");

			// set attributes
			dataset[DicomTags.Rows].SetInt32(0, rows);
			dataset[DicomTags.Columns].SetInt32(0, columns);
			dataset[DicomTags.BitsAllocated].SetInt32(0, bitsAllocated);
			dataset[DicomTags.BitsStored].SetInt32(0, bitsStored);
			dataset[DicomTags.HighBit].SetInt32(0, highBit);
			dataset[DicomTags.SamplesPerPixel].SetInt32(0, 1);
			dataset[DicomTags.PlanarConfiguration].SetInt32(0, 0);
			dataset[DicomTags.PixelRepresentation].SetInt32(0, isSigned ? 1 : 0);
			dataset[DicomTags.NumberOfFrames].SetInt32(0, frames);
			dataset[DicomTags.PhotometricInterpretation].SetStringValue(PhotometricInterpretation.Monochrome2.Code);
			dataset[FixVR(DicomTags.PixelData, bitsAllocated == 16 ? DicomVr.OWvr : DicomVr.OBvr)].Values = pixelData;
		}
 public SegmentationDocumentIod(IDicomAttributeProvider dicomAttributeProvider)
 {
     _dicomAttributeProvider = dicomAttributeProvider;
     _patientModule = new PatientModuleIod(_dicomAttributeProvider);
     _clinicalTrialSubjectModule = new ClinicalTrialSubjectModuleIod(_dicomAttributeProvider);
     _generalStudyModule = new GeneralStudyModuleIod(_dicomAttributeProvider);
     _patientStudyModule = new PatientStudyModuleIod(_dicomAttributeProvider);
     _clinicalTrialStudyModule = new ClinicalTrialStudyModuleIod(_dicomAttributeProvider);
     _generalSeriesModule = new GeneralSeriesModuleIod(_dicomAttributeProvider);
     _segmentationSeriesModule = new SegmentationSeriesModuleIod(_dicomAttributeProvider);
     _clinicalTrialSeriesModule = new ClinicalTrialSeriesModuleIod(_dicomAttributeProvider);
     _frameOfReferenceModule = new FrameOfReferenceModuleIod(_dicomAttributeProvider);
     _generalEquipmentModule = new GeneralEquipmentModuleIod(_dicomAttributeProvider);
     //_enhanceGeneralEquipmentModule = new EnhanceGeneralEquipmentModuleIod(_dicomAttributeProvider);
     _generalImageModule = new GeneralImageModuleIod(_dicomAttributeProvider);
     _imagePixelModule = new ImagePixelMacroIod(_dicomAttributeProvider);
     _segmentationImageModule = new SegmentationImageModuleIod(_dicomAttributeProvider);
     _multiFrameFunctionalGroupsModule = new MultiFrameFunctionalGroupsModuleIod(_dicomAttributeProvider);
     _multiFrameDimensionModule = new MultiFrameDimensionModuleIod(_dicomAttributeProvider);
     _specimenModule = new SpecimenModuleIod(_dicomAttributeProvider);
     _commonInstanceReferenceModule = new CommonInstanceReferenceModuleIod(_dicomAttributeProvider);
     _sopCommonModule = new SopCommonModuleIod(_dicomAttributeProvider);
     _frameExtractionModule = new FrameExtractionModuleIod(_dicomAttributeProvider);
 }
		/// <summary>
		/// Sets an overlay plane module on the given dataset by embedding the overlay in an unused bit of the Pixel Data.
		/// </summary>
		/// <remarks>
		/// Call <see cref="SetImagePixels"/> before calling this method as it updates the current PixelData in the dataset.
		/// </remarks>
		/// <param name="dataset">The dataset.</param>
		/// <param name="overlayIndex">The index of the overlay plane.</param>
		/// <param name="overlayData">The overlay data.</param>
		/// <param name="type">The overlay type.</param>
		/// <param name="origin">The overlay origin per frame.</param>
		/// <param name="bitPosition">The position of the unused bit in the PixelData where the overlay should be stored.</param>
		/// <param name="bigEndian">Whether or not the dataset is big endian.</param>
		/// <exception cref="ArgumentException">Thrown if input values are inconsistent.</exception>
		public static void AddOverlayPlane(IDicomAttributeProvider dataset, int overlayIndex, bool[] overlayData, OverlayType type, Point origin, int bitPosition, bool bigEndian)
		{
			Platform.CheckForNullReference(dataset, "dataset");

			var rows = dataset[DicomTags.Rows].GetInt32(0, 0);
			var columns = dataset[DicomTags.Columns].GetInt32(0, 0);
			var frames = dataset[DicomTags.NumberOfFrames].GetInt32(0, 1);
			var bitsAllocated = dataset[DicomTags.BitsAllocated].GetInt32(0, 16);
			var bitsStored = dataset[DicomTags.BitsStored].GetInt32(0, 16);
			var highBit = dataset[DicomTags.HighBit].GetInt32(0, bitsStored - 1);
			var pixelData = (byte[]) dataset[DicomTags.PixelData].Values;

			// sanity check
			Platform.CheckForNullReference(overlayData, "overlayData");
			Platform.CheckArgumentRange(overlayIndex, 0, 15, "overlayIndex");
			Platform.CheckTrue(bitPosition >= 0 && bitPosition <= 15 && (bitPosition > highBit || bitPosition <= highBit - bitsStored), "bitPosition must specify an unused bit");
			Platform.CheckTrue(rows*columns*frames == overlayData.Length, "overlayData must have length equal to rows*columns*frames");
			Platform.CheckArgumentRange(bitsStored, 1, 16, "bitsStored");
			Platform.CheckTrue(highBit >= bitsStored - 1 && highBit <= 15, "highBit must be between bitsStored-1 and 15, inclusive");
			Platform.CheckTrue(bitsAllocated == 8 || bitsAllocated == 16, "bitsAllocated must be 8 or 16");
			Platform.CheckTrue(rows*columns*frames*(bitsAllocated/8) == pixelData.Length, "pixelData must have length equal to rows*columns*frames*bitsAllocated/8");

			uint tagOffset = ((uint) overlayIndex)*2*0x10000;

			// set basic attributes
			dataset[tagOffset + DicomTags.OverlayRows].SetInt32(0, rows);
			dataset[tagOffset + DicomTags.OverlayColumns].SetInt32(0, columns);
			dataset[tagOffset + DicomTags.OverlayType].SetString(0, type.ToString());
			dataset[tagOffset + DicomTags.OverlayOrigin].SetStringValue(string.Format(@"{0}\{1}", origin.X, origin.Y));
			dataset[tagOffset + DicomTags.OverlayBitsAllocated].SetInt32(0, bitsAllocated);
			dataset[tagOffset + DicomTags.OverlayBitPosition].SetInt32(0, bitPosition);

			// set multiframe attributes
			if (frames > 1)
				dataset[tagOffset + DicomTags.NumberOfFramesInOverlay].SetInt32(0, frames);
			else
				dataset[tagOffset + DicomTags.NumberOfFramesInOverlay].SetEmptyValue();
			dataset[tagOffset + DicomTags.ImageFrameOrigin].SetEmptyValue();

			// set overlay in unused bits of pixel data
			if (bitsAllocated == 16)
			{
				var highByte = bigEndian ? 0 : 1; // in a big endian word, the high byte is first
				var overlayBitMaskLow = (byte) (bitPosition <= 7 ? (1 << bitPosition) : 0);
				var overlayBitMaskHigh = (byte) (bitPosition > 7 ? (1 << (bitPosition - 8)) : 0);
				for (int i = 0; i < overlayData.Length; i++)
				{
					var cursor = i*2;
					pixelData[cursor + highByte] = (byte) ((pixelData[cursor + highByte] & ~overlayBitMaskHigh) | (overlayData[i] ? overlayBitMaskHigh : (byte) 0));
					pixelData[cursor + 1 - highByte] = (byte) ((pixelData[cursor + 1 - highByte] & ~overlayBitMaskLow) | (overlayData[i] ? overlayBitMaskLow : (byte) 0));
				}
			}
			else if (bitsAllocated == 8)
			{
				var overlayBitMask = (byte) (1 << bitPosition);
				for (int i = 0; i < overlayData.Length; i++)
				{
					pixelData[i] = (byte) ((pixelData[i] & ~overlayBitMask) | (overlayData[i] ? overlayBitMask : (byte) 0));
				}
			}
			dataset[DicomTags.PixelData].Values = pixelData;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="PetMultiGatedAcquisitionModuleIod"/> class.
		/// </summary>
		/// <param name="dicomAttributeProvider">The DICOM attribute collection.</param>
		public PetMultiGatedAcquisitionModuleIod(IDicomAttributeProvider dicomAttributeProvider)
			: base(dicomAttributeProvider) {}
		/// <summary>
		/// Initializes a new instance of the <see cref="PresentationSeriesModuleIod"/> class.
		/// </summary>
		public PresentationSeriesModuleIod(IDicomAttributeProvider provider) : base(provider) {}
		/// <summary>
		/// Initializes a new instance of the <see cref="ClinicalTrialSeriesModuleIod"/> class.
		/// </summary>
		public ClinicalTrialSeriesModuleIod(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider) { }
        /// <summary>
        /// Gets the specified functional group for a specific frame in the data set.
        /// </summary>
        /// <remarks>
        /// This method automatically handles getting the correct functional group IOD class for the specified frame, regardless
        /// whether the functional group exists in the Per-Frame Functional Groups Sequence, or the Shared Functional Groups Sequence.
        /// </remarks>
        /// <param name="functionalGroupDescriptor">The functional group type (derived class of <see cref="FunctionalGroupMacro"/>).</param>
        /// <param name="dataSet">The DICOM data set of the composite image SOP instance.</param>
        /// <param name="frameNumber">The DICOM frame number to be retrieved (1-based index).</param>
        /// <returns>A new instance of <paramref name="functionalGroupDescriptor"/> wrapping the sequence item pertaining to the specified frame.</returns>
        public static FunctionalGroupMacro GetFunctionalGroup(FunctionalGroupDescriptor functionalGroupDescriptor, IDicomAttributeProvider dataSet, int frameNumber)
        {
            bool dummy;

            return(GetFunctionalGroup(functionalGroupDescriptor, dataSet, frameNumber, out dummy));
        }
        /// <summary>
        /// Gets the specified functional group for a specific frame in the data set.
        /// </summary>
        /// <remarks>
        /// This method automatically handles getting the correct functional group IOD class for the specified frame, regardless
        /// whether the functional group exists in the Per-Frame Functional Groups Sequence, or the Shared Functional Groups Sequence.
        /// </remarks>
        /// <param name="functionalGroupDescriptor">The functional group type (derived class of <see cref="FunctionalGroupMacro"/>).</param>
        /// <param name="dataSet">The DICOM data set of the composite image SOP instance.</param>
        /// <param name="frameNumber">The DICOM frame number to be retrieved (1-based index).</param>
        /// <param name="isFrameSpecific">Returns True if the functional group was invoked in the Per-Frame Functional Groups Sequence (5200,9230); returns False otherwise.</param>
        /// <returns>A new instance of <paramref name="functionalGroupDescriptor"/> wrapping the sequence item pertaining to the specified frame,.</returns>
        public static FunctionalGroupMacro GetFunctionalGroup(FunctionalGroupDescriptor functionalGroupDescriptor, IDicomAttributeProvider dataSet, int frameNumber, out bool isFrameSpecific)
        {
            Platform.CheckForNullReference(functionalGroupDescriptor, "functionalGroupType");
            Platform.CheckForNullReference(dataSet, "dataSet");
            Platform.CheckPositive(frameNumber, "frameNumber");
            isFrameSpecific = false;

            DicomAttribute sqAttribute;

            if (dataSet.TryGetAttribute(DicomTags.PerFrameFunctionalGroupsSequence, out sqAttribute) && sqAttribute.Count >= frameNumber)
            {
                var sequenceItem    = ((DicomAttributeSQ)sqAttribute)[frameNumber - 1];
                var functionalGroup = functionalGroupDescriptor.Create(sequenceItem);
                if (functionalGroup.HasValues())
                {
                    isFrameSpecific = true;
                    return(functionalGroup);
                }
            }

            if (dataSet.TryGetAttribute(DicomTags.SharedFunctionalGroupsSequence, out sqAttribute) && sqAttribute.Count > 0)
            {
                var sequenceItem    = ((DicomAttributeSQ)sqAttribute)[0];
                var functionalGroup = functionalGroupDescriptor.Create(sequenceItem);
                functionalGroup.DicomSequenceItem = sequenceItem;
                if (functionalGroup.HasValues())
                {
                    return(functionalGroup);
                }
            }

            return(null);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiFrameFunctionalGroupsModuleIod"/> class.
 /// </summary>
 /// <param name="dicomAttributeProvider">The DICOM attribute collection.</param>
 public MultiFrameFunctionalGroupsModuleIod(IDicomAttributeProvider dicomAttributeProvider)
     : base(dicomAttributeProvider)
 {
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="SpecimenIdentificationModuleIod"/> class.
		/// </summary>
		public SpecimenIdentificationModuleIod(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider) {}
 /// <summary>
 /// Initializes a new instance of the <see cref="EncapsulatedDocumentSeriesModuleIod"/> class.
 /// </summary>
 /// <param name="dicomAttributeProvider">The DICOM attribute provider.</param>
 public EncapsulatedDocumentSeriesModuleIod(IDicomAttributeProvider dicomAttributeProvider)
     : base(dicomAttributeProvider)
 {
 }
Esempio n. 28
0
        public static PaletteColorLut Create(IDicomAttributeProvider dataSource)
        {
            int    lutSize, firstMappedPixel, bitsPerLutEntry;
            string sourceSopInstanceUid;

            DicomAttribute attribDescriptor = dataSource[DicomTags.RedPaletteColorLookupTableDescriptor];

            bool tagExists = attribDescriptor.TryGetInt32(0, out lutSize);

            if (!tagExists)
            {
                throw new Exception("LUT Size missing.");
            }

            tagExists = attribDescriptor.TryGetInt32(1, out firstMappedPixel);

            if (!tagExists)
            {
                throw new Exception("First Mapped Pixel missing.");
            }

            tagExists = attribDescriptor.TryGetInt32(2, out bitsPerLutEntry);

            if (!tagExists)
            {
                throw new Exception("Bits Per Entry missing.");
            }

            byte[] redLut = dataSource[DicomTags.RedPaletteColorLookupTableData].Values as byte[];
            if (redLut == null)
            {
                throw new Exception("Red Palette Color LUT missing.");
            }

            byte[] greenLut = dataSource[DicomTags.GreenPaletteColorLookupTableData].Values as byte[];
            if (greenLut == null)
            {
                throw new Exception("Green Palette Color LUT missing.");
            }

            byte[] blueLut = dataSource[DicomTags.BluePaletteColorLookupTableData].Values as byte[];
            if (blueLut == null)
            {
                throw new Exception("Blue Palette Color LUT missing.");
            }

            // The DICOM standard says that if the LUT size is 0, it means that it's 65536 in size.
            if (lutSize == 0)
            {
                lutSize = 65536;
            }

            //TODO (CR Sept 2010): just leave it blank?  There are plenty of use cases for this class without need of a source sop instance uid
            if (!dataSource[DicomTags.SopInstanceUid].TryGetString(0, out sourceSopInstanceUid))
            {
                sourceSopInstanceUid = DicomUid.GenerateUid().UID;
            }

            return(new PaletteColorLut(
                       sourceSopInstanceUid,
                       lutSize,
                       firstMappedPixel,
                       bitsPerLutEntry,
                       redLut,
                       greenLut,
                       blueLut));
        }
Esempio n. 29
0
 public static IAnnotationLayout CreateLayoutByImageSop(IDicomAttributeProvider dicomAttributeProvider)
 {
     return(DicomAnnotationLayoutFactory.CreateLayout(dicomAttributeProvider));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PresentationSeriesModuleIod"/> class.
 /// </summary>
 public PresentationSeriesModuleIod(IDicomAttributeProvider provider) : base(provider)
 {
 }
Esempio n. 31
0
        /// <summary>
        /// Builds a list of <see cref="BaseImageLevelUpdateCommand"/> for the specified study using the specified mapping template.
        /// </summary>
        /// <typeparam name="TMappingObject"></typeparam>
        /// <param name="storage"></param>
        /// <returns></returns>
        /// <remarks>
        /// This method generates a list of <see cref="BaseImageLevelUpdateCommand"/> based on the mapping in <see cref="TMappingObject"/>.
        /// <see cref="TMappingObject"/> specifies which Dicom fields the application is interested in, using <see cref="DicomFieldAttribute"/>.
        /// For example, if the application needs to update the study instance uid and study date in an image with what's in the database,
        /// it will define the mapping class as:
        /// <code>
        /// class StudyInfoMapping
        /// {
        ///     [DicomField(DicomTags.StudyInstanceUid)]
        ///     public String StudyInstanceUid{
        ///         get{ ... }
        ///         set{ ... }
        ///     }
        ///
        ///     [DicomField(DicomTags.StudyDate)]
        ///     public String StudyDate{
        ///         get{ ... }
        ///         set{ ... }
        ///     }
        /// }
        ///
        /// ImageUpdateCommandBuilder builder = new ImageUpdateCommandBuilder();
        /// IList<BaseImageLevelUpdateCommand> commandList = builder.BuildCommands<StudyInfoMapping>(studystorage);
        ///
        /// DicomFile file = new DicomFile("file.dcm");
        /// foreach(BaseImageUpdateCommand command in commandList)
        /// {
        ///     command.Apply(file);
        /// }
        ///
        ///
        /// </code>
        ///
        /// </remarks>
        public IList <BaseImageLevelUpdateCommand> BuildCommands <TMappingObject>(StudyStorage storage, IDicomAttributeProvider originalDicomAttributeProvider)
        {
            IList <StudyStorageLocation> storageLocationList = StudyStorageLocation.FindStorageLocations(storage);

            Debug.Assert(storageLocationList != null && storageLocationList.Count > 0);
            StudyStorageLocation storageLocation = storageLocationList[0];

            return(BuildCommands <TMappingObject>(storageLocation, originalDicomAttributeProvider));
        }
Esempio n. 32
0
        private static IList <BaseImageLevelUpdateCommand> BuildCommandsFromEntity(ServerEntity entity, IDicomAttributeProvider originalDicomAttributeProvider)
        {
            List <BaseImageLevelUpdateCommand> commandList = new List <BaseImageLevelUpdateCommand>();
            EntityDicomMap fieldMap = EntityDicomMapManager.Get(entity.GetType());

            foreach (DicomTag tag in fieldMap.Keys)
            {
                object         value         = fieldMap[tag].GetValue(entity, null);
                string         originalValue = null;
                DicomAttribute attribute;
                if (originalDicomAttributeProvider.TryGetAttribute(tag, out attribute))
                {
                    originalValue = attribute.ToString();
                }

                SetTagCommand cmd = new SetTagCommand(tag.TagValue, originalValue, value != null ? value.ToString() : null);
                commandList.Add(cmd);
            }
            return(commandList);
        }
Esempio n. 33
0
        private static IList <BaseImageLevelUpdateCommand> BuildCommandsFromStudyXml(Type type, StudyXml studyXml, IDicomAttributeProvider originalDicomAttributeProvider)
        {
            var            commandList = new List <BaseImageLevelUpdateCommand>();
            EntityDicomMap fieldMap    = EntityDicomMapManager.Get(type);
            //XmlDocument studyXmlDoc = studyXml.GetMemento(new StudyXmlOutputSettings());

            // Get the First InstanceXml of the first image
            IEnumerator <SeriesXml> seriesEnumerator = studyXml.GetEnumerator();

            seriesEnumerator.MoveNext();
            SeriesXml seriesXml = seriesEnumerator.Current;
            IEnumerator <InstanceXml> instanceEnumerator = seriesXml.GetEnumerator();

            instanceEnumerator.MoveNext();
            InstanceXml instanceXml = instanceEnumerator.Current;

            foreach (DicomTag tag in fieldMap.Keys)
            {
                string         originalValue = null;
                string         newValue      = null;
                DicomAttribute attribute;

                if (originalDicomAttributeProvider != null && originalDicomAttributeProvider.TryGetAttribute(tag, out attribute))
                {
                    originalValue = attribute.ToString();
                }

                if (instanceXml != null)
                {
                    attribute = instanceXml[tag];
                }
                else
                {
                    attribute = null;
                }
                if (attribute != null)
                {
                    newValue = attribute.ToString();
                }
                SetTagCommand cmd = new SetTagCommand(tag.TagValue, originalValue, newValue);
                commandList.Add(cmd);
            }
            return(commandList);
        }
Esempio n. 34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DisplayedAreaModuleIod"/> class.
 /// </summary>
 public DisplayedAreaModuleIod(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PerformedProcedureStepInformationModuleIod"/> class.
 /// </summary>
 public PerformedProcedureStepInformationModuleIod(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider)
 {
 }
Esempio n. 36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RadiationDoseModuleIod"/> class.
 /// </summary>
 public RadiationDoseModuleIod(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider)
 {
 }
Esempio n. 37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilmBoxModuleIod"/> class.
 /// </summary>
 public BasicFilmBoxModuleIod(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider)
 {
 }
Esempio n. 38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GeneralEquipmentModuleIod"/> class.
 /// </summary>
 public GeneralEquipmentModuleIod(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BitmapDisplayShutterModuleIod"/> class.
 /// </summary>
 public BitmapDisplayShutterModuleIod(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider)
 {
 }
Esempio n. 40
0
		/// <summary>
		/// Initializes a new instance of the <see cref="SrDocumentContentModuleIod"/> class.
		/// </summary>
		public SrDocumentContentModuleIod(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider) { }
        public static IAnnotationLayout CreateLayout(IDicomAttributeProvider dicomAttributeProvider)
        {
            string layoutId = DicomFilteredAnnotationLayoutStore.Instance.GetMatchingStoredLayoutId(dicomAttributeProvider);

            return(AnnotationLayoutFactory.CreateLayout(layoutId));
        }
Esempio n. 42
0
        /// <summary>
		/// Initializes a new instance of the <see cref="MultiframeOverlayModule"/> class.
        /// </summary>
		public MultiframeOverlayModule(IDicomAttributeProvider dicomAttributeProvider)
			: base(dicomAttributeProvider)
        {
        }
		/// <summary>
		/// Sets an overlay plane module on the given dataset using the OverlayData attribute.
		/// </summary>
		/// <param name="dataset">The dataset.</param>
		/// <param name="overlayIndex">The index of the overlay plane.</param>
		/// <param name="overlayData">The overlay data.</param>
		/// <param name="type">The overlay type.</param>
		/// <param name="origin">The overlay origin.</param>
		/// <param name="rows">The number of rows.</param>
		/// <param name="columns">The number of columns.</param>
		/// <param name="bigEndian">Whether or not the dataset is big endian.</param>
		/// <param name="useOW">Whether or not OverlayData should have a VR of OW.</param>
		/// <exception cref="ArgumentException">Thrown if input values are inconsistent.</exception>
		public static void AddOverlayPlane(IDicomAttributeProvider dataset, int overlayIndex, bool[] overlayData, OverlayType type, Point origin, int rows, int columns, bool bigEndian, bool useOW)
		{
			AddOverlayPlane(dataset, overlayIndex, overlayData, type, origin, rows, columns, null, null, bigEndian, useOW);
		}
Esempio n. 44
0
		/// <summary>
		/// Initializes a new instance of the <see cref="SopCommonModuleIod"/> class.
		/// </summary>
		/// <param name="dicomAttributeProvider">The DICOM attribute provider.</param>
		public SopCommonModuleIod(IDicomAttributeProvider dicomAttributeProvider)
			: base(dicomAttributeProvider) {}
 /// <summary>
 /// Initializes a new instance of the <see cref="BasicPixelSpacingCalibrationMacro"/> class.
 /// </summary>
 /// <param name="dicomAttributeProvider">The <see cref="IDicomAttributeProvider"/>.</param>
 public BasicPixelSpacingCalibrationMacro(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider)
 {
 }
		/// <summary>
		/// Sets an overlay plane module on the given dataset using the OverlayData attribute.
		/// </summary>
		/// <param name="dataset">The dataset.</param>
		/// <param name="overlayIndex">The index of the overlay plane.</param>
		/// <param name="overlayData">The overlay data.</param>
		/// <param name="type">The overlay type.</param>
		/// <param name="origin">The overlay origin per frame.</param>
		/// <param name="rows">The number of rows per frame.</param>
		/// <param name="columns">The number of columns per frame.</param>
		/// <param name="frames">The number of frames. If NULL, will not set multiframe attributes.</param>
		/// <param name="frameOrigin">The number of the image frame that matches the first overlay frame. If NULL, the attribute is not included and the reader is supposed to assume 1.</param>
		/// <param name="bigEndian">Whether or not the dataset is big endian.</param>
		/// <param name="useOW">Whether or not OverlayData should have a VR of OW.</param>
		/// <exception cref="ArgumentException">Thrown if input values are inconsistent.</exception>
		public static void AddOverlayPlane(IDicomAttributeProvider dataset, int overlayIndex, bool[] overlayData, OverlayType type, Point origin, int rows, int columns, int? frames, int? frameOrigin, bool bigEndian, bool useOW)
		{
			// sanity check
			Platform.CheckForNullReference(dataset, "dataset");
			Platform.CheckForNullReference(overlayData, "overlayData");
			Platform.CheckArgumentRange(overlayIndex, 0, 15, "overlayIndex");
			Platform.CheckTrue(rows*columns*frames.GetValueOrDefault(1) == overlayData.Length, "overlayData must have length equal to rows*columns*frames");

			uint tagOffset = ((uint) overlayIndex)*2*0x10000;

			// set basic attributes
			dataset[tagOffset + DicomTags.OverlayRows].SetInt32(0, rows);
			dataset[tagOffset + DicomTags.OverlayColumns].SetInt32(0, columns);
			dataset[tagOffset + DicomTags.OverlayType].SetString(0, type.ToString());
			dataset[tagOffset + DicomTags.OverlayOrigin].SetStringValue(string.Format(@"{0}\{1}", origin.X, origin.Y));
			dataset[tagOffset + DicomTags.OverlayBitsAllocated].SetInt32(0, 1);
			dataset[tagOffset + DicomTags.OverlayBitPosition].SetInt32(0, 0);

			// set multiframe attributes
			if (frames.HasValue)
			{
				dataset[tagOffset + DicomTags.NumberOfFramesInOverlay].SetInt32(0, frames.Value);
				if (frameOrigin.HasValue)
					dataset[tagOffset + DicomTags.ImageFrameOrigin].SetInt32(0, frameOrigin.Value);
				else
					dataset[tagOffset + DicomTags.ImageFrameOrigin].SetEmptyValue();
			}
			else
			{
				dataset[tagOffset + DicomTags.NumberOfFramesInOverlay].SetEmptyValue();
				dataset[tagOffset + DicomTags.ImageFrameOrigin].SetEmptyValue();
			}

			// set overlay data by bit packing
			var packedBitsLength = (int) Math.Ceiling(overlayData.Length/8f);
			var packedBits = new byte[packedBitsLength + (packedBitsLength%2)];
			if (useOW)
			{
				var highByte = bigEndian ? 0 : 1; // in a big endian word, the high byte is first
				var cursor = 0;
				ushort window = 0;
				for (int n = 0; n < overlayData.Length; n++)
				{
					window = (ushort) (((window >> 1) & 0x007FFF) | (overlayData[n] ? 0x008000 : 0x000000));
					if ((n + 1)%16 == 0)
					{
						packedBits[cursor + highByte] = (byte) ((window >> 8) & 0x00FF);
						packedBits[cursor + 1 - highByte] = (byte) (window & 0x00FF);
						cursor += 2;
						window = 0;
					}
				}

				// flush the last window
				if (cursor == packedBits.Length - 1)
				{
					packedBits[cursor + highByte] = (byte) ((window >> 8) & 0x00FF);
					packedBits[cursor + 1 - highByte] = (byte) (window & 0x00FF);
				}
			}
			else
			{
				var cursor = 0;
				byte window = 0;
				for (int n = 0; n < overlayData.Length; n++)
				{
					window = (byte) (((window >> 1) & 0x007F) | (overlayData[n] ? 0x0080 : 0x0000));
					if ((n + 1)%8 == 0)
					{
						packedBits[cursor++] = window;
						window = 0;
					}
				}

				// flush the last window
				if (cursor == packedBits.Length - 1)
					packedBits[cursor] = window;
			}
			dataset[FixVR(tagOffset + DicomTags.OverlayData, useOW ? DicomVr.OWvr : DicomVr.OBvr)].Values = packedBits;
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="SpecimenIdentificationModuleIod"/> class.
 /// </summary>
 public SpecimenIdentificationModuleIod(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider)
 {
 }
Esempio n. 48
0
        private static void FillDataSet(IDicomAttributeProvider volumeDataSet, IList <IDicomAttributeProvider> sourceSops, int bitsAllocated, int bitsStored, bool isSigned, double rescaleSlope, double rescaleIntercept, string laterality)
        {
            const string enumYes      = "YES";
            const string enumNo       = "NO";
            const string enumLossy    = "01";
            const string enumLossless = "00";

            var source = sourceSops[0];

            // perform exact copy on the Patient Module
            foreach (uint tag in PatientModuleIod.DefinedTags)
            {
                volumeDataSet[tag] = source[tag].Copy();
            }

            // perform exact copy on the Clinical Trial Subject Module
            foreach (uint tag in ClinicalTrialSubjectModuleIod.DefinedTags)
            {
                volumeDataSet[tag] = source[tag].Copy();
            }

            // perform exact copy on the General Study Module
            foreach (uint tag in GeneralStudyModuleIod.DefinedTags)
            {
                volumeDataSet[tag] = source[tag].Copy();
            }

            // perform exact copy on the Patient Study Module
            foreach (uint tag in PatientStudyModuleIod.DefinedTags)
            {
                volumeDataSet[tag] = source[tag].Copy();
            }

            // perform exact copy on the Clinical Trial Study Module
            foreach (uint tag in ClinicalTrialStudyModuleIod.DefinedTags)
            {
                volumeDataSet[tag] = source[tag].Copy();
            }

            // perform exact copy on the General Series Module except for tags that will be overridden as part of reformatting
            foreach (uint tag in GeneralSeriesModuleIod.DefinedTags.Except(new[] { DicomTags.LargestPixelValueInSeries, DicomTags.SmallestPixelValueInSeries, DicomTags.SeriesInstanceUid }))
            {
                volumeDataSet[tag] = source[tag].Copy();
            }

            // perform exact copy on the Clinical Trial Series Module
            foreach (uint tag in ClinicalTrialSeriesModuleIod.DefinedTags)
            {
                volumeDataSet[tag] = source[tag].Copy();
            }

            // perform exact copy on additional modality specific modules in the series IE
            foreach (uint tag in ModalitySpecificSeriesModuleTags)
            {
                volumeDataSet[tag] = source[tag].Copy();
            }

            // perform exact copy on the General Equipment Module
            foreach (uint tag in GeneralEquipmentModuleIod.DefinedTags)
            {
                volumeDataSet[tag] = source[tag].Copy();
            }

            // copy volume-consistent values for the Frame of Reference Module
            foreach (uint tag in FrameOfReferenceModuleIod.DefinedTags)
            {
                volumeDataSet[tag] = source[tag].Copy();
            }

            // update computed normalized values for the Modality LUT Module
            volumeDataSet[DicomTags.RescaleSlope].SetFloat64(0, rescaleSlope);
            volumeDataSet[DicomTags.RescaleIntercept].SetFloat64(0, rescaleIntercept);
            volumeDataSet[DicomTags.RescaleType] = source[DicomTags.RescaleType].Copy();
            volumeDataSet[DicomTags.Units]       = source[DicomTags.Units].Copy();       // PET series use this attribute to designate rescale units

            // generate volume-consistent values for the General Image Module
            var burnedInAnnotationValues         = sourceSops.Select(s => s[DicomTags.BurnedInAnnotation].GetBoolean(0, enumYes, enumNo)).ToList();
            var burnedInAnnotation               = burnedInAnnotationValues.Any(v => v.GetValueOrDefault(false)) ? true : (burnedInAnnotationValues.All(v => !v.GetValueOrDefault(true)) ? false : (bool?)null);
            var recognizableVisualFeaturesValues = sourceSops.Select(s => s[DicomTags.RecognizableVisualFeatures].GetBoolean(0, enumYes, enumNo)).ToList();
            var recognizableVisualFeatures       = recognizableVisualFeaturesValues.Any(v => v.GetValueOrDefault(false)) ? true : (recognizableVisualFeaturesValues.All(v => !v.GetValueOrDefault(true)) ? false : (bool?)null);
            var lossyImageCompressionValues      = sourceSops.Select(s => s[DicomTags.LossyImageCompression].GetBoolean(0, enumLossy, enumLossless)).ToList();
            var lossyImageCompression            = lossyImageCompressionValues.Any(v => v.GetValueOrDefault(false)) ? true : (lossyImageCompressionValues.All(v => !v.GetValueOrDefault(true)) ? false : (bool?)null);
            var lossyImageCompressionRatioValues = sourceSops.Select(s => s[DicomTags.LossyImageCompressionRatio].GetFloat32(0, 0)).ToList();
            var lossyImageCompressionRatio       = lossyImageCompressionRatioValues.Max();

            volumeDataSet[DicomTags.BurnedInAnnotation].SetBoolean(0, burnedInAnnotation, enumYes, enumNo);
            volumeDataSet[DicomTags.RecognizableVisualFeatures].SetBoolean(0, recognizableVisualFeatures, enumYes, enumNo);
            volumeDataSet[DicomTags.LossyImageCompression].SetBoolean(0, lossyImageCompression, enumLossy, enumLossless);
            if (lossyImageCompressionRatio > 0)
            {
                volumeDataSet[DicomTags.LossyImageCompressionRatio].SetFloat32(0, lossyImageCompressionRatio);
            }

            // record the source images for the General Image Module
            volumeDataSet[DicomTags.SourceImageSequence].Values = CreateSourceImageSequence(sourceSops);

            // generate volume-consistent values for the Image Pixel Module
            volumeDataSet[DicomTags.SamplesPerPixel]           = source[DicomTags.SamplesPerPixel].Copy();
            volumeDataSet[DicomTags.PhotometricInterpretation] = source[DicomTags.PhotometricInterpretation].Copy();
            volumeDataSet[DicomTags.BitsAllocated].SetInt32(0, bitsAllocated);
            volumeDataSet[DicomTags.BitsStored].SetInt32(0, bitsStored);
            volumeDataSet[DicomTags.HighBit].SetInt32(0, bitsStored - 1);
            volumeDataSet[DicomTags.PixelRepresentation].SetInt32(0, isSigned ? 1 : 0);

            // fill values for additional modality specific modules in the image IE
            if (!string.IsNullOrEmpty(laterality))
            {
                volumeDataSet[DicomTags.ImageLaterality].SetStringValue(laterality);
            }
        }
Esempio n. 49
0
        public IList <BaseImageLevelUpdateCommand> BuildCommands <TMappingObject>(StudyStorageLocation storageLocation, IDicomAttributeProvider originalDicomAttributeProvider)
        {
            StudyXml studyXml = GetStudyXml(storageLocation);
            List <BaseImageLevelUpdateCommand> commandList = new List <BaseImageLevelUpdateCommand>();

            if (studyXml.NumberOfStudyRelatedInstances == 0)
            {
                // StudyXml is empty, resort to the db instead.
                Study study = storageLocation.LoadStudy(ServerExecutionContext.Current.PersistenceContext);
                IList <BaseImageLevelUpdateCommand> cmds = BuildCommandsFromEntity(study, originalDicomAttributeProvider);

                // find the original values from originalDicomAttributeProvider
                if (originalDicomAttributeProvider != null)
                {
                    foreach (BaseImageLevelUpdateCommand cmd in cmds)
                    {
                        IUpdateImageTagCommand theCmd = cmd;
                        if (theCmd != null)
                        {
                            DicomAttribute attribute;
                            if (originalDicomAttributeProvider.TryGetAttribute(theCmd.UpdateEntry.TagPath.Tag, out attribute))
                            {
                                theCmd.UpdateEntry.OriginalValue = attribute.ToString();
                            }
                        }
                    }
                }

                commandList.AddRange(cmds);
            }
            else
            {
                commandList.AddRange(BuildCommandsFromStudyXml(typeof(TMappingObject), studyXml, originalDicomAttributeProvider));
            }

            return(commandList);
        }
Esempio n. 50
0
        /// <summary>
		/// Initializes a new instance of the <see cref="QueryIodBase"/> class.
        /// </summary>
		public QueryIodBase(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider)
        {
            SetAttributeFromEnum(DicomAttributeProvider[DicomTags.QueryRetrieveLevel], QueryRetrieveLevel.Series);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiframeOverlayModule"/> class.
 /// </summary>
 public MultiframeOverlayModule(IDicomAttributeProvider dicomAttributeProvider)
     : base(dicomAttributeProvider)
 {
 }
		public static IAnnotationLayout CreateLayout(IDicomAttributeProvider dicomAttributeProvider)
		{
			string layoutId = DicomFilteredAnnotationLayoutStore.Instance.GetMatchingStoredLayoutId(dicomAttributeProvider);
			return AnnotationLayoutFactory.CreateLayout(layoutId);
		}
Esempio n. 53
0
 /// <summary>
 /// Initializes a new instance of the Iod class.
 /// </summary>
 /// <param name="_dicomAttributeCollection"></param>
 public RequestedProcedureModuleIod(IDicomAttributeProvider dicomAttributeProvider) : base(dicomAttributeProvider)
 {
 }