diff --git a/doc/source/example/comparing/ridf.py b/doc/source/example/comparing/ridf.py new file mode 100644 index 0000000000000000000000000000000000000000..a52ffb0c3464584ca3068b646062944a49deceb5 --- /dev/null +++ b/doc/source/example/comparing/ridf.py @@ -0,0 +1,33 @@ +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() diff --git a/navipy/comparing/__init__.py b/navipy/comparing/__init__.py index a871b809565e865f0d88376fd0a84906cb90d40d..e33ae9059e0c986705006cc285315ebfd125c282 100644 --- a/navipy/comparing/__init__.py +++ b/navipy/comparing/__init__.py @@ -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\ diff --git a/todo b/todo index e54bfd07a7f7d3a9a780c43bf633619a486fd2a3..c072d18683019c20eb97c925d53b2bde322c3c9a 100644 --- a/todo +++ b/todo @@ -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