CCB.MShape (r1.1 vs. r1.18)
Diffs

 <<O>>  Difference Topic MShape (r1.18 - 23 Sep 2008 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape - An interface to ShapeTools from within Matlab

Line: 89 to 89

  1. ) Get, and unpack the SurfStat package onto your computer.
Changed:
<
<
  1. ) Copy the ShapeToolsReadSurf1.m file into the directory containing the SurfStat files (you may download it from this web page).
>
>
  1. ) Copy the ShapeToolsReadSurf1.m file into the directory containing the SurfStat files (you may download it from this web page).

  1. ) Download a copy of ShapeTools and copy the file 'ShapeTools.jar' into the directory containing the SurfStat files (However, you can avoid having to do so via step 5b, below).
  2. ) start your Matlab interpreter from the directory containing the SurfStat files.
  3. ) type javaaddpath('ShapeTools.jar'); into your matlab interpeter

 <<O>>  Difference Topic MShape (r1.17 - 11 Sep 2008 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape - An interface to ShapeTools from within Matlab

Line: 150 to 150

Changed:
<
<
>
>

Changed:
<
<
META FILEATTACHMENT ShapeToolsReadSurf1?.m attr="" comment="!ShapeToolsReadSurf1 (12 Aug 08)" date="1218571131" path="ShapeToolsReadSurf1.m" size="5510" user="craig" version="1.3"
>
>
META FILEATTACHMENT ShapeToolsSurfStat?.zip attr="" comment="Contains Matlab files needed to use ShapeTools?.jar with SurfStat?" date="1221175135" path="ShapeToolsSurfStat.zip" size="6930" user="craig" version="1.1"

META TOPICMOVED craig date="1128035238" from="CCB.MatlabShape" to="CCB.MShape"

 <<O>>  Difference Topic MShape (r1.16 - 02 Sep 2008 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape - An interface to ShapeTools from within Matlab


 <<O>>  Difference Topic MShape (r1.15 - 19 Aug 2008 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape - An interface to ShapeTools from within Matlab


 <<O>>  Difference Topic MShape (r1.14 - 12 Aug 2008 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape - An interface to ShapeTools from within Matlab

Line: 152 to 152

Changed:
<
<
META FILEATTACHMENT ShapeToolsReadSurf1?.m attr="" comment="!ShapeToolsReadSurf1 (6 Aug 08)" date="1218144535" path="ShapeToolsReadSurf1.m" size="5436" user="craig" version="1.2"
>
>
META FILEATTACHMENT ShapeToolsReadSurf1?.m attr="" comment="!ShapeToolsReadSurf1 (12 Aug 08)" date="1218571131" path="ShapeToolsReadSurf1.m" size="5510" user="craig" version="1.3"

META TOPICMOVED craig date="1128035238" from="CCB.MatlabShape" to="CCB.MShape"

 <<O>>  Difference Topic MShape (r1.13 - 07 Aug 2008 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape - An interface to ShapeTools from within Matlab

Line: 150 to 150

Changed:
<
<
META FILEATTACHMENT ShapeToolsReadSurf1?.m attr="" comment="!ShapeToolsReadSurf1.m" date="1217890507" path="ShapeToolsReadSurf1.m" size="5339" user="craig" version="1.1"
>
>

META FILEATTACHMENT ShapeToolsReadSurf1?.m attr="" comment="!ShapeToolsReadSurf1 (6 Aug 08)" date="1218144535" path="ShapeToolsReadSurf1.m" size="5436" user="craig" version="1.2"

META TOPICMOVED craig date="1128035238" from="CCB.MatlabShape" to="CCB.MShape"

 <<O>>  Difference Topic MShape (r1.12 - 04 Aug 2008 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram
Changed:
<
<

mShape

>
>

mShape - An interface to ShapeTools from within Matlab


Changed:
<
<
Purpose: An interface to ShapeTools from within Matlab
>
>

Using ShapeTools with SurfStat : A Case Study

Objective: Increase the number of surface file types that can be analyzed with SurfStat

Overview

SurfStat is a Matlab toolbox for the statistical analysis of univariate and multivariate surface data, written by Keith J. Worsley, of McGill University. The matlab source code can be easily modified to use the ShapeTools surface readers, allowing application of SurfStat toolbox analyses to all the suface file formats supported by ShapeTools.

Reading SurfStat surfaces with ShapeTools - a simple replacement

In the SurfStat toolbox, surface data is read by the file SurfStatReadSurf1.m . This matlab function reads the vertices of a file surface, for later analysis by the SurfStat toolbox. The SurfStatReadSurf1 matlab function can be replaced with about eleven lines of (matlab) code that use the ShapeTools library to identify and read a surface from a data file.

The following example shows how to use ShapeTools to read a surface file:

% specify file containing a surface

filename='yourSurfaceFile.obj';

% tell Matlab where to find the !ShapeTools java classes
javaaddpath('ShapeTools.jar');

% replace SurfStat code

s = SurfStatReadSurf1(filename);

% with ShapeTools reader. 

% Load Java Classes
import edu.ucla.loni.ccb.shape.Shape;
import edu.ucla.loni.ccb.shapeio.util.ShapeToolsReader;
import edu.ucla.loni.ccb.shape.geometry.IPointSet;
import edu.ucla.loni.ccb.shape.math.MatrixMath;

% read shape
shape = ShapeToolsReader.readShape(filename);

% reformat vertices to Matlab / SurfStat conventions
shapeCoords = shape.getVertices().getPoints();
surf.coord  = MatrixMath.transpose(shapeCoords);

% free temporarily used memory
clear shapeCoords 

A complete example: ShapeToolsReadSurf1

The SurfStat function SurfStatReadSurf1 does more than read surface vertices. In addition to these, it may also return:

  • surface vertex normals
  • vertex colors
  • surface face triangulations.
  • whether the surface file format is binary or ascii.

Because many surface file format do not include normals and colors, and may not even be composed of triangular surface facets, adding more supported file formats to the SurfStat package is not a trivial undertaking. However, use of the ShapeTools library to accomplish these tasks made it possible to write a ShapeTools based matlab function, ShapeToolsReadSurf1, in about an hour.

This function will read any ShapeTools compatible file format. Surface vertex coordinates returned in all cases. If requested by the user, some or all of the following actions are performed:

  • Surface normals are computed at each vertex
  • Each vertex's color is read, f supported by the file format. If the file format does not supply vertex colors, a
default color is applied to all vertices.
  • The surface triangulation is returned. If the surface is composed of rectangles (e.g. LONI UCF), the surface is triangulated and these triangulations are used.

If the file format is not recognized by ShapeTools, an error message is printed and the function returns without setting the value of the surface.

Using ShapeToolsReadSurf1

  1. ) Get, and unpack the SurfStat package onto your computer.

  1. ) Copy the ShapeToolsReadSurf1.m file into the directory containing the SurfStat files (you may download it from this web page).
  2. ) Download a copy of ShapeTools and copy the file 'ShapeTools.jar' into the directory containing the SurfStat files (However, you can avoid having to do so via step 5b, below).
  3. ) start your Matlab interpreter from the directory containing the SurfStat files.
  4. ) type javaaddpath('ShapeTools.jar'); into your matlab interpeter (note 'ShapeTools.jar' must be a locally valid file system path to the ShapeTools.jar file).m
  5. a) Alternatively, you may instruct matlab to read the ShapeTools.jar from our website, by typing
    javaaddpath('http://www.loni.ucla.edu/~shapetls/bin/ShapeTools.jar');
  6. ) test whether ShapeToolsSurfRead1 works, by typing, into your matlab interpreter:
 s=ShapeToolsReadSurf1('cube.obj')

You should see something like the following output:

>> s=ShapeToolsReadSurf1('cube.obj')

s = 

     coord: [8x3 single]
    normal: [8x3 single]
      colr: [8x4 single]
       tri: [12x3 double]

This indicates that the ShapeToolsReadSurf1 matlab function has created a surface containing vertex coordinates, surface normals, vertex colors and the face triangulation.

  1. ) Replace use of the SurfStatReadSurf1 function with the ShapeToolsReadSurf1 function:
    1. ) locate the file SurfStatReadSurf.m
    2. ) make a copy of this file, named, for example: SurfStatReadSurfOriginal.m
    3. ) edit SurfStatReadSurf.m.
    4. ) on lines 64 and 106 replace SurfStatReadSurf1 by ShapeToolsReadSurf1
    5. ) save your changes and exit your editor.
  2. ) use SurfStat normally.


Using ShapeTools with Matlab


Requirements

Matlab 6, or greater (must support Java).
Deleted:
<
<

Status

  • ShapeTools installed in LONI Matlab6

Frequently Asked Questions

Line: 25 to 150

Changed:
<
<

Lessons Learned

  • Need instruction for all support operating systems (e.g. Windows)
  • allow time for dependence on other people who must do essential actions (e.g. sys admin response time).
  • once a good example was found, it was easy to use.

