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

graph to_json doesn't save enough arguments to reload Transformer with required arguments #396

Open
adelavega opened this issue May 7, 2020 · 1 comment
Labels

Comments

@adelavega
Copy link
Member

adelavega commented May 7, 2020

Here's a simple example of a Pliers Graph

nodes = [
    (FrameSamplingFilter(every=10),
         ['BrightnessExtractor']),
    (STFTAudioExtractor(freq_bins=[(100, 300)]))
]

and it outputs this JSON:

g.to_json()
>{'roots': [{'transformer': 'FrameSamplingFilter',
   'children': [{'transformer': 'BrightnessExtractor'}]},
  {'transformer': 'STFTAudioExtractor'}]}

However, this same JSON cannot initialize a Graph object:

Graph(nodes=j)
>ValueError: When initializing the FrameSamplingFilter, one of the 'every', 'hertz', or 'top_n' must be specified.

This is because the JSON does not specify the arguments that were originally passed into FrameSamplingFilter.

The reason I'm asking is I'm trying to implement the ability to extract Graphs in Neuroscout (current we only do one extractor at a time, and I have my own JSON notation for specifying arguments to Extractors).

I think it would make more sense to exploit the fact that pliers already has a JSON format for specifying sequences of extractors, and simply load the graph from JSON and transform the stimuli.

Is this a bug or am I missing something?

@adelavega
Copy link
Member Author

I spoke too soon as usually, obviously you can pass arguments in the JSON

j ={'roots': [{'transformer': 'FrameSamplingFilter', 'parameters': {'every': 10},
   'children': [{'transformer': 'BrightnessExtractor'}]},
  {'transformer': 'STFTAudioExtractor'}]}

I think the issue then is more than to_json doesn't save arguments, which possibly it doesn't because it might be too explicit, but then it leads to this weird asymetry

@adelavega adelavega changed the title how to specifiy arguments for extractors in Graph json graph to_json doesn't save enough arguments to reload Transformer with required arguments May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant