Skip to content
Snippets Groups Projects
Commit d8e95281 authored by Olivier Bertrand's avatar Olivier Bertrand
Browse files

Add example on navipy

parent 99775986
No related branches found
No related tags found
No related merge requests found
import numpy as np
import matplotlib.pyplot as plt
from navipy.database import DataBaseLoad
from navipy.comparing import rot_imagediff
import pkg_resources
# 1) Connect to the database
mydb_filename = pkg_resources.resource_filename(
'navipy', 'resources/database.db')
mydb = DataBaseLoad(mydb_filename)
# 2) Define the position-orinetation at which
# we want the image and get the scene
rowid = 12
my_scene_memory = mydb.scene(rowid=rowid)
rowid = 1
my_scene_current = mydb.scene(rowid=rowid)
# Calculate image rot diff
rotdf = rot_imagediff(my_scene_current, my_scene_memory)
rotdf = np.roll(rotdf, 180, axis=0)
f, axarr = plt.subplots(1, 2, figsize=(15, 4))
for chan_i, chan_n in enumerate(mydb.channels):
if chan_n == 'D':
color = 'k'
ax = axarr[1]
else:
color = chan_n
ax = axarr[0]
ax.plot(rotdf[:, chan_i], color=color)
f.show()
......@@ -48,9 +48,6 @@ the current and memorised place code
:returns: the image difference
:rtype: float #array(1,4) for ibpc and float for obpc
..ref: Zeil, J., 2012. Visual homing: an insect perspective.
Current opinion in neurobiology
"""
simple_diff = simple_imagediff(current, memory)
diff = np.power(simple_diff, 2)
......@@ -76,6 +73,10 @@ the current and memorised place code.
..note: assume that the image is periodic along the x axis
(the left-right axis)
.. literalinclude:: example/comparing/ridf.py
:lines: 4,20
.. plot:: example/comparing/ridf.py
"""
if not is_ibpc(current): # and not is_obpc(current):
raise TypeError('The current and memory place code\
......
......@@ -32,40 +32,4 @@
3. Ring-attractor (Goldschmidt 2017)
4. Ring-attractor (Stone 2017)
------------------------------------------------------
Are those below still to do ?
------------------------------------------------------
0003: Improve database
In the init database I would like to use class properties instead of get/read
line: 263,273,and 394
def create(self)
should be replaced by:
@property
def create(self)
It implies that at every point that self.create() is called should be changed to self.create [Note the absence of parenthesis]
line: 298
def get_posorients(self)
should be replaced by
@property
def posorients(self)
Need to propagate the changes through all the code (see rendering / processing / moving )
Should be done, but maybe I missed something?
------------------------------------------------------
0005: Write test function for raise Error
- for every raise error create a test function, checking that the error is correctly thrown (see moving/test_agent for inspiration)
also should be done. But I did not add any more checks to the moving part, shall I check for additional possible checks?
--------------------------------------------------------------------
0009: can the last dimension (4) of the place-code be greater 1? (should be 1)
Yes it can, see apcv a [1x1x1x3] array
0010: what is the image in the database? must it be transformed to a a scene?
The image is an image, and distance the distance. I added scene as a join image+distance array
now we do not have a read_image function in database anymore, is it supposed to be like this?
0005: Change output of comparing to be consistent with place code
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment