Navigation:  I Want To... > Basics >

Load DICOM images from disk

Previous pageReturn to chapter overviewNext page

Use Case

You want to load DICOM images from disk into an ImageViewerComponent

Relevant Architecture

Physical and Logical Workspaces
Opening a study

Relevant Types

OpenStudyHelper

Sample Code

using System;

using ClearCanvas.Common;

using ClearCanvas.Desktop;

using ClearCanvas.Desktop.Actions;

using ClearCanvas.ImageViewer;

using ClearCanvas.ImageViewer.BaseTools;

using ClearCanvas.ImageViewer.Configuration;

using ClearCanvas.ImageViewer.StudyManagement;

 

// ... (other using namespace statements here)

 

namespace MyPlugin.Basics

{

   [ButtonAction("open""global-toolbars/ToolbarStandard/OpenFiles""Open")]

   [IconSet("open", IconScheme.Colour, "Icons.MyToolSmall.png""Icons.MyToolMedium.png""Icons.MyToolLarge.png")]

   // ... (other action attributes here)

   [ExtensionOf(typeof (ImageViewerToolExtensionPoint))]

   public class LoadDicomFilesTool : ImageViewerTool

   {

      public void Open()

      {

         string[] filenames = new string[] {"C:\\File1.dcm""C:\\File2.dcm"};

 

         this.LoadStudy(filenames);

      }

 

      public void LoadStudy(string[] filenames)

      {

         try

         {

            OpenStudyHelper.OpenFiles(filenames, ViewerLaunchSettings.WindowBehaviour);

         }

         catch (Exception e)

         {

            ExceptionHandler.Report(e, this.Context.DesktopWindow);

         }

      }

   }

}

Remarks

If you are using ClearCanvas Workstation in its default configuration, it's unlikely you will ever have to load images in this way, since all the image loading facilities are already provided for you by the application.  However, if you're creating a new application with the Framework and need to have control over the loading of images, this maybe what you need.

Loading images in this way is slow, as it needs to load and parse each DICOM file.  The amount of time required to load n images is O(n), i.e., linear with the number of images.  Also, images loaded in this way will not show up in My Studies; it is the equivalent of loading images through the My Computer tab of the Explorer.  If you want to load images in such a way that it takes advantage of CC's local database, use the IImageViewer.LoadStudy() methods instead.

Examples in Code Base

ClearCanvas.ImageViewer.Explorer.Local.DicomImageLoaderTool