baccuslab / pyret

Python tools for analysis of neurophysiology data
https://pyret.readthedocs.io/en/master/
MIT License
35 stars 8 forks source link

Custom classes for filters #60

Closed nirum closed 8 years ago

nirum commented 9 years ago

OK, this is a new feature I want to add which is a bit complicated and will require shaking some things up. This issue is here to get feedback to see if this is something people want or would find useful.

I want to create a custom Filter class that subclasses from np.ndarray. Currently, we treat filters as numpy arrays which get passed around to the different functions in pyret (such as viz.plotsta, viz.decompose, etc.)

Having a custom Filter class would then wrap lots of the functions that require a filter-like object. We could pass other metadata when we instantiate the filter (such as time steps and spatial pixel sizes), which would simplify other function calls.

I'll make a quick version of this in a separate branch, but let me know if you have thoughts

Potential sample code:

from pyret.containers import Filter
import pyret.filtertools as ft

# build the Filter object
arr = ft.getsta(time, stim, spikes, filter_length)
sta = Filter(arr, dt=1e-3, dx=0.1, dy=0.1)

# plot the sta with appropriate time axes
sta.plot()

# animation
sta.play()

# convolve with a stimulus
sta.convolve(stim)
nirum commented 8 years ago

Closed in 04e87dd0d7ba036e742f1903065a5d0a3c098584

:smiley_cat: