This PR has two enhancements for the read_mef_session_metadata, read_mef_channel_metadata and read_mef_segment_metadata functions:
Finishes the implementation of the map_indices_flag. This optional argument was already present but did not do anything, now it does.
It adds an additional optional argument (copy_metadata_to_dict) to copy the metadata solely into standard python dictionaries and return that to the user; instead of returning a dictionary that often branches into numpy structured array objects that have pointers to underlying C data.
With the copy_metadata_to_dict option set to true, the data is copied into python objects that own their own data while the complete session/channel/segment is cleared in c. This has the advantage that no separate call to C is required to empty the struct that underlies the returned object. The returned python object can just be deleted(or None'ed) which frees all the data.
To ensure backward compatibility, the copy_metadata_to_dict options is False by default, mapping to numpy structured array objects using exactly the same routines that were always there.
The dictionaries have the exact same keys as the numpy structured arrays. So for example:
session_md['session_specific_metadata']['number_of_video_channels']
will work for both ndarrays (copy_metadata_to_dict=False) as with dictionaries (copy_metadata_to_dict=True)
An addition advantage of copy_metadata_to_dict is that it makes inspection of the structure slightly easier:
ndarray:
dict:
Hope these enhancements are acceptable
@cimbi I'll do one last PR after this one to see if I can fix Tom his issue, thanks!!
Hi!
This PR has two enhancements for the
read_mef_session_metadata
,read_mef_channel_metadata
andread_mef_segment_metadata
functions:Finishes the implementation of the
map_indices_flag
. This optional argument was already present but did not do anything, now it does.It adds an additional optional argument (
copy_metadata_to_dict
) to copy the metadata solely into standard python dictionaries and return that to the user; instead of returning a dictionary that often branches into numpy structured array objects that have pointers to underlying C data.With the
copy_metadata_to_dict
option set to true, the data is copied into python objects that own their own data while the complete session/channel/segment is cleared in c. This has the advantage that no separate call to C is required to empty the struct that underlies the returned object. The returned python object can just be deleted(or None'ed) which frees all the data.To ensure backward compatibility, the
copy_metadata_to_dict
options is False by default, mapping to numpy structured array objects using exactly the same routines that were always there.The dictionaries have the exact same keys as the numpy structured arrays. So for example: session_md['session_specific_metadata']['number_of_video_channels'] will work for both ndarrays (copy_metadata_to_dict=False) as with dictionaries (copy_metadata_to_dict=True)
An addition advantage of copy_metadata_to_dict is that it makes inspection of the structure slightly easier: ndarray: dict:
Hope these enhancements are acceptable @cimbi I'll do one last PR after this one to see if I can fix Tom his issue, thanks!!
Best, Max