Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_topoplot function error in PYTHONNET #25

Closed
STREETKILLER007 opened this issue Aug 15, 2018 · 2 comments
Closed

add_topoplot function error in PYTHONNET #25

STREETKILLER007 opened this issue Aug 15, 2018 · 2 comments
Labels

Comments

@STREETKILLER007
Copy link

STREETKILLER007 commented Aug 15, 2018

I trying to implement Visbrain in a c# program, using Visual Studio 2017 Community.

  • Using Anaconda3 5.2.0.
  • Window 7, 64 bit.
  • Python version
(py36) C:\Users\JamesTan\Desktop>python --version
Python 3.6.6 :: Anaconda, Inc.

Embedding python in c# by using Pythonnet.

below is my pip list

(py36) C:\Users\JamesTan\Desktop>pip list
Package         Version
--------------- ----------
certifi         2018.8.13
click           6.7
cycler          0.10.0
kiwisolver      1.0.1
matplotlib      2.2.3
mkl-fft         1.0.4
mkl-random      1.0.1
numpy           1.15.0
pandas          0.23.4
Pillow          5.2.0
pip             18.0
PyOpenGL        3.1.0
pyparsing       2.2.0
PyQt5           5.11.2
PyQt5-sip       4.19.12
python-dateutil 2.7.3
pythonnet       2.4.0.dev0
pytz            2018.5
scipy           1.1.0
setuptools      40.0.0
six             1.11.0
visbrain        0.4.2
vispy           0.5.3
wheel           0.31.1
wincertstore    0.2

Follow is the code :

using (Py.GIL())
{
                // import visbrain
                dynamic myVisbrain = Py.Import("visbrain");
                Console.WriteLine("hi visbrain");

                // import topo from Visbrain
                dynamic myTopo = myVisbrain.Topo();
                Console.WriteLine("hi topo");

                // Create a list of channels, data, title and colorbar label :
                dynamic myName = "Test";
                dynamic myTitle = "Basic topoplot illustration";
                dynamic myCblabel = "Colorbar label";
                dynamic myChannels = new List<String> { "C3", "C4", "Cz", "Fz", "Pz" };
                dynamic myData = new List<Double> { 10, 20, 30, 10, 10 };

                 // ERROR OCCURS HERE
                // Add a central topoplot :
                myTopo.add_topoplot(myName, myChannels, Py.kw("channels", myData), Py.kw("title", myTitle), Py.kw("cblabel", myCblabel));

                // show
               // myTopo.show();
}

error message :

Python.Runtime.PythonException: 'UnboundLocalError : local variable 'keeponly' referenced before assignment'

stack trace :

Python.Runtime.PythonException
  HResult=0x80131500
  Message=UnboundLocalError : local variable 'keeponly' referenced before assignment
  Source=Python.Runtime
  StackTrace:
['  File "d:\\Anaconda3\\envs\\py36\\lib\\site-packages\\visbrain\\topo\\topo.py", line 153, in add_topoplot\n    margin)\n', '  File "d:\\Anaconda3\\envs\\py36\\lib\\site-packages\\visbrain\\visuals\\TopoVisual.py", line 197, in __init__\n    auto = self._get_channel_coordinates(xyz, channels, system, unit)\n', '  File "d:\\Anaconda3\\envs\\py36\\lib\\site-packages\\visbrain\\visuals\\TopoVisual.py", line 388, in _get_channel_coordinates\n    if any(keeponly):\n']

Any idea on this issue ? Thank You.

@EtienneCmb
Copy link
Owner

GitMate.io thinks possibly related issues are #18 (Topo Error), #22 (Visbrain in Pythonnet), #12 (Brain import error), and #13 (Import error: cannot import _cntr).

@EtienneCmb EtienneCmb added the bug label Aug 15, 2018
@STREETKILLER007
Copy link
Author

STREETKILLER007 commented Aug 16, 2018

Ok, i realized that this error occur because i pass in variable by wrong sequence.

wrong sequence :

myTopo.add_topoplot(myName, myChannels, Py.kw("channels", myData), Py.kw("title", myTitle), Py.kw("cblabel", myCblabel));

correct sequence :

myTopo.add_topoplot(myName, myData, Py.kw("channels", myChannels), Py.kw("title", myTitle), Py.kw("cblabel", myCblabel));

Type in correct sequence works.

@EtienneCmb EtienneCmb added invalid and removed bug labels Aug 16, 2018
Repository owner locked as spam and limited conversation to collaborators Aug 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants