SimpleITK  1.2.4
Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
itk::simple::ImageViewer Class Reference

Display an image in an external viewer (Fiji by default) More...

#include <sitkImageViewer.h>

+ Collaboration diagram for itk::simple::ImageViewer:

Public Member Functions

void Execute (const Image &image)
 Launch the viewing application to display the given image. More...
 
const std::string & GetApplication () const
 Get the full path to the viewing application used in the command string. More...
 
const std::string & GetCommand () const
 
virtual std::string GetName () const
 
 ImageViewer ()
 
void SetApplication (const std::string &app, const std::string &command="%a %f")
 Set the full path to the viewing application used in the command string. More...
 
void SetCommand (const std::string &command)
 Set the command string used to launch the viewing application. More...
 
std::string ToString () const
 Print ourself out to a string. More...
 
void SetFileExtension (const std::string &ext)
 Set/Get file extension of the temporary image file (default='.nii') More...
 
const std::string & GetFileExtension () const
 Set/Get file extension of the temporary image file (default='.nii') More...
 
void SetTitle (const std::string &t)
 Set/Get Title string on the ImageJ window. More...
 
const std::string & GetTitle () const
 Set/Get Title string on the ImageJ window. More...
 

Static Public Member Functions

static void SetGlobalDefaultSearchPath (const std::vector< std::string > &path)
 Set/Get the search path used to find the viewing application. More...
 
static const std::vector< std::string > & GetGlobalDefaultSearchPath ()
 Set/Get the search path used to find the viewing application. More...
 
static void SetGlobalDefaultExecutableNames (const std::vector< std::string > &names)
 Set/Get name list used to find the viewing application. More...
 
static const std::vector< std::string > & GetGlobalDefaultExecutableNames ()
 Set/Get name list used to find the viewing application. More...
 
static void SetGlobalDefaultFileExtension (const std::string &ext)
 Set/Get the default file extension. More...
 
static const std::string & GetGlobalDefaultFileExtension ()
 Set/Get the default file extension. More...
 
static void SetGlobalDefaultApplication (const std::string &app)
 Set/Get the default application used in the command string. More...
 
static const std::string & GetGlobalDefaultApplication ()
 Set/Get the default application used in the command string. More...
 
static void SetGlobalDefaultDebug (const bool dbg)
 Set/Get Debug flag. More...
 
static bool GetGlobalDefaultDebug ()
 Set/Get Debug flag. More...
 
static void SetGlobalDefaultDebugOn ()
 Set/Get Debug flag. More...
 
static void SetGlobalDefaultDebugOff ()
 Set/Get Debug flag. More...
 
static void SetProcessDelay (const unsigned int delay)
 Set/Get Process delay, the wait time after launching the viewing application. More...
 
static unsigned int GetProcessDelay ()
 Set/Get Process delay, the wait time after launching the viewing application. More...
 

Static Private Member Functions

static std::string FindViewingApplication ()
 
static void initializeDefaults ()
 

Private Attributes

std::string m_Application
 
std::string m_CustomCommand
 
std::string m_FileExtension
 
std::string m_Title
 
std::string m_ViewCommand
 

Static Private Attributes

static bool m_GlobalAreDefaultsInitialized
 
static std::string m_GlobalDefaultApplication
 
static bool m_GlobalDefaultDebug
 
static std::vector< std::string > m_GlobalDefaultExecutableNames
 
static std::string m_GlobalDefaultFileExtension
 
static std::vector< std::string > m_GlobalDefaultSearchPath
 
static std::string m_GlobalDefaultViewCommand
 
static unsigned int m_GlobalProcessDelay
 
static int m_GlobalViewerImageCount
 

Detailed Description

Display an image in an external viewer (Fiji by default)

