/// <summary> /// Creates an instance of <see cref="UpdateSeriesCommand"/> to update the existing Series record in the database /// </summary> public UpdateSeriesCommand(StudyStorageLocation storageLocation, ServerActionContext sopContext) : base(String.Concat("Update Series Command")) { _storageLocation = storageLocation; _data = sopContext.Message.DataSet; _context = sopContext; }
public void AssertTagValueChanged(uint tag, string valueToSet, string originalCharacterSet, string expectedNewCharacterSet) { DicomAttributeCollection dataset = new DicomAttributeCollection(); SetupDataSet(dataset, originalCharacterSet); DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset); Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString()); SetTagCommand cmd = new SetTagCommand(tag, valueToSet); Assert.AreEqual(cmd.CanSaveInUnicode, UnicodeAllowed, "SetTagCommand.CanSaveInUnicode returns an incorrect value"); Assert.IsTrue(cmd.Apply(file), "SetTagCommand.Apply failed"); var filename = string.Format("Test-{0}.dcm", DicomTagDictionary.GetDicomTag(tag).Name); Assert.IsTrue(file.Save(filename), "Unable to save dicom file"); file = new DicomFile(filename); file.Load(); if (valueToSet == null) Assert.AreEqual(string.Empty, file.DataSet[tag].ToString()); else Assert.AreEqual(valueToSet, file.DataSet[tag].ToString()); Assert.IsTrue(file.DataSet[DicomTags.SpecificCharacterSet].ToString().Equals(expectedNewCharacterSet)); Delete(filename); }
public void TestFormatNil() { var dataset = new DicomAttributeCollection(); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null), "1"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null, false), "2"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription), "3"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription, false), "4"); dataset[DicomTags.PatientBreedCodeSequence].SetNullValue(); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null), "5"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null, false), "6"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription), "7"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription, false), "8"); dataset[DicomTags.PatientBreedDescription].SetNullValue(); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null), "9"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null, false), "10"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription), "11"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription, false), "12"); dataset[DicomTags.PatientBreedCodeSequence].SetEmptyValue(); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null), "13"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, null, false), "14"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription), "15"); Assert.IsEmpty(CodeSequenceAnnotationItem.FormatCodeSequence(dataset, DicomTags.PatientBreedCodeSequence, DicomTags.PatientBreedDescription, false), "16"); }
public void OBAttributeOddLengthTests() { using(var ms = new MemoryStream()) { var writer = new DicomStreamWriter(ms); var ds = new DicomAttributeCollection(); var rawdata = new byte[] {0x0, 0x1, 0x2}; ds[DicomTags.EncapsulatedDocument].Values = rawdata; writer.Write(TransferSyntax.ImplicitVrLittleEndian, ds, DicomWriteOptions.Default); ms.Position = 0; var output = ms.ToArray(); var expectedOutput = new byte[] { 0x42, 0x00, 0x11, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0, 0x1, 0x2, 0x0 /* pad */ }; Assert.AreEqual(output, expectedOutput); } }
private void _queryButton_Click(object sender, EventArgs e) { var scu = new StudyRootFindScu(); var query = new DicomAttributeCollection(); scu.AssociationRejected += scu_AssociationRejected; scu.AssociationAccepted += scu_AssociationAccepted; scu.AssociationReleased += scu_AssociationReleased; scu.AssociationAborted += scu_AssociationAborted; scu.NetworkError += scu_NetworkError; query[DicomTags.QueryRetrieveLevel].SetStringValue("STUDY"); query[DicomTags.PatientId].SetStringValue(""); query[DicomTags.PatientsName].SetStringValue(""); query[DicomTags.AccessionNumber].SetStringValue(""); query[DicomTags.StudyDescription].SetStringValue(""); query[DicomTags.StudyDate].SetStringValue(""); query[DicomTags.StudyInstanceUid].SetStringValue(""); if (_studyDateTextBox.Text != "") { query[DicomTags.StudyDate].SetStringValue(_studyDateTextBox.Text +"-" + DateTime.Today.ToString("yyyyMMdd")); } _results = null; _results = scu.Find(_aeTitleTextbox.Text, _calledAETitleTextbox.Text, _hostnameTextbox.Text, int.Parse(_portTextbox.Text), query); scu.Dispose(); }
public void TestIsValidMultiFrameOverlay() { const int size = 3; var dataset = new DicomAttributeCollection(); SetOverlay(dataset, 0, new bool[size*size], OverlayType.R, new Point(0, 0), size, size, null, false, false); SetOverlay(dataset, 1, new bool[size*size], OverlayType.R, new Point(0, 0), size, size, 1, false, false); SetOverlay(dataset, 2, new bool[size*size*5], OverlayType.R, new Point(0, 0), size, size, 5, false, false); SetOverlay(dataset, 3, new bool[size*size], OverlayType.R, new Point(0, 0), size, size, 1, 3, false, false); SetOverlay(dataset, 4, new bool[size*size*5], OverlayType.R, new Point(0, 0), size, size, 5, 2, false, false); var module = new OverlayPlaneModuleIod(dataset); Assert.IsTrue(module[0].IsValidMultiFrameOverlay(1), "Single Frame Overlay / 1 Frame in Image"); Assert.IsTrue(module[0].IsValidMultiFrameOverlay(2), "Single Frame Overlay / 2 Frames in Image"); Assert.IsTrue(module[1].IsValidMultiFrameOverlay(1), "1 Frame in Overlay (origin null==1) / 1 Frame in Image"); Assert.IsTrue(module[1].IsValidMultiFrameOverlay(2), "1 Frame in Overlay (origin null==1) / 2 Frames in Image"); Assert.IsFalse(module[2].IsValidMultiFrameOverlay(4), "5 Frames in Overlay (origin null==1) / 4 Frames in Image"); Assert.IsTrue(module[2].IsValidMultiFrameOverlay(5), "5 Frames in Overlay (origin null==1) / 5 Frames in Image"); Assert.IsTrue(module[2].IsValidMultiFrameOverlay(6), "5 Frames in Overlay (origin null==1) / 6 Frames in Image"); Assert.IsFalse(module[3].IsValidMultiFrameOverlay(2), "1 Frames in Overlay (origin 3) / 2 Frames in Image"); Assert.IsTrue(module[3].IsValidMultiFrameOverlay(3), "1 Frames in Overlay (origin 3) / 3 Frames in Image"); Assert.IsTrue(module[3].IsValidMultiFrameOverlay(4), "1 Frames in Overlay (origin 3) / 4 Frames in Image"); Assert.IsFalse(module[4].IsValidMultiFrameOverlay(5), "5 Frames in Overlay (origin 2) / 5 Frames in Image"); Assert.IsTrue(module[4].IsValidMultiFrameOverlay(6), "5 Frames in Overlay (origin 2) / 6 Frames in Image"); Assert.IsTrue(module[4].IsValidMultiFrameOverlay(7), "5 Frames in Overlay (origin 2) / 7 Frames in Image"); }
public void SetupMRWithUNVR(DicomAttributeCollection theSet) { SetupMR(theSet); theSet[DicomTags.LossyImageCompressionMethod].SetStringValue("ISO_15444_1"); ConvertAttributeToUN(theSet, DicomTags.LossyImageCompressionMethod); }
public void SelectAllSeries() { Study study = CreateTestStudy1(); var criteria = new DicomAttributeCollection(); var filters = new SeriesPropertyFilters(criteria); var results = filters.FilterResults(study.GetSeries().Cast<Series>()); Assert.AreEqual(4, results.Count()); }
/// <summary> /// Constructs a new <see cref="PatientNode"/> using actual values from attributes in the given <see cref="DicomAttributeCollection"/>. /// </summary> /// <param name="dicomDataSet">The data set from which to initialize this node.</param> public PatientNode(DicomAttributeCollection dicomDataSet) { _studies = new StudyNodeCollection(this); _patientId = dicomDataSet[DicomTags.PatientId].GetString(0, ""); _name = dicomDataSet[DicomTags.PatientsName].GetString(0, ""); _birthdate = DicomConverter.GetDateTime(dicomDataSet[DicomTags.PatientsBirthDate].GetDateTime(0), dicomDataSet[DicomTags.PatientsBirthTime].GetDateTime(0)); _sex = DicomConverter.GetSex(dicomDataSet[DicomTags.PatientsSex].GetString(0, "")); }
public PixelDataInfo(DicomAttributeCollection dataset) { dataset.LoadDicomFields(this); AspectRatio = PixelAspectRatio.FromString(dataset[DicomTags.PixelAspectRatio].ToString()) ?? new PixelAspectRatio(0, 0); PixelSpacing = PixelSpacing.FromString(dataset[DicomTags.PixelSpacing].ToString()) ?? new PixelSpacing(0, 0); ImagerPixelSpacing = PixelSpacing.FromString(dataset[DicomTags.ImagerPixelSpacing].ToString()) ?? new PixelSpacing(0, 0); }
public IList<DicomAttributeCollection> SetupMRSeries(int seriesCount, int instancesPerSeries, string studyInstanceUid) { List<DicomAttributeCollection> instanceList = new List<DicomAttributeCollection>(); DicomAttributeCollection baseCollection = new DicomAttributeCollection(); SetupMR(baseCollection); baseCollection[DicomTags.StudyInstanceUid].SetStringValue(studyInstanceUid); int acquisitionNumber = 1; int instanceNumber = 100; float positionX = -61.7564f; float positionY = -212.04848f; float positionZ = -99.6208f; float orientation1 = 0.861f; float orientation2 = 0.492f; float orientation3 = 0.126f; float orientation4 = -0.2965f; for (int i = 0; i < seriesCount; i++) { string seriesInstanceUid = DicomUid.GenerateUid().UID; for (int j = 0; j < instancesPerSeries; j++) { string sopInstanceUid = DicomUid.GenerateUid().UID; DicomAttributeCollection instanceCollection = baseCollection.Copy(); instanceCollection[DicomTags.SopInstanceUid].SetStringValue(sopInstanceUid); instanceCollection[DicomTags.SeriesInstanceUid].SetStringValue(seriesInstanceUid); instanceCollection[DicomTags.SeriesNumber].SetStringValue((i + 1).ToString()); instanceCollection[DicomTags.SeriesDescription].SetStringValue("Series" + (i + 1).ToString()); instanceCollection[DicomTags.AcquisitionNumber].SetStringValue(acquisitionNumber++.ToString()); instanceCollection[DicomTags.InstanceNumber].SetStringValue(instanceNumber++.ToString()); instanceCollection[DicomTags.ImagePositionPatient].SetFloat32(0, positionX); instanceCollection[DicomTags.ImagePositionPatient].SetFloat32(1, positionY); instanceCollection[DicomTags.ImagePositionPatient].SetFloat32(2, positionZ); positionY += 0.1f; instanceCollection[DicomTags.ImageOrientationPatient].SetFloat32(0, orientation1); instanceCollection[DicomTags.ImageOrientationPatient].SetFloat32(1, orientation2); instanceCollection[DicomTags.ImageOrientationPatient].SetFloat32(2, orientation3); instanceCollection[DicomTags.ImageOrientationPatient].SetFloat32(2, orientation4); orientation2 += 0.01f; instanceList.Add(instanceCollection); } } return instanceList; }
public void SelectBySeriesUid_Multiple() { Study study = CreateTestStudy1(); var criteria = new DicomAttributeCollection(); criteria[DicomTags.SeriesInstanceUid].SetStringValue("1.2.3.2\\1.2.3.3"); var filters = new SeriesPropertyFilters(criteria); var results = filters.FilterResults(study.GetSeries().Cast<Series>()); Assert.AreEqual(2, results.Count()); }
/// <summary> /// Populate at the IMAGE level a response message. /// </summary> /// <param name="request"></param> /// <param name="response"></param> /// <param name="tagList"></param> /// <param name="theInstanceStream"></param> private void PopulateInstance(DicomAttributeCollection request, DicomMessage response, List<uint> tagList, InstanceXml theInstanceStream) { DicomAttributeCollection dataSet = response.DataSet; dataSet[DicomTags.RetrieveAeTitle].SetStringValue(Partition.AeTitle); dataSet[DicomTags.InstanceAvailability].SetStringValue("ONLINE"); DicomAttributeCollection sourceDataSet = theInstanceStream.Collection; if (false == sourceDataSet.Contains(DicomTags.SpecificCharacterSet)) { dataSet[DicomTags.SpecificCharacterSet].SetStringValue(sourceDataSet[DicomTags.SpecificCharacterSet].ToString()); dataSet.SpecificCharacterSet = sourceDataSet[DicomTags.SpecificCharacterSet].ToString(); // this will ensure the data is encoded using the specified character set } foreach (uint tag in tagList) { try { switch (tag) { case DicomTags.PatientId: dataSet[DicomTags.PatientId].SetStringValue(request[DicomTags.PatientId].ToString()); break; case DicomTags.StudyInstanceUid: dataSet[DicomTags.StudyInstanceUid].SetStringValue( request[DicomTags.StudyInstanceUid].ToString()); break; case DicomTags.SeriesInstanceUid: dataSet[DicomTags.SeriesInstanceUid].SetStringValue( request[DicomTags.SeriesInstanceUid].ToString()); break; case DicomTags.QueryRetrieveLevel: dataSet[DicomTags.QueryRetrieveLevel].SetStringValue("IMAGE"); break; default: if (sourceDataSet.Contains(tag)) dataSet[tag] = sourceDataSet[tag].Copy(); else dataSet[tag].SetNullValue(); break; // Meta tags that should have not been in the RQ, but we've already set case DicomTags.RetrieveAeTitle: case DicomTags.InstanceAvailability: case DicomTags.SpecificCharacterSet: break; } } catch (Exception e) { Platform.Log(LogLevel.Warn, e, "Unexpected error setting tag {0} in C-FIND-RSP", dataSet[tag].Tag.ToString()); dataSet[tag].SetNullValue(); } } }
/// <summary> /// Update an <see cref="DicomAttributeCollection"/> with pixel data related tags. /// </summary> /// <param name="dataset">The collection to update.</param> public override void UpdateAttributeCollection(DicomAttributeCollection dataset) { if (dataset.Contains(DicomTags.NumberOfFrames) || NumberOfFrames > 1) dataset[DicomTags.NumberOfFrames].SetInt32(0, NumberOfFrames); if (dataset.Contains(DicomTags.PlanarConfiguration)) dataset[DicomTags.PlanarConfiguration].SetInt32(0, PlanarConfiguration); if (dataset.Contains(DicomTags.LossyImageCompression) || LossyImageCompression.Length > 0) dataset[DicomTags.LossyImageCompression].SetString(0, LossyImageCompression); if (dataset.Contains(DicomTags.LossyImageCompressionRatio) || (LossyImageCompressionRatio != 1.0f && LossyImageCompressionRatio != 0.0f)) dataset[DicomTags.LossyImageCompressionRatio].SetFloat32(0, LossyImageCompressionRatio); if (dataset.Contains(DicomTags.LossyImageCompressionMethod) || LossyImageCompressionMethod.Length > 0) dataset[DicomTags.LossyImageCompressionMethod].SetString(0, LossyImageCompressionMethod); if (dataset.Contains(DicomTags.DerivationDescription) || DerivationDescription.Length > 0) { string currentValue = dataset[DicomTags.DerivationDescription].ToString(); dataset[DicomTags.DerivationDescription].SetStringValue(DerivationDescription); if (!currentValue.Equals(DerivationDescription)) { DicomSequenceItem item = new DicomSequenceItem(); CodeSequenceMacro macro = new CodeSequenceMacro(item); macro.CodeMeaning = "Lossy Compression"; macro.CodeValue = "113040"; macro.CodingSchemeDesignator = "DCM"; macro.ContextGroupVersion = new DateTime(2005, 8, 22); macro.ContextIdentifier = "7203"; macro.MappingResource = "DCMR"; dataset[DicomTags.DerivationCodeSequence].AddSequenceItem(item); } } if (dataset.Contains(DicomTags.RescaleSlope) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M) dataset[DicomTags.RescaleSlope].SetString(0, RescaleSlope); if (dataset.Contains(DicomTags.RescaleIntercept) || DecimalRescaleSlope != 1.0M || DecimalRescaleIntercept != 0.0M) dataset[DicomTags.RescaleIntercept].SetString(0, RescaleIntercept); if (dataset.Contains(DicomTags.WindowCenter) || LinearVoiLuts.Count > 0) Window.SetWindowCenterAndWidth(dataset, LinearVoiLuts); //Remove the palette color lut, if the pixels were translated to RGB if (dataset.Contains(DicomTags.RedPaletteColorLookupTableData) && dataset.Contains(DicomTags.BluePaletteColorLookupTableData) && dataset.Contains(DicomTags.GreenPaletteColorLookupTableData) && !HasPaletteColorLut) { dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.BluePaletteColorLookupTableData); dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.RedPaletteColorLookupTableData); dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableDescriptor); dataset.RemoveAttribute(DicomTags.GreenPaletteColorLookupTableData); } dataset.SaveDicomFields(this); dataset[DicomTags.PixelData] = _sq; }
public void SelectAllSops() { Study study = CreateTestStudy1(); var sops = study.GetSeries().First().GetSopInstances().Cast<SopInstance>().ToList(); var criteria = new DicomAttributeCollection(); var filters = new SopInstancePropertyFilters(criteria); var results = filters.FilterResults(sops); Assert.AreEqual(5, results.Count()); }
public void SelectBySeriesDescription_Equals() { Study study = CreateTestStudy1(); var criteria = new DicomAttributeCollection(); criteria[DicomTags.SeriesDescription].SetString(0, "Series1"); var filters = new SeriesPropertyFilters(criteria); var results = filters.FilterResults(study.GetSeries().Cast<Series>()); Assert.AreEqual(1, results.Count()); }
public void TestDicomTagPathGetAttribute_NoCreate() { var collection = new DicomAttributeCollection(); var path = new DicomTagPath(DicomTags.PatientId); //PatientID IS empty Assert.IsNull(path.GetAttribute(collection)); collection[DicomTags.PatientId].SetNullValue(); //PatientID NOT empty Assert.IsNotNull(path.GetAttribute(collection)); collection[DicomTags.PatientId].SetStringValue("PatientId"); collection[DicomTags.PatientsName].SetStringValue("PatientsName"); //PatientID NOT empty Assert.IsNotNull(path.GetAttribute(collection)); path = new DicomTagPath(DicomTags.PatientsName); //PatientsName NOT empty Assert.IsNotNull(path.GetAttribute(collection)); //ViewCodeSequence IS empty path = new DicomTagPath(DicomTags.ViewCodeSequence); Assert.IsNull(path.GetAttribute(collection)); var sequence1 = new DicomSequenceItem(); collection[DicomTags.ViewCodeSequence].AddSequenceItem(sequence1); //ViewCodeSequence NOT empty Assert.IsNotNull(path.GetAttribute(collection)); path += DicomTags.CodeMeaning; //ViewCodeSequence/CodeMeaning IS empty Assert.IsNull(path.GetAttribute(collection)); sequence1[DicomTags.CodeMeaning].SetNullValue(); //ViewCodeSequence/CodeMeaning NOT empty Assert.IsNotNull(path.GetAttribute(collection)); //ViewCodeSequence/ConceptNameCodeSequence IS empty path = new DicomTagPath(DicomTags.ViewCodeSequence, DicomTags.ConceptNameCodeSequence); Assert.IsNull(path.GetAttribute(collection)); var sequence2 = new DicomSequenceItem(); sequence1[DicomTags.ConceptNameCodeSequence].AddSequenceItem(sequence2); //ViewCodeSequence/ConceptNameCodeSequence NOT empty Assert.IsNotNull(path.GetAttribute(collection)); path += DicomTags.CodeValue; //ViewCodeSequence/ConceptNameCodeSequence/CodeValue IS empty Assert.IsNull(path.GetAttribute(collection)); sequence2[DicomTags.CodeValue].SetStringValue("Code"); //ViewCodeSequence/ConceptNameCodeSequence/CodeValue IS empty Assert.IsNotNull(path.GetAttribute(collection)); }
/// <summary> /// Constructs a new <see cref="StudyNode"/> using actual values from attributes in the given <see cref="DicomAttributeCollection"/>. /// </summary> /// <param name="dicomDataSet">The data set from which to initialize this node.</param> public StudyNode(DicomAttributeCollection dicomDataSet) { _series = new SeriesNodeCollection(this); _studyId = dicomDataSet[DicomTags.StudyId].GetString(0, ""); _description = dicomDataSet[DicomTags.StudyDescription].GetString(0, ""); _dateTime = DicomConverter.GetDateTime(dicomDataSet[DicomTags.StudyDate].GetDateTime(0), dicomDataSet[DicomTags.StudyTime].GetDateTime(0)); _accessionNum = dicomDataSet[DicomTags.AccessionNumber].GetString(0, ""); _instanceUid = dicomDataSet[DicomTags.StudyInstanceUid].GetString(0, ""); if (_instanceUid == "") _instanceUid = StudyBuilder.NewUid(); }
/// <summary> /// Constructs a new <see cref="SeriesNode"/> using actual values from attributes from the given <see cref="DicomAttributeCollection"/>. /// </summary> /// <param name="dicomDataSet">The data set from which to initialize this node.</param> public SeriesNode(DicomAttributeCollection dicomDataSet) { _images = new SopInstanceNodeCollection(this); _description = dicomDataSet[DicomTags.SeriesDescription].GetString(0, ""); _dateTime = DicomConverter.GetDateTime(dicomDataSet[DicomTags.SeriesDate].GetDateTime(0), dicomDataSet[DicomTags.SeriesTime].GetDateTime(0)); _instanceUid = dicomDataSet[DicomTags.SeriesInstanceUid].GetString(0, ""); if (_instanceUid == "") _instanceUid = StudyBuilder.NewUid(); }
/// <summary> /// Writes the data in this node into the given <see cref="DicomAttributeCollection"/>. /// </summary> /// <param name="dataSet">The data set to write data into.</param> /// <param name="writeUid"></param> internal void Update(DicomAttributeCollection dataSet, bool writeUid) { int imageNumber = 0; if (this.Parent != null) imageNumber = this.Parent.Images.IndexOf(this) + 1; DicomConverter.SetInt32(dataSet[DicomTags.InstanceNumber], imageNumber); if (writeUid) dataSet[DicomTags.SopInstanceUid].SetStringValue(_instanceUid); }
/// <summary> /// Create a new empty DICOM Part 10 format file. /// </summary> /// <param name="filename"></param> public DicomFile(String filename) { MetaInfo = new DicomAttributeCollection(0x00020000, 0x0002FFFF); DataSet = new DicomAttributeCollection(0x00040000, 0xFFFFFFFF); ImplementationVersionName = DicomImplementation.Version; ImplementationClassUid = DicomImplementation.ClassUID.UID; MetaInfo[DicomTags.TransferSyntaxUid].SetStringValue(TransferSyntax.ExplicitVrLittleEndian.UidString); MetaInfo[DicomTags.FileMetaInformationVersion].Values = new byte[] { 0x00, 0x01 }; _filename = filename; }
/// <summary> /// Initializes a new <see cref="ISopDataSource"/> for the given volume slice. /// </summary> /// <param name="slice">A volume slice. This instance will be disposed when the <see cref="VolumeSliceSopDataSource"/> instance is disposed.</param> public AsyncVolumeSliceSopDataSource(VolumeSlice slice) { Slice = slice; DataSet = new DicomAttributeCollection(); DataSet[DicomTags.Rows].SetInt32(0, Slice.Rows); DataSet[DicomTags.Columns].SetInt32(0, Slice.Colums); DataSet[DicomTags.NumberOfFrames].SetInt32(0, 1); DataSet[DicomTags.ImageOrientationPatient].SetStringValue(Slice.ImageOrientationPatient); DataSet[DicomTags.ImagePositionPatient].SetStringValue(Slice.ImagePositionPatient); DataSet[DicomTags.SopInstanceUid].SetString(0, DicomUid.GenerateUid().UID); }
private ImageSop CreateImageSop(string patientId, string studyUid, string seriesUid, string sopUid) { DicomAttributeCollection dataSet = new DicomAttributeCollection(); base.SetupMR(dataSet); DicomFile file = new DicomFile(null, new DicomAttributeCollection(), dataSet); TestDataSource dataSource = new TestDataSource(file); file.DataSet[DicomTags.PatientId].SetStringValue(patientId); file.DataSet[DicomTags.StudyInstanceUid].SetStringValue(studyUid); file.DataSet[DicomTags.SeriesInstanceUid].SetStringValue(seriesUid); file.DataSet[DicomTags.SopInstanceUid].SetStringValue(sopUid); return new ImageSop(dataSource); }
public void ConvertAttributeToUN(DicomAttributeCollection theSet, uint tag) { ByteBuffer theData = theSet[tag].GetByteBuffer(TransferSyntax.ImplicitVrLittleEndian, theSet.SpecificCharacterSet); DicomTag baseTag = DicomTagDictionary.GetDicomTag(tag); DicomTag theTag = new DicomTag(tag, baseTag.Name, baseTag.VariableName, DicomVr.UNvr, baseTag.MultiVR, baseTag.VMLow, baseTag.VMHigh, baseTag.Retired); DicomAttribute unAttrib = DicomVr.UNvr.CreateDicomAttribute(theTag, theData); theSet[tag] = unAttrib; }
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); }
/// <summary> /// Create a DicomFile instance from existing MetaInfo and DataSet. /// </summary> /// <param name="filename">The name for the file.</param> /// <param name="metaInfo">A <see cref="DicomAttributeCollection"/> for the MetaInfo (group 0x0002 attributes).</param> /// <param name="dataSet">A <see cref="DicomAttributeCollection"/> for the DataSet.</param> public DicomFile(String filename, DicomAttributeCollection metaInfo, DicomAttributeCollection dataSet) { MetaInfo = metaInfo; DataSet = dataSet; _filename = filename; ImplementationVersionName = DicomImplementation.Version; ImplementationClassUid = DicomImplementation.ClassUID.UID; // If the meta info doesn't already specify the transfer syntax, give it the default transfer syntax of ELE if (string.IsNullOrEmpty(MetaInfo[DicomTags.TransferSyntaxUid].ToString())) MetaInfo[DicomTags.TransferSyntaxUid].SetStringValue(TransferSyntax.ExplicitVrLittleEndian.UidString); MetaInfo[DicomTags.FileMetaInformationVersion].Values = new byte[] { 0x00, 0x01 }; }
public FusionSopDataSource(ISopDataSource realSopDataSource, PETFusionType type, IEnumerable<IDicomAttributeProvider> overlayFrames) { _realSopDataSource = realSopDataSource; _fusionHeaders = new DicomAttributeCollection() {ValidateVrLengths = false, ValidateVrValues = false}; var scEquipment = new ScEquipmentModuleIod(_fusionHeaders); scEquipment.ConversionType = @"WSD"; scEquipment.SecondaryCaptureDeviceManufacturer = @"ClearCanvas Inc."; scEquipment.SecondaryCaptureDeviceManufacturersModelName = ProductInformation.GetName(false, false); scEquipment.SecondaryCaptureDeviceSoftwareVersions = new[] {ProductInformation.GetVersion(true, true, true, true)}; // generate values for the General Image Module _fusionHeaders[DicomTags.ImageType].SetStringValue(@"DERIVED\SECONDARY"); _fusionHeaders[DicomTags.SourceImageSequence].Values = UpdateSourceImageSequence(realSopDataSource, overlayFrames); UpdateDerivationType(type); }
public void SetupMRWithOverlay(DicomAttributeCollection theSet) { SetupMR(theSet); OverlayPlaneModuleIod overlayIod = new OverlayPlaneModuleIod(theSet); DicomUncompressedPixelData pd = new DicomUncompressedPixelData(theSet); OverlayPlane overlay = overlayIod[0]; // Embedded overlays are retired in dicom, just doing it for testing purposes theSet[DicomTags.OverlayBitPosition].SetInt32(0, pd.HighBit + 1); overlay.OverlayBitsAllocated = 1; overlay.OverlayColumns = pd.ImageWidth; overlay.OverlayRows = pd.ImageHeight; overlay.OverlayOrigin = new Point(0, 0); overlay.OverlayType = OverlayType.R; }
private void UpdateStudyTree(DicomAttributeCollection ds) { string acession = ds[DicomTags.AccessionNumber].GetString(0, ""); string patientid = ds[DicomTags.PatientId].GetString(0, ""); string name= ds[DicomTags.PatientsName].GetString(0, ""); string modality = ds[DicomTags.ModalitiesInStudy].GetString(0, ""); string description = ds[DicomTags.StudyDescription].GetString(0, ""); string studyinstanceuid = ds[DicomTags.StudyInstanceUid].GetString(0, ""); String text = String.Format("{0}-{1}-{2}-{3}", patientid, name, acession, description); TreeNode studyNode = new TreeNode(); studyNode.Text = text; studyNode.Tag = studyinstanceuid; StudyTree.Nodes.Add(studyNode); }
public IList<DicomAttributeCollection> Query(DicomAttributeCollection queryCriteria) { Platform.CheckForNullReference(queryCriteria, "queryCriteria"); string level = queryCriteria[DicomTags.QueryRetrieveLevel].ToString(); switch (level) { case "STUDY": return StudyQuery(queryCriteria); case "SERIES": return SeriesQuery(queryCriteria); case "IMAGE": return ImageQuery(queryCriteria); default: throw new ArgumentException(String.Format("Invalid query level: {0}", level)); } }
/// <summary> /// Generates an (issued) "Query" event in the audit log, according to DICOM Supplement 95. /// </summary> /// <param name="remoteAETitle">The application entity on which the query is taking place.</param> /// <param name="remoteHostName">The hostname of the application entity on which the query is taking place.</param> /// <param name="eventSource">The source user or application entity which invoked the operation.</param> /// <param name="eventResult">The result of the operation.</param> /// <param name="sopClassUid">The SOP Class Uid of the type of DICOM Query being issued</param> /// <param name="query">The dataset containing the DICOM query being issued</param> public static void LogQueryIssued(string remoteAETitle, string remoteHostName, EventSource eventSource, EventResult eventResult, string sopClassUid, DicomAttributeCollection query) { AuditLogHelper.LogQueryIssued(LocalAETitle, remoteAETitle, remoteHostName, eventSource, EventSource.GetCurrentDicomAE(), eventResult, sopClassUid, query); }
public InstanceNumber(DicomAttributeCollection criteria) : base(DicomTags.InstanceNumber, criteria) { AddToQueryEnabled = false; FilterResultsEnabled = true; }
/// <summary> /// Generates an (issued) "Query" event in the audit log, according to DICOM Supplement 95. /// </summary> /// <param name="localAETitle">The local application entity making the query.</param> /// <param name="remoteAETitle">The application entity on which the query is taking place.</param> /// <param name="remoteHostName">The hostname of the application entity on which the query is taking place.</param> /// <param name="eventSource">The source user or application entity which invoked the operation.</param> /// <param name="currentAE">The current DICOM AE performing the operation.</param> /// <param name="eventResult">The result of the operation.</param> /// <param name="sopClassUid">The SOP Class Uid of the type of DICOM Query being issued</param> /// <param name="ds">The dataset containing the DICOM query being issued</param> public static void LogQueryIssued(string localAETitle, string remoteAETitle, string remoteHostName, EventSource eventSource, EventSource currentAE, EventResult eventResult, string sopClassUid, DicomAttributeCollection ds) { if (!AuditingEnabled) { return; } try { var auditHelper = new QueryAuditHelper(eventSource, eventResult, localAETitle, LocalHostname, remoteAETitle ?? localAETitle, remoteHostName ?? LocalHostname, sopClassUid, ds); if (eventSource != currentAE) { auditHelper.AddOtherParticipant(currentAE); } Log(auditHelper); } catch (Exception ex) { Platform.Log(LogLevel.Warn, ex, _messageAuditFailed); } }
public override StudyItemList Query(QueryParameters queryParams, IApplicationEntity targetServer) { Platform.CheckForNullReference(queryParams, "queryParams"); Platform.CheckForNullReference(targetServer, "targetServer"); var selectedServer = targetServer.ToServiceNode(); //.NET strings are unicode, therefore, so is all the query data. const string utf8 = "ISO_IR 192"; var requestCollection = new DicomAttributeCollection { SpecificCharacterSet = utf8 }; requestCollection[DicomTags.SpecificCharacterSet].SetStringValue(utf8); requestCollection[DicomTags.QueryRetrieveLevel].SetStringValue("STUDY"); requestCollection[DicomTags.StudyInstanceUid].SetStringValue(""); requestCollection[DicomTags.PatientId].SetStringValue(queryParams["PatientId"]); requestCollection[DicomTags.AccessionNumber].SetStringValue(queryParams["AccessionNumber"]); requestCollection[DicomTags.PatientsName].SetStringValue(queryParams["PatientsName"]); requestCollection[DicomTags.ReferringPhysiciansName].SetStringValue(queryParams["ReferringPhysiciansName"]); requestCollection[DicomTags.StudyDate].SetStringValue(queryParams["StudyDate"]); requestCollection[DicomTags.StudyTime].SetStringValue(""); requestCollection[DicomTags.StudyDescription].SetStringValue(queryParams["StudyDescription"]); requestCollection[DicomTags.PatientsBirthDate].SetStringValue(""); requestCollection[DicomTags.ModalitiesInStudy].SetStringValue(queryParams["ModalitiesInStudy"]); requestCollection[DicomTags.NumberOfStudyRelatedInstances].SetStringValue(""); requestCollection[DicomTags.InstanceAvailability].SetEmptyValue(); // must not be included in request requestCollection[DicomTags.PatientSpeciesDescription].SetStringValue(GetString(queryParams, "PatientSpeciesDescription")); var codeValue = GetString(queryParams, "PatientSpeciesCodeSequenceCodeValue"); var codeMeaning = GetString(queryParams, "PatientSpeciesCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; requestCollection[DicomTags.PatientSpeciesCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } requestCollection[DicomTags.PatientBreedDescription].SetStringValue(GetString(queryParams, "PatientBreedDescription")); codeValue = GetString(queryParams, "PatientBreedCodeSequenceCodeValue"); codeMeaning = GetString(queryParams, "PatientBreedCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; requestCollection[DicomTags.PatientBreedCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } requestCollection[DicomTags.ResponsiblePerson].SetStringValue(GetString(queryParams, "ResponsiblePerson")); requestCollection[DicomTags.ResponsiblePersonRole].SetStringValue(""); requestCollection[DicomTags.ResponsibleOrganization].SetStringValue(GetString(queryParams, "ResponsibleOrganization")); IList <DicomAttributeCollection> results = Query(selectedServer, requestCollection); StudyItemList studyItemList = new StudyItemList(); foreach (DicomAttributeCollection result in results) { StudyItem item = new StudyItem(result[DicomTags.StudyInstanceUid].GetString(0, ""), selectedServer); //TODO: add DicomField attributes to the StudyItem class (implement typeconverter for PersonName class). item.PatientsBirthDate = result[DicomTags.PatientsBirthDate].GetString(0, ""); item.AccessionNumber = result[DicomTags.AccessionNumber].GetString(0, ""); item.StudyDescription = result[DicomTags.StudyDescription].GetString(0, ""); item.StudyDate = result[DicomTags.StudyDate].GetString(0, ""); item.StudyTime = result[DicomTags.StudyTime].GetString(0, ""); item.PatientId = result[DicomTags.PatientId].GetString(0, ""); item.PatientsName = new PersonName(result[DicomTags.PatientsName].GetString(0, "")); item.ReferringPhysiciansName = new PersonName(result[DicomTags.ReferringPhysiciansName].GetString(0, "")); item.ModalitiesInStudy = DicomStringHelper.GetStringArray(result[DicomTags.ModalitiesInStudy].ToString()); DicomAttribute attribute = result[DicomTags.NumberOfStudyRelatedInstances]; if (!attribute.IsEmpty && !attribute.IsNull) { item.NumberOfStudyRelatedInstances = attribute.GetInt32(0, 0); } item.SpecificCharacterSet = result.SpecificCharacterSet; item.InstanceAvailability = result[DicomTags.InstanceAvailability].GetString(0, ""); if (String.IsNullOrEmpty(item.InstanceAvailability)) { item.InstanceAvailability = "ONLINE"; } item.PatientSpeciesDescription = result[DicomTags.PatientSpeciesDescription].GetString(0, ""); var patientSpeciesCodeSequence = result[DicomTags.PatientSpeciesCodeSequence]; if (!patientSpeciesCodeSequence.IsNull && patientSpeciesCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[])result[DicomTags.PatientSpeciesCodeSequence].Values)[0]); item.PatientSpeciesCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientSpeciesCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientSpeciesCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.PatientBreedDescription = result[DicomTags.PatientBreedDescription].GetString(0, ""); var patientBreedCodeSequence = result[DicomTags.PatientBreedCodeSequence]; if (!patientBreedCodeSequence.IsNull && patientBreedCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[])result[DicomTags.PatientBreedCodeSequence].Values)[0]); item.PatientBreedCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientBreedCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientBreedCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.ResponsiblePerson = new PersonName(result[DicomTags.ResponsiblePerson].GetString(0, "")); item.ResponsiblePersonRole = result[DicomTags.ResponsiblePersonRole].GetString(0, ""); item.ResponsibleOrganization = result[DicomTags.ResponsibleOrganization].GetString(0, ""); studyItemList.Add(item); } AuditHelper.LogQueryIssued(selectedServer.AETitle, selectedServer.ScpParameters.HostName, EventSource.CurrentUser, EventResult.Success, SopClass.StudyRootQueryRetrieveInformationModelFindUid, requestCollection); return(studyItemList); }
public void SetupDataSet(DicomAttributeCollection theSet, string characterSet) { DateTime studyTime = DateTime.Now; theSet[DicomTags.SpecificCharacterSet].SetStringValue(characterSet); theSet[DicomTags.ImageType].SetStringValue("ORIGINAL\\PRIMARY\\OTHER\\"); theSet[DicomTags.InstanceCreationDate].SetStringValue(DateParser.ToDicomString(DateTime.Now)); theSet[DicomTags.InstanceCreationTime].SetStringValue(TimeParser.ToDicomString(DateTime.Now)); theSet[DicomTags.SopClassUid].SetStringValue(SopClass.SecondaryCaptureImageStorageUid); theSet[DicomTags.SopInstanceUid].SetStringValue(DicomUid.GenerateUid().UID); theSet[DicomTags.StudyDate].SetStringValue(DateParser.ToDicomString(studyTime)); theSet[DicomTags.StudyTime].SetStringValue(TimeParser.ToDicomString(studyTime)); theSet[DicomTags.SeriesDate].SetStringValue(DateParser.ToDicomString(studyTime)); theSet[DicomTags.SeriesTime].SetStringValue(TimeParser.ToDicomString(studyTime)); theSet[DicomTags.AccessionNumber].SetStringValue("A1234"); theSet[DicomTags.Modality].SetStringValue("MR"); theSet[DicomTags.Manufacturer].SetStringValue("ClearCanvas"); theSet[DicomTags.ManufacturersModelName].SetNullValue(); theSet[DicomTags.InstitutionName].SetStringValue("Toronto General Hospital"); theSet[DicomTags.ReferringPhysiciansName].SetStringValue("Last^First"); theSet[DicomTags.StudyDescription].SetStringValue("TEST"); theSet[DicomTags.SeriesDescription].SetStringValue("TEST"); theSet[DicomTags.PatientsName].SetStringValue("Patient^Test"); theSet[DicomTags.PatientId].SetStringValue("ID123-45-9999"); theSet[DicomTags.PatientsBirthDate].SetStringValue("19600102"); theSet[DicomTags.PatientsSize].SetStringValue("10.000244140625"); theSet[DicomTags.SequenceVariant].SetStringValue("OTHER"); theSet[DicomTags.DeviceSerialNumber].SetStringValue("1234"); theSet[DicomTags.SoftwareVersions].SetStringValue("V1.0"); theSet[DicomTags.PatientPosition].SetStringValue("HFS"); theSet[DicomTags.StudyInstanceUid].SetStringValue(DicomUid.GenerateUid().UID); theSet[DicomTags.SeriesInstanceUid].SetStringValue(DicomUid.GenerateUid().UID); theSet[DicomTags.StudyId].SetStringValue("1933"); theSet[DicomTags.SeriesNumber].SetStringValue("1"); theSet[DicomTags.InstanceNumber].SetStringValue("1"); theSet[DicomTags.ImageComments].SetStringValue("Test SC Image"); theSet[DicomTags.SamplesPerPixel].SetStringValue("1"); theSet[DicomTags.PhotometricInterpretation].SetStringValue("MONOCHROME2"); theSet[DicomTags.Rows].SetStringValue("256"); theSet[DicomTags.Columns].SetStringValue("256"); theSet[DicomTags.BitsAllocated].SetStringValue("16"); theSet[DicomTags.BitsStored].SetStringValue("12"); theSet[DicomTags.HighBit].SetStringValue("11"); theSet[DicomTags.PixelRepresentation].SetStringValue("0"); uint length = 256 * 256 * 2; DicomAttributeOW pixels = new DicomAttributeOW(DicomTags.PixelData); byte[] pixelArray = new byte[length]; for (uint i = 0; i < length; i += 2) { pixelArray[i] = (byte)(i % 255); } pixels.Values = pixelArray; theSet[DicomTags.PixelData] = pixels; DicomSequenceItem item = new DicomSequenceItem(); theSet[DicomTags.RequestAttributesSequence].AddSequenceItem(item); item[DicomTags.RequestedProcedureId].SetStringValue("MRR1234"); item[DicomTags.ScheduledProcedureStepId].SetStringValue("MRS1234"); item = new DicomSequenceItem(); theSet[DicomTags.RequestAttributesSequence].AddSequenceItem(item); item[DicomTags.RequestedProcedureId].SetStringValue("MR2R1234"); item[DicomTags.ScheduledProcedureStepId].SetStringValue("MR2S1234"); DicomSequenceItem studyItem = new DicomSequenceItem(); item[DicomTags.ReferencedStudySequence].AddSequenceItem(studyItem); studyItem[DicomTags.ReferencedSopClassUid].SetStringValue(SopClass.SecondaryCaptureImageStorageUid); studyItem[DicomTags.ReferencedSopInstanceUid].SetStringValue("1.2.3.4.5.6.7.8.9"); }
public StudyRootQueryResultEntry(DicomAttributeCollection attributeCollection) { this._attributeCollection = attributeCollection; }
public SopClassUid(DicomAttributeCollection criteria) : base(DicomTags.SopClassUid, criteria) { AddToQueryEnabled = false; FilterResultsEnabled = true; }
public CodingSchemeDesignator(DicomAttributeCollection criteria) : base(new DicomTagPath(DicomTags.PatientSpeciesCodeSequence, DicomTags.CodingSchemeDesignator), criteria) { }
public CodeMeaning(DicomAttributeCollection criteria) : base(new DicomTagPath(DicomTags.PatientSpeciesCodeSequence, DicomTags.CodeMeaning), criteria) { }
public void OnReceiveDimseCommand(DicomServer server, ServerAssociationParameters association, byte presentationId, DicomAttributeCollection command) { }
public NotificationSeries(DicomAttributeCollection c) : base(c) { }
public PatientId(DicomAttributeCollection criteria) : base(new DicomTagPath(DicomTags.PatientId), criteria) { }
public PatientsBirthTime(DicomAttributeCollection criteria) : base(new DicomTagPath(DicomTags.PatientsBirthTime), criteria) { }
public PatientsSex(DicomAttributeCollection criteria) : base(DicomTags.PatientsSex, criteria) { }
/// <summary> /// Called when received response message. /// </summary> /// <param name="client">The client.</param> /// <param name="association">The association.</param> /// <param name="presentationID">The presentation ID.</param> /// <param name="message">The message.</param> public override void OnReceiveResponseMessage(DicomClient client, ClientAssociationParameters association, byte presentationID, DicomMessage message) { try { base.ResultStatus = message.Status.Status; if (message.Status.Status == DicomState.Success) { if (message.CommandField == DicomCommandField.NCreateResponse && message.AffectedSopClassUid == SopClass.BasicFilmSessionSopClassUid) { _filmSessionUid = message.AffectedSopInstanceUid; } else if (message.CommandField == DicomCommandField.NCreateResponse && message.AffectedSopClassUid == SopClass.BasicFilmBoxSopClassUid) { _filmBoxUids.Add(message.AffectedSopInstanceUid); _filmBoxResponseMessages.Add(message.AffectedSopInstanceUid, message.DataSet); } Platform.Log(LogLevel.Info, "Success status received in Printer Status Scu!"); _results = message.DataSet; switch (_nextRequestType) { case RequestType.FilmBox: SendCreateFilmBoxRequest(client, association, message); break; case RequestType.ImageBox: SendSetImageBoxRequest(client, association); break; case RequestType.PrintAction: SendActionPrintRequest(client, association); break; case RequestType.DeleteFilmBox: SendDeleteFilmBoxRequest(client, association, message); break; case RequestType.DeleteFilmSession: SendDeleteFilmSessionRequest(client, association); break; case RequestType.Close: base.ReleaseConnection(client); break; case RequestType.None: default: // TODO: throw error.... break; } } else { // TODO: Handle this... check for warnings - they are OK? throw exception on errors... ? } } catch (Exception ex) { Platform.Log(LogLevel.Error, ex.ToString()); base.ReleaseConnection(client); throw; } }
protected DicomSoftcopyPresentationStateBase(SopClass psSopClass, DicomAttributeCollection dataSource) : base(psSopClass, dataSource) { }
public NotificationPatient(DicomAttributeCollection c) : base(c) { }
protected StringDicomPropertyFilter(DicomTagPath path, DicomAttributeCollection criteria) : base(path, criteria) { _rule = new MultiValuedPropertyRule <TDatabaseObject>(this); }
public PatientSpeciesDescription(DicomAttributeCollection criteria) : base(new DicomTagPath(DicomTags.PatientSpeciesDescription), criteria) { }
public NotificationImage(DicomAttributeCollection c) : base(c) { }
public void InstanceMINTXmlConstructorTest() { string xml = @"<Instance> <Attributes> <Attr tag='00100010' vr='PN' val='DOE^JON' /> <Attr tag='00080018' vr='UI' val='123.333' /> <Attr tag='00080032' vr='TM' val='134437.3' /> <Attr tag='00080033' vr='TM' val='134437.4' /> <Attr tag='00081140' vr='SQ' > <Item id='0'> <Attr tag='00081150' vr='UI' val='1.2.3.4' /> <Attr tag='00081155' vr='UI' val='4.3.2.1' /> </Item> <Item id='0'> <Attr tag='00081150' vr='UI' val='5.6.7.8' /> <Attr tag='00081155' vr='UI' val='9.8.7.6' /> </Item> </Attr> <Attr tag='7fe00010' vr='OW' bid='13' /> </Attributes> </Instance>" ; XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); var loaderArgs = new StudyLoaderArgs("123.111", null); var studyAttributes = new DicomAttributeCollection(); var seriesAttributes = new DicomAttributeCollection(); // Make sure one attribute is in conflict with an attribute parsed from the // instance XML (the instance XML value should not take precedence here). This would // typically never happen. studyAttributes[DicomTags.StudyInstanceUid].SetStringValue("123.111"); studyAttributes[DicomTags.PatientsName].SetStringValue("ABC^TUV"); seriesAttributes[DicomTags.SeriesInstanceUid].SetStringValue("123.222"); var instance = new InstanceMINTXml(loaderArgs, "http://some-uri/DICOM/metadata", doc.DocumentElement, studyAttributes, seriesAttributes, null); Assert.AreEqual("123.111", instance[DicomTags.StudyInstanceUid].GetString(0, "")); Assert.AreEqual("123.222", instance[DicomTags.SeriesInstanceUid].GetString(0, "")); Assert.AreEqual("ABC^TUV", instance[DicomTags.PatientsName].GetString(0, "")); Assert.AreEqual("123.333", instance[DicomTags.SopInstanceUid].GetString(0, "")); Assert.AreEqual("134437.3", instance[DicomTags.AcquisitionTime].GetString(0, "")); Assert.AreEqual("134437.4", instance[DicomTags.ContentTime].GetString(0, "")); Assert.IsInstanceOfType(typeof(DicomAttributeSQ), instance[DicomTags.ReferencedImageSequence]); var sq = instance[DicomTags.ReferencedImageSequence] as DicomAttributeSQ; Assert.IsNotNull(sq); Assert.AreEqual(2, sq.Count); var item = sq[0]; Assert.AreEqual("1.2.3.4", item[DicomTags.ReferencedSopClassUid].GetString(0, "")); Assert.AreEqual("4.3.2.1", item[DicomTags.ReferencedSopInstanceUid].GetString(0, "")); item = sq[1]; Assert.AreEqual("5.6.7.8", item[DicomTags.ReferencedSopClassUid].GetString(0, "")); Assert.AreEqual("9.8.7.6", item[DicomTags.ReferencedSopInstanceUid].GetString(0, "")); Assert.AreEqual("http://some-uri/DICOM/binaryitems/13", instance.PixelDataUri.AbsoluteUri); }
/// <summary> /// Internal constructor used when making a copy of a <see cref="DicomAttributeCollection"/>. /// </summary> /// <param name="source"></param> /// <param name="copyBinary"></param> /// <param name="copyPrivate"></param> /// <param name="copyUnknown"></param> internal DicomSequenceItem(DicomAttributeCollection source, bool copyBinary, bool copyPrivate, bool copyUnknown) : base(source, copyBinary, copyPrivate, copyUnknown) { }
public SystemCacheProxy() { _dataHead = new DicomAttributeCollection(); }
public void PrivateAttributeTest() { DicomFile file = new DicomFile("LittleEndianPrivateReadFileTest.dcm"); DicomAttributeCollection dataSet = file.DataSet; SetupMR(dataSet); DicomTag privateCreatorTag = new DicomTag(0x00090010, "PrivateCreator", "PrivateCreator", DicomVr.LOvr, false, 1, 1, false); dataSet[privateCreatorTag].SetStringValue("ClearCanvasGroup9"); DicomTag privateTagFL = new DicomTag(0x00091020, "PrivateFL", "PrivateFL", DicomVr.FLvr, true, 1, 10, false); DicomTag privateTagLO = new DicomTag(0x00091021, "PrivateLO", "PrivateLO", DicomVr.LOvr, true, 1, 10, false); DicomTag privateTagAE = new DicomTag(0x00091022, "PrivateAE", "PrivateAE", DicomVr.AEvr, true, 1, 10, false); DicomTag privateTagAS = new DicomTag(0x00091023, "PrivateAS", "PrivateAS", DicomVr.ASvr, true, 1, 10, false); DicomTag privateTagAT = new DicomTag(0x00091024, "PrivateAT", "PrivateAT", DicomVr.ATvr, true, 1, 10, false); DicomTag privateTagCS = new DicomTag(0x00091025, "PrivateCS", "PrivateCS", DicomVr.CSvr, true, 1, 10, false); DicomTag privateTagDA = new DicomTag(0x00091026, "PrivateDA", "PrivateDA", DicomVr.DAvr, true, 1, 10, false); DicomTag privateTagDS = new DicomTag(0x00091027, "PrivateDS", "PrivateDS", DicomVr.DSvr, true, 1, 10, false); DicomTag privateTagDT = new DicomTag(0x00091028, "PrivateDT", "PrivateDT", DicomVr.DTvr, true, 1, 10, false); DicomTag privateTagFD = new DicomTag(0x00091029, "PrivateFD", "PrivateFD", DicomVr.FDvr, true, 1, 10, false); DicomTag privateTagIS = new DicomTag(0x00091030, "PrivateIS", "PrivateIS", DicomVr.ISvr, true, 1, 10, false); DicomTag privateTagLT = new DicomTag(0x00091031, "PrivateLT", "PrivateLT", DicomVr.LTvr, true, 1, 1, false); DicomTag privateTagOB = new DicomTag(0x00091032, "PrivateOB", "PrivateOB", DicomVr.OBvr, true, 1, 1, false); DicomTag privateTagOF = new DicomTag(0x00091033, "PrivateOF", "PrivateOF", DicomVr.OFvr, true, 1, 1, false); DicomTag privateTagOW = new DicomTag(0x00091034, "PrivateOW", "PrivateOW", DicomVr.OWvr, true, 1, 1, false); DicomTag privateTagPN = new DicomTag(0x00091035, "PrivatePN", "PrivatePN", DicomVr.PNvr, true, 1, 10, false); DicomTag privateTagSH = new DicomTag(0x00091036, "PrivateSH", "PrivateSH", DicomVr.SHvr, true, 1, 10, false); DicomTag privateTagSL = new DicomTag(0x00091037, "PrivateSL", "PrivateSL", DicomVr.SLvr, true, 1, 10, false); DicomTag privateTagSQ = new DicomTag(0x00091038, "PrivateSQ", "PrivateSQ", DicomVr.SQvr, true, 1, 10, false); DicomTag privateTagSS = new DicomTag(0x00091039, "PrivateSS", "PrivateSS", DicomVr.SSvr, true, 1, 10, false); DicomTag privateTagST = new DicomTag(0x00091040, "PrivateST", "PrivateST", DicomVr.STvr, true, 1, 10, false); DicomTag privateTagTM = new DicomTag(0x00091041, "PrivateTM", "PrivateTM", DicomVr.TMvr, true, 1, 10, false); DicomTag privateTagUI = new DicomTag(0x00091042, "PrivateUI", "PrivateUI", DicomVr.UIvr, true, 1, 10, false); DicomTag privateTagUL = new DicomTag(0x00091043, "PrivateUI", "PrivateUI", DicomVr.ULvr, true, 1, 10, false); DicomTag privateTagUS = new DicomTag(0x00091044, "PrivateUS", "PrivateUS", DicomVr.USvr, true, 1, 10, false); DicomTag privateTagUT = new DicomTag(0x00091045, "PrivateUT", "PrivateUT", DicomVr.UTvr, true, 1, 1, false); List <DicomTag> tagList = new List <DicomTag>(); dataSet[privateTagFL].AppendFloat32(1.1f); dataSet[privateTagFL].AppendFloat32(1.1123132f); tagList.Add(privateTagFL); dataSet[privateTagLO].AppendString("Test"); dataSet[privateTagLO].AppendString("Test Me 2"); tagList.Add(privateTagLO); dataSet[privateTagAE].AppendString("TESTAE1"); dataSet[privateTagAE].AppendString("TESTAE2"); tagList.Add(privateTagAE); dataSet[privateTagAS].AppendString("003Y"); dataSet[privateTagAS].AppendString("003D"); tagList.Add(privateTagAS); dataSet[privateTagAT].AppendUInt32(DicomTags.ZoomFactor); dataSet[privateTagAT].AppendUInt32(DicomTags.PhotometricInterpretation); tagList.Add(privateTagAT); dataSet[privateTagCS].AppendString("CODE1"); dataSet[privateTagCS].AppendString("CODE2"); tagList.Add(privateTagCS); dataSet[privateTagDA].AppendDateTime(DateTime.Now); dataSet[privateTagDA].AppendDateTime(DateTime.Now); tagList.Add(privateTagDA); dataSet[privateTagDS].AppendFloat64(1.12351234124124f); dataSet[privateTagDS].AppendFloat64(-12312312312.1231f); tagList.Add(privateTagDS); dataSet[privateTagDT].AppendDateTime(DateTime.Now); dataSet[privateTagDT].AppendDateTime(DateTime.Now); tagList.Add(privateTagDT); dataSet[privateTagFD].AppendFloat64(1.112312d); dataSet[privateTagFD].AppendFloat64(-11123.13211d); tagList.Add(privateTagFD); dataSet[privateTagIS].AppendString("123456789"); dataSet[privateTagIS].AppendString("123456789876"); tagList.Add(privateTagIS); dataSet[privateTagLT].SetStringValue("Now is the time for all good men to come to the aide of their country."); tagList.Add(privateTagLT); dataSet[privateTagPN].AppendString("Last^First^Middle^Post"); dataSet[privateTagPN].AppendString("W^Steven^R^Test"); tagList.Add(privateTagPN); dataSet[privateTagST].SetStringValue("Now is the time for all good men to come to the aide of their country."); tagList.Add(privateTagST); dataSet[privateTagSH].AppendString("Short text 1"); dataSet[privateTagSH].AppendString("Short text 2"); dataSet[privateTagSH].AppendString("Short text 3"); dataSet[privateTagSH].AppendString("Short text 4"); tagList.Add(privateTagSH); dataSet[privateTagSL].AppendInt32(1024); dataSet[privateTagSL].AppendInt32(2048); dataSet[privateTagSL].AppendInt32(4096); dataSet[privateTagSL].AppendInt32(8192); dataSet[privateTagSL].AppendInt32(-1024); dataSet[privateTagSL].AppendInt32(-2048); dataSet[privateTagSL].AppendInt32(-4096); dataSet[privateTagSL].AppendInt32(-8192); tagList.Add(privateTagSL); dataSet[privateTagSS].AppendInt16(-1024); dataSet[privateTagSS].AppendInt16(512); dataSet[privateTagSS].AppendInt16(-256); dataSet[privateTagSS].AppendInt16(128); tagList.Add(privateTagSS); dataSet[privateTagTM].AppendDateTime(DateTime.Now); dataSet[privateTagTM].AppendDateTime(DateTime.Now); tagList.Add(privateTagTM); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); tagList.Add(privateTagUI); dataSet[privateTagUL].AppendUInt32(128); dataSet[privateTagUL].AppendUInt32(1024); dataSet[privateTagUL].AppendUInt32(16384); dataSet[privateTagUL].AppendUInt32(123123123); tagList.Add(privateTagUL); dataSet[privateTagUS].AppendUInt16(128); dataSet[privateTagUS].AppendUInt16(64); dataSet[privateTagUS].AppendUInt16(256); tagList.Add(privateTagUS); dataSet[privateTagUT].SetStringValue("A man, a plan, a canal, panama."); tagList.Add(privateTagUT); dataSet[privateTagOB].Values = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; tagList.Add(privateTagOB); dataSet[privateTagOW].Values = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; tagList.Add(privateTagOW); dataSet[privateTagOF].Values = new[] { 1.1111f, 2.222f, 3.3333f, 44444.444f, 5555.555f, 66666.66666f, 123123.123123f }; tagList.Add(privateTagOF); DicomSequenceItem item = new DicomSequenceItem(); item[DicomTags.PhotometricInterpretation].AppendString("MONOCHROME1"); item[DicomTags.Rows].AppendUInt16(256); item[DicomTags.Columns].AppendUInt16(256); item[DicomTags.BitsAllocated].AppendUInt16(8); item[DicomTags.BitsStored].AppendUInt16(8); item[DicomTags.HighBit].AppendUInt16(7); dataSet[privateTagSQ].AddSequenceItem(item); // SQ Attribute UN parsing does not work right now, don't add to the list. //tagList.Add(privateTagSQ); SetupMetaInfo(file); dataSet[DicomTags.StudyDescription].SetNullValue(); // Little Endian Tests file.TransferSyntax = TransferSyntax.ImplicitVrLittleEndian; DicomReadOptions readOptions = DicomReadOptions.Default; // Use ExplicitLengthSequence to force SQ attributes to UN VR when they're ready back in bool result = file.Save(DicomWriteOptions.ExplicitLengthSequence); Assert.AreEqual(result, true); DicomFile newFile = new DicomFile(file.Filename); newFile.Load(readOptions); Assert.IsTrue(newFile.DataSet[DicomTags.StudyDescription].IsNull); Assert.AreNotEqual(file.DataSet.Equals(newFile.DataSet), true); foreach (DicomTag tag in tagList) { DicomAttributeUN unAttrib = newFile.DataSet[tag] as DicomAttributeUN; Assert.IsNotNull(unAttrib, String.Format("UN VR Attribute is not null for tag {0}", tag)); ByteBuffer bb = unAttrib.GetByteBuffer(TransferSyntax.ImplicitVrLittleEndian, newFile.DataSet[DicomTags.SpecificCharacterSet].ToString()); Assert.IsNotNull(bb, String.Format("ByteBuffer not null for tag: {0}", tag)); DicomAttribute validAttrib = tag.VR.CreateDicomAttribute(tag, bb); Assert.IsNotNull(validAttrib); Assert.IsTrue(validAttrib.Equals(file.DataSet[tag]), String.Format("Attributes equal for tag {0}", tag)); } }
public void SQUNTests() { uint fakeTag = 0x00880199; // IconImageSequence is 0x00880200 DicomTag fakeSQTag = new DicomTag(fakeTag, "Fake Icon", "FakeIcon", DicomVr.SQvr, false, 1, 1, false); if (DicomTagDictionary.TagDictionary.ContainsKey(fakeTag)) { DicomTagDictionary.TagDictionary.Remove(fakeTag); } DicomTagDictionary.TagDictionary.Add(fakeTag, fakeSQTag); DicomFile file = new DicomFile("SQUNTest.dcm"); DicomAttributeCollection dataSet = file.DataSet; SetupMetaInfo(file); SetupMR(dataSet); DicomSequenceItem item = new DicomSequenceItem(); item[DicomTags.PhotometricInterpretation].AppendString("MONOCHROME1"); item[DicomTags.Rows].AppendUInt16(4); item[DicomTags.Columns].AppendUInt16(4); item[DicomTags.BitsAllocated].AppendUInt16(8); item[DicomTags.BitsStored].AppendUInt16(8); item[DicomTags.HighBit].AppendUInt16(7); item[DicomTags.PixelData].Values = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 }; dataSet[fakeSQTag].AddSequenceItem(item); // Save the file DicomFile originalFile = new DicomFile("", file.MetaInfo.Copy(), file.DataSet.Copy()); DicomTagDictionary.TagDictionary.Remove(fakeTag); List <DicomAttributeComparisonResult> results = new List <DicomAttributeComparisonResult>(); bool compare; DicomReadOptions readOptions = DicomReadOptions.Default; // Little Endian Tests file.TransferSyntax = TransferSyntax.ImplicitVrLittleEndian; // Implicit Little Endian, No tag in the Dictionary, Explicit Length SQ Assert.IsTrue(file.Save(DicomWriteOptions.ExplicitLengthSequence), "UN File Save"); DicomFile newFile = new DicomFile(file.Filename); newFile.Load(readOptions); Assert.AreNotEqual(originalFile.DataSet.Equals(newFile.DataSet), true); DicomFile saveUNfile = newFile; // Implicit Little Endian, No tag in the Dictionary, Implicit Length SQ // Parser knows its a SQ from implicit length SQ Assert.IsTrue(file.Save(DicomWriteOptions.ExplicitLengthSequenceItem), "UN File Save"); newFile = new DicomFile(file.Filename); newFile.Load(readOptions); results = new List <DicomAttributeComparisonResult>(); compare = originalFile.DataSet.Equals(newFile.DataSet, ref results); Assert.IsTrue(compare, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty); // Implicit Little Endian, No tag in the Dictionary, Implicit Length SQ // Parser knows its a SQ from implicit length SQ Assert.IsTrue(file.Save(DicomWriteOptions.None), "UN File Save"); newFile = new DicomFile(file.Filename); newFile.Load(readOptions); results = new List <DicomAttributeComparisonResult>(); compare = originalFile.DataSet.Equals(newFile.DataSet, ref results); Assert.IsTrue(compare, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty); file = saveUNfile; file.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian; // Explicit Little Endian, No tag in the dictionary, UN SQ // Parser keeps tag as UN Assert.IsTrue(file.Save(DicomWriteOptions.None), "UN File Save"); newFile = new DicomFile(file.Filename); newFile.Load(readOptions); results = new List <DicomAttributeComparisonResult>(); compare = file.DataSet.Equals(newFile.DataSet, ref results); Assert.IsTrue(compare, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty); Assert.AreNotEqual(originalFile.DataSet.Equals(newFile.DataSet), true); file.TransferSyntax = TransferSyntax.ExplicitVrBigEndian; // Explicit Big Endian, No tag in the dictionary, UN SQ // Parser keeps tag as UN Assert.IsTrue(file.Save(DicomWriteOptions.None), "UN File Save"); newFile = new DicomFile(file.Filename); newFile.Load(readOptions); results = new List <DicomAttributeComparisonResult>(); compare = file.DataSet.Equals(newFile.DataSet, ref results); Assert.IsTrue(compare, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty); Assert.AreNotEqual(originalFile.DataSet.Equals(newFile.DataSet), true); // Now add the tag into thedictionary DicomTagDictionary.TagDictionary.Add(fakeTag, fakeSQTag); file.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian; // Note, if we add parsing of SQ UN tags, the result of this test would change // Explicit Little Endian, Tag in the dictionary, UN SQ // Parser keeps tag as UN Assert.IsTrue(file.Save(DicomWriteOptions.None), "UN File Save"); newFile = new DicomFile(file.Filename); newFile.Load(readOptions); results = new List <DicomAttributeComparisonResult>(); compare = file.DataSet.Equals(newFile.DataSet, ref results); Assert.IsTrue(compare, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty); Assert.AreNotEqual(originalFile.DataSet.Equals(newFile.DataSet), true); file.TransferSyntax = TransferSyntax.ExplicitVrBigEndian; // Note, if we add parsing of SQ UN tags, the result of this test would change // Explicit Big Endian, Tag in the dictionary, UN SQ // Parser keeps tag as UN Assert.IsTrue(file.Save(DicomWriteOptions.None), "UN File Save"); newFile = new DicomFile(file.Filename); newFile.Load(readOptions); results = new List <DicomAttributeComparisonResult>(); compare = file.DataSet.Equals(newFile.DataSet, ref results); Assert.IsTrue(compare, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty); Assert.AreNotEqual(originalFile.DataSet.Equals(newFile.DataSet), true); }
private void SetupPrivateGroups(List <DicomTag> tagList, DicomAttributeCollection dataSet) { DicomTag privateCreatorTag = new DicomTag(0x00090010, "PrivateCreator", "PrivateCreator", DicomVr.LOvr, false, 1, 1, false); dataSet[privateCreatorTag].SetStringValue("ClearCanvasGroup9"); DicomTag privateTagFL = new DicomTag(0x00091020, "PrivateFL", "PrivateFL", DicomVr.FLvr, true, 1, 10, false); DicomTag privateTagLO = new DicomTag(0x00091021, "PrivateLO", "PrivateLO", DicomVr.LOvr, true, 1, 10, false); DicomTag privateTagAE = new DicomTag(0x00091022, "PrivateAE", "PrivateAE", DicomVr.AEvr, true, 1, 10, false); DicomTag privateTagAS = new DicomTag(0x00091023, "PrivateAS", "PrivateAS", DicomVr.ASvr, true, 1, 10, false); DicomTag privateTagAT = new DicomTag(0x00091024, "PrivateAT", "PrivateAT", DicomVr.ATvr, true, 1, 10, false); DicomTag privateTagCS = new DicomTag(0x00091025, "PrivateCS", "PrivateCS", DicomVr.CSvr, true, 1, 10, false); DicomTag privateTagDA = new DicomTag(0x00091026, "PrivateDA", "PrivateDA", DicomVr.DAvr, true, 1, 10, false); DicomTag privateTagDS = new DicomTag(0x00091027, "PrivateDS", "PrivateDS", DicomVr.DSvr, true, 1, 10, false); DicomTag privateTagDT = new DicomTag(0x00091028, "PrivateDT", "PrivateDT", DicomVr.DTvr, true, 1, 10, false); DicomTag privateTagFD = new DicomTag(0x00091029, "PrivateFD", "PrivateFD", DicomVr.FDvr, true, 1, 10, false); DicomTag privateTagIS = new DicomTag(0x00091030, "PrivateIS", "PrivateIS", DicomVr.ISvr, true, 1, 10, false); DicomTag privateTagLT = new DicomTag(0x00091031, "PrivateLT", "PrivateLT", DicomVr.LTvr, true, 1, 1, false); DicomTag privateTagOB = new DicomTag(0x00091032, "PrivateOB", "PrivateOB", DicomVr.OBvr, true, 1, 1, false); DicomTag privateTagOF = new DicomTag(0x00091033, "PrivateOF", "PrivateOF", DicomVr.OFvr, true, 1, 1, false); DicomTag privateTagOW = new DicomTag(0x00091034, "PrivateOW", "PrivateOW", DicomVr.OWvr, true, 1, 1, false); DicomTag privateTagPN = new DicomTag(0x00091035, "PrivatePN", "PrivatePN", DicomVr.PNvr, true, 1, 10, false); DicomTag privateTagSH = new DicomTag(0x00091036, "PrivateSH", "PrivateSH", DicomVr.SHvr, true, 1, 10, false); DicomTag privateTagSL = new DicomTag(0x00091037, "PrivateSL", "PrivateSL", DicomVr.SLvr, true, 1, 10, false); DicomTag privateTagSQ = new DicomTag(0x00091038, "PrivateSQ", "PrivateSQ", DicomVr.SQvr, true, 1, 10, false); DicomTag privateTagSS = new DicomTag(0x00091039, "PrivateSS", "PrivateSS", DicomVr.SSvr, true, 1, 10, false); DicomTag privateTagST = new DicomTag(0x00091040, "PrivateST", "PrivateST", DicomVr.STvr, true, 1, 10, false); DicomTag privateTagTM = new DicomTag(0x00091041, "PrivateTM", "PrivateTM", DicomVr.TMvr, true, 1, 10, false); DicomTag privateTagUI = new DicomTag(0x00091042, "PrivateUI", "PrivateUI", DicomVr.UIvr, true, 1, 10, false); DicomTag privateTagUL = new DicomTag(0x00091043, "PrivateUI", "PrivateUI", DicomVr.ULvr, true, 1, 10, false); DicomTag privateTagUS = new DicomTag(0x00091044, "PrivateUS", "PrivateUS", DicomVr.USvr, true, 1, 10, false); DicomTag privateTagUT = new DicomTag(0x00091045, "PrivateUT", "PrivateUT", DicomVr.UTvr, true, 1, 1, false); dataSet[privateTagFL].AppendFloat32(1.1f); dataSet[privateTagFL].AppendFloat32(1.1123132f); tagList.Add(privateTagFL); dataSet[privateTagLO].AppendString("Test"); dataSet[privateTagLO].AppendString("Test Me 2"); tagList.Add(privateTagLO); dataSet[privateTagAE].AppendString("TESTAE1"); dataSet[privateTagAE].AppendString("TESTAE2"); tagList.Add(privateTagAE); dataSet[privateTagAS].AppendString("003Y"); dataSet[privateTagAS].AppendString("003D"); tagList.Add(privateTagAS); dataSet[privateTagAT].AppendUInt32(DicomTags.ZoomFactor); dataSet[privateTagAT].AppendUInt32(DicomTags.PhotometricInterpretation); tagList.Add(privateTagAT); dataSet[privateTagCS].AppendString("CODE1"); dataSet[privateTagCS].AppendString("CODE2"); tagList.Add(privateTagCS); dataSet[privateTagDA].AppendDateTime(DateTime.Now); dataSet[privateTagDA].AppendDateTime(DateTime.Now); tagList.Add(privateTagDA); dataSet[privateTagDS].AppendFloat64(1.12351234124124f); dataSet[privateTagDS].AppendFloat64(-12312312312.1231f); tagList.Add(privateTagDS); dataSet[privateTagDT].AppendDateTime(DateTime.Now); dataSet[privateTagDT].AppendDateTime(DateTime.Now); tagList.Add(privateTagDT); dataSet[privateTagFD].AppendFloat64(1.112312d); dataSet[privateTagFD].AppendFloat64(-11123.13211d); tagList.Add(privateTagFD); dataSet[privateTagIS].AppendString("123456789"); dataSet[privateTagIS].AppendString("123456789876"); tagList.Add(privateTagIS); dataSet[privateTagLT].SetStringValue("Now is the time for all good men to come to the aide of their country."); tagList.Add(privateTagLT); dataSet[privateTagPN].AppendString("Last^First^Middle^Post"); dataSet[privateTagPN].AppendString("W^Steven^R^Test"); tagList.Add(privateTagPN); dataSet[privateTagST].SetStringValue("Now is the time for all good men to come to the aide of their country."); tagList.Add(privateTagST); dataSet[privateTagSH].AppendString("Short text 1"); dataSet[privateTagSH].AppendString("Short text 2"); dataSet[privateTagSH].AppendString("Short text 3"); dataSet[privateTagSH].AppendString("Short text 4"); tagList.Add(privateTagSH); dataSet[privateTagSL].AppendInt32(1024); dataSet[privateTagSL].AppendInt32(2048); dataSet[privateTagSL].AppendInt32(4096); dataSet[privateTagSL].AppendInt32(8192); dataSet[privateTagSL].AppendInt32(-1024); dataSet[privateTagSL].AppendInt32(-2048); dataSet[privateTagSL].AppendInt32(-4096); dataSet[privateTagSL].AppendInt32(-8192); tagList.Add(privateTagSL); dataSet[privateTagSS].AppendInt16(-1024); dataSet[privateTagSS].AppendInt16(512); dataSet[privateTagSS].AppendInt16(-256); dataSet[privateTagSS].AppendInt16(128); tagList.Add(privateTagSS); dataSet[privateTagTM].AppendDateTime(DateTime.Now); dataSet[privateTagTM].AppendDateTime(DateTime.Now); tagList.Add(privateTagTM); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); dataSet[privateTagUI].AppendUid(DicomUid.GenerateUid()); tagList.Add(privateTagUI); dataSet[privateTagUL].AppendUInt32(128); dataSet[privateTagUL].AppendUInt32(1024); dataSet[privateTagUL].AppendUInt32(16384); dataSet[privateTagUL].AppendUInt32(123123123); tagList.Add(privateTagUL); dataSet[privateTagUS].AppendUInt16(128); dataSet[privateTagUS].AppendUInt16(64); dataSet[privateTagUS].AppendUInt16(256); tagList.Add(privateTagUS); dataSet[privateTagUT].SetStringValue("A man, a plan, a canal, panama."); tagList.Add(privateTagUT); dataSet[privateTagOB].Values = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; tagList.Add(privateTagOB); dataSet[privateTagOW].Values = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; tagList.Add(privateTagOW); dataSet[privateTagOF].Values = new[] { 1.1111f, 2.222f, 3.3333f, 44444.444f, 5555.555f, 66666.66666f, 123123.123123f }; tagList.Add(privateTagOF); DicomSequenceItem item = new DicomSequenceItem(); item[DicomTags.PhotometricInterpretation].AppendString("MONOCHROME1"); item[DicomTags.Rows].AppendUInt16(256); item[DicomTags.Columns].AppendUInt16(256); item[DicomTags.BitsAllocated].AppendUInt16(8); item[DicomTags.BitsStored].AppendUInt16(8); item[DicomTags.HighBit].AppendUInt16(7); item[DicomTags.PixelData].Values = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; dataSet[privateTagSQ].AddSequenceItem(item); // SQ Attribute UN parsing does not work right now, don't add to the list. //tagList.Add(privateTagSQ); }
protected static IList <DicomAttributeCollection> Query(IApplicationEntity server, DicomAttributeCollection requestCollection) { //special case code for ModalitiesInStudy. An IStudyFinder must accept a multi-valued //string for ModalitiesInStudy (e.g. "MR\\CT") and process it appropriately for the //datasource that is being queried. In this case (Dicom) does not allow multiple //query keys, so we have to execute one query per modality specified in the //ModalitiesInStudy query item. List <string> modalityFilters = new List <string>(); if (requestCollection.Contains(DicomTags.ModalitiesInStudy)) { string modalityFilterString = requestCollection[DicomTags.ModalitiesInStudy].ToString(); if (!String.IsNullOrEmpty(modalityFilterString)) { modalityFilters.AddRange(modalityFilterString.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries)); } if (modalityFilters.Count == 0) { modalityFilters.Add(""); //make sure there is at least one filter, the default. } } SortedList <string, DicomAttributeCollection> resultsByStudy = new SortedList <string, DicomAttributeCollection>(); string combinedFilter = requestCollection[DicomTags.ModalitiesInStudy]; try { foreach (string modalityFilter in modalityFilters) { using (StudyRootFindScu scu = new StudyRootFindScu()) { requestCollection[DicomTags.ModalitiesInStudy].SetStringValue(modalityFilter); IList <DicomAttributeCollection> results = scu.Find( DicomServer.AETitle, server.AETitle, server.ScpParameters.HostName, server.ScpParameters.Port, requestCollection); scu.Join(new TimeSpan(0, 0, 0, 0, 1000)); if (scu.Status == ScuOperationStatus.Canceled) { String message = String.Format(SR.MessageFormatRemoteServerCancelledFind, scu.FailureDescription ?? "no failure description provided"); throw new DicomException(message); } if (scu.Status == ScuOperationStatus.ConnectFailed) { String message = String.Format(SR.MessageFormatConnectionFailed, scu.FailureDescription ?? "no failure description provided"); throw new DicomException(message); } else if (scu.Status == ScuOperationStatus.AssociationRejected) { String message = String.Format(SR.MessageFormatAssociationRejected, scu.FailureDescription ?? "no failure description provided"); throw new DicomException(message); } if (scu.Status == ScuOperationStatus.Failed) { String message = String.Format(SR.MessageFormatQueryOperationFailed, scu.FailureDescription ?? "no failure description provided"); throw new DicomException(message); } if (scu.Status == ScuOperationStatus.TimeoutExpired) { String message = String.Format(SR.MessageFormatConnectTimeoutExpired, scu.FailureDescription ?? "no failure description provided"); throw new DicomException(message); } if (scu.Status == ScuOperationStatus.NetworkError) { throw new DicomException(SR.MessageUnexpectedNetworkError); } if (scu.Status == ScuOperationStatus.UnexpectedMessage) { throw new DicomException(SR.MessageUnexpectedMessage); } //if this function returns true, it means that studies came back whose //modalities did not match the filter, meaning that filtering on //ModalitiesInStudy is not supported by that server. if (FilterResultsByModality(results, resultsByStudy, modalityFilter)) { break; } } } return(new List <DicomAttributeCollection>(resultsByStudy.Values)); } finally { //for consistencies sake, put the original filter back. requestCollection[DicomTags.ModalitiesInStudy].SetStringValue(combinedFilter); } }
public void StandardAttributeTest() { DicomFile file = new DicomFile("UNTest.dcm"); DicomAttributeCollection dataSet = file.DataSet; SetupMetaInfo(file); SetupMR(dataSet); dataSet[DicomTags.RetrieveAeTitle].SetStringValue("TESTAE"); dataSet[DicomTags.RetrieveAeTitle].AppendString("TESTAE2"); dataSet[DicomTags.RetrieveAeTitle].AppendString("TESTAE3"); dataSet[DicomTags.RetrieveAeTitle].AppendString("TESTAE4"); dataSet[DicomTags.InstitutionAddress].SetStringValue("1224 Milwaukee Ave."); dataSet[DicomTags.TimeRange].SetFloat32(0, 1.111111f); dataSet[DicomTags.TimeRange].AppendFloat32(2.222222f); dataSet[DicomTags.RecommendedDisplayFrameRateInFloat].AppendFloat32(2.222222f); dataSet[DicomTags.ReferencePixelX0].AppendInt32(101010); dataSet[DicomTags.VerticesOfThePolygonalExposureControlSensingRegion].AppendInt16(324); dataSet[DicomTags.VerticesOfThePolygonalExposureControlSensingRegion].AppendInt16(111); dataSet[DicomTags.VerticesOfThePolygonalExposureControlSensingRegion].AppendInt16(1234); dataSet[DicomTags.DimensionIndexValues].AppendInt32(123456); dataSet[DicomTags.DimensionIndexValues].AppendInt32(789); dataSet[DicomTags.DimensionIndexValues].AppendInt32(98765); dataSet[DicomTags.PixelDataProviderUrl].SetStringValue("http://www.clearcanvas.ca"); dataSet[DicomTags.EncapsulatedDocument].Values = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; dataSet[DicomTags.VectorGridData].Values = new[] { 1234f, .01010f, 31231.31231f, 41414.4141414f }; DicomAttributeCollection originalDataSet = file.DataSet.Copy(); DicomAttributeCollection originalMetaInfo = file.MetaInfo.Copy(); DicomFile originalFile = new DicomFile("", originalMetaInfo, originalDataSet); // Force a sampling of tags to UN ConvertAttributeToUN(dataSet, DicomTags.RetrieveAeTitle); // AE ConvertAttributeToUN(dataSet, DicomTags.PatientsAge); // AS ConvertAttributeToUN(dataSet, DicomTags.TimeRange); // FD ConvertAttributeToUN(dataSet, DicomTags.RecommendedDisplayFrameRateInFloat); // FL ConvertAttributeToUN(dataSet, DicomTags.Modality); // CS ConvertAttributeToUN(dataSet, DicomTags.SeriesDate); // DA ConvertAttributeToUN(dataSet, DicomTags.PatientsWeight); // DS ConvertAttributeToUN(dataSet, DicomTags.AcquisitionDatetime); // DT ConvertAttributeToUN(dataSet, DicomTags.EchoTrainLength); // IS ConvertAttributeToUN(dataSet, DicomTags.Manufacturer); // LO ConvertAttributeToUN(dataSet, DicomTags.ImageComments); // LT ConvertAttributeToUN(dataSet, DicomTags.EncapsulatedDocument); // OB ConvertAttributeToUN(dataSet, DicomTags.VectorGridData); // OF ConvertAttributeToUN(dataSet, DicomTags.ReferringPhysiciansName); // PN ConvertAttributeToUN(dataSet, DicomTags.AccessionNumber); // SH ConvertAttributeToUN(dataSet, DicomTags.ReferencePixelX0); // SL ConvertAttributeToUN(dataSet, DicomTags.VerticesOfThePolygonalExposureControlSensingRegion); // SS ConvertAttributeToUN(dataSet, DicomTags.InstitutionAddress); // ST ConvertAttributeToUN(dataSet, DicomTags.SeriesTime); // TM ConvertAttributeToUN(dataSet, DicomTags.StudyInstanceUid); // UI ConvertAttributeToUN(dataSet, DicomTags.DimensionIndexValues); // UL ConvertAttributeToUN(dataSet, DicomTags.SamplesPerPixel); // US ConvertAttributeToUN(dataSet, DicomTags.PixelDataProviderUrl); // UT // Explicit Big file.TransferSyntax = TransferSyntax.ExplicitVrBigEndian; file.Save(); DicomFile newFile = new DicomFile(file.Filename); newFile.Load(DicomReadOptions.UseDictionaryForExplicitUN); List <DicomAttributeComparisonResult> results = new List <DicomAttributeComparisonResult>(); bool compare = originalFile.DataSet.Equals(newFile.DataSet, ref results); Assert.IsTrue(compare, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty); // Explicit Little file.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian; file.Save(); newFile = new DicomFile(file.Filename); newFile.Load(DicomReadOptions.UseDictionaryForExplicitUN); results = new List <DicomAttributeComparisonResult>(); compare = originalFile.DataSet.Equals(newFile.DataSet, ref results); Assert.IsTrue(compare, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty); // Implicit Little file.TransferSyntax = TransferSyntax.ImplicitVrLittleEndian; file.Save(); newFile = new DicomFile(file.Filename); newFile.Load(DicomReadOptions.UseDictionaryForExplicitUN); results = new List <DicomAttributeComparisonResult>(); compare = originalFile.DataSet.Equals(newFile.DataSet, ref results); Assert.IsTrue(compare, results.Count > 0 ? CollectionUtils.FirstElement(results).Details : string.Empty); }
/// <summary> /// Constructs a new <see cref="DicomMessageSopDataSource"/>. /// </summary> /// <param name="sourceMessage">The source <see cref="DicomMessageBase"/> which provides all the SOP instance data.</param> protected DicomMessageSopDataSource(DicomMessageBase sourceMessage) { _dummy = new DicomAttributeCollection(); SetSourceMessage(sourceMessage); }
protected StringDicomPropertyFilter(uint tag, DicomAttributeCollection criteria) : this(new DicomTagPath(tag), criteria) { }