ioam / topographica

A general-purpose neural simulator focusing on topographic maps.
topographica.org
BSD 3-Clause "New" or "Revised" License
53 stars 32 forks source link

Using notebook : a error of measure_sine_pref() when running gcal model in the notebook #623

Closed dancehours closed 9 years ago

dancehours commented 9 years ago

In [31]: from topo.command.analysis import measure_sine_pref measure_sine_pref()['V1']['OrientationPreference'].top

100% measurement progress 00:00:12

KeyError Traceback (most recent call last)

in () 1 from topo.command.analysis import measure_sine_pref ----> 2 measure_sine_pref()['V1']['OrientationPreference'].top /home/wenqi/env/topographica/external/holoviews/holoviews/core/layout.pyc in **getitem**(self, key) 465 raise KeyError('Index %s is outside available item range' % str(key)) 466 key = keys[idx] --> 467 return super(Layout, self).**getitem**(key) 468 469 /home/wenqi/env/topographica/external/holoviews/holoviews/core/tree.pyc in **getitem**(self, identifier) 169 return self.**dict**[identifier] 170 else: --> 171 raise KeyError(identifier) 172 path_item = self 173 for identifier in split_label: KeyError: 'V1'
dancehours commented 9 years ago

Also, I can't find the class of measure_sine_pref defined in the "analysis.py" of the file"command"of the file"topo". Why, please ?

jbednar commented 9 years ago

measure_sine_pref and measure_or_pref can be imported from featuremapper.command; they are part of the FeatureMapper project, no longer Topographica itself. If that's not enough to fix the problem above, please provide more context so that we can see what you are doing. In particular, please separate the measure_sine_pref call from indexing it with ["V1"], showing what's being returned by measure_sine_pref before trying to index it.

dancehours commented 9 years ago

Thanks for answering. Version of topographica : installed in April 28th ,2015 Running : the "gcal.ipynb" file in the notebook Error : appeared when I run the last command in this page, In [ ]: from topo.command.analysis import measure_sine_pref measure_sine_pref()['V1']['OrientationPreference'].top

just the same as showed above

dancehours commented 9 years ago

In addition, I can from topo.command.analysis import measure_sine_pref and measure_or_pref in the notebook, even I can not find they are defined in the "analysis.py" of the file"command"of the file"topo". I am confused by this.

philippjfr commented 9 years ago

Which gcal.ipynb are you running? Have a look at the GCAL Tutorial and GCAL Collector notebooks. Those HTML snapshots are slightly outdated (I'll be updating them later today/tomorrow), but the latest and working ipynb files are available here or in topographica/doc/Tutorials if you have a local copy of the git repository. The return type for measure_sine_pref has changed in more recent versions of topographica and featuremapper. This import:

from topo.command.analysis import measure_sine_pref

is simply a legacy alias, to allow importing of the measurement commands. They have since moved to ioam/featuremapper. All the measurement commands now return a holoviews Layout, which displays all the measured preferences and selectivities:

preferences = measure_sine_pref()
preferences.display('all')

and allows attribute access of the individual measurements, e.g.:

preferences.OrientationPreference.V1
dancehours commented 9 years ago

thanks for answering my question. I installed topographica using git about 5 days ago. Today I tested the"ipynb" files in topographica/doc/Tutorials as you mentioned, but there are also some commands I can't run, are you sure they can work ? Actually I am confused by these issues, about 1 month ago I started to use topographica, but I usually encounter these kinds of problems, I have installed many times using both of pip and git, now I am using the installed version by git following the instructions in https://github.com/wenqi2015/topographica. I don't know which way to install it can make it works well.

Also thanks for telling me the movement of measurement commands, now I am learning them,:).

jbednar commented 9 years ago

Topographica is under very active development at the moment, but unfortunately we have not recently made a public release. If you use the previous release 0.9.8, it should work, but it will be missing many features, and the code involved has changed so much since then that it's hard for us to recommend that you use that. Unfortunately, the latest git code changes every day right now, and has been getting out of sync with the changes to the underlying libraries it is based on (primarily HoloViews, and to some extent FeatureMapper and ImaGen). Thus if Philipp mentions that something should work, he's referring to the latest git version, not something 5 days ago. You should do a "git pull" and try again, just before reporting any problems, because that way we will know it's a current problem. As it is, you probably got a copy of Topographica from a period when we were working on HoloViews and breaking some things in Topographica, and before we fixed Topographica to match the changes. Sorry it's hard to keep up right now!

dancehours commented 9 years ago

Thank you and philippjfr very much! With your reminds, I installed the newer version and indeed, the tutorials work well except 2 tiny errors I found and solved. Anyway, I should say sorry for reporting errors without doing the last step. Also, thanks for sharing so fantastic Topographica with us !

jbednar commented 9 years ago

No problem; glad it's useful!