Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmatically find all the time series in any NWB file #560

Open
afonsobspinto opened this issue Jul 14, 2018 · 4 comments · May be fixed by #1737
Open

Programmatically find all the time series in any NWB file #560

afonsobspinto opened this issue Jul 14, 2018 · 4 comments · May be fixed by #1737
Labels
category: enhancement improvements of code or code behavior priority: low alternative solution already working and/or relevant to only specific user(s)
Milestone

Comments

@afonsobspinto
Copy link

Hello everyone.
I've been using your API to develop my GSoC project and one of my tasks was to find a way to programmatically find all the time series present in any NWB 2.x file.
I've tried to develop this as follows:

def _get_data_interfaces(self, node):
        """Given a NWBHDF5IO returns all the data_interfaces objects presents on it."""
        data_interfaces_list = []
        for child in node.children:
            if isinstance(child, NWBDataInterface):
                data_interfaces_list.append(child)
            data_interfaces_list += self._get_data_interfaces(child)
       return data_interfaces_list

def _get_timeseries(self):
        """Given all the nwb_data_interfaces returns all of those that are timeseries objects."""
        time_series_list = []
        for data_interface in self.nwb_data_interfaces_list:
            if isinstance(data_interface, TimeSeries):
                time_series_list.append(data_interface)
return time_series_list

I believe this returns all the TimeSeries objects, then I simply run over each one of them to get mono dimensional time series easily plottable:

def get_mono_dimensional_timeseries(self, values):
        """Given a timeseries object returns all mono dimensional timeseries presents on it."""
        mono_time_series_list = []
        if isinstance(values, collections.Iterable):
            try:
                data = [float(i) for i in values]
                mono_time_series_list.append(data)
            except:
                for inner_list in values:
                    mono_time_series_list += self.get_mono_dimensional_timeseries(inner_list)
return mono_time_series_list

I would like to get your opinion on this.
I wasn't able to find this feature in your API. Do you think it has any value? Would you do this any other way?
I understand that this is not a typical issue, so apologies in advance if it should be asked elsewhere. 🙏

@afonsobspinto afonsobspinto changed the title Programmatically find all the time series in the NWB file Programmatically find all the time series in any NWB file Jul 14, 2018
@bendichter
Copy link
Contributor

Hi @afonsobspinto, thanks for working on this. I know @ajtritt has been working on query functionality that looks a lot like this, but it's not finished/supported/documented. He may be able to point you in the direction of these tools so you can use them for your own work. In the meantime, keep hacking away!

@ajtritt
Copy link
Member

ajtritt commented Jul 16, 2018

hey @afonsobspinto, look at the getitem implementation on LabelledDict. I apologize for the lack of documentation--as @bendichter said, it's not finished.

def __getitem__(self, args):

@jezekp
Copy link

jezekp commented Jul 17, 2018

@afonsobspinto. Maybe The NWB query engine: https://github.com/jezekp/NwbQueryEngine could be useful too

@afonsobspinto
Copy link
Author

afonsobspinto commented Jul 17, 2018

Thanks guys. I'll take a look. 👍

@ajtritt ajtritt added this to the Future milestone Aug 20, 2018
@rly rly linked a pull request Jul 25, 2023 that will close this issue
7 tasks
@stephprince stephprince added category: enhancement improvements of code or code behavior priority: low alternative solution already working and/or relevant to only specific user(s) labels Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: enhancement improvements of code or code behavior priority: low alternative solution already working and/or relevant to only specific user(s)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants