Closed BCIstorm closed 5 years ago
You're using the old Pupil plugin. The new one here has completely different structure.
But I guess you still have some data files using the old structure that you need to analyze. The old plugin made several streams. One of them, like the one you show here, has each sample is a python object encoded in a string. This is a bit difficult to work with because you first have to decode it (I don't think it's regular JSON but maybe). One of the other streams should have a representation of the data that is easier to work with. I think the streams you want have names like 'Pupil Primitive Data - Eye 0' and Eye 1.
This may be a beginner question... I'm trying to read a XDF in Python 2.7.14. Based on the provided example by pyxdf, I get 9 streams for a file recorded in LabRecorder.
In Python, each of these streams in a
dict
with 4 elements: 'footer', 'info', 'time_series' and 'time_stamps'. In this case,time_series
is alist
of size 91476:In[74]: type(streams[5]['time_series'][0])
Out[74]: list
In[75]: type(streams[5]['time_series'][0][0])
Out[75]: unicode
The first element of the list is:
In[76]: streams[5]['time_series'][0]
Out[76]: [u"{'topic': 'pupil.0', 'circle_3d': {'center': [-2.3497767498603004, 2.654025112890184, 65.72036350503458], 'normal': [-0.36184812409195516, 0.2045810554549084, -0.9095122466685583], 'radius': 2.5317374778936554}, 'confidence': 0.5710644240694664, 'timestamp': 163227.772341, 'diameter_3d': 5.063474955787311, 'ellipse': {'center': [138.12961511213774, 144.87301244823018], 'axes': [42.43878278862324, 47.78052690005625], 'angle': -31.2436050134567}, 'norm_pos': [0.43165504722543047, 0.3963624481323742], 'diameter': 47.78052690005625, 'sphere': {'center': [1.9924007392431637, 0.19905244743128203, 76.63451046505729], 'radius': 12.0}, 'projected_sphere': {'center': [176.11921901548533, 121.61040393757936], 'axes': [194.16839632302174, 194.16839632302174], 'angle': 90.0}, 'model_confidence': 0.2126201167521935, 'model_id': 198, 'model_birth_timestamp': 163208.737941, 'theta': 1.77683201806055, 'phi': -1.9494466265525878, 'method': '3d c++', 'id': 0}"]
Now, how can I access the
'ellipse': {'diameter'}
value of each element in the list?