>
>
META FILEATTACHMENT ShapeToolsReadSurf1?.m attr="" comment="!ShapeToolsReadSurf1.m" date="1217890507" path="ShapeToolsReadSurf1.m" size="5339" user="craig" version="1.1"

META TOPICMOVED craig date="1128035238" from="CCB.MatlabShape" to="CCB.MShape"

 <<O>>  Difference Topic MShape (r1.11 - 13 Mar 2007 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape

Line: 21 to 21

You can then use ShapeTools directly in your matlab interpeter.

Changed:
<
<

Example CCB_Tools_MeiheXu_SurfaceExtractionTutorialUsage of ShapeTools from within Matlab

>
>

Example Usage of ShapeTools from within Matlab



 <<O>>  Difference Topic MShape (r1.10 - 06 Dec 2006 - IvoDinov)

META TOPICPARENT ShapeToolLibraryProgram

mShape

Line: 21 to 21

You can then use ShapeTools directly in your matlab interpeter.

Changed:
<
<

Example Usage of ShapeTools from within Matlab

>
>

Example CCB_Tools_MeiheXu_SurfaceExtractionTutorialUsage of ShapeTools from within Matlab



 <<O>>  Difference Topic MShape (r1.9 - 11 Apr 2006 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape

Line: 22 to 22

You can then use ShapeTools directly in your matlab interpeter.

Example Usage of ShapeTools from within Matlab

Changed:
<
<
>
>

Changed:
<
<
# start matlab code sample
>
>

Lessons Learned

  • Need instruction for all support operating systems (e.g. Windows)
  • allow time for dependence on other people who must do essential actions (e.g. sys admin response time).
  • once a good example was found, it was easy to use.

Deleted:
<
<

import edu.ucla.loni.ccb.shape.Shape;

import edu.ucla.loni.ccb.shape.geometry.IPointSet;

import edu.ucla.loni.ccb.shapeio.util.ShapeToolsReader;

reader = ShapeToolsReader;

shape = reader.readShape('short.ucf');

points = shape.getVertices;

coords = points.getPoints;

# view coordinates

coords

coords =

1 59 59 59 60 1 133 134 135 135 1 48 48 48 48

# read Minc Binary OBJ # (Not otherwise possible w/o much suffering)

shape = reader.readShape('tri_binary.obj'); coords = shape.getVertices.getPoints; coords coords =

0 1 1 0 0 1 0 0 0

# end matlab code sample ....


META TOPICMOVED craig date="1128035238" from="CCB.MatlabShape" to="CCB.MShape"

 <<O>>  Difference Topic MShape (r1.8 - 05 Apr 2006 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape

Purpose: An interface to ShapeTools from within Matlab

Deleted:
<
<
Loni Matlab Users
  • Jussi Tohka (jtohka)
  • Yongang

Requirements

Matlab 6, or greater (must support Java).

 <<O>>  Difference Topic MShape (r1.7 - 27 Mar 2006 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape

Line: 14 to 14

Status

  • ShapeTools installed in LONI Matlab6
Added:
>
>

Frequently Asked Questions


How to set it up

  • Ensure java 1.4 or greater is used by your Matlab Java Virtual Machine.
  • Add the ShapeTools library Jar file to your Matlab installation classpath (See above for details).

 <<O>>  Difference Topic MShape (r1.6 - 22 Feb 2006 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape

Line: 23 to 23

You can then use ShapeTools directly in your matlab interpeter.

Example Usage of ShapeTools from within Matlab

Added:
>
>

# start matlab code sample

Added:
>
>


import edu.ucla.loni.ccb.shape.Shape;

import edu.ucla.loni.ccb.shape.geometry.IPointSet;


 <<O>>  Difference Topic MShape (r1.5 - 16 Nov 2005 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape


 <<O>>  Difference Topic MShape (r1.4 - 11 Oct 2005 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape

Changed:
<
<
An interface to ShapeTools from within Matlab
>
>
Purpose: An interface to ShapeTools from within Matlab

Added:
>
>
Loni Matlab Users
  • Jussi Tohka (jtohka)
  • Yongang

Requirements

Matlab 6, or greater (must support Java).

 <<O>>  Difference Topic MShape (r1.3 - 10 Oct 2005 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape

Line: 8 to 8

Matlab 6, or greater (must support Java).

Status

Changed:
<
<
  • ShapeTools? installed in LONI Matlab6
>
>
  • ShapeTools installed in LONI Matlab6

How to set it up

  • Ensure java 1.4 or greater is used by your Matlab Java Virtual Machine.

 <<O>>  Difference Topic MShape (r1.2 - 30 Sep 2005 - CraigSchwartz)

META TOPICPARENT ShapeToolLibraryProgram

mShape

Line: 7 to 7

Requirements

Matlab 6, or greater (must support Java).
Added:
>
>

Status

  • ShapeTools? installed in LONI Matlab6

How to set it up

  • Ensure java 1.4 or greater is used by your Matlab Java Virtual Machine.
  • Add the ShapeTools library Jar file to your Matlab installation classpath (See above for details).

 <<O>>  Difference Topic MShape (r1.1 - 29 Sep 2005 - CraigSchwartz)
Line: 1 to 1
Added:
>
>
META TOPICPARENT ShapeToolLibraryProgram

mShape

An interface to ShapeTools from within Matlab

Requirements

Matlab 6, or greater (must support Java).

How to set it up

  • Ensure java 1.4 or greater is used by your Matlab Java Virtual Machine.
  • Add the ShapeTools library Jar file to your Matlab installation classpath (See above for details).

See the Matlab web site for details.

You can then use ShapeTools directly in your matlab interpeter.

Example Usage of ShapeTools from within Matlab

# start matlab code sample import edu.ucla.loni.ccb.shape.Shape;

import edu.ucla.loni.ccb.shape.geometry.IPointSet;

import edu.ucla.loni.ccb.shapeio.util.ShapeToolsReader;

reader = ShapeToolsReader;

shape = reader.readShape('short.ucf');

points = shape.getVertices;

coords = points.getPoints;

# view coordinates

coords

coords =

1 59 59 59 60 1 133 134 135 135 1 48 48 48 48

# read Minc Binary OBJ # (Not otherwise possible w/o much suffering)

shape = reader.readShape('tri_binary.obj'); coords = shape.getVertices.getPoints; coords coords =

0 1 1 0 0 1 0 0 0

# end matlab code sample ....

META TOPICMOVED craig date="1128035238" from="CCB.MatlabShape" to="CCB.MShape"

Topic: MShape . { View | Diffs | r1.18 | > | r1.17 | > | r1.16 | More }

Revision r1.1 - 29 Sep 2005 - 23:08 - CraigSchwartz
Revision r1.18 - 23 Sep 2008 - 00:21 - CraigSchwartz