tne-lab / py-behav-box-v2

Pybehave is an open source software interface and framework for controlling behavioral experiments in neuroscience and psychology.
https://py-behav-box-v2.readthedocs.io/en/latest/
MIT License
3 stars 8 forks source link

AddressFile documentation #75

Closed alustig3 closed 5 months ago

alustig3 commented 5 months ago

I am trying to add a video feed and am having trouble with my AddressFile. I created an my_address_file.py based on this page of documentation. A downloadable example address file would be helpful instead of the current code snippets provided in the docs.

my attempted address file has the following content:

from pybehave.Utilities import AddressFile
addresses = AddressFile()
addresses.add_component("video", "Video", "es", 0, None, {"fr": 30})

When trying to run a task I get the following error:

Exception in thread Thread-1 (update_gui):
Traceback (most recent call last):
  File "C:\Users\karpo\pybehave_eval\Lib\site-packages\pybehave\GUIs\GUI.py", line 60, in __init__
    file_globals = runpy.run_path(address_file, {"AddressFile": AddressFile})
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen runpy>", line 286, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "C:/Users/karpo/Desktop/py-behav/Local/my_address.py", line 2, in <module>
    addresses = AddressFile()
                ^^^^^^^^^^^^^
TypeError: 'module' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\karpo\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "C:\Users\karpo\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\karpo\pybehave_eval\Lib\site-packages\pybehave\Workstation\Workstation.py", line 222, in update_gui
    self.guis[event.chamber] = gui(event, self.task_gui.subsurface(col * self.w, row * self.h, self.w, self.h), self)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\karpo\pybehave_eval\Lib\site-packages\pybehave\GUIs\GUI.py", line 62, in __init__
    raise MalformedAddressFileError
pybehave.Utilities.Exceptions.MalformedAddressFileError
theonlydvr commented 5 months ago

So the reason this crashed is because that initial import line is unnecessary. When the AddressFile is run, the import is automatically provided. There is a GUI tool on the dev branch which streamlines the creation process somewhat if you'd like to give that a try. There's some documentation on the feature in the dev branch version of the docs. I will add example AddressFiles to the example-tasks repo though which is also relevant to #76