changeset 34:922f5c7192c6

matlab
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Jul 2016 14:18:47 +0200
parents 11e204c432a7
children 5737f51ff94e
files Sphinx/source/faq.rst Sphinx/source/faq/matlab.rst Sphinx/source/faq/same-origin.rst Sphinx/source/images/Matlab.png Sphinx/source/plugins/serve-folders.rst
diffstat 5 files changed, 54 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Sphinx/source/faq.rst	Wed Jul 20 13:52:37 2016 +0200
+++ b/Sphinx/source/faq.rst	Wed Jul 20 14:18:47 2016 +0200
@@ -46,4 +46,5 @@
    faq/iis.rst
    faq/https.rst
    faq/same-origin.rst
+   faq/matlab.rst
    faq/why-orthanc.rst
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sphinx/source/faq/matlab.rst	Wed Jul 20 14:18:47 2016 +0200
@@ -0,0 +1,43 @@
+Interfacing with Matlab and Octave
+==================================
+
+Thanks to the REST API of Orthanc, it is easy to access DICOM images
+from Matlab or Octave, as depicted in the following sample image:
+
+.. image:: ../images/Matlab.png
+           :align: center
+           :width: 470px
+
+Both Matlab and Octave have access to HTTP servers thanks to their
+built-in `urlread() function
+<http://nl.mathworks.com/help/matlab/ref/urlread.html>`__.  Once must
+simply install a Matlab/Octave library to decode JSON files.  The
+`JSONlab toolkit
+<http://www.mathworks.com/matlabcentral/fileexchange/33381-jsonlab--a-toolbox-to-encode-decode-json-files>`__
+works perfectly to this end.
+
+.. highlight:: matlab
+
+Using JSONlab, the following code will download and display a DICOM image::
+
+  SERIES = 'ae164c84-e5bd0366-ba937a6d-65414092-f294d6b6';
+  URL = 'http://orthanc.chu.ulg.ac.be/demo';
+
+  # Get information about the instances in this DICOM series
+  instances = loadjson(urlread([ URL '/series/' SERIES '/instances' ]));
+
+  # Select one slice from the series
+  instance = instances{1,1}.ID
+
+  # Decode the slice with Orthanc thanks to the "/matlab" URI
+  slice = eval(urlread([ URL '/instances/' instance '/matlab' ]));
+
+  # Compute the maximum value in this slice
+  max(max(slice))
+
+  # Display the slice
+  imagesc(slice)
+
+  # Annotate the graph with the patient name and ID
+  tags = loadjson(urlread([ URL '/instances/' instance '/tags?simplify' ]));
+  title([ 'This is a slice from patient ' tags.PatientID ' (' tags.PatientName ')' ])
--- a/Sphinx/source/faq/same-origin.rst	Wed Jul 20 13:52:37 2016 +0200
+++ b/Sphinx/source/faq/same-origin.rst	Wed Jul 20 14:18:47 2016 +0200
@@ -1,3 +1,5 @@
+.. _same-origin:
+
 Same-origin policy in JavaScript
 ================================
 
@@ -31,11 +33,10 @@
    server that serves the JavaScript code (cf. the instructions for
    :ref:`Apache <apache>` and :ref:`nginx <nginx>`). This is the best
    solution for production.
-2. Use the official `ServeFolders plugin
-   <https://bitbucket.org/sjodogne/orthanc/src/default/Plugins/Samples/ServeFolders>`__
-   that can be used to serve JavaScript code directly by the
-   **embedded Web server of Orthanc** (i.e. next to its REST
-   API). This is the best solution for development or debugging.
+2. Use the official :ref:`ServeFolders plugin <serve-folders>` that
+   can be used to serve JavaScript code directly by the **embedded Web
+   server of Orthanc** (i.e. next to its REST API). This is the best
+   solution for development or debugging.
 3. Enable **CORS on the top of Orthanc** with your Web server (cf. the
-   instructions for :ref:`nginx <nginx-cors>`). This is the most 
-   hacky solution.
+   instructions for :ref:`nginx <nginx-cors>`). This is the most hacky
+   solution.
Binary file Sphinx/source/images/Matlab.png has changed
--- a/Sphinx/source/plugins/serve-folders.rst	Wed Jul 20 13:52:37 2016 +0200
+++ b/Sphinx/source/plugins/serve-folders.rst	Wed Jul 20 14:18:47 2016 +0200
@@ -7,9 +7,8 @@
 This **official** plugin enables Orthanc to serve additional folders
 from the filesystem using its embedded Web server. This plugin is
 extremely useful when creating new Web applications on the top of the
-REST API of Orthanc, as it allows to fulfill the `same-origin policy
-<https://en.wikipedia.org/wiki/Same-origin_policy>`__ without setting
-up a reverse proxy.
+REST API of Orthanc, as it allows to fulfill the :ref:`same-origin
+policy <same-origin>` without setting up a reverse proxy.
  
 The source code of this sample plugin is `available in the source
 distribution of Orthanc