SimpleITK  
Public Member Functions | 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:

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 executable. The image is written out to a temporary file and then passed to the application.

When the first ImageViewer object is constructed 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.

The environment variables are not checked for subsequent ImageViewer objects.

Definition at line 51 of file sitkImageViewer.h.

Public Member Functions

void Execute (const Image &image)
 Launch the viewing application to display the given image. More...
 
const PathTypeGetApplication () 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 PathType &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< PathType > &path)
 Set/Get the search path used to find the viewing application. More...
 
static const std::vector< PathType > & GetGlobalDefaultSearchPath ()
 Set/Get the search path used to find the viewing application. More...
 
static void SetGlobalDefaultExecutableNames (const std::vector< PathType > &names)
 Set/Get name list used to find the viewing application. More...
 
static const std::vector< PathType > & 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 PathType &app)
 Set/Get the default application used in the command string. More...
 
static const PathTypeGetGlobalDefaultApplication ()
 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...
 

Private Attributes

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

Constructor & Destructor Documentation

◆ ImageViewer()

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

Member Function Documentation

◆ Execute()

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

Launch the viewing application to display the given image.

◆ GetApplication()

const PathType& itk::simple::ImageViewer::GetApplication ( ) const

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

◆ GetCommand()

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

◆ GetFileExtension()

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.

◆ GetGlobalDefaultApplication()

static const PathType& itk::simple::ImageViewer::GetGlobalDefaultApplication ( )
static

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

◆ GetGlobalDefaultDebug()

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.

◆ GetGlobalDefaultExecutableNames()

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

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

◆ GetGlobalDefaultFileExtension()

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.

◆ GetGlobalDefaultSearchPath()

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

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

◆ GetName()

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

Return the user readable name of the class

Definition at line 59 of file sitkImageViewer.h.

◆ GetProcessDelay()

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.

◆ GetTitle()

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

Set/Get Title string on the ImageJ window.

◆ SetApplication()

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

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

The SetApplication method expects the app parameter to be a full path name to the display application's executable. For instance, on Windows when using Fiji, one would use the full path to the ImageJ-win64.exe such as:

'C:\Users\dave\Fiji.app\ImageJ-win64.exe'

On Linux, app would be set to something like:

'/home/dave/bin/Fiji.app/ImageJ-linux64'

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.

◆ SetCommand()

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.

◆ SetFileExtension()

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.

◆ SetGlobalDefaultApplication()

static void itk::simple::ImageViewer::SetGlobalDefaultApplication ( const PathType app)
static

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

◆ SetGlobalDefaultDebug()

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.

◆ SetGlobalDefaultDebugOff()

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.

◆ SetGlobalDefaultDebugOn()

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.

◆ SetGlobalDefaultExecutableNames()

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

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

◆ SetGlobalDefaultFileExtension()

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.

◆ SetGlobalDefaultSearchPath()

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

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

◆ SetProcessDelay()

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.

◆ SetTitle()

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

Set/Get Title string on the ImageJ window.

◆ ToString()

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

Print ourself out to a string.

Member Data Documentation

◆ m_Application

PathType itk::simple::ImageViewer::m_Application
private

Definition at line 242 of file sitkImageViewer.h.

◆ m_CustomCommand

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

Definition at line 240 of file sitkImageViewer.h.

◆ m_FileExtension

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

Definition at line 244 of file sitkImageViewer.h.

◆ m_Title

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

Definition at line 246 of file sitkImageViewer.h.

◆ m_ViewCommand

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

Definition at line 239 of file sitkImageViewer.h.


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