VSG Logo   Avizo Forum

Go Back   Avizo Forum > Resources

Resources Scripts, samples, demos,...

Reply
 
Thread Tools Display Modes
  #1  
Old 18th March 2008, 16:41
Daniel Lichau Daniel Lichau is offline
VSG Staff
 
Join Date: Mar 2008
Posts: 39
Default CalculusMatlab: exchanging arbitrary data with MATLAB

The Avizo module CalculusMatlab allows executing MATLAB scripts. Uniform fields can be connected as inputs. These are made available in the MATLAB workspace as script variables. Results are returned in the same data objects.

Here is a possible way to exchange arbitrary data between Avizo and MATLAB, involving some TCL script commands.

In this example, data are point coordinates from a landmark or vertex set "landmark.am":
  • Create an Arithmetic module via top menu Create/Data/Arithmetic, and press apply button, just to create a uniform field with float values ("Result")

  • You can use a 3 x N x 1 lattice to store N coordinates x,y,z. You could have defined lattice resolution in Arithmetic module. Otherwise use the TCL command "crop":
    Result crop 0 2 0 [landmark.am getNumPoints] 0 0
    (Usage: crop [-auto threshold | imin imax jmin jmax kmin kmax [value]])
  • Retrieve point coordinates and store them in lattice data:
    for {set pointIndex 0 } { $pointIndex < [landmarks.am getNumPoints] } {incr $pointIndex }
    for {set coordIndex 0 } { $coordIndex < 3 } { incr coordIndex} {
    set coordValue [landmarks.am getPoint $coordIndex ]
    Result setValue $coordIndex $pointIndex 0 $coordValue
    }
    }
    Notice that you can use such command split in mutiple lines only in a script file (.hx or .scro). To enter the command sequence above in the console, use a single line.

  • Connect CalculusMatlab module to Result: data are then available in MATLAB script. See CalculusMatlab help for details.

  • You can retrieve result data from MATLAB via TCL:
    Result getValue <i> <j> <k>

Credits

Daniel Lichau

Last edited by Daniel Lichau; 21st March 2008 at 15:57.
Reply With Quote
  #2  
Old 20th March 2008, 15:36
forum_admin forum_admin is offline
Administrator
 
Join Date: Feb 2008
Posts: 86
Default Re: CalculusMatlab: exchanging arbitrary data with MATLAB

Very interesting Daniel,
Thanks for this contribution.
Can you add a sample script file or hx file to illustrate that ?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 13:20.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Copyright VSG SAS, 2008.