RatInABox-Lab / RatInABox

A python package for modelling locomotion in complex environments and spatially/velocity selective cell activity.
MIT License
175 stars 31 forks source link

Non-rectangular environments #24

Closed TomGeorge1234 closed 1 year ago

TomGeorge1234 commented 1 year ago

An upgrade is planned to allow non-rectangular environments in RiaB.

Users would (optionally) pass, at initialisation, coordinates defining a simple polygon which would then make up the boundaries of the arena.

Whenever the Agents position, or the location of a Neuron etc. is selected it would be guaranteed to fall within this polygon. Plotting rate maps etc. would also be updated too so they still look elegant.

This may require adding in the shapely package as a requirement.

TomGeorge1234 commented 1 year ago

RatInABox now supports any-polygon-shaped environments and adding holes into environments. These are handled when a class is initialised by passing them as lists of corners:

Env = Environment(params={'boundary':[[0,-0.2],[0,0.2],[1.5,0.5],[1.5,-0.5]]})

trapezium

Env = Environment(params={
    'aspect':1.8,
    'holes' : [[[0.2,0.2],[0.8,0.2],[0.8,0.8],[0.2,0.8]],
               [[1,0.2],[1.6,0.2],[1.6,0.8],[1,0.8]]]
})

fig_of_eight

Nb. polygons must be "simple" (not self intersecting, no holes) and holes must be non-intersecting.