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


C# Dicom.DicomFile类代码示例

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


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

示例1: LoadInstance

		/// <summary>
		/// Load the first instance from the first series of the StudyXml file for a study.
		/// </summary>
		/// <param name="location">The storage location of the study.</param>
		/// <returns></returns>
		protected static DicomFile LoadInstance(StudyStorageLocation location)
		{
			string studyXml = Path.Combine(location.GetStudyPath(), location.StudyInstanceUid + ".xml");

			if (!File.Exists(studyXml))
			{
				return null;
			}

			FileStream stream = FileStreamOpener.OpenForRead(studyXml, FileMode.Open);
			var theDoc = new XmlDocument();
			StudyXmlIo.Read(theDoc, stream);
			stream.Close();
			stream.Dispose();
			var xml = new StudyXml();
			xml.SetMemento(theDoc);
            
			IEnumerator<SeriesXml> seriesEnumerator = xml.GetEnumerator();
			if (seriesEnumerator.MoveNext())
			{
				SeriesXml seriesXml = seriesEnumerator.Current;
				IEnumerator<InstanceXml> instanceEnumerator = seriesXml.GetEnumerator();
				if (instanceEnumerator.MoveNext())
				{
					InstanceXml instance = instanceEnumerator.Current;
					var file = new DicomFile("file.dcm",new DicomAttributeCollection(), instance.Collection)
						{TransferSyntax = instance.TransferSyntax};
					return file;
				}
			}

			return null;
		}
开发者ID:jfphilbin,项目名称:ClearCanvas,代码行数:38,代码来源:BaseReapplyRulesServiceLockItemProcessor.cs

示例2: buttonCompress_Click

        private void buttonCompress_Click(object sender, EventArgs e)
        {
            TransferSyntax syntax = this.comboBoxCompressionType.SelectedItem as TransferSyntax;
            if (syntax == null)
            {
                MessageBox.Show("Transfer syntax not selected");
                return;
            }

            DicomFile dicomFile = new DicomFile(textBoxSourceFile.Text);

            dicomFile.Load();
            if (dicomFile.TransferSyntax.Encapsulated)
            {
                MessageBox.Show(String.Format("Message encoded as {0}, cannot compress.", dicomFile.TransferSyntax));
                return;
            }

            dicomFile.Filename = textBoxDestinationFile.Text;

            dicomFile.ChangeTransferSyntax(syntax);

            dicomFile.Save();

        }
开发者ID:nhannd,项目名称:Xian,代码行数:25,代码来源:TestCompressionForm.cs

