This is a somewhat long feature request.
I'm really excited about these packages and I think it's a major step in the right direction for getting plotting functions of neural time-series data. However, I think the current API is severely limited, especially with respect to the features
and conditions
arguments.
I would love to see an API which bears more similarity to @mwaskom's seaborn.
Seaborn's plotting functionality is amazing. For pretty much all of seaborn's plotting functions, you pass in a pandas dataframe as well as the column names you want plotted against each other. Then, you can split the data into colors by passing a column name for the hue
argument, or break out the plot into an array of subplots where each col/row is defined according to a different factor.
The utility of this approach is more clear looking at the factorplot examples: https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.factorplot.html
Since I use seaborn extensively for data exploration already, wrote up a few functions that wrap the neurovis plotting functions in something more seaborn-like so you can see what I mean. Here's a notebook that demonstrates (a) getting the features and conditions into a friendly pandas dataframe and (b) plotting with seaborn style.
https://gist.github.com/neuromusic/f6fe2c5d7c1101811b5cd497b98a516c
Currently, by treating features
and conditions
as separate arguments, neurovis is incredibly limited. For one, the dictionary format of the conditions
is not intuitive. Second, it's hard to compute complex conditions from the dictionary format that is currently used -- it seems largely limited to performing "AND" operations between factors and only filtering factors with ranges. It is better, I think, to let the user use pandas to construct factors with whatever logic they want.
In my above example, I only used "hue" since neurovis already supports this. Along with fixing #22, it would not be too hard to add a col
or row
factor. Then, in my example in the gist above, one could quickly plot the same plot as above but breaking out plots for correct and incorrect trials into rows like so...
trials = events_df[(events_df['GoodTrials']==True)]
# plot the PSTH
psthplot('RealCueTimes',trials,
spike_times,nid=neuron_n,
hue='response',
row='correct',
window=window,
binsize=100)
One could also then also address #42 and/or other PSTH-like computations (e.g. gaussian kernels, poisson GLM models, etc) by setting a style
argument or passing in some standardized estimation function.
See also seaborn's tsplot function https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.tsplot.html and discussion on it's future: mwaskom/seaborn#896