|
7 | 7 |
|
8 | 8 | Preprocessing of the data was made with [Kilosort 2.0](https://github.com/MouseLand/Kilosort) and spike sorting was made with [Klusters](https://neurosuite.sourceforge.net/).
|
9 | 9 |
|
10 |
| -Instructions for installing pynapple can be found [here](https://pynapple-org.github.io/pynapple/#installation). |
| 10 | +Instructions for installing pynapple can be found [here](../../../installation). |
11 | 11 |
|
12 | 12 | ***
|
13 | 13 |
|
14 | 14 | This notebook is meant to provide an overview of pynapple by going through:
|
15 | 15 |
|
16 |
| -- **Input output (IO)**. In this case, pynapple will load a NWB file using the [NWBFile object](https://pynapple-org.github.io/pynapple/reference/io/interface_nwb/#pynapple.io.interface_nwb.NWBFile) within a project [Folder](https://pynapple-org.github.io/pynapple/reference/io/folder/) that represent a dataset. |
17 |
| -- **Core functions** that handle time series, interval sets and groups of time series. See this [notebook](https://pynapple-org.github.io/pynapple/generated/api_guide/tutorial_pynapple_core/) for a detailled usage of the core functions. |
18 |
| -- **Process functions**. A small collection of high-level functions widely used in system neuroscience. This [notebook](https://pynapple-org.github.io/pynapple/generated/api_guide/tutorial_pynapple_process) details those functions. |
| 16 | +- **Input output (IO)**. In this case, pynapple will load a NWB file using the [NWBFile object](../../../reference/io/interface_nwb/#pynapple.io.interface_nwb.NWBFile) within a project [Folder](../../../reference/io/folder/) that represent a dataset. |
| 17 | +- **Core functions** that handle time series, interval sets and groups of time series. See this [notebook](../../api_guide/tutorial_pynapple_core/) for a detailled usage of the core functions. |
| 18 | +- **Process functions**. A small collection of high-level functions widely used in system neuroscience. This [notebook](../../api_guide/tutorial_pynapple_process) details those functions. |
19 | 19 |
|
20 | 20 | """
|
21 | 21 |
|
|
63 | 63 |
|
64 | 64 |
|
65 | 65 | # %%
|
66 |
| -# We can load the session with the function [load_folder](https://pynapple-org.github.io/pynapple/reference/io/misc/#pynapple.io.misc.load_folder). Pynapple will walks throught the folder and collects every subfolders. |
| 66 | +# We can load the session with the function [load_folder](../../../reference/io/misc/#pynapple.io.misc.load_folder). Pynapple will walks throught the folder and collects every subfolders. |
67 | 67 | # We can use the attribute `view` or the function `expand` to display a tree view of the dataset. The treeview shows all the compatible data format (i.e npz files or NWBs files) and their equivalent pynapple type.
|
68 | 68 | data = nap.load_folder(DATA_DIRECTORY)
|
69 | 69 | data.view
|
70 | 70 |
|
71 | 71 | # %%
|
72 |
| -# The object `data` is a [`Folder`](https://pynapple-org.github.io/pynapple/reference/io/folder/) object that allows easy navigation and interaction with a dataset. |
| 72 | +# The object `data` is a [`Folder`](../../../reference/io/folder/) object that allows easy navigation and interaction with a dataset. |
73 | 73 | # In this case, we want to load the NWB file in the folder `/pynapplenwb`. Data are always lazy loaded. No time series is loaded until it's actually called.
|
74 | 74 | # When calling the NWB file, the object `nwb` is an interface to the NWB file. All the data inside the NWB file that are compatible with one of the pynapple objects are shown with their corresponding keys.
|
75 | 75 | nwb = data["sub-A2929"]["A2929-200711"]["pynapplenwb"]["A2929-200711"]
|
|
79 | 79 | # %%
|
80 | 80 | # We can individually call each object and they are actually loaded.
|
81 | 81 | #
|
82 |
| -# `units` is a [TsGroup](https://pynapple-org.github.io/pynapple/reference/core/ts_group/) object. It allows to group together time series with different timestamps and couple metainformation to each neuron. In this case, the location of where the neuron was recorded has been added when loading the session for the first time. |
| 82 | +# `units` is a [TsGroup](../../../reference/core/ts_group/) object. It allows to group together time series with different timestamps and couple metainformation to each neuron. In this case, the location of where the neuron was recorded has been added when loading the session for the first time. |
83 | 83 | # We load `units` as `spikes`
|
84 | 84 | spikes = nwb["units"]
|
85 | 85 | print(spikes)
|
|
90 | 90 | print(neuron_0)
|
91 | 91 |
|
92 | 92 | # %%
|
93 |
| -# `neuron_0` is a [Ts](https://pynapple-org.github.io/pynapple/reference/core/time_series/#pynapple.core.time_series.Ts) object containing the times of the spikes. |
| 93 | +# `neuron_0` is a [Ts](../../../reference/core/time_series/#pynapple.core.time_series.Ts) object containing the times of the spikes. |
94 | 94 |
|
95 | 95 | # %%
|
96 | 96 | # The other information about the session is contained in `nwb["epochs"]`. In this case, the start and end of the sleep and wake epochs. If the NWB time intervals contains tags of the epochs, pynapple will try to group them together and return a dictionary of IntervalSet instead of IntervalSet.
|
|
147 | 147 | # ***
|
148 | 148 | # Tuning curves
|
149 | 149 | # -------------
|
150 |
| -# Let's do a more advanced analysis. Neurons from ADn (group 0 in the `spikes` group object) are know to fire for a particular direction. Therefore, we can compute their tuning curves, i.e. their firing rates as a function of the head-direction of the animal in the horizontal plane (*ry*). To do this, we can use the function [`compute_1d_tuning_curves`](https://pynapple-org.github.io/pynapple/reference/process/tuning_curves/#pynapple.process.tuning_curves.compute_1d_tuning_curves). In this case, the tuning curves are computed over 120 bins and between 0 and 2$\pi$. |
| 150 | +# Let's do a more advanced analysis. Neurons from ADn (group 0 in the `spikes` group object) are know to fire for a particular direction. Therefore, we can compute their tuning curves, i.e. their firing rates as a function of the head-direction of the animal in the horizontal plane (*ry*). To do this, we can use the function [`compute_1d_tuning_curves`](../../../reference/process/tuning_curves/#pynapple.process.tuning_curves.compute_1d_tuning_curves). In this case, the tuning curves are computed over 120 bins and between 0 and 2$\pi$. |
151 | 151 |
|
152 | 152 | tuning_curves = nap.compute_1d_tuning_curves(
|
153 | 153 | group=spikes, feature=head_direction, nb_bins=121, minmax=(0, 2 * np.pi)
|
|
170 | 170 | plt.show()
|
171 | 171 |
|
172 | 172 | # %%
|
173 |
| -# While ADN neurons show obvious modulation for head-direction, it is not obvious for all CA1 cells. Therefore we want to restrict the remaining of the analyses to only ADN neurons. We can split the `spikes` group with the function [`getby_category`](https://pynapple-org.github.io/pynapple/reference/core/ts_group/#pynapple.core.ts_group.TsGroup.getby_category). |
| 173 | +# While ADN neurons show obvious modulation for head-direction, it is not obvious for all CA1 cells. Therefore we want to restrict the remaining of the analyses to only ADN neurons. We can split the `spikes` group with the function [`getby_category`](../../../reference/core/ts_group/#pynapple.core.ts_group.TsGroup.getby_category). |
174 | 174 |
|
175 | 175 | spikes_by_location = spikes.getby_category("location")
|
176 | 176 |
|
|
186 | 186 | # ------------
|
187 | 187 | # A classical question with head-direction cells is how pairs stay coordinated across brain states i.e. wake vs sleep (see Peyrache, A., Lacroix, M. M., Petersen, P. C., & Buzsáki, G. (2015). Internally organized mechanisms of the head direction sense. Nature neuroscience, 18(4), 569-575.)
|
188 | 188 | #
|
189 |
| -# In this example, this coordination across brain states will be evaluated with cross-correlograms of pairs of neurons. We can call the function [`compute_crosscorrelogram`](https://pynapple-org.github.io/pynapple/reference/process/correlograms/#pynapple.process.correlograms.compute_crosscorrelogram) during both sleep and wake epochs. |
| 189 | +# In this example, this coordination across brain states will be evaluated with cross-correlograms of pairs of neurons. We can call the function [`compute_crosscorrelogram`](../../../reference/process/correlograms/#pynapple.process.correlograms.compute_crosscorrelogram) during both sleep and wake epochs. |
190 | 190 |
|
191 | 191 | cc_wake = nap.compute_crosscorrelogram(
|
192 | 192 | group=spikes_adn,
|
|
240 | 240 | # This last analysis shows how to use the pynapple's decoding function.
|
241 | 241 | #
|
242 | 242 | # The previous result indicates a persistent coordination of head-direction cells during sleep. Therefore it is possible to decode a virtual head-direction signal even if the animal is not moving its head.
|
243 |
| -# This example uses the function [`decode_1d`](https://pynapple-org.github.io/pynapple/reference/process/decoding/#pynapple.process.decoding.decode_1d) which implements bayesian decoding (see : Zhang, K., Ginzburg, I., McNaughton, B. L., & Sejnowski, T. J. (1998). Interpreting neuronal population activity by reconstruction: unified framework with application to hippocampal place cells. Journal of neurophysiology, 79(2), 1017-1044.) |
| 243 | +# This example uses the function [`decode_1d`](../../../reference/process/decoding/#pynapple.process.decoding.decode_1d) which implements bayesian decoding (see : Zhang, K., Ginzburg, I., McNaughton, B. L., & Sejnowski, T. J. (1998). Interpreting neuronal population activity by reconstruction: unified framework with application to hippocampal place cells. Journal of neurophysiology, 79(2), 1017-1044.) |
244 | 244 | #
|
245 | 245 | # First we can validate the decoding function with the real position of the head of the animal during wake.
|
246 | 246 |
|
|
285 | 285 | )
|
286 | 286 |
|
287 | 287 | # %%
|
288 |
| -# Here we are gonna chain the TsGroup function [`set_info`](https://pynapple-org.github.io/pynapple/reference/core/ts_group/#pynapple.core.ts_group.TsGroup.set_info) and the function [`to_tsd`](https://pynapple-org.github.io/pynapple/reference/core/ts_group/#pynapple.core.ts_group.TsGroup.to_tsd) to flatten the TsGroup and quickly assign to each spikes a corresponding value found in the metadata table. Any columns of the metadata table can be assigned to timestamps in a TsGroup. |
| 288 | +# Here we are gonna chain the TsGroup function [`set_info`](../../../reference/core/ts_group/#pynapple.core.ts_group.TsGroup.set_info) and the function [`to_tsd`](../../../reference/core/ts_group/#pynapple.core.ts_group.TsGroup.to_tsd) to flatten the TsGroup and quickly assign to each spikes a corresponding value found in the metadata table. Any columns of the metadata table can be assigned to timestamps in a TsGroup. |
289 | 289 | #
|
290 | 290 | # Here the value assign to the spikes comes from the preferred firing direction of the neurons. The following line is a quick way to sort the neurons based on their preferred firing direction
|
291 | 291 | order = np.argsort(np.argmax(tuning_curves_adn.values, 0))
|
|
0 commit comments