当前位置: 首页>>代码示例>>C#>>正文


C# DicomFile类代码示例

本文整理汇总了C#中DicomFile的典型用法代码示例。如果您正苦于以下问题:C# DicomFile类的具体用法?C# DicomFile怎么用?C# DicomFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DicomFile类属于命名空间,在下文中一共展示了DicomFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestFile

        public void TestFile()
        {
            string filename = "OutOfRange.dcm";

            DicomFile file = new DicomFile(filename, new DicomAttributeCollection(), new DicomAttributeCollection());
            SetupMR(file.DataSet);
            SetupMetaInfo(file);

            DicomTag tag = new DicomTag(0x00030010, "Test", "TestBad", DicomVr.LOvr, false, 1, 1, false);

            file.DataSet[tag].SetStringValue("Test");

            file.Save(filename);

            file = new DicomFile(filename);

            file.DataSet.IgnoreOutOfRangeTags = true;

            file.Load();

            Assert.IsNotNull(file.DataSet.GetAttribute(tag));

            file = new DicomFile(filename);

            file.DataSet.IgnoreOutOfRangeTags = false;

            try
            {
                file.Load();
                Assert.Fail("file.Load failed");
            }
            catch (DicomException)
            {
            }
        }
开发者ID:khaha2210,项目名称:radio,代码行数:35,代码来源:AttributeCollectionTest.cs

