Loss of numpy append_field functionality
LoganJF opened this issue · 7 comments
LoganJF commented
LoganJF commented
mivade commented
Possibly relevant: https://stackoverflow.com/a/42373715/6628184
mivade commented
LoganJF commented
Okay I uploaded them (https://gist.github.com/LoganJF/034adbea7ef12a2e2e9871a12871e6da) can you view them?
mivade commented
Yes. Thanks!
mivade commented
The problem is that the stim_params
field in the JSON events is itself a Python dict. This was a poor design choice when the JSON events were defined that we are now unfortunately stuck with. If you create a subset of events which omits stim_params
, you can append fields without issues.
Example:
ra = np.rec.array(json_events)
names = [name for name in ra.dtype.names if name not in ['stim_params']]
ra2 = ra[names]
append_fields(base=ra2, names='new_field', data=data_values, dtypes=ra2.mstime.dtype)