Difference between revisions of "2017 Winter Project Week/Improve Matlab integration"

From NAMIC Wiki
Jump to: navigation, search
Line 28: Line 28:
 
|
 
|
 
<!-- Progress and Next steps bullet points (fill out at the end of project week) -->
 
<!-- Progress and Next steps bullet points (fill out at the end of project week) -->
 +
* Nothing implemented, just discussions made with Andras.
 +
* To be able to work with the Matlab environment & MatlabBridge within Slicer, you need to :
 +
** define variables as global in your code (matlab commander or matlab module)
 +
** open Matlab & Slicer without running the matab commander server from Slicer
 +
** run matlab commander server from Matlab
 +
** run your matlab code from slicer
 +
** stop matlab commander server on Matlab
 +
** call global on variables defined in Slicer within Matlab to see them appear in your workspace and be able to analyze it.
 +
* A way to automatize the above would be to:
 +
** run matab environement from Slicer
 +
** have a button in Slicer to Stop/Start the server in matlab environment
 +
** when the server is stopped, run `whos global` to get a list of variables and `global variablename` to display them in the workspace automatically
 +
* The given module was running some window interfaces with Matlab, which opens a new thread and therefore becomes out of scope from the slicer matlab server instance which would end without keeping an handle on variables defines later on. We would advise not to use Matlab GUI items and do Matlab modules within Slicer to be able to control every step of the way.
 
|}
 
|}
  

Revision as of 16:22, 13 January 2017

Home < 2017 Winter Project Week < Improve Matlab integration

Key Investigators

  • Alexis Girault (Kitware, Inc.)

Project Description

Objective Approach and Plan Progress and Next Steps
  • Allowing the access to Matlab variables that are defined in a Matlab module once that module terminates, as if that code was run in the Matlab command line environment.
  • Offer a more user-friendly interface to send matlab commands and display the results. Right now the way to do it is to go in MatlabCommander and to type the command in a LineEdit, after which the output result appears in another LineEdit. While it is functional, our end users have had difficulties handling it since the display isn't as nice as in a Matlab console.
  • Offer a way to visualize the Matlab workspace variables just like in the Matlab environment: there is currently no way in MatlabBridge to see the variables of the current instance.
  • Discuss with Andras to better understand the way MatlabBridge work, and showcase an example where we can not access the variables defined in a Matlab module once it has ended. This will lead to a work allowing to address the first objective.
  • Look into using a custom ctkConsole (like the python console) in order to mimic the console from the main Matlab environment, OR try to get the commandwindow command from Matlab to directly open up.
  • Retrieve workspace from the Matlab instance after each command sent (or matlab module run) and display the variables and their values in a table node, OR try to get the workspace command from Matlab to directly open up.
  • Nothing implemented, just discussions made with Andras.
  • To be able to work with the Matlab environment & MatlabBridge within Slicer, you need to :
    • define variables as global in your code (matlab commander or matlab module)
    • open Matlab & Slicer without running the matab commander server from Slicer
    • run matlab commander server from Matlab
    • run your matlab code from slicer
    • stop matlab commander server on Matlab
    • call global on variables defined in Slicer within Matlab to see them appear in your workspace and be able to analyze it.
  • A way to automatize the above would be to:
    • run matab environement from Slicer
    • have a button in Slicer to Stop/Start the server in matlab environment
    • when the server is stopped, run `whos global` to get a list of variables and `global variablename` to display them in the workspace automatically
  • The given module was running some window interfaces with Matlab, which opens a new thread and therefore becomes out of scope from the slicer matlab server instance which would end without keeping an handle on variables defines later on. We would advise not to use Matlab GUI items and do Matlab modules within Slicer to be able to control every step of the way.

Background and References