Skip to content

Commit

Permalink
Wrap up documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
agricolab committed Dec 13, 2019
1 parent e8868da commit 227a654
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 74 deletions.
6 changes: 0 additions & 6 deletions docs/source/_autosummary/localite.api.rst

This file was deleted.

Binary file added docs/source/_static/flow-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Application Programming Interface
---------------------------------

The main interface to controlling your TMS coil with localite-flow


Localite Flow
*************

.. automodule:: localite.flow.mitm
:members: start, kill

Controlling the Coil
********************

Before you can control the coil and read its parameters, make sure the localite-flow is running, e.g. with :meth:`~localite.flow.mitm.start` or using the command-line-interface.


.. automodule:: localite.coil
:members: Coil
26 changes: 26 additions & 0 deletions docs/source/cli.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Command Line Interface
----------------------

Use ``localite-flow`` to interface with a real localite TMS Navigator.


.. code-block:: none
usage: localite-flow [-h] [--host HOST] [--kill]
optional arguments:
-h, --help show this help message and exit
--host HOST The IP-Adress of the localite-PC
--kill
Use ``localite-mock`` if you don't have access to a real TMS Navigator, but want to develop and tests tasks or experiments using the API.

.. code-block:: none
usage: localite-mock [-h] [--kill]
optional arguments:
-h, --help show this help message and exit
--kill
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = [".rst", ".md"]
source_suffix = [".rst"]

# The master toctree document.
master_doc = "index"
Expand Down
76 changes: 66 additions & 10 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,79 @@
Welcome to ctrl-localite's documentation!
=========================================

This package allows you to stream the current settings and messages from your `localite TMS Navigator <https://www.localite.de/en/home/>`_ as `LSL stream <https://labstreaminglayer.readthedocs.io/>`_ Additionally, it allows you to control the TMS device connected to the localite software over an api.

This package has been developed using MagVenture TMS devices connected with localite TMS Navigator, and with a beta version of TMS Navigator 4.0. It's current test and coverage status is:


.. image:: https://github.com/pyreiz/ctrl-localite/workflows/pytest/badge.svg
:target: https://github.com/pyreiz/ctrl-localite/actions

.. image:: https://coveralls.io/repos/github/pyreiz/ctrl-localite/badge.svg?branch=master
:target: https://coveralls.io/github/pyreiz/ctrl-localite?branch=master


Installation
------------

.. code-block:: bash
git clone [email protected]:pyreiz/ctrl-localite.git
cd ctrl-localite
pip install .
Basic Usage
-----------

Usage of the API depends on a running localite-flow Server. Start this server ideally from the command line using e.g. ``localite-flow --host HOST`` with HOST the ip-adress of your localite PC.

.. code-block:: bash
usage: localite-flow [-h] [--host HOST] [--kill]
optional arguments:
-h, --help show this help message and exit
--host HOST The IP-Adress of the localite-PC
--kill
After that, you can use the python API to access the stream and control TMS Navigator remotely.

.. code-block:: python
from localite.api import Coil
coil = Coil(0) # initializes the api for coil 1 (of e.g. 2)
coil.amplitude = 30 # sets the amplitude of this coil to 30% MSO
coil.trigger() # triggers the coil
coil.push_marker("Experiment finished") # publishes a marker over LSL
.. toctree::
:maxdepth: 2
:caption: Contents:
cli
api

Information Flow
----------------

Information flows within the server in a relatively complex fashion. There is an EXT listening to messsages sent over the API, which are queued to be delivered to LOC, where they are sent to the localite PC. Concurrently, LOC is constantly listening for messages from the localite PC and sends them indirectly to MRK, where these messages are pubklished in an LSL Marker StreamOutlet. This allows you to publish additional markers over the API, and additonally supports easy automated logging of any command sent to localite.

.. image:: _static/flow-diagram.png
:width: 600

The setup is based on




API
---

The main interface to controlling your TMS coil with localite-flow

.. autosummary::
:toctree: _autosummary
:template: module.rst

localite.api

Indices and tables
==================
******************

* :ref:`genindex`
* :ref:`modindex`
Expand Down
19 changes: 0 additions & 19 deletions localite/api.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
"""
Localite Flow
-------------
.. automodule:: localite.flow.mitm
:members: start, kill
Controlling the Coil
--------------------
Before you can control the coil and read its parameters, make sure the localite-flow is running, e.g. with :meth:`~localite.flow.mitm.start` or the command-line-interface.
.. automodule:: localite.coil
:members: Coil
"""

from localite.flow.mitm import start, kill
from localite.coil import Coil

76 changes: 38 additions & 38 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://en.wikipedia.org/wiki/MIT_License) [![pytest-status](https://github.com/pyreiz/ctrl-localite/workflows/pytest/badge.svg)](https://github.com/pyreiz/ctrl-localite/actions) [![Coverage Status](https://coveralls.io/repos/github/pyreiz/ctrl-localite/badge.svg?branch=develop)](https://coveralls.io/github/pyreiz/ctrl-localite?branch=develop)
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://en.wikipedia.org/wiki/MIT_License) [![pytest-status](https://github.com/pyreiz/ctrl-localite/workflows/pytest/badge.svg)](https://github.com/pyreiz/ctrl-localite/actions) [![Coverage Status](https://coveralls.io/repos/github/pyreiz/ctrl-localite/badge.svg?branch=master)](https://coveralls.io/github/pyreiz/ctrl-localite?branch=master) [![Documentation Status](https://readthedocs.org/projects/ctrl-localite/badge/?version=latest)](https://ctrl-localite.readthedocs.io/en/latest/?badge=latest)

### ctrl-localite
ctrl-localite
------------

A repository to control localite 4.0
This package allows you to stream the current settings and messages from your [localite TMS Navigator](https://www.localite.de/en/home/>) as [LSL stream](https://labstreaminglayer.readthedocs.io/) Additionally, it allows you to control the TMS device connected to the localite software over an api.

### Command Line Tools
This package has been developed using MagVenture TMS devices connected with localite TMS Navigator, and with a beta version of TMS Navigator 4.0.

- localiteLSL
Installation
------------

starts reading from localite TCP/IP-json and forwards all stimulation trigger
events as LSL Marker stream
``` bash
git clone [email protected]:pyreiz/ctrl-localite.git
cd ctrl-localite
pip install .
```

- localiteMock
Basic Usage
-----------

mocks a localite TCP/IP-json server for testing and development
Usage of the API depends on a running localite-flow Server. Start this server ideally from the command line using e.g. ``localite-flow --host HOST`` with HOST the ip-adress of your localite PC.

usage: localite-flow [-h] [--host HOST] [--kill]

### Information Flow
optional arguments:
-h, --help show this help message and exit
--host HOST The IP-Adress of the localite-PC
--kill

![Alt text](https://g.gravizo.com/source/custom_mark10?https://raw.githubusercontent.com/pyreiz/ctrl-localite/develop/readme.md)
<details>
<summary></summary>
custom_mark10
digraph Flow {
rankdir=LR;
{
node [shape = circle]
node [style=filled]
rankdir=LR;
QUEUE -> CTRL
EXT -> QUEUE
CTRL -> LOC
CTRL -> MRK
LOC -> QUEUE
}
fo[label="", shape=plaintext]
fo -> EXT
to[label="", shape=plaintext]
lo[label="", shape=plaintext]
MRK -> to
LOC -> lo
}
custom_mark10
</details>

The EXT receives a payload via JSON over TCP-IP. Payloads have to have the form
`[<fmt>:str, <message>:str, <tstamp>:int]`. The fmt defines how the message will be distributed. Only the following targets for `fmt` are valid: `["cmd", "mrk", "loc"]`. Invalid fmts will not be forwarded, and their message ignored.

Whether the message part of the payload is valid depends on the recipient and will be evaluated there.
After that, you can use the python API to access the stream and control TMS Navigator remotely.

``` python
from localite.api import Coil
coil = Coil(0) # initializes the api for coil 1 (of e.g. 2)

coil.amplitude = 30 # sets the amplitude of this coil to 30% MSO
coil.trigger() # triggers the coil

coil.push_marker("Experiment finished") # publishes a marker over LSL
```


Information Flow
----------------

Information flows within the server in a relatively complex fashion. There is an EXT listening to messsages sent over the API, which are queued to be delivered to LOC, where they are sent to the localite PC. Concurrently, LOC is constantly listening for messages from the localite PC and sends them indirectly to MRK, where these messages are pubklished in an LSL Marker StreamOutlet. This allows you to publish additional markers over the API, and additonally supports easy automated logging of any command sent to localite.

![flow-diagram](docs/source/_static/flow-diagram.png)

0 comments on commit 227a654

Please sign in to comment.