-
Notifications
You must be signed in to change notification settings - Fork 12
Home
Christian Kellner edited this page Jul 31, 2013
·
14 revisions
How to list all entities in a file called maoli01.mcd
:
import neuroshare as ns
fd = ns.File('maoli01.mcd')
for idx, entity in enumerate(fd.entities):
print('%04d: "%s" [type: %d]' % (idx, entity.label, entity.entity_type))
This will produces the following output:
0000: "trig0001 0000 0000 trig0001" [type: 1]
0001: "elec0001 0000 0000 01" [type: 2]
0002: "elec0001 0001 0001 02" [type: 2]
0003: "elec0001 0002 0002 03" [type: 2]
[...]
analog1 = fd.entities[1] #access the entity 1
data = analog1.get_data() #get all the raw data
The data
value is a tuple
which contains the raw data and the timestamps for each datapoint.
It is also possible to retrieve a subset of the available data:
data = analog1.get_data(100, 10) #fetch 10 elements starting at index 100
print("%d" % data[0].shape)
# -> 10
print (data[0])
# ->
# [ 8.50000000e-05 7.00000000e-05 2.16666667e-05 3.16666667e-05
# 3.66666667e-05 0.00000000e+00 -5.50000000e-05 -9.33333333e-05
# -6.66666667e-05 3.33333333e-06]
Metadata is exposed as properties of the individual entities:
print(analog1.units)
# -> 'V'
print(analog1.sample_rate)
# -> 25000.0