| 1 |
.. toctree:: |
| 2 |
:maxdepth: 1 |
| 3 |
|
| 4 |
|
| 5 |
Image data |
| 6 |
========== |
| 7 |
|
| 8 |
Color images can be stored as 3-D data in a *DataArray*. The first two |
| 9 |
dimensions represent *width* and *height* of the image while the 3rd |
| 10 |
dimension represents the color channels. Accordingly, we need three |
| 11 |
dimension descriptors. The first two are *SampledDimensions* since the |
| 12 |
pixels of the image are regularly sampled in space. The third |
| 13 |
dimension is a *SetDimension* with labels for each of the channels. |
| 14 |
In this tutorial the "Lenna" image is used. Please see the author |
| 15 |
attribution in the code. |
| 16 |
|
| 17 |
.. literalinclude:: examples/imageData.py |
| 18 |
:lines: 59-64 |
| 19 |
:caption: Image data is just 3-D data that can be easily stored in a *DataArray*. We need to add three dimension descriptors, though (to run the example you need the :download:`example code <examples/imageData.py>` , the :download:`image <examples/lenna.png>` *imagemagick* or *xv* packages). |
| 20 |
|
| 21 |
.. image:: examples/lenna.png |
| 22 |
:alt: lenna |
| 23 |
:width: 240 |
| 24 |
|
| 25 |
|
| 26 |
Tagging regions |
| 27 |
--------------- |
| 28 |
|
| 29 |
One key feature of the nix-model is its ability to annotate, or "tag", points or regions-of-interest in the stored data. This feature can be used to state the occurrence of events during the recording, to state the intervals of a certain condition, e.g. a stimulus presentation, or to mark the regions of interests in image data. In the nix data-model two types of Tags are discriminated. (1) the **Tag** for single points or regions, and (2) the **MultiTag** to annotate multiple points or regions using the same entity. |
| 30 |
|
| 31 |
.. _single_roi: |
| 32 |
|
| 33 |
Tagging a single point or region |
| 34 |
-------------------------------- |
| 35 |
|
| 36 |
Single points of regions-of-interest are annotated using a **Tag** object. The Tag contains the start *position* and, optional, the *extent* of the point or region. The link to the data is established by adding the **DataArray** that contains the data to the list of references. It is important to note that *position* and *extent* are arrays with the length matching the dimensionality of the referenced data. The same Tag can be applied to many references as long as *position* and *extent* can be applied to these. |
| 37 |
|
| 38 |
.. literalinclude:: examples/singleROI.py |
| 39 |
:lines: 77-81 |
| 40 |
:caption: A *Tag* is used to tag a a single region of interest. Most image data is 3-D with the third dimension representing the color channels (:download:`singleROI.py <examples/singleROI.py>`). |
| 41 |
|
| 42 |
.. image:: images/single_roi.png |
| 43 |
:alt: single roi |
| 44 |
:width: 240 |
| 45 |
|
| 46 |
|
| 47 |
Tagging multiple regions |
| 48 |
------------------------ |
| 49 |
|
| 50 |
For tagging multiple regions in the image data we again use a *MultiTag* entity. |
| 51 |
|
| 52 |
.. literalinclude:: examples/multipleROIs.py |
| 53 |
:lines: 97 - 122 |
| 54 |
:caption: The image data is stored in the very same way as above, the ROIs are defined by their respective start positions and their extents (:download:`example code <examples/multipleROIs.py>`). |
| 55 |
|
| 56 |
.. image:: images/multiple_rois.png |
| 57 |
:alt: many rois |
| 58 |
:width: 240 |
| 59 |
|
| 60 |
The start positions and extents of the ROIs are stored in two separate *DataArrays*, these are each 2-D, the first dimension represents the number of regions, the second defines the position/extent for each single dimension of the data (height, width, color channels). |
| 61 |
|
| 62 |
The *MultiTag* has a ``tagged_data`` method that is used to retrieve the data tagged by the *MultiTag*. |
| 63 |
|
| 64 |
.. literalinclude:: examples/multipleROIs.py |
| 65 |
:lines: 68 - 73 |
| 66 |
:caption: Tagged data is read by using the ``tagged_data`` method. The first argument is the region number, the second the name of the referenced *DataArray* (:download:`example code <examples/multipleROIs.py>`). |
| 67 |
|
| 68 |
.. image:: images/retrieved_rois.png |
| 69 |
:alt: many rois |
| 70 |
:width: 240 |