Skip to main content

A simple package for rat vision rendering simulation.

Project description

ratvision

A Python library for simulating rat vision through 3D rendering.

ratvision provides a simple interface to render what a rat would see based on its position and head direction in a 3D environment. It uses Blender for the 3D rendering process, making it possible to create realistic simulations of a rat's visual perspective.

Installation

pip install ratvision

Or by cloning this repository:

git clone git@github.com:marcoabrate/ratvision.git
cd ratvision
pip install .

Usage

renderer = Renderer(blender_exec='/path/to/Blender')

# positions is List[Tuple[float, float]]
# head_directions is List[float]
renderer.render(positions, head_directions)

See examples/render_demo.py for a thorough example. After cloning this repository or downloading the examples folder, you can run the demo with:

python examples/render_demo.py --blender_exec "/path/to/Blender"

Rendered frames and an animation animation.mp4 will be saved to a new output directory.

Requirements

  • Python 3.7+
  • Blender (external dependency, not included in the package)

The code was tested with Blender 3.6 on Linux and MacOS machines.

Features

  • Generate rat-eye-view video animations from movement trajectories
  • Easy to use Python API
  • Compatible with custom 3D environments
  • Built-in visualization function

Configuration Options

The renderer can be configured with the following parameters:

Parameter Description Default
env_file Path to Blender environment file Built-in box
output_dir Directory where rendered frames are saved 'output'
frame_dim Dimensions of the rendered frames (width, height) (120, 64)
camera_name Name of the camera in the Blender scene 'Camera_main'
camera_height Height of the camera from the ground in meters 0.035
camera_vertical_angle Vertical inclination of the camera in radians pi/2

You can view the configuration description by calling:

Renderer.config_description()

Customizable 3D environment

While ratvision comes with a default 3D environment, you can use your own Blender files:

renderer.update_config({'env_file': '/path/to/environment.blend'})

Note: All rendering and camera settings defined in the Blender environment will be preserved when rendering with ratvision. Only the parameters that can be set through the config will be overwritten. Be sure to change them to your preference before running ratvision. For biologically-plausible rendering and camera settings, you can check the provided environment environments/box_messy.blend.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Marco P. Abrate marcopietro.abrate@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ratvision-0.1.0.tar.gz (15.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ratvision-0.1.0-py3-none-any.whl (15.9 MB view details)

Uploaded Python 3

File details

Details for the file ratvision-0.1.0.tar.gz.

File metadata

  • Download URL: ratvision-0.1.0.tar.gz
  • Upload date:
  • Size: 15.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for ratvision-0.1.0.tar.gz
Algorithm Hash digest
SHA256 58c89cccea885c78eaaa9fd20379627786cf991b3b54f38dcaf171610013dbcf
MD5 f6cb8ce18ecc2538edfc19be466b4211
BLAKE2b-256 f48a04f9eccc062eed264f4900571c42e6452bddddc084cef4a262eeac3a6b7d

See more details on using hashes here.

File details

Details for the file ratvision-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ratvision-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for ratvision-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae38eff4a84934c3e8d5392ef4ba2998612ae77be45603a6550213271a64f6b6
MD5 4b7d08e14dbc5ad2cac24d7ae5e1fff9
BLAKE2b-256 2ff01524b51f3fc3fd88bae6a14757c4a67de040202359dfbec0c6090250055a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page