Difference between revisions of "Projects/Slicer3/2007 Project Week Slicer Matlab Pipeline for scalars and tensors"

From NAMIC Wiki
Jump to: navigation, search
Line 55: Line 55:
 
* Matlab scripts: getSlicerVolume.m and putSlicerVolume.m use Matlab extention [http://labrosa.ee.columbia.edu/matlab/popenrw.html popen] to connect to stdout(stdin respectively) of the tcl client slicerget.tcl (slicerput.tcl respectively). The tcl client establishes a channel to the SlicerDaemon socket and requests(sends) data.
 
* Matlab scripts: getSlicerVolume.m and putSlicerVolume.m use Matlab extention [http://labrosa.ee.columbia.edu/matlab/popenrw.html popen] to connect to stdout(stdin respectively) of the tcl client slicerget.tcl (slicerput.tcl respectively). The tcl client establishes a channel to the SlicerDaemon socket and requests(sends) data.
 
* flag in these scripts can be set to do/undo gradientSpace->IJKspace transformation for tensor data.  
 
* flag in these scripts can be set to do/undo gradientSpace->IJKspace transformation for tensor data.  
 +
 +
===Motivation===
  
 
The Matlab pipeline client can be used to send data from Slicer to Matlab, where data can be processed making advantage of already existing code and powerful Matlab toolboxes. The data can then be sent back to Slicer for visualisation or further processing. No file I/O is necessary. This can be very useful since a lot of methods or algorithms are first prototyped in Matlab.
 
The Matlab pipeline client can be used to send data from Slicer to Matlab, where data can be processed making advantage of already existing code and powerful Matlab toolboxes. The data can then be sent back to Slicer for visualisation or further processing. No file I/O is necessary. This can be very useful since a lot of methods or algorithms are first prototyped in Matlab.
Line 61: Line 63:
 
** Thresholding
 
** Thresholding
 
** Do tensor statistics after masking tensor with labelmap
 
** Do tensor statistics after masking tensor with labelmap
** Average two tensors
+
** Average tensors
** smoothing of tensor field (Marco's algorithm?)
+
** Smooth tensor fields
 
*Scalars:
 
*Scalars:
 
** plot histogram (that allows to quantify, at the moment slicer-histograms are not associated with numbers )
 
** plot histogram (that allows to quantify, at the moment slicer-histograms are not associated with numbers )
  
====Tensor transformation issues====
+
===Tensor transformation issues===
  
When tensors are loaded into Slicer, vtkNRRDReader performs transformation from diffusion gradient space into image space (IJK space). This is done to improve performance since most itk-filters require data in ijk coordinates.  
+
When tensors are loaded into Slicer, the vtkNRRDReader performs transformation from diffusion gradient space into image space (IJK space). This is done to improve performance since most itk-filters require data in ijk coordinates.
Tensors piped to Matlab will live in IJK-space, since this is where they are in Slicer memory. Assuming the dataset will be sent back to Slicer after processing in Matlab, no such transformations need to be done. To apply this transformation and afterwards the inverse transformation will introduce numberical errors due to matrix inversion.
+
 +
Tensors piped to Matlab by default will live in IJK-space, since this is where they are in Slicer memory. Assuming the dataset will be sent back to Slicer after Matlab processing, no such transformation needs to be done. Besides, this transformation and especially the inverse transformation when putting data back into Slicer will introduce numerical errors due to matrix inversion.
  
 
However, the Matlab user might wish to transform the data back to gradient space. Matlab tools are provided to perform transformations needed.
 
However, the Matlab user might wish to transform the data back to gradient space. Matlab tools are provided to perform transformations needed.
  
+
===Issues with different coordinate conventions in Matlab and Slicer ===
 +
 
 +
 
  
 
----
 
----
  
 
[[2007_Programming/Project_Week_MIT|Back to Project week]]
 
[[2007_Programming/Project_Week_MIT|Back to Project week]]

Revision as of 15:33, 22 June 2007

Home < Projects < Slicer3 < 2007 Project Week Slicer Matlab Pipeline for scalars and tensors


Key Investigators

  • BWH: Katharina Quintus
  • Isomics: Steve Pieper
  • BWH: Sylvain Bouix
  • BWH: Marc Niethammer


Objective

  • Provide tools to pipe volume data from Slicer3 memory to Matlab and back.

Approach, Plan

  • Finalize utilities that transform tensor data from Slicer's IJK space to the original gradient space and transform the data from gradient space back to Slicer's IJK space respectively.
  • Quantify numerical error for these transformations.
  • Application testing: Get user feedback.

Progress

  • Pipeline tools for scalar data are ready to use


References

Slicer Deamon Wiki page

Additional Information

When Slicer is started with the "--daemon" flag, a server socket is created that is listening and waiting for new connections. This network service can be used to access the MRML scene or other objects in Slicer memory. Several clients have been written or are beeing worked on at the moment:

  • Tcl scripts that read out volumes to stdout or write to stdin
  • Python based clients
  • Matlab clients

The Slicer Deamon Wiki page provides more details.

The Matlab client

  • Matlab scripts: getSlicerVolume.m and putSlicerVolume.m use Matlab extention popen to connect to stdout(stdin respectively) of the tcl client slicerget.tcl (slicerput.tcl respectively). The tcl client establishes a channel to the SlicerDaemon socket and requests(sends) data.
  • flag in these scripts can be set to do/undo gradientSpace->IJKspace transformation for tensor data.

Motivation

The Matlab pipeline client can be used to send data from Slicer to Matlab, where data can be processed making advantage of already existing code and powerful Matlab toolboxes. The data can then be sent back to Slicer for visualisation or further processing. No file I/O is necessary. This can be very useful since a lot of methods or algorithms are first prototyped in Matlab. Ideas what can be done easily in Matlab while Slicer does not have the functionality yet:

  • Tensors:
    • Thresholding
    • Do tensor statistics after masking tensor with labelmap
    • Average tensors
    • Smooth tensor fields
  • Scalars:
    • plot histogram (that allows to quantify, at the moment slicer-histograms are not associated with numbers )

Tensor transformation issues

When tensors are loaded into Slicer, the vtkNRRDReader performs transformation from diffusion gradient space into image space (IJK space). This is done to improve performance since most itk-filters require data in ijk coordinates.

Tensors piped to Matlab by default will live in IJK-space, since this is where they are in Slicer memory. Assuming the dataset will be sent back to Slicer after Matlab processing, no such transformation needs to be done. Besides, this transformation and especially the inverse transformation when putting data back into Slicer will introduce numerical errors due to matrix inversion.

However, the Matlab user might wish to transform the data back to gradient space. Matlab tools are provided to perform transformations needed.

Issues with different coordinate conventions in Matlab and Slicer


Back to Project week