help with Python & Numpy (yes a noob!)

241 views
Skip to first unread message

Jay Vargas

unread,
Jan 22, 2016, 6:32:54 PM1/22/16
to pupil-discuss
Hello everyone - Just was seeking some assistance on how to extract data from the "pupil_positions.npy" and similar files the system produces. A bit about my build, I have the Pupil Pro headset with binocular 120Hz eye cameras and it seems to be working fine on a Windows 7 machine that has dual boot Ubuntu 14.04 LTS.

On a second windows machine (windows 7, 64 bit) I am attempting to use Python for the very first time to look at the data. The text below is what I am doing, VERY basic, just trying to open the pupil data file. Until I can get better at using this software, my goal is just to convert it to .csv file so I can manipulate in excel or matlab even (yes, I know how to do one or two things in that) ha!

I took the .npy file from the Ubuntu system and put it on the desktop of the system with Python and Numpy installed. I am not quite certain how to set the directory, or similar, like I remember in matlab. So I just placed the "pupil_positions.npy" file on my desktop. I would like to see the data, maybe plot it in numpy, but ultimately save as .cvs.

Any hep would be greatly appreciated!

Thanks,
Jay


Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import numpy as np
>>> np.__version__
'1.8.1'
>>> pupil_positions =np.load("pupil_positions.npy")
print p[:,5]
SyntaxError: multiple statements found while compiling a single statement
>>> pupil_positions =np.load("pupil_positions.npy")
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    pupil_positions =np.load("pupil_positions.npy")
  File "C:\Python34\lib\site-packages\numpy\lib\npyio.py", line 370, in load
    fid = open(file, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'pupil_positions.npy'
>>> 

Pupil Labs Info

unread,
Jan 22, 2016, 9:32:34 PM1/22/16
to pupil-...@googlegroups.com
Hi Jay, 

You're almost there -- you just need to either specify the full path to the numpy file or run python from within directory where the file is located. 

Specifying the full path to the file - I believe that the desktop path for Windows is: `C:\Users\(username)\Desktop\(filename.npy) -- just replace the items in parens with your values and the file should be loaded. So the np.load line should read: 

pupil_positions = np.load("C:\Users\YourUserName\Desktop\pupil_positions.npy") 

I hope this helps :)

Best, 
_w

--
You received this message because you are subscribed to the Google Groups "pupil-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pupil-discus...@googlegroups.com.
To post to this group, send email to pupil-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pupil-discuss/f7b3bd02-8434-4306-84ea-b07642cb298a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Pupil Labs
research + development + design

Jay Vargas

unread,
Jan 23, 2016, 12:59:58 AM1/23/16
to pupil-discuss
Thanks Will!

So I actually had given that a shot, and got this:

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import numpy as np
>>> pupil_positions = np.load("C:\Users\Jay Vargas\Desktop\pupil_positions.npy")
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
>>> import numpy as np
>>> pupil_positions = np.load("C:\Users\Jay Vargas\Desktop\pupil_positions.npy")

Jay Vargas

unread,
Jan 23, 2016, 7:41:56 PM1/23/16
to pupil-discuss
Hello again, just wanted to follow up on this SIMPLE task! I could not get anything loaded or saved until I used two backslashes, I have no idea why (see below). I am very excited about my new coding abilities! =)

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import numpy as np
>>> pupil_positions = np.load("C:\\Users\\Jay Vargas\\Desktop\\pupil_positions.npy")
>>> np.savetxt("C:\\Users\\Jay Vargas\\Desktop\\pupil_positions.csv", pupil_positions, delimiter=",")

Pupil Labs Info

unread,
Jan 24, 2016, 4:04:11 AM1/24/16
to pupil-...@googlegroups.com
Hi Jay, 

Sorry - about the incomplete/untested example. The double backslash `\\` is required because the `\` is an escape character in Python. 

I think you can just use the forwardslash `/` instead and Python will take care of it for your OS (Windows). Again, untested as I do not have Windows on the machine I am using at the moment, but you should also be able to write: "C:/Users/Jay Vargas/Desktop/pupil_positions.csv"

Best, 
_w


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages