-
Notifications
You must be signed in to change notification settings - Fork 24
place fields #126
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
Open
MRScheid
wants to merge
49
commits into
master
Choose a base branch
from
place_field
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
place fields #126
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
60f1c75
Initial code draft
9e9c7c3
place fields almost working
bendichter 4ff6a58
Merge branch 'master' into place_field
bendichter b752882
interactive widget working
bendichter 8d5f754
interactive widget working
bendichter 50e284c
NaN out unexplored territory
bendichter 03f617b
1D place code widget
09e0669
1D place code widget working
c346a60
nelpy package integrated into 1D rate map widget
2e92ed4
1D rate map speed threshold implementation
7b48dc0
1D rate map normalization and collapsed view feature addition
ece7795
- Added Numpy docstring for plot_tuning_curves1D fxn
07a7ae7
Removed nelpy dependency
7f8a790
Moved analysis code to analysis/placefields.py
6fd92c1
Merge branch 'master' into place_field
bendichter 55611dd
Dynamically route rate maps to correspond to dimensionality of the data
d0ff81b
Merge branch 'place_field' of https://github.com/NeurodataWithoutBord…
4c414fa
Merge branch 'master' into place_field
bendichter 8b3bbad
Merge branch 'master' into place_field
bendichter 0ff0037
Add optional TimeSeries of velocity as input
81c40b2
Update nwbwidgets/placefield.py
MRScheid 2601b86
Update nwbwidgets/placefield.py
MRScheid 7290f00
Update nwbwidgets/placefield.py
MRScheid 33f3c70
Update nwbwidgets/placefield.py
MRScheid 0f77f2d
Update nwbwidgets/placefield.py
MRScheid 45ae3ec
Update nwbwidgets/placefield.py
MRScheid c7b0208
Update nwbwidgets/placefield.py
MRScheid fdb0d5b
Corrected velocity as optional input
69bc054
Cleaned up code, fixed single unit input bug
866236a
Merge branch 'master' into place_field
bendichter 6fbd006
Removed group and sort controller. Added multi-select.
9dab486
* lru_cache
bendichter 52d1706
correct index and cache
bendichter 84e87aa
style and caching some analyses
bendichter 6bb219e
Place field modification for towers task.
85dc581
Merge remote-tracking branch 'origin/place_field' into place_field
43080e8
Place field modification for towers task.
c365f2b
Fixed the "TypeError: unhashable type: 'numpy.ndarray" issue that aro…
194f457
Remove group and sort controller import
2624add
Re-factor code
d6905bc
Allow for different pixel width in x and y dimension
04cca71
Changes to accomodate towers task place field
6c68ddf
Added bin number control
3b7863d
Merge branch 'master' into place_field
MRScheid 6e3c1b1
Simple formatting
d259182
Merge branch 'place_field' of https://github.com/NeurodataWithoutBord…
c9fa416
Update imports
c4cc8f6
Merge branch 'master' into place_field
MRScheid 87a2433
Removed old ignore files
MRScheid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,33 +3,41 @@ | |||||
| from scipy.ndimage.filters import gaussian_filter, maximum_filter | ||||||
|
|
||||||
| import matplotlib.pyplot as plt | ||||||
| import nelpy.plotting as nlp | ||||||
|
|
||||||
| import pynwb | ||||||
| from ipywidgets import widgets, BoundedFloatText, Dropdown | ||||||
|
|
||||||
|
|
||||||
| from .utils.widgets import interactive_output | ||||||
| from .utils.units import get_spike_times | ||||||
| from .utils.timeseries import get_timeseries_in_units, get_timeseries_tt | ||||||
| from .base import vis2widget | ||||||
|
|
||||||
| import plotly.graph_objects as go | ||||||
|
|
||||||
|
|
||||||
| ## To-do | ||||||
| # [] Create PlaceFieldWidget class | ||||||
| # [X] Refactor place field calculation code to deal with nwb data type | ||||||
| # [X] Incorporate place field fxns into class | ||||||
| # [X] Change all internal attributes references | ||||||
| # [X]Change all internal method references | ||||||
|
|
||||||
| # [X] Get pos | ||||||
| # [X] Get time | ||||||
| # [X] Get spikes | ||||||
| # [] Get trials / epochs | ||||||
| # [X] Create PlaceFieldWidget class | ||||||
| # [X] Refactor place field calculation code to deal with nwb data type | ||||||
| # [X] Incorporate place field fxns into class | ||||||
| # [X] Change all internal attributes references | ||||||
| # [X]Change all internal method references | ||||||
|
|
||||||
| # [X] Get pos | ||||||
| # [X] Get time | ||||||
| # [X] Get spikes | ||||||
| # [] Get trials / epochs | ||||||
|
|
||||||
| # [X] Submit draft PR | ||||||
|
|
||||||
| # [] 1D Place Field Widget | ||||||
| # [X] Incorporate nelpy package into widget | ||||||
| # [] Add foreign group and sort controller to pick unit groups and ranges? | ||||||
| # [] Normalized firing rate figure? | ||||||
| # [] Add collapsed unit vizualization? | ||||||
| # [] Scale bar? | ||||||
| # [] Sort place cell tuning curves by peak firing rate position? | ||||||
| # [] Color palette control? | ||||||
|
|
||||||
| # [] Submit draft PR | ||||||
|
|
||||||
| # [] Modify plotly_show_spatial_trace to plot 2D heatmap representing place fields or create new figure function? | ||||||
| # [] Dropdown that controls which unit | ||||||
|
|
||||||
| # [x] Work in buttons / dropdowns / sliders to modify following parameters in place field calculation: | ||||||
|
|
@@ -395,9 +403,18 @@ def compute_linear_firing_rate(pos, pos_tt, spikes, gaussian_sd=0.0557, | |||||
| class PlaceField_1D_Widget(widgets.HBox): | ||||||
|
|
||||||
| def __init__(self, spatial_series: pynwb.behavior.SpatialSeries, **kwargs): | ||||||
| # foreign_group_and_sort_controller: GroupAndSortController = None, | ||||||
| # group_by=None, | ||||||
|
|
||||||
| super().__init__() | ||||||
|
|
||||||
| # if foreign_group_and_sort_controller: | ||||||
| # self.gas = foreign_group_and_sort_controller | ||||||
| # else: | ||||||
| # self.gas = self.make_group_and_sort(group_by=group_by, control_order=False) | ||||||
|
|
||||||
| self.units = spatial_series.get_ancestor('NWBFile').units | ||||||
|
|
||||||
| self.pos_tt = get_timeseries_tt(spatial_series) | ||||||
|
|
||||||
| istart = 0 | ||||||
|
|
@@ -417,7 +434,7 @@ def __init__(self, spatial_series: pynwb.behavior.SpatialSeries, **kwargs): | |||||
| self.controls = dict( | ||||||
| gaussian_sd=bft_gaussian, | ||||||
| spatial_bin_len=bft_spatial_bin_len, | ||||||
| index=dd_unit_select | ||||||
| # index=dd_unit_select | ||||||
| ) | ||||||
|
|
||||||
| out_fig = interactive_output(self.do_1d_rate_map, self.controls) | ||||||
|
|
@@ -426,25 +443,95 @@ def __init__(self, spatial_series: pynwb.behavior.SpatialSeries, **kwargs): | |||||
| widgets.VBox([ | ||||||
| bft_gaussian, | ||||||
| bft_spatial_bin_len, | ||||||
| dd_unit_select | ||||||
| # dd_unit_select | ||||||
| ]), | ||||||
| vis2widget(out_fig) | ||||||
| ] | ||||||
|
|
||||||
| def do_1d_rate_map(self, index=0, gaussian_sd=0.0557, spatial_bin_len=0.0168): | ||||||
| def do_1d_rate_map(self, gaussian_sd=0.0557, spatial_bin_len=0.0168): | ||||||
| tmin = min(self.pos_tt) | ||||||
| tmax = max(self.pos_tt) | ||||||
|
|
||||||
| spikes = get_spike_times(self.units, index, [tmin, tmax]) | ||||||
| index = np.arange(len(self.units)) | ||||||
|
|
||||||
| spikes = get_spike_times(self.units, index[0], [tmin, tmax]) | ||||||
| xx, occupancy, filtered_firing_rate = compute_linear_firing_rate( | ||||||
| self.pos, self.pos_tt, spikes, gaussian_sd=gaussian_sd, spatial_bin_len=spatial_bin_len) | ||||||
|
|
||||||
| fig, ax = plt.subplots() | ||||||
| all_unit_firing_rate = np.zeros([len(self.units), len(xx)]) | ||||||
| all_unit_firing_rate[0] = filtered_firing_rate | ||||||
|
|
||||||
| fig = ax.plot(xx, filtered_firing_rate, '-') | ||||||
| ax.set_xlabel('x ({})'.format(self.unit)) | ||||||
| ax.set_ylabel('firing rate (Hz)') | ||||||
| for ind in index[1:]: | ||||||
| spikes = get_spike_times(self.units, ind, [tmin, tmax]) | ||||||
| _, _, all_unit_firing_rate[ind] = compute_linear_firing_rate( | ||||||
| self.pos, self.pos_tt, spikes, gaussian_sd=gaussian_sd, spatial_bin_len=spatial_bin_len) | ||||||
|
|
||||||
| # npl.set_palette(npl.colors.rainbow) | ||||||
| # with npl.FigureManager(show=True, figsize=(8, 8)) as (fig, ax): | ||||||
| # npl.utils.skip_if_no_output(fig) | ||||||
| fig, ax = plt.subplots() | ||||||
|
||||||
| fig, ax = plt.subplots() | |
| fig, ax = plt.subplots(figsize=(7,7)) |
MRScheid marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
MRScheid marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.