<jupyter_start><jupyter_text>Creating a Simple Output Module An output module listens for selections from the MindAffect decoder and acts on them to create some output. By the end of this tutorial you will be able to: * make a simple output module which prints "Hello World" when the presentation 'button' with ID=1 is selected. * know how to make your own output modules to perform arbitary actions under brain control**Before starting this tutorial please read the** [how an evoked bci works](https://mindaffect-bci.readthedocs.io/en/latest/how_an_evoked_bci_works.html) **tutorial to gain a general understanding of the components of this BCI.  And the [quickstart tutorial](quickstart.ipynb) or [DIY Brain Computer Interface](DIY_brain_computer_interfacing.ipynb) for how they are used in the mindaffectBCI. **  *The non-Jupyter Notebook version of this code and other output examples can be found in the* [examples/output](https://github.com/mindaffect/pymindaffectBCI/blob/doc/mindaffectBCI/examples/output/minimal_output.py) *directory*    First, we import the module responsible for translating selections to output, and create the utopia2output object:<jupyter_code># Import the utopia2output module
from mindaffectBCI.utopia2output import Utopia2Output

u2o=Utopia2Output()<jupyter_output><empty_output><jupyter_text>Defining the Output functionNow we define a function to print hello-world.<jupyter_code>def helloworld(objID):
   print("hello world")<jupyter_output><empty_output><jupyter_text>Connecting the Output functionAnd connect it so it is run when the object with ID=1 is selected. You can create as many output functions as needed, and connect them to different object ID's by simply adding them to the dictionary as *key-value* pairs.<jupyter_code># set the objectID2Action dictionary to use our helloworld function if 1 is selected
u2o.objectID2Action={ 1:helloworld }<jupyter_output><empty_output><jupyter_text>Start the BCI decoder in the background.To successfully test your presentation module it is important to have the other components of the BCI running. As explained in the [quickstart tutorial](quickstart.ipynb), additionally to the presentation we build here, we need the Hub, Decoder, and Acquisition components for a functioning BCI.  For a quick test (with fake data) of this presentation module you can run all these components with a given configuration file using.N.B. if you run directly in this notebook, *don't forget to shutdown the decoder* at the end.<jupyter_code>import mindaffectBCI.online_bci
config = mindaffectBCI.online_bci.load_config('fake_recogniser.json')
mindaffectBCI.online_bci.run(**config)<jupyter_output><empty_output><jupyter_text>Alternatively you can run this config from the command line with:```python3 -m mindaffectBCI.online_bci --config_file fake_recogniser.json``` Or from you Anaconda environment:   ```python -m mindaffectBCI.online_bci --config_file fake_recognizer.json```**See our tutorial** [Running Custom Presentation](simple_integration_tutorial.ipynb) **to set-up a BCI using your own Presentation module**  Connect and RunWe now connect our output module to a running decoder and run the main loop. Selection of ID=1 will result in printing "Hello World" to this prompt.<jupyter_code># connect
u2o.connect()

# run the main loop
u2o.run()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06801909307875895, 'fraction_numerical': 0.005071599045346062, 'mean_word_length': 6.134042553191489, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '138886', 'license': 'MIT', 'n_tokens_mistral': 974, 'n_tokens_neox': 933, 'n_words': 385, 'path': 'docs/source/simple_output_tutorial.ipynb', 'repo_name': 'Jedite/CommunicationWithoutMovement', 'size': '3352'}