VolViewer Scripting in more detail: Difference between revisions

From BanghamLab
Jump to navigation Jump to search
No edit summary
No edit summary
Line 29: Line 29:
2) '''Launch VolViewer''' from Matlab
2) '''Launch VolViewer''' from Matlab
*Assuming temporary data files on paths are to be saved in PathToVolViewer
*Assuming temporary data files on paths are to be saved in PathToVolViewer
   VOL=VolViewer(1,'C:\VolViewer_x64','C:\VolViewer_x64')
   VO=VolViewer(1,'D:\VolViewer_x64','D:\VolViewer_x64')
creates a VolViewer object - which, because there is no semicolon at the end, is displayed as:
creates a VolViewer object - which, because there is no semicolon at the end, is displayed as:
           PathToVolViewer: C:\VolViewer_x64,
           PathToVolViewer: D:\VolViewer_x64  
           PathToWatchFile: C:\VolViewer_x64,
           PathToWatchFile: D:\VolViewer_x64  
           WatchFileNumber:    1.00000,
           WatchFileNumber:    1.00000  
                PathToMSR:  
        PathToImageStack:  
            PathToImages:  
          imageFilenames:  
                ImageList:  
              msrFilename:
                 Commands:
              tfnFilename:
              slcFilename:
              vvrFilename:
              objFilename:  
                 Commands:  
Notice that the paths have been filled in and that this is the first copy of VolViewer (WatchFileNumber is 1).<br>
Notice that the paths have been filled in and that this is the first copy of VolViewer (WatchFileNumber is 1).<br>
3) '''Display an image''' stack in VolViewer
3) '''Display an image''' stack in VolViewer
*The key step is to notify VolViewer where to find the images by putting a command into WatchFile1.txt. This is done automatically with the following
*The key step is to notify VolViewer where to find the images by putting a command into WatchFile1.txt. This is done automatically with the following
VOL=imshowVOL('VolViewerObject',VOL, 'PathToImages','S:\MyDocuments\1554')
  VO=imshowVOL('VolViewerObject',VO, 'PathToImageStack','D:\Shape_T1_only\Image_data\11to14DFS\1554')
In this case the image stack is in the directory 'S:\MyDocuments\1554'. Notice, that VOL has been updated
In this case the image stack is in the directory 'D:\Shape_T1_only\Image_data\11to14DFS\1554'. Notice, that VOL has been updated
  >> VOL
  >> VOL
           PathToVolViewer: C:\VolViewer_x64,
           PathToVolViewer: D:\VolViewer_x64  
           PathToWatchFile: C:\VolViewer_x64,
           PathToWatchFile: D:\VolViewer_x64  
           WatchFileNumber:    1.00000,
           WatchFileNumber:    1.00000  
                PathToMSR:  
        PathToImageStack: D:\Shape_T1_only\Image_data\11to14DFS\1554  
            PathToImages: S:\MyDocuments\1554,
          imageFilenames:
                ImageList:  
              msrFilename:
                 Commands:
              tfnFilename:
              slcFilename:
              vvrFilename:
              objFilename:  
                 Commands:  
4) '''Display an MSR''' (results) file
4) '''Display an MSR''' (results) file
*Put the command into WatchFile1.txt using
*Put the command into WatchFile1.txt using

Revision as of 17:52, 29 February 2012

Back to VolViewer overview

See also

MSR file specification MSR file specification (MSR stands for Measure.) MSR files describe 3D objects and are used to pass data between the 3D BanghamLab toolboxes: VolViewer, GFtbox and AAMToolbox.
VolViewerScriptsAPI The VolViewerScriptsAPI enables external applications, such as the AAMToolbox, to exploit VolViewer.

VolViewer scripting and accessing VolViewer from Matlab

VolViewer scripting

A script is a limited form of program - a list of commands. In this case the commands (http://dmbi.nbi.bbsrc.ac.uk/index.php/VolViewerScriptsAPI see VolViewerScriptsAPI]) cover most of the operations that you would usually do interactively. On Windows, VolViewer is an exe file that can either be
interactive, i.e. launched by clicking its icon or from the command prompt using the command

VolViewer.exe

or scripted. In which case the operations (commands) are stored in a script file. In which case VolViewer is launched with

VolViewer set_watchfile('file.txt')

where file.txt contains the commands. For example, if VolViewer is to be a viewing tool for an external program, e.g. a Matlab program, then the file.txt could contain

open_image_stack(0, 'E:\VOLUME DATA\ScanID1934_Leaf1\')

where ScanID1934_Leaf1 is a directory containing a stack of images. VolViewer will automatically load and display these images as soon as it finds that the watchfile has been updated.

Other examples

It is not practical to script VolViewer using these commands manually. It is better to use VolViewer as a tool that is controlled through a library of commands in, for example, Matlab. Or, when running VolViewer on the server side of a server/client session where the user is interacting with VolViewer through a client web page.

Matlab to Volviewer

The DArT_Toolbox contains a library of functions for using and controlling VolViewer from Matlab.

Accessing VolViewer from Matlab

1) Install VolViewer

  • For example, in 'C:\VolViewer_x64'. This is the PathToVolViewer.

2) Launch VolViewer from Matlab

  • Assuming temporary data files on paths are to be saved in PathToVolViewer
 VO=VolViewer(1,'D:\VolViewer_x64','D:\VolViewer_x64')

creates a VolViewer object - which, because there is no semicolon at the end, is displayed as:

         PathToVolViewer: D:\VolViewer_x64 
         PathToWatchFile: D:\VolViewer_x64 
         WatchFileNumber:    1.00000 
        PathToImageStack: 
          imageFilenames: 
             msrFilename: 
             tfnFilename: 
             slcFilename: 
             vvrFilename: 
             objFilename: 
                Commands: 

Notice that the paths have been filled in and that this is the first copy of VolViewer (WatchFileNumber is 1).
3) Display an image stack in VolViewer

  • The key step is to notify VolViewer where to find the images by putting a command into WatchFile1.txt. This is done automatically with the following
 VO=imshowVOL('VolViewerObject',VO, 'PathToImageStack','D:\Shape_T1_only\Image_data\11to14DFS\1554')

In this case the image stack is in the directory 'D:\Shape_T1_only\Image_data\11to14DFS\1554'. Notice, that VOL has been updated

>> VOL
         PathToVolViewer: D:\VolViewer_x64 
         PathToWatchFile: D:\VolViewer_x64 
         WatchFileNumber:    1.00000 
        PathToImageStack: D:\Shape_T1_only\Image_data\11to14DFS\1554 
          imageFilenames: 
             msrFilename: 
             tfnFilename: 
             slcFilename: 
             vvrFilename: 
             objFilename: 
                Commands: 

4) Display an MSR (results) file

  • Put the command into WatchFile1.txt using