Skip to content

Commit

Permalink
Update notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
CBroz1 committed Dec 19, 2023
1 parent 47b1884 commit ec0ebff
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 40 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
- Add Mixin class to centralize `fetch_nwb` functionality. #692
- Refactor restriction use in `delete_downstream_merge` #703
- Add `cautious_delete` to Mixin class, initial implementation. #711
- Add `deprecation_factory` to facilitate table migration
- Add `deprecation_factory` to facilitate table migration. #717

### Pipelines

- Position: Refactor input validation in DLC pipeline. #688
- Spike sorting: Add SpikeSorting V1 pipeline #651
- LFP: Minor fixes to LFPBandV1 populator #706
- Spike sorting: Add SpikeSorting V1 pipeline. #651
- LFP: Minor fixes to LFPBandV1 populator. #706
- Linearization:
- Minor fixes to LinearizedPositionV1 pipeline #695
- Rename `position_linearization` -> `linearization`
- Migrate linearization tables: `common_position` -> `linearization.v0`
- Rename `position_linearization` -> `linearization`. #717
- Migrate tables: `common_position` -> `linearization.v0`. #717

## [0.4.3] (November 7, 2023)

Expand Down
53 changes: 26 additions & 27 deletions notebooks/24_Linearization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Position - Linearization"
"# Position - Linearization\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Overview"
"## Overview\n"
]
},
{
Expand All @@ -33,7 +33,7 @@
"\"linearizes\" it to 1D position. If you haven't already done so, please generate\n",
"input data with either the [Trodes](./20_Position_Trodes.ipynb) or DLC notebooks\n",
"([1](./21_Position_DLC_1.ipynb), [2](./22_Position_DLC_2.ipynb),\n",
"[3](./23_Position_DLC_3.ipynb))."
"[3](./23_Position_DLC_3.ipynb)).\n"
]
},
{
Expand Down Expand Up @@ -81,7 +81,7 @@
"\n",
"import spyglass.common as sgc\n",
"import spyglass.position.v1 as sgp\n",
"import spyglass.position_linearization.v1 as sgpl\n",
"import spyglass.linearization.v1 as sgpl\n",
"\n",
"# ignore datajoint+jupyter async warnings\n",
"import warnings\n",
Expand All @@ -94,15 +94,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Retrieve 2D position "
"## Retrieve 2D position\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To retrieve 2D position data, we'll specify an nwb file, a position time\n",
"interval, and the set of parameters used to compute the position info."
"interval, and the set of parameters used to compute the position info.\n"
]
},
{
Expand Down Expand Up @@ -133,7 +133,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We will fetch the pandas dataframe from the `PositionOutput` table."
"We will fetch the pandas dataframe from the `PositionOutput` table.\n"
]
},
{
Expand Down Expand Up @@ -354,7 +354,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Before linearizing, plotting the head position will help us understand the data."
"Before linearizing, plotting the head position will help us understand the data.\n"
]
},
{
Expand Down Expand Up @@ -411,20 +411,20 @@
"\n",
"- `node_positions` (cm): the 2D positions of the graph\n",
"- `edges`: how the nodes are connected, as pairs of node indices, labeled by\n",
" their respective index in `node_positions`. \n",
"- `linear_edge_order`: layout of edges in linear space in *order*, as tuples. \n",
" their respective index in `node_positions`.\n",
"- `linear_edge_order`: layout of edges in linear space in _order_, as tuples.\n",
"- `linear_edge_spacing`: spacing between each edge, as either a single number\n",
"for all gaps or an array with a number for each gap. Gaps may be important for\n",
"edges not connected in 2D space.\n",
" for all gaps or an array with a number for each gap. Gaps may be important for\n",
" edges not connected in 2D space.\n",
"\n",
"For example, (79.910, 216.720) is the 2D position of node 0 and (183.784,\n",
"45.375) is the 2D position of node 8. Edge (0, 8) means there is an edge between\n",
"node 0 and node 8. Nodes order controls order in 1D space. Edge (0, 1) connects\n",
"from node 0 to 1. Edge (1, 0) would connect from node 1 to 0, reversing the\n",
"linear positions for that edge.\n",
"\n",
"For more examples, see \n",
"[this notebook](https://github.com/LorenFrankLab/track_linearization/blob/master/notebooks/)."
"For more examples, see\n",
"[this notebook](https://github.com/LorenFrankLab/track_linearization/blob/master/notebooks/).\n"
]
},
{
Expand Down Expand Up @@ -481,7 +481,7 @@
"metadata": {},
"source": [
"With these variables, we then add a `track_graph_name` and the corresponding\n",
"`environment`."
"`environment`.\n"
]
},
{
Expand Down Expand Up @@ -611,7 +611,7 @@
"metadata": {},
"source": [
"`TrackGraph` has several methods for visualizing in 2D and 1D space.\n",
"`plot_track_graph` plots in 2D to make sure our layout makes sense."
"`plot_track_graph` plots in 2D to make sure our layout makes sense.\n"
]
},
{
Expand Down Expand Up @@ -648,7 +648,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"`plot_track_graph_as_1D` shows what this looks like in 1D."
"`plot_track_graph_as_1D` shows what this looks like in 1D.\n"
]
},
{
Expand Down Expand Up @@ -683,15 +683,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"By default, linearization assigns each 2D position to its nearest point on the\n",
"track graph. This is then translated into 1D space.\n",
"\n",
"If `use_hmm` is set to `true`, a Hidden Markov model is used to assign points.\n",
"The HMM takes into account the prior position and edge, and can keep the\n",
"position from suddenly jumping to another. Position jumping like this may occur\n",
"at intersections or the head position swings closer to a non-target reward well\n",
"while on another edge."
"while on another edge.\n"
]
},
{
Expand Down Expand Up @@ -806,15 +805,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Linearization"
"## Linearization\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With linearization parameters, we specify the position interval we wish to \n",
"linearize from the `PositionOutput` table and create an entry in `LinearizationSelection`"
"With linearization parameters, we specify the position interval we wish to\n",
"linearize from the `PositionOutput` table and create an entry in `LinearizationSelection`\n"
]
},
{
Expand Down Expand Up @@ -1051,7 +1050,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"And then run linearization by populating `LinearizedPositionV1`."
"And then run linearization by populating `LinearizedPositionV1`.\n"
]
},
{
Expand Down Expand Up @@ -1225,7 +1224,7 @@
"- `time`: dataframe index\n",
"- `linear_position`: 1D linearized position\n",
"- `track_segment_id`: index number of the edges given to track graph\n",
"- `projected_{x,y}_position`: 2D position projected to the track graph"
"- `projected_{x,y}_position`: 2D position projected to the track graph\n"
]
},
{
Expand Down Expand Up @@ -1394,7 +1393,7 @@
" \"linearization_param_name\": \"default\",\n",
"}\n",
"\n",
"from spyglass.position_linearization import LinearizedPositionOutput\n",
"from spyglass.linearization.merge import LinearizedPositionOutput\n",
"\n",
"linear_position_df = (LinearizedPositionOutput & linear_key).fetch1_dataframe()\n",
"linear_position_df"
Expand All @@ -1405,7 +1404,7 @@
"metadata": {},
"source": [
"We'll plot the 1D position over time, colored by edge, and use the 1D track\n",
"graph layout on the y-axis."
"graph layout on the y-axis.\n"
]
},
{
Expand Down Expand Up @@ -1455,7 +1454,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also plot the 2D position projected to the track graph"
"We can also plot the 2D position projected to the track graph\n"
]
},
{
Expand Down
Loading

0 comments on commit ec0ebff

Please sign in to comment.