The ImageViewer class displays an image with an external image display application. By default the class will search for a Fiji ( https://fiji.sc ) executable. The image is written out to a temporary file and then passed to the application.

When SimpleITK is first invoked the following environment variables are queried to set up the external viewer:

SITK_SHOW_EXTENSION: file format extension of the temporary image file. The default is '.mha', the MetaIO file format.

SITK_SHOW_COMMAND: The user can specify an application other than Fiji to view images.

These environment variables are only checked at SimpleITK's launch.

Definition at line 50 of file sitkImageViewer.h.

Constructor & Destructor Documentation

itk::simple::ImageViewer::ImageViewer ( )

Member Function Documentation

void itk::simple::ImageViewer::Execute ( const Image image)

Launch the viewing application to display the given image.

static std::string itk::simple::ImageViewer::FindViewingApplication ( )
staticprivate
const std::string& itk::simple::ImageViewer::GetApplication ( ) const

Get the full path to the viewing application used in the command string.

const std::string& itk::simple::ImageViewer::GetCommand ( ) const
const std::string& itk::simple::ImageViewer::GetFileExtension ( ) const

Set/Get file extension of the temporary image file (default='.nii')

If the viewing application is Fiji, the default image format is MetaIO, '.mha'.

If the viewing application is ImageJ, the default image format is NifTi, '.nii'. This is because by default ImageJ does not come with the MetaIO plugin.

static const std::string& itk::simple::ImageViewer::GetGlobalDefaultApplication ( )
static

Set/Get the default application used in the command string.

static bool itk::simple::ImageViewer::GetGlobalDefaultDebug ( )
static

Set/Get Debug flag.

Turning on/off the Debug flag produces output showing the command string used to launch the viewing application.

static const std::vector<std::string>& itk::simple::ImageViewer::GetGlobalDefaultExecutableNames ( )
static

Set/Get name list used to find the viewing application.

static const std::string& itk::simple::ImageViewer::GetGlobalDefaultFileExtension ( )
static

Set/Get the default file extension.

The file extension determines the image file type used when writing out the temporary image file.

static const std::vector<std::string>& itk::simple::ImageViewer::GetGlobalDefaultSearchPath ( )
static

Set/Get the search path used to find the viewing application.

virtual std::string itk::simple::ImageViewer::GetName ( ) const
inlinevirtual

Return the user readable name of the class

Definition at line 57 of file sitkImageViewer.h.

static unsigned int itk::simple::ImageViewer::GetProcessDelay ( )
static

Set/Get Process delay, the wait time after launching the viewing application.

On Windows the delay is in seconds, default=1sec. On Mac/Linux the delay is in milli-seconds, default=500ms.

const std::string& itk::simple::ImageViewer::GetTitle ( ) const

Set/Get Title string on the ImageJ window.

static void itk::simple::ImageViewer::initializeDefaults ( )
staticprivate
void itk::simple::ImageViewer::SetApplication ( const std::string &  app,
const std::string &  command = "%a %f" 
)

Set the full path to the viewing application used in the command string.

The SetApplication method expects a full path name.

Using this method overrides the default application search.

By default, when this method is called, the command string is set to "%a %f" which simply means the application path followed by the temporary image file.

void itk::simple::ImageViewer::SetCommand ( const std::string &  command)

Set the command string used to launch the viewing application.

This command string may include the following tokens:

  • 'a' for the image viewing application (Fiji by default)
  • 'f' for SimpleITK's temporary image file

For example, the default command string on Linux systems is:

%a -o %f

After token substitution it may become:

/opt/Fiji.app/ImageJ-linux64 -o /tmp/Temp-65535-0.mha

For another example, the default command string on Mac OS X is:

open -a %a -n --args -eval \'open(\"%f\"); rename(\"%t\"); \'

After token substitution the string may become:

open -a /Applications/Fiji.app -n --args -eval 'open("/tmp/TempFile-29696-0.mha"); rename("/tmp/TempFile-29696-0.mha");'

The string after '-eval' is an ImageJ macro the opens the file and sets the title of the window.

If the 'f' token is not found in the command string, the temporary file name is automatically appended to the command argument list.

Note: Using the ImageViewer::SetCommand method overrides the default command and/or the SITK_SHOW_COMMAND environment variable.

void itk::simple::ImageViewer::SetFileExtension ( const std::string &  ext)

Set/Get file extension of the temporary image file (default='.nii')

If the viewing application is Fiji, the default image format is MetaIO, '.mha'.

If the viewing application is ImageJ, the default image format is NifTi, '.nii'. This is because by default ImageJ does not come with the MetaIO plugin.

static void itk::simple::ImageViewer::SetGlobalDefaultApplication ( const std::string &  app)
static

Set/Get the default application used in the command string.

static void itk::simple::ImageViewer::SetGlobalDefaultDebug ( const bool  dbg)
static

Set/Get Debug flag.

Turning on/off the Debug flag produces output showing the command string used to launch the viewing application.

static void itk::simple::ImageViewer::SetGlobalDefaultDebugOff ( )
static

Set/Get Debug flag.

Turning on/off the Debug flag produces output showing the command string used to launch the viewing application.

static void itk::simple::ImageViewer::SetGlobalDefaultDebugOn ( )
static

Set/Get Debug flag.

Turning on/off the Debug flag produces output showing the command string used to launch the viewing application.

static void itk::simple::ImageViewer::SetGlobalDefaultExecutableNames ( const std::vector< std::string > &  names)
static

Set/Get name list used to find the viewing application.

static void itk::simple::ImageViewer::SetGlobalDefaultFileExtension ( const std::string &  ext)
static

Set/Get the default file extension.

The file extension determines the image file type used when writing out the temporary image file.

static void itk::simple::ImageViewer::SetGlobalDefaultSearchPath ( const std::vector< std::string > &  path)
static

Set/Get the search path used to find the viewing application.

static void itk::simple::ImageViewer::SetProcessDelay ( const unsigned int  delay)
static

Set/Get Process delay, the wait time after launching the viewing application.

On Windows the delay is in seconds, default=1sec. On Mac/Linux the delay is in milli-seconds, default=500ms.

void itk::simple::ImageViewer::SetTitle ( const std::string &  t)

Set/Get Title string on the ImageJ window.

std::string itk::simple::ImageViewer::ToString ( ) const

Print ourself out to a string.

Member Data Documentation

std::string itk::simple::ImageViewer::m_Application
private

Definition at line 221 of file sitkImageViewer.h.

std::string itk::simple::ImageViewer::m_CustomCommand
private

Definition at line 219 of file sitkImageViewer.h.

std::string itk::simple::ImageViewer::m_FileExtension
private

Definition at line 223 of file sitkImageViewer.h.

bool itk::simple::ImageViewer::m_GlobalAreDefaultsInitialized
staticprivate

Definition at line 204 of file sitkImageViewer.h.

std::string itk::simple::ImageViewer::m_GlobalDefaultApplication
staticprivate

Definition at line 213 of file sitkImageViewer.h.

bool itk::simple::ImageViewer::m_GlobalDefaultDebug
staticprivate

Definition at line 216 of file sitkImageViewer.h.

std::vector<std::string> itk::simple::ImageViewer::m_GlobalDefaultExecutableNames
staticprivate

Definition at line 208 of file sitkImageViewer.h.

std::string itk::simple::ImageViewer::m_GlobalDefaultFileExtension
staticprivate

Definition at line 212 of file sitkImageViewer.h.

std::vector<std::string> itk::simple::ImageViewer::m_GlobalDefaultSearchPath
staticprivate

Definition at line 207 of file sitkImageViewer.h.

std::string itk::simple::ImageViewer::m_GlobalDefaultViewCommand
staticprivate

Definition at line 211 of file sitkImageViewer.h.

unsigned int itk::simple::ImageViewer::m_GlobalProcessDelay
staticprivate

Definition at line 209 of file sitkImageViewer.h.

int itk::simple::ImageViewer::m_GlobalViewerImageCount
staticprivate

Definition at line 203 of file sitkImageViewer.h.

std::string itk::simple::ImageViewer::m_Title
private

Definition at line 225 of file sitkImageViewer.h.

std::string itk::simple::ImageViewer::m_ViewCommand
private

Definition at line 218 of file sitkImageViewer.h.


The documentation for this class was generated from the following file: