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


C# DicomFile.Load方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: ImageStreamingContext

        public ImageStreamingContext(HttpListenerContext context)
        {
            Request = context.Request;
            Response = context.Response;
            NameValueCollection query = Request.QueryString;

            #region INIT STUFF FOR PERFORMANCE TESTING
            #if DEBUG 

            if (query["testcompressed"] != null)
            {
                testCompressed= true;
            }
            else if (query["testuncompressed"] != null)
            {
                testUncompressed = true;
            }
            if (_testCompressedImage == null)
            {
                using (Stream stream = typeof(ImageStreamingContext).Assembly.GetManifestResourceStream("ClearCanvas.ImageServer.Services.Streaming.ImageStreaming.Test.TestSamples.compressed.dcm"))
                {
                    DicomFile file = new DicomFile();
                    file.Load(stream);

                    _testCompressedImage = DicomPixelData.CreateFrom(file);
                }
                
            }

            if (_testUncompressedImage == null)
            {
                using (Stream stream = typeof(ImageStreamingContext).Assembly.GetManifestResourceStream("ClearCanvas.ImageServer.Services.Streaming.ImageStreaming.Test.TestSamples.uncompressed.dcm"))
                {
                    DicomFile file = new DicomFile();
                    file.Load(stream);

                    _testUncompressedImage = DicomPixelData.CreateFrom(file);
                }
                
            }
            #endif

            #endregion

            _frameNumber = 0;
            if (query["FrameNumber"] != null)
                int.TryParse(query["FrameNumber"], out _frameNumber);

            _nextSeriesUid = query["nextSeriesUid"];
            _nextSopUid = query["nextObjectUid"];

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

示例5: ButtonLoadFile_Click

        private void ButtonLoadFile_Click(object sender, EventArgs e)
        {
            openFileDialog.DefaultExt = "dcm";
            openFileDialog.ShowDialog();

            DicomFile dicomFile = new DicomFile(openFileDialog.FileName);

            DicomReadOptions options = new DicomReadOptions();

            dicomFile.Load(options);
            


            _theStream.AddFile(dicomFile);

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

示例6: ImportSop

        public ImportSopResponse ImportSop(ImportSopRequest request)
        {
            try
            {
                var theFile = new DicomFile(string.Format("{0}{1}", request.SopInstanceUid, ServerPlatform.DicomFileExtension));

                using (var stream = new LargeMemoryStream(request.SopInstance))
                {
                    theFile.Load(stream);
                }

                var partition = ServerPartitionMonitor.Instance.GetPartition(request.CalledAETitle);

                string aeTitle = theFile.SourceApplicationEntityTitle;

                if (_importerContext == null)
                    _importerContext = new SopInstanceImporterContext(
                        String.Format("{0}_{1}", aeTitle, DateTime.Now.ToString("yyyyMMddhhmmss")),
                        partition.AeTitle, partition);

                var utility = new SopInstanceImporter(_importerContext);


                var importResult = utility.Import(theFile);
                if (!importResult.Successful)
                    Platform.Log(LogLevel.Error, "Failure importing file file from Web Service: {0}, SOP Instance UID: {1}", importResult.ErrorMessage, request.SopInstanceUid);
                else
                    Platform.Log(LogLevel.Info, "Processed import for SOP through Web Service: {0}.", request.SopInstanceUid);

                var result = new ImportSopResponse
                    {
                        DicomStatusCode = importResult.DicomStatus.Code,
                        FailureMessage = importResult.ErrorMessage,
                        Successful = importResult.Successful
                    };

                return result;
            }
            catch (Exception ex)
            {
                var message = string.Format("Failed to import files: {0}, SOP Instance UID: {1}", ex.Message, request.SopInstanceUid);
                Platform.Log(LogLevel.Error, message);
                throw new FaultException(message);
            }
        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:45,代码来源:DicomImportService.cs

示例7: Process

        public MimeTypeProcessorOutput Process(ImageStreamingContext context)
        {
            var output = new MimeTypeProcessorOutput
                             {
                                 ContentType = OutputMimeType
                             };

            var file = new DicomFile(context.ImagePath);
            file.Load(DicomReadOptions.StorePixelDataReferences);

            if (!file.SopClass.Equals(SopClass.EncapsulatedPdfStorage))
                throw new WADOException(HttpStatusCode.NotImplemented, "image/pdf is not supported for this type of object: " + file.SopClass.Name);

            var iod = new EncapsulatedDocumentModuleIod(file.DataSet);

            output.Output = iod.EncapsulatedDocument;
            return output;            
        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:18,代码来源:PdfMimeType.cs

示例8: LoadDicomFile

		public DicomFile LoadDicomFile(LoadDicomFileArgs args)
		{
			try
			{
				var client = new StreamingClient(_wadoUri);
				var file = new DicomFile();
				using (var stream = client.RetrieveImageHeader(_aeTitle, args.StudyInstanceUid, args.SeriesInstanceUid, args.SopInstanceUid))
				{
					file.Load(stream);
				}

				return file;
			}
			catch (Exception e)
			{
				throw TranslateStreamingException(e);
			}
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:18,代码来源:ImageServerWadoLoader.cs

示例9: buttonDecompress_Click

        private void buttonDecompress_Click(object sender, EventArgs e)
        {
            if (this.textBoxSourceFile.Text.Length == 0 || this.textBoxDestinationFile.Text.Length == 0)
            {
                MessageBox.Show("Invalid source or destination filename");
                return;
            }

            DicomFile dicomFile = new DicomFile(textBoxSourceFile.Text);

            dicomFile.Load();

            dicomFile.Filename = textBoxDestinationFile.Text;

            dicomFile.ChangeTransferSyntax(TransferSyntax.ExplicitVrLittleEndian);

            dicomFile.Save();
        }
开发者ID:nhannd,项目名称:Xian,代码行数:18,代码来源:TestCompressionForm.cs

示例10: LoadDicomFile

		public DicomFile LoadDicomFile(LoadDicomFileArgs args)
		{
			try
			{
				Uri uri = new Uri(string.Format(StreamingSettings.Default.FormatWadoUriPrefix, _hostName, _wadoServicePort));
				var client = new StreamingClient(uri);
				var file = new DicomFile();
				using (var stream = client.RetrieveImageHeader(_aeTitle, args.StudyInstanceUid, args.SeriesInstanceUid, args.SopInstanceUid))
				{
					file.Load(stream);
				}

				return file;
			}
			catch (Exception e)
			{
				throw TranslateStreamingException(e);
			}
		}
开发者ID:jfphilbin,项目名称:ClearCanvas,代码行数:19,代码来源:ImageServerWadoLoader.cs

示例11: Process

		public MimeTypeProcessorOutput Process(ImageStreamingContext context)
		{
			uint stopTag;
			if (!uint.TryParse(context.Request.QueryString["stopTag"] ?? "", NumberStyles.HexNumber, null, out stopTag))
				stopTag = DicomTags.PixelData;

			if (stopTag > DicomTags.PixelData)
				throw new WADOException(HttpStatusCode.BadRequest,
										"Stop tag must be less than PixelData tag.");

			MimeTypeProcessorOutput output = new MimeTypeProcessorOutput();
			output.ContentType = OutputMimeType;
			DicomFile file = new DicomFile(context.ImagePath);
			file.Load(stopTag, DicomReadOptions.Default);

			output.ContentType = OutputMimeType;

			MemoryStream memStream = new MemoryStream();
			file.Save(memStream, DicomWriteOptions.Default);
			output.Output = memStream.ToArray();

			return output;
		}
开发者ID:nhannd,项目名称:Xian,代码行数:23,代码来源:ImageHeaderMimeType.cs

示例12: Main

        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintCommandLine();
                return;
            }

            if (false == ParseArgs(args))
                return;

            foreach (String filename in args)
            {
                if (filename.StartsWith("-"))
                    continue;

                DicomFile file = new DicomFile(filename);

                DicomReadOptions readOptions = DicomReadOptions.Default;

				try
				{
					file.Load(readOptions);
				}
				catch (Exception e)
				{
					Console.WriteLine("Unexpected exception when loading file: {0}", e.Message);
				}

                StringBuilder sb = new StringBuilder();

                file.Dump(sb, "", _options);

                Console.WriteLine(sb.ToString());
            }
        }
开发者ID:nhannd,项目名称:Xian,代码行数:36,代码来源:DicomDump.cs

示例13: AddFileToSend

        public bool AddFileToSend(String file)
        {

            try
            {
                DicomFile dicomFile = new DicomFile(file);

                // Only load to sopy instance uid to reduce amount of data read from file
                dicomFile.Load(DicomTags.SopInstanceUid, DicomReadOptions.Default | DicomReadOptions.DoNotStorePixelDataInDataSet);

                FileToSend fileStruct = new FileToSend();

                fileStruct.filename = file;
                string sopClassInFile = dicomFile.DataSet[DicomTags.SopClassUid].ToString();
                if (sopClassInFile.Length == 0)
                    return false;

                if (!sopClassInFile.Equals(dicomFile.SopClass.Uid))
                {
                    Logger.LogError("SOP Class in Meta Info does not match SOP Class in DataSet");
                    fileStruct.sopClass = SopClass.GetSopClass(sopClassInFile);
                }
                else
                    fileStruct.sopClass = dicomFile.SopClass;

                fileStruct.transferSyntax = dicomFile.TransferSyntax;

                _fileList.Add(fileStruct);
            }
            catch (DicomException e)
            {
                Logger.LogErrorException(e, "Unexpected exception when loading file for sending: {0}", file);
                return false;
            }
            return true;
        }
开发者ID:khaha2210,项目名称:radio,代码行数:36,代码来源:StorageScu.cs

示例14: ProcessUidList

		private void ProcessUidList()
		{
			int counter = 0;
			Platform.Log(LogLevel.Info, "Populating new images into study folder.. {0} to go", Context.WorkQueueUidList.Count);

			StudyProcessorContext context = new StudyProcessorContext(_destinationStudyStorage);

			// Load the rules engine
			context.SopProcessedRulesEngine = new ServerRulesEngine(ServerRuleApplyTimeEnum.SopProcessed, Context.WorkQueueItem.ServerPartitionKey);
			context.SopProcessedRulesEngine.AddOmittedType(ServerRuleTypeEnum.SopCompress);
			context.SopProcessedRulesEngine.Load();

			// Load the Study XML File
			StudyXml xml = LoadStudyXml(_destinationStudyStorage);

		    string lastErrorMessage="";

		    foreach (WorkQueueUid uid in Context.WorkQueueUidList)
			{
				string imagePath = GetReconcileUidPath(uid);
				DicomFile file = new DicomFile(imagePath);
			
				try
				{
					file.Load();
					
					string groupID = ServerHelper.GetUidGroup(file, _destinationStudyStorage.ServerPartition, Context.WorkQueueItem.InsertTime);

				    SopInstanceProcessor sopProcessor = new SopInstanceProcessor(context);
                    ProcessingResult result = sopProcessor.ProcessFile(groupID, file, xml, false, true, uid, GetReconcileUidPath(uid));
					if (result.Status != ProcessingStatus.Success)
					{
						throw new ApplicationException(String.Format("Unable to reconcile image {0}", file.Filename));
					}

					counter++;
			
					Platform.Log(ServerPlatform.InstanceLogLevel, "Reconciled SOP {0} [{1} of {2}]",
					             uid.SopInstanceUid, counter, Context.WorkQueueUidList.Count);
				}
				catch (Exception e)
				{
					Platform.Log(LogLevel.Error, e, "Error occurred when processing uid {0}", uid.SopInstanceUid);

                    if (e is InstanceAlreadyExistsException
                        || e.InnerException != null && e.InnerException is InstanceAlreadyExistsException)
                    {
                        DuplicateSopProcessorHelper.CreateDuplicateSIQEntry(file, _destinationStudyStorage, GetReconcileUidPath(uid),
                                                                           Context.WorkQueueItem, uid);
                    }
                    else
                    {
                        lastErrorMessage = e.Message;
                        SopInstanceProcessor.FailUid(uid, true);
                    }
				}
			}

            
            if (counter == 0)
            {
                throw new ApplicationException(lastErrorMessage);
            }
		}
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:64,代码来源:ProcessAsIsCommand.cs

示例15: ReprocessFilesystem

	    /// <summary>
        /// Reprocess a file systems
        /// </summary>
        /// <param name="filesystem"></param>
        private void ReprocessFilesystem(Filesystem filesystem)
        {
            var filesystemDir = new DirectoryInfo(filesystem.FilesystemPath);

            foreach (DirectoryInfo partitionDir in filesystemDir.GetDirectories())
            {
                ServerPartition partition;
                if (GetServerPartition(partitionDir.Name, out partition) == false)
                {
					if (!partitionDir.Name.EndsWith("_Incoming") && !partitionDir.Name.Equals("temp")
					 && !partitionDir.Name.Equals("ApplicationLog") && !partitionDir.Name.Equals("AlertLog"))
	                    Platform.Log(LogLevel.Error, "Unknown partition folder '{0}' in filesystem: {1}", partitionDir.Name,
                                 filesystem.Description);
                    continue;
                }

                // Since we found a partition, we should find a rules engine too.
                ServerRulesEngine engine = _engines[partition];
            	ServerRulesEngine postArchivalEngine = _postArchivalEngines[partition];
                ServerRulesEngine dataAccessEngine = _dataAccessEngine[partition];

				foreach (DirectoryInfo dateDir in partitionDir.GetDirectories())
				{
					if (dateDir.FullName.EndsWith("Deleted")
						|| dateDir.FullName.EndsWith(ServerPlatform.ReconcileStorageFolder))
						continue;

					foreach (DirectoryInfo studyDir in dateDir.GetDirectories())
					{
						String studyInstanceUid = studyDir.Name;
						try
						{
							StudyStorageLocation location = LoadReadableStorageLocation(partition.GetKey(), studyInstanceUid);
							if (location == null)
							{
								foreach (DirectoryInfo seriesDir in studyDir.GetDirectories())
								{
									FileInfo[] sopInstanceFiles = seriesDir.GetFiles("*.dcm");

									DicomFile file = null;
									foreach (FileInfo sopFile in sopInstanceFiles)
									{
										if (!sopFile.FullName.EndsWith(ServerPlatform.DicomFileExtension))
											continue;

										try
										{
											file = new DicomFile(sopFile.FullName);
                                            file.Load(DicomTags.StudyId, DicomReadOptions.DoNotStorePixelDataInDataSet | DicomReadOptions.Default);
											break;
										}
										catch (Exception e)
										{
											Platform.Log(LogLevel.Warn, e, "Unexpected failure loading file: {0}.  Continuing to next file.",
											             sopFile.FullName);
											file = null;
										}
									}
									if (file != null)
									{
										studyInstanceUid = file.DataSet[DicomTags.StudyInstanceUid].ToString();
										break;
									}
								}

								location = LoadReadableStorageLocation(partition.GetKey(), studyInstanceUid);
								if (location == null)
									continue;
							}

                            ProcessStudy(partition, location, engine, postArchivalEngine, dataAccessEngine);
							_stats.NumStudies++;

							if (CancelPending) return;
						}
						catch (Exception e)
						{
							Platform.Log(LogLevel.Error, e,
							             "Unexpected error while processing study: {0} on partition {1}.", studyInstanceUid,
							             partition.Description);
						}
					}

					// Cleanup the directory, if its empty.
					DirectoryUtility.DeleteIfEmpty(dateDir.FullName);
				}
            }
        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:92,代码来源:FilesystemStudyProcessItemProcessor.cs


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