示例3: Apply

        /// <summary>
        /// Updates the Patient's Name tag in the specified <see cref="DicomFile"/>
        /// based on the specified <see cref="StudyStorageLocation"/>. Normalization
        /// may occur.
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public UpdateItem Apply(DicomFile file)
        {
            Platform.CheckForNullReference(file, "file");
            
            string orginalPatientsNameInFile = file.DataSet[DicomTags.PatientsName].ToString();

			// Note: only apply the name rules if we can't update it to match the study
            if (!UpdateNameBasedOnTheStudy(file))
                UpdateNameBasedOnRules(file);

            string newPatientName = file.DataSet[DicomTags.PatientsName].ToString();
            UpdateItem change = null;

            if (!newPatientName.Equals(orginalPatientsNameInFile, StringComparison.InvariantCultureIgnoreCase))
            {
                change = new UpdateItem(DicomTags.PatientsName, orginalPatientsNameInFile, newPatientName);

                StringBuilder log = new StringBuilder();
                log.AppendLine(String.Format("AUTO-CORRECTION: SOP {0}", file.MediaStorageSopInstanceUid));
                log.AppendLine(String.Format("\tPatient's Name: {0} ==> {1}. ",
                                             change.OriginalValue, change.NewValue));
                Platform.Log(LogLevel.Info, log.ToString());
            }

            return change;
        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:33,代码来源:PatientNameRules.cs

示例4: Apply

		public override bool Apply(DicomFile file)
		{
            if (_uidMapper == null)
                return true; // Nothing to do

			string oldSeriesUid = file.DataSet[DicomTags.SeriesInstanceUid].GetString(0, String.Empty);
			string oldSopUid = file.DataSet[DicomTags.SopInstanceUid].GetString(0, String.Empty);

			string newSeriesUid;
            if (_uidMapper.ContainsSeries(oldSeriesUid))
                newSeriesUid = _uidMapper.FindNewSeriesUid(oldSeriesUid);
            else
            {
                newSeriesUid = DicomUid.GenerateUid().UID;
                _uidMapper.AddSeries(_originalStudy.StudyInstanceUid, _targetStudy.StudyInstanceUid, oldSeriesUid, newSeriesUid);
            }

			string newSopInstanceUid;
			if (_uidMapper.ContainsSop(oldSopUid))
				newSopInstanceUid = _uidMapper.FindNewSopUid(oldSopUid);
			else
			{
				newSopInstanceUid = DicomUid.GenerateUid().UID;
				_uidMapper.AddSop(oldSopUid, newSopInstanceUid);
			}

			file.DataSet[DicomTags.SeriesInstanceUid].SetStringValue(newSeriesUid);
			file.DataSet[DicomTags.SopInstanceUid].SetStringValue(newSopInstanceUid);
			file.MediaStorageSopInstanceUid = newSopInstanceUid;

            // add Source Image Sequence
            AddSourceImageSequence(file, oldSopUid);

		    return true;
		}
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:35,代码来源:SeriesSopUpdateCommand.cs

示例5: MultiFrameProcess

 public static void MultiFrameProcess(DbStudy study)
 {
     string dcmPath = ADCM.GetStoreString();
     var seriesList = Directory.GetDirectories(Path.Combine(dcmPath, study.study_uid));
     foreach (var sePath in seriesList)
     {
         var filesList = Directory.GetFiles(sePath, "*.dcm");
         if (filesList.Length < 2)
             continue;
         for (int i = 0; i < filesList.Length; i++)
         {
             var dcm = new DicomFile(filesList[i]);
             dcm.Load();
             int frameCount = dcm.DataSet[DicomTags.NumberOfFrames].GetInt16(0, 0);                
             if (frameCount > 1)
             {
                 string newSeriesUID = sePath + "." + i;
                 newSeriesUID = newSeriesUID.Substring(newSeriesUID.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                 string newSeriesPath = Path.Combine(dcmPath, study.study_uid, newSeriesUID);
                 Directory.CreateDirectory(newSeriesPath);
                 string fileName = Path.GetFileName(filesList[i]);
                 string oldPath = filesList[i];
                 string newPath = Path.Combine(newSeriesPath, fileName);
                 File.Move(filesList[i], Path.Combine(newSeriesPath, fileName));
             }
         }                        
     }
     foreach (string sePath in seriesList)
     {
         var filesCount = Directory.GetFiles(sePath);
         if (filesCount.Length < 1)
             Directory.Delete(sePath);
     }
 }
开发者ID:radiopaedia,项目名称:uploader-agent,代码行数:34,代码来源:AIMG.cs

示例6: Process

        /// <summary>
        /// Processes the specified <see cref="DicomFile"/> object.
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        /// <exception cref="TargetStudyInvalidStateException">Thrown when the target study is in invalid state and cannot be updated.</exception>
        public InstancePreProcessingResult Process(DicomFile file)
        {
            Platform.CheckForNullReference(file, "file");

            AutoReconcilerResult preProcessingResult = null;
            
            // Update the file based on the reconciliation in the past
            IList<StudyHistory> histories = FindReconcileHistories(StorageLocation, file);
            if (histories != null && histories.Count > 0)
            {
                preProcessingResult = ApplyHistories(file, histories);
            }

            if (preProcessingResult!=null)
            {
                StringBuilder log = new StringBuilder();
                log.AppendLine(String.Format("AUTO-RECONCILE: {0}. SOP {1}", preProcessingResult.Action, file.MediaStorageSopInstanceUid));
                foreach (UpdateItem change in preProcessingResult.Changes)
                {
                    if (change.NewValue != null && !change.NewValue.Equals(change.OriginalValue))
                    {
                        log.AppendLine(String.Format("\tSet {0}: {1} => {2}", change.Tag, change.OriginalValue, change.NewValue));    
                    }
                }
                Platform.Log(LogLevel.Info, log.ToString());
               
            }
            return preProcessingResult;
        }
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:35,代码来源:AutoReconciler.cs

示例7: CreateTestStudy1

        protected Study CreateTestStudy1()
        {
            var studyUid = "1.2.3";
            var sops = base.SetupMRSeries(4, 5, studyUid);
            var xml = new StudyXml(studyUid);

            var seriesUids = new Dictionary<string, string>();
            var seriesModalities = new Dictionary<string, string>();
            var modalities = new[] { "MR", "MR", "SC", "KO" };

            foreach (var sop in sops)
            {
                //Make the UIDs constant.
                var seriesUid = sop[DicomTags.SeriesInstanceUid].ToString();
                if (!seriesUids.ContainsKey(seriesUid))
                {
                    seriesModalities[seriesUid] = modalities[seriesUids.Count];
                    seriesUids[seriesUid] = string.Format("1.2.3.{0}", seriesUids.Count + 1);
                }

                var modality = seriesModalities[seriesUid];
                seriesUid = seriesUids[seriesUid];

                sop[DicomTags.SeriesInstanceUid].SetString(0, seriesUid);
                sop[DicomTags.Modality].SetString(0, modality);

                var file = new DicomFile("", new DicomAttributeCollection(), sop);
                xml.AddFile(file);
            }

            var study = new Study();
            study.Update(xml);
            return study;
        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:34,代码来源:TestBase.cs

示例8: AssertTagValueChanged

        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);

        }
开发者ID:nhannd,项目名称:Xian,代码行数:29,代码来源:SetDicomTagTestBase.cs

示例9: RemoveInstanceFromStudyXmlCommand

 public RemoveInstanceFromStudyXmlCommand(StudyStorageLocation location, StudyXml studyXml, DicomFile file)
     :base("Remove Instance From Study Xml", true)
 {
     _studyLocation = location;
     _file = file;
     _studyXml = studyXml;
 }
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:7,代码来源:RemoveInstanceFromStudyXmlCommand.cs

示例10: PreProcessFile

        protected override InstancePreProcessingResult PreProcessFile(Model.WorkQueueUid uid, DicomFile file)
        {
            // Return a result indicating the file has been reconciled.
            InstancePreProcessingResult result = new InstancePreProcessingResult {AutoReconciled = true};

        	return result;
        }
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:7,代码来源:ReconcilePostProcessingProcessor.cs

示例11: ProcessFile

		protected override void ProcessFile(Model.WorkQueueUid queueUid, DicomFile file, ClearCanvas.Dicom.Utilities.Xml.StudyXml stream, bool compare)
		{
            Platform.CheckFalse(compare, "compare");

			SopInstanceProcessor processor = new SopInstanceProcessor(Context);

			FileInfo fileInfo = new FileInfo(file.Filename);
			long fileSize = fileInfo.Length;
			processor.InstanceStats.FileSize = (ulong)fileSize;
			string sopInstanceUid = file.DataSet[DicomTags.SopInstanceUid].GetString(0, "File:" + fileInfo.Name);
			processor.InstanceStats.Description = sopInstanceUid;

			if (Study != null)
			{
				StudyComparer comparer = new StudyComparer();
				DifferenceCollection list = comparer.Compare(file, Study, ServerPartition.GetComparisonOptions());
				if (list != null && list.Count > 0)
				{
					Platform.Log(LogLevel.Warn, "Dicom file contains information inconsistent with the study in the system");
				}
			}

		    string groupID = ServerHelper.GetUidGroup(file, StorageLocation.ServerPartition, WorkQueueItem.InsertTime);
			processor.ProcessFile(groupID, file, stream, false, false, null, null);

			Statistics.StudyInstanceUid = StorageLocation.StudyInstanceUid;
			if (String.IsNullOrEmpty(processor.Modality) == false)
				Statistics.Modality = processor.Modality;

			// Update the statistics
			Statistics.NumInstances++;
		}
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:32,代码来源:ReconcilePostProcessingProcessor.cs

示例12: UpdateInstanceCommand

		public UpdateInstanceCommand(ServerPartition partition,
								  StudyStorageLocation studyLocation,
								  DicomFile file)
			: base("Update existing SOP Instance")
		{
			_partition = partition;
			_studyLocation = studyLocation;
			_file = file;
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:9,代码来源:UpdateInstanceCommand.cs

示例13: ConvertToDicomFile

        /// <summary>
        /// Converts a <see cref="DicomMessage"/> instance into a <see cref="DicomFile"/>.
        /// </summary>
        /// <remarks>This routine sets the Source AE title, </remarks>
        /// <param name="message"></param>
        /// <param name="filename"></param>
        /// <param name="assocParms"></param>
        /// <returns></returns>
        protected static DicomFile ConvertToDicomFile(DicomMessage message, string filename, AssociationParameters assocParms)
        {
            // This routine sets some of the group 0x0002 elements.
            DicomFile file = new DicomFile(message, filename);

            file.SourceApplicationEntityTitle = assocParms.CallingAE;
            file.TransferSyntax = message.TransferSyntax;
            return file;
        }
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:17,代码来源:StorageScp.cs

示例14: InsertInstanceCommand

		public InsertInstanceCommand(DicomFile file, StudyStorageLocation location)
			: base("Insert Instance into Database")
		{
			Platform.CheckForNullReference(file, "Dicom File object");
			Platform.CheckForNullReference(location, "Study Storage Location");

			_file = file;
			_storageLocation = location;
		}
开发者ID:nhannd,项目名称:Xian,代码行数:9,代码来源:InsertInstanceCommand.cs

示例15: CreateSopDataSource

		private static ISopDataSource CreateSopDataSource()
		{
			var uid = DicomUid.GenerateUid().UID;
			var dcf = new DicomFile();
			dcf.MediaStorageSopInstanceUid = uid;
			dcf.MediaStorageSopClassUid = DicomUids.SecondaryCaptureImageStorage.UID;
			dcf.DataSet[DicomTags.SopInstanceUid].SetStringValue(uid);
			dcf.DataSet[DicomTags.SopClassUid].SetStringValue(DicomUids.SecondaryCaptureImageStorage.UID);
			return new TestDataSource(dcf);
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:10,代码来源:MockImageSop.cs


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