示例2: OpenFile

        public void OpenFile(DicomFile file)
        {
            try
            {
                lvDicom.BeginUpdate();

                Reset();

                _file = file;

                new DicomDatasetWalker(_file.FileMetaInfo).Walk(new DumpWalker(this));
                new DicomDatasetWalker(_file.Dataset).Walk(new DumpWalker(this));

                //if (_file.Dataset.Contains(DicomTag.PixelData))
                    menuItemView.Enabled = true;
                menuItemSyntax.Enabled = true;
                menuItemSave.Enabled = true;

                menuItemJpegLossy.Enabled = _file.Dataset.Get<int>(DicomTag.BitsStored, 0, 16) <= 12;
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    this,
                    "Exception while loading DICOM file: " + ex.Message,
                    "Error loading DICOM file",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
            finally
            {
                lvDicom.EndUpdate();
            }
        }
开发者ID:GMZ,项目名称:fo-dicom,代码行数:34,代码来源:MainForm.cs

示例3: WriteOptionsTest

        public void WriteOptionsTest(DicomFile sourceFile, DicomWriteOptions options)
        {
            bool result = sourceFile.Save(options);

            Assert.AreEqual(result, true);

            DicomFile newFile = new DicomFile(sourceFile.Filename);

            DicomReadOptions readOptions = DicomReadOptions.Default;
            newFile.Load(readOptions);

            Assert.AreEqual(sourceFile.DataSet.Equals(newFile.DataSet), true);

            // update a tag, and make sure it shows they're different
            newFile.DataSet[DicomTags.PatientsName].Values = "NewPatient^First";
            Assert.AreEqual(sourceFile.DataSet.Equals(newFile.DataSet), false);

            // Now update the original file with the name, and they should be the same again
            sourceFile.DataSet[DicomTags.PatientsName].Values = "NewPatient^First";
            Assert.AreEqual(sourceFile.DataSet.Equals(newFile.DataSet), true);

            // Return the original string value.
            sourceFile.DataSet[DicomTags.PatientsName].SetStringValue("Patient^Test");

        }
开发者ID:scottshea,项目名称:monodicom,代码行数:25,代码来源:FileTest.cs

示例4: DicomCStoreRequest

 /// <summary>
 /// Initializes DICOM C-Store request to be sent to SCP.
 /// </summary>
 /// <param name="file">DICOM file to be sent</param>
 /// <param name="priority">Priority of request</param>
 public DicomCStoreRequest(DicomFile file, DicomPriority priority = DicomPriority.Medium)
     : base(DicomCommandField.CStoreRequest, file.Dataset.Get<DicomUID>(DicomTag.SOPClassUID), priority)
 {
     File = file;
     Dataset = file.Dataset;
     SOPInstanceUID = File.Dataset.Get<DicomUID>(DicomTag.SOPInstanceUID);
 }
开发者ID:aerik,项目名称:fo-dicom,代码行数:12,代码来源:DicomCStoreRequest.cs

示例5: Validate

			public void Validate(DicomFile dicomFile)
			{
				DicomAttributeCollection sopInstanceDataset = dicomFile.DataSet;
				DicomAttributeCollection metaInfo = dicomFile.MetaInfo;

				DicomAttribute attribute = metaInfo[DicomTags.MediaStorageSopClassUid];
				// we want to skip Media Storage Directory Storage (DICOMDIR directories)
				if ("1.2.840.10008.1.3.10" == attribute.ToString())
					throw new DataStoreException("Cannot process dicom directory files.");

				DicomValidator.ValidateStudyInstanceUID(sopInstanceDataset[DicomTags.StudyInstanceUid]);
				DicomValidator.ValidateSeriesInstanceUID(sopInstanceDataset[DicomTags.SeriesInstanceUid]);
				DicomValidator.ValidateSOPInstanceUID(sopInstanceDataset[DicomTags.SopInstanceUid]);
				DicomValidator.ValidateTransferSyntaxUID(metaInfo[DicomTags.TransferSyntaxUid]);
				
				if (dicomFile.SopClass == null)
					throw new DataStoreException("The sop class must not be empty.");

				DicomValidator.ValidateSopClassUid(dicomFile.SopClass.Uid);

				Study study = new Study();
				study.Initialize(dicomFile);

				_validator.ValidatePersistentObject(study);
			}
开发者ID:scottshea,项目名称:monodicom,代码行数:25,代码来源:DicomPersistentStoreValidator.cs

示例6: RleTest

        public void RleTest()
        {
            DicomFile file = new DicomFile("RleCodecTest.dcm");

            SetupMR(file.DataSet);

            SetupMetaInfo(file);

            RleTest(file);

            file = new DicomFile("MultiframeRleCodecTest.dcm");

            SetupMultiframeXA(file.DataSet, 511, 511, 5);

            RleTest(file);


            file = new DicomFile("MultiframeRleCodecTest.dcm");

            SetupMultiframeXA(file.DataSet, 63, 63, 1);

            RleTest(file);

            file = new DicomFile("MultiframeRleCodecTest.dcm");

            SetupMultiframeXA(file.DataSet, 1024, 1024, 3);

            RleTest(file);

            file = new DicomFile("MultiframeRleCodecTest.dcm");

            SetupMultiframeXA(file.DataSet, 512, 512, 2);

            RleTest(file);
        }
开发者ID:nhannd,项目名称:Xian,代码行数:35,代码来源:CodecTest.cs

示例7: LosslessImageTest

	    public static void LosslessImageTest(TransferSyntax syntax, DicomFile theFile)
		{
			if (File.Exists(theFile.Filename))
				File.Delete(theFile.Filename);

			DicomFile saveCopy = new DicomFile(theFile.Filename, theFile.MetaInfo.Copy(), theFile.DataSet.Copy());

			theFile.ChangeTransferSyntax(syntax);

			theFile.Save(DicomWriteOptions.ExplicitLengthSequence);

			DicomFile newFile = new DicomFile(theFile.Filename);

			newFile.Load(DicomReadOptions.Default);

			newFile.ChangeTransferSyntax(saveCopy.TransferSyntax);

			List<DicomAttributeComparisonResult> list = new List<DicomAttributeComparisonResult>();
			bool result = newFile.DataSet.Equals(saveCopy.DataSet, ref list);

			StringBuilder sb = new StringBuilder();
			foreach (DicomAttributeComparisonResult compareResult in list)
				sb.AppendFormat("Comparison Failure: {0}, ", compareResult.Details);

			Assert.IsTrue(result,sb.ToString());
		}
开发者ID:khaha2210,项目名称:radio,代码行数:26,代码来源:AbstractCodecTest.cs

示例8: OnExecute

		protected override void OnExecute(CommandProcessor theProcessor)
		{
		    if (!File.Exists(_path))
			{
				Platform.Log(LogLevel.Error, "Unexpected error finding file to add to XML {0}", _path);
				throw new ApplicationException("Unexpected error finding file to add to XML {0}" + _path);
			}

			var finfo = new FileInfo(_path);
			long fileSize = finfo.Length;

			var dicomFile = new DicomFile(_path);
			dicomFile.Load(DicomReadOptions.StorePixelDataReferences | DicomReadOptions.Default);

		    _sopInstanceUid = dicomFile.DataSet[DicomTags.SopInstanceUid];
		    _seriesInstanceUid = dicomFile.DataSet[DicomTags.SeriesInstanceUid];

			// Setup the insert parameters
			if (false == _stream.AddFile(dicomFile, fileSize))
			{
				Platform.Log(LogLevel.Error, "Unexpected error adding SOP to XML Study Descriptor for file {0}",
				             _path);
				throw new ApplicationException("Unexpected error adding SOP to XML Study Descriptor for SOP: " +
				                               dicomFile.MediaStorageSopInstanceUid);
			}
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:26,代码来源:InsertInstanceXmlCommand.cs

示例9: Validate

			public void Validate(DicomFile dicomFile)
			{
				const string metaInfoErrorMessageFormat = "Invalid DICOM File Meta Info ({0})";

				DicomAttributeCollection sopInstanceDataset = dicomFile.DataSet;
				DicomAttributeCollection metaInfo = dicomFile.MetaInfo;

				DicomAttribute attribute = metaInfo[DicomTags.MediaStorageSopClassUid];
				// we want to skip Media Storage Directory Storage (DICOMDIR directories)
				if ("1.2.840.10008.1.3.10" == attribute.ToString())
					throw new DataStoreException("Cannot process DICOM directory files.");

				DicomValidator.ValidateStudyInstanceUID(sopInstanceDataset[DicomTags.StudyInstanceUid]);
				DicomValidator.ValidateSeriesInstanceUID(sopInstanceDataset[DicomTags.SeriesInstanceUid]);
				DicomValidator.ValidateSOPInstanceUID(sopInstanceDataset[DicomTags.SopInstanceUid]);
				DicomValidator.ValidateTransferSyntaxUID(metaInfo[DicomTags.TransferSyntaxUid]);

				if (dicomFile.SopClass == null)
					throw new DataStoreException(string.Format(metaInfoErrorMessageFormat, "SOP Class UID is missing"));

				try
				{
					DicomValidator.ValidateSopClassUid(dicomFile.SopClass.Uid);
				}
				catch (DicomDataException ex)
				{
					throw new DataStoreException(string.Format(metaInfoErrorMessageFormat, "SOP Class UID is missing"), ex);
				}

				Study study = new Study();
				study.Initialize(dicomFile);

				_validator.ValidatePersistentObject(study);
			}
开发者ID:khaha2210,项目名称:radio,代码行数:34,代码来源:DicomPersistentStoreValidator.cs

示例10: ConstructorTests

		public void ConstructorTests()
		{
			DicomFile file = new DicomFile(null);

			file = new DicomFile("filename");

			file = new DicomFile(null, new DicomAttributeCollection(), new DicomAttributeCollection());
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:8,代码来源:DicomFileTests.cs

示例11: Clone

 public static DicomFile Clone(this DicomFile original)
 {
     var df = new DicomFile();
     df.FileMetaInfo.Add(original.FileMetaInfo);
     df.Dataset.Add(original.Dataset);
     df.Dataset.InternalTransferSyntax = original.Dataset.InternalTransferSyntax;
     return df;
 }
开发者ID:GMZ,项目名称:fo-dicom,代码行数:8,代码来源:DicomFileExtensions.cs

示例12: SopInstanceNode

		/// <summary>
		/// Constructs a new <see cref="SopInstanceNode"/> using the given <see cref="DicomFile"/> as a template.
		/// </summary>
		/// <param name="sourceDicomFile">The <see cref="DicomFile"/> from which to initialize this node.</param>
		public SopInstanceNode(DicomMessageBase sourceDicomFile)
		{
			_dicomFile = new DicomFile("", sourceDicomFile.MetaInfo.Copy(), sourceDicomFile.DataSet.Copy());

			_instanceUid = sourceDicomFile.DataSet[DicomTags.SopInstanceUid].GetString(0, "");
			if (_instanceUid == "")
				_instanceUid = StudyBuilder.NewUid();
		}
开发者ID:scottshea,项目名称:monodicom,代码行数:12,代码来源:SopInstanceNode.cs

示例13: DicomCStoreRequest

 /// <summary>
 /// Initializes DICOM C-Store request to be sent to SCP.
 /// </summary>
 /// <param name="file">DICOM file to be sent</param>
 /// <param name="priority">Priority of request</param>
 public DicomCStoreRequest(DicomFile file, DicomPriority priority = DicomPriority.Medium)
     : base(DicomCommandField.CStoreRequest, file.FileMetaInfo.MediaStorageSOPClassUID, priority)
 {
     File = file;
     Dataset = file.Dataset;
     AffectedSOPClassUID = File.FileMetaInfo.MediaStorageSOPClassUID;
     SOPInstanceUID = File.FileMetaInfo.MediaStorageSOPInstanceUID;
 }
开发者ID:vdrm,项目名称:fo-dicom,代码行数:13,代码来源:DicomCStoreRequest.cs

示例14: Transcode

 /// <summary>
 /// Transcode a <see cref="DicomFile"/> from <see cref="IDicomTranscoder.InputSyntax"/> to <see cref="IDicomTranscoder.OutputSyntax"/>.
 /// </summary>
 /// <param name="file">DICOM file.</param>
 /// <returns>New, transcoded, DICOM file.</returns>
 public DicomFile Transcode(DicomFile file)
 {
     var f = new DicomFile();
     f.FileMetaInfo.Add(file.FileMetaInfo);
     f.FileMetaInfo.TransferSyntax = OutputSyntax;
     f.Dataset.InternalTransferSyntax = OutputSyntax;
     f.Dataset.Add(Transcode(file.Dataset));
     return f;
 }
开发者ID:aerik,项目名称:fo-dicom,代码行数:14,代码来源:DicomTranscoder.cs

示例15: SaveDicomFileCommand

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="file">The file to save.</param>
        /// <param name="failOnExists">If the file already exists, the file will save.</param>
        /// <param name="path">The path for the file.</param>
        public SaveDicomFileCommand(string path, DicomFile file, bool failOnExists)
            : base("Save DICOM File", true)
        {
            Platform.CheckForNullReference(file, "Dicom File object");
            Platform.CheckForNullReference(path, "Path to save file");

            _path = path;
            _file = file;
            _failOnExists = failOnExists;
        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:16,代码来源:SaveDicomFileCommand.cs


注:本文中的DicomFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。