| 1 |
.. toctree:: |
| 2 |
:maxdepth: 1 |
| 3 |
|
| 4 |
Noting the origin of data |
| 5 |
========================= |
| 6 |
|
| 7 |
In cases in which we want to store where the data originates from *Source* entities can be used. Almost all entities of the NIX-model can have *Sources*. For example, if the recorded data originates from experiments done with one specific experimental |
| 8 |
subject. |
| 9 |
|
| 10 |
*Sources* have a name and a type and can have some definition and link to further :ref:`metadata<metadata>`. |
| 11 |
|
| 12 |
.. literalinclude:: examples/sources.py |
| 13 |
:lines: 9-10, 16-19 |
| 14 |
:caption: Sources are used to note the origin of the data (:download:`example code <examples/sources.py>`). |
| 15 |
|
| 16 |
|
| 17 |
*Sources* may depend on other *Sources*. For example, in an electrophysiological experiment we record from different cells in the same brain region of the same animal. To represent this hierarchy, *Sources* can be nested, create a tree-like structure. |
| 18 |
|
| 19 |
.. literalinclude:: examples/sources.py |
| 20 |
:lines: 12 - 16, 23, 27 |
| 21 |
:caption: Sources are used to note the origin of the data (:download:`example code <examples/sources.py>`). |
| 22 |
|
| 23 |
As mentioned above the Sources build a tree. The block (as the root of the tree) at the moment has only a single source attached to it |
| 24 |
|
| 25 |
.. literalinclude:: examples/sources.py |
| 26 |
:lines: 52 - 54 |
| 27 |
|
| 28 |
The output should yield: |
| 29 |
|
| 30 |
.. code-block:: text |
| 31 |
|
| 32 |
block sources: [Source: {name = subject A, type = nix.experimental_subject}] |
| 33 |
subject sources: [Source: {name = hippocampus, type = nix.experimental_subject.subject}] |
| 34 |
brain region sources: [Source: {name = Cell 1, type = nix.experimental_subject.cell}, Source: {name = Cell 2, type = nix.experimental_subject.cell}] |
| 35 |
|
| 36 |
Search and find |
| 37 |
--------------- |
| 38 |
|
| 39 |
In a data-centered search we can then ask the *DataArray* for it's *Source* to get information about the cell and get the linked metadata. A *DataArray* may have several sources attached to it. To make sure we get the right one (with the cell information) we perform a search on the sources using the **type** information. |
| 40 |
|
| 41 |
.. literalinclude:: examples/sources.py |
| 42 |
:lines: 58 - 60 |
| 43 |
|
| 44 |
The output should give |
| 45 |
|
| 46 |
.. code-block:: text |
| 47 |
|
| 48 |
Source: Source: {name = Cell 1, type = nix.experimental_subject.cell} |
| 49 |
Source metadata: |
| 50 |
Cell 1 [odml.cell] |
| 51 |
|- Type: ('pyramidal',) |
| 52 |
|- BrainSubregion: ('CA1',) |
| 53 |
|- BaselineRate: (15,)Hz |
| 54 |
|- Layer: ('4',) |
| 55 |
|
| 56 |
In a source-centered search we can ask for the *DataArrays* that link to a source. |
| 57 |
|
| 58 |
.. literalinclude:: examples/sources.py |
| 59 |
:lines: 62 |
| 60 |
|
| 61 |
This should return a list with a single entry: |
| 62 |
|
| 63 |
.. code-block:: text |
| 64 |
|
| 65 |
[DataArray: {name = cell a data, type = nix.sampled.time_series}] |