Skip to content

Commit

Permalink
Additional typo fixes.
Browse files Browse the repository at this point in the history
Added additional possible paths to data dictionaries so that notebook can run on Google Colab.
  • Loading branch information
colleenjg committed Mar 2, 2024
1 parent 9c8fecf commit a6211f3
Showing 1 changed file with 32 additions and 22 deletions.
54 changes: 32 additions & 22 deletions docs/projects/cred_assign_figures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"source": [
"### Summary of experiments\n",
"\n",
"In brief, for this project, mice were head-fixed on a running disc and underwent 3 two-photon calcium imaging sessions in primary visual cortex (VisP) while passively viewing a visual stimulus (described below). In each mouse, imaging was performed in one of four cortical planes: layer 2/3 distal apical dendrites (**L2/3-D**), layer 2/3 somata (**L2/3-S**), layer 5 distal apical dendrites (**L5-D**) or layer 5 somata (**L5-S**). \n",
"In brief, for this project, mice were head-fixed on a running disc and underwent **three** two-photon calcium imaging sessions in primary visual cortex (VisP) while passively viewing a visual stimulus (described below). In each mouse, imaging was performed in one of four cortical planes: layer 2/3 distal apical dendrites (**L2/3-D**), layer 2/3 somata (**L2/3-S**), layer 5 distal apical dendrites (**L5-D**) or layer 5 somata (**L5-S**). \n",
"\n",
"**Figure 1** from {cite}`Gillon2023`.\n",
"\n",
Expand All @@ -40,21 +40,21 @@
"source": [
"Previous to the imaging sessions, mice had been habituated over 6 days to stimuli with consistent features: (1) a Gabor sequence stimulus, and (2) a visual flow stimulus. \n",
"\n",
"The Gabor sequence stimulus was presented for 34 minutes. Each sequence lasted 1.5 seconds and consisted of 5 consecutive images (A-B-C-D-G) presented for 300 ms each. Images A, B, C and D comprised 30 Gabor patches each with positions and sizes fixed within a single session, while image G was simply a grayscreen image. For each sequence, a mean orientation was randomly sampled from {0, 45, 90, 135}°. This mean orientation was used to sample the orientation of each Gabor patch for all images in the sequence. \n",
"The Gabor sequence stimulus was presented for 34 minutes. Each sequence lasted 1.5 seconds and consisted of five consecutive images (A-B-C-D-G) presented for 300 ms each. Images A, B, C and D comprised 30 Gabor patches each with positions and sizes fixed within a single session, while image G was simply a grayscreen image. For each sequence, a mean orientation was randomly sampled from {0, 45, 90, 135}°. This mean orientation was used to sample the orientation of each Gabor patch for all images in the sequence. \n",
"\n",
"The visual flow stimulus consisted of white squares moving together at a consistent speed in one direction (17 min) and then the other (17 min) (directions: nasal-to-temporal and temporal-to-nasal).\n",
"\n",
"**Figure 3** from {cite}`Gillon2023`.\n",
"\n",
"![title](https://media.springernature.com/full/springer-static/image/art%3A10.1038%2Fs41597-023-02214-y/MediaObjects/41597_2023_2214_Fig3_HTML.png?as=webp)\n",
"\n",
"As mentioned above, once the mice had been habituated to these stimuli, inconsistent stimulus features were introduced into the Gabor sequence stimulus and the visual flow stimulus during the 3 two-photon calcium imaging sessions which were performed on different days. \n",
"As mentioned above, once the mice had been habituated to these stimuli, inconsistent stimulus features were introduced into the Gabor sequence stimulus and the visual flow stimulus during the three two-photon calcium imaging sessions which were performed on different days. \n",
"\n",
"For the Gabor sequence stimulus, inconsistent sequences were randomly introduced, accounting for about 7% of all sequences. In these inconsistent sequences, D images were replaced with U images. The Gabor patches in U images had their own positions and sizes, and in addition, their orientations were rotated by 90° with respect to the rest of the sequence they were in. \n",
"\n",
"For the visual flow stimulus, inconsistent flow was introduced randomly, accounting for around 5% of the total duration of the stimulus. During inconsistent flow, 25% of the squares randomly flipped their direction of flow for 2-4 seconds, before resuming consistent flow.\n",
"\n",
"Full series of 3 imaging sessions were obtained for 11 mice, in total."
"Full series of three imaging sessions were obtained for 11 mice, in total."
]
},
{
Expand All @@ -75,6 +75,8 @@
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"sys.path.append(\"../..\")\n",
"try:\n",
" from databook_utils import cred_assign_utils\n",
"except:\n",
Expand Down Expand Up @@ -234,19 +236,26 @@
"def load_data_dict(fig=\"2\", panel=\"B\", paper=\"dataset\", direc=None):\n",
" \n",
" if direc is None:\n",
" parent_direcs = [Path(\"data\"), Path(\"..\", \"..\", \"data\")]\n",
" possible_parent_direcs = [\n",
" Path(\"openscope_databook\", \"data\"), \n",
" Path(\"data\"), \n",
" Path(\"..\", \"data\"), \n",
" Path(\"..\", \"..\", \"data\")\n",
" ]\n",
" direc = None\n",
" for parent_direc in parent_direcs:\n",
" if parent_direc.is_dir():\n",
" direc = Path(parent_direc, \"cred_assign_data\")\n",
" for parent_direc in possible_parent_direcs:\n",
" possible_direc = Path(parent_direc, \"cred_assign_data\")\n",
" if possible_direc.is_dir():\n",
" direc = possible_direc\n",
" break\n",
"\n",
" if direc is None:\n",
" parent_direc_names = \" or \".join([str(direc) for direc in parent_direcs])\n",
" raise OSError(f\"Data directory not found in the following locations: {parent_direc_names}.\")\n",
"\n",
" if not direc.is_dir():\n",
" raise OSError(f\"Credit assignment data directory not found here: {direc}.\")\n",
" possible_parent_direc_names = \", \".join(\n",
" [f\"'{direc}'\" for direc in possible_parent_direcs]\n",
" )\n",
" raise OSError(\n",
" \"'cred_assign_direc' not found in any of the following \"\n",
" f\" locations: {possible_parent_direc_names}.\")\n",
" \n",
" filename = f\"{paper}_fig{fig}{panel}.json\"\n",
" filepath = Path(direc, filename)\n",
Expand Down Expand Up @@ -305,7 +314,9 @@
"- `basepar`: parameters used to baseline the data, if applicable,\n",
"- `extrapar`: any additional parameters used, specific to this analysis,\n",
"\n",
"In addition, each data dictionary contains a dataframe-structured dictionary, e.g., `ex_traces_df`, in which the analysis results are stored, typically with one line per session analyzed."
"In addition, each data dictionary contains a dataframe-structured dictionary, e.g., `ex_traces_df`, in which the analysis results are stored, typically with one line per session analyzed. \n",
"\n",
"Here is an example data dictionary:"
]
},
{
Expand Down Expand Up @@ -526,7 +537,7 @@
"source": [
"## Replications\n",
"\n",
"The functions used to replicate the figures below have been specifically written to work with the data dictionaries generated for these paper analyses. As a result, they are not directly applicable to other datasets or analyses. Instead, these functions can be seen as helpful examples for how to store the parameters and results of an analysis in minimal, portable files, and directly plot informative figures in `Python` from the stored data.\n",
"The functions used to replicate the figures below have been specifically written to work with the data dictionaries generated for these paper analyses. As a result, they are not directly applicable to other datasets or analyses. Instead, these functions can be seen as helpful examples of how to store the parameters and results of an analysis in minimal, portable files, and directly plot informative figures in `Python` from the stored data.\n",
"\n",
"Note that the functions may call some additional functions from the `cred_assign_utils` module. The functions in this extra module mostly handle aesthetic details in the plots, and were left out of the notebook for brevity. "
]
Expand Down Expand Up @@ -562,7 +573,6 @@
" - roi_mask_df (pd.DataFrame in dict format):\n",
" dataframe with a row for each mouse, and the following \n",
" columns, in addition to the basic sess_df columns: \n",
"\n",
" - \"max_projections\" (list): pixel intensities of the maximum \n",
" projection for the plane (hei x wid)\n",
" - \"registered_roi_mask_idxs\" (list): list of mask indices, \n",
Expand Down Expand Up @@ -704,7 +714,7 @@
"source": [
"Specifically, examples are shown for one L5-D mouse and one L5-S mouse. In each case, at the top, the two-photon calcium imaging projections are shown for each recording session (1-3, left to right). Dendritic segments (top) and somata (bottom) can be seen as white blobs over a black background. Over the projections, the contours of tracked ROIs have been drawn in different colors for each session. Below these images, the ROI masks for all three imaging sessions are shown realigned and overlaid. \n",
"\n",
"Note that in each case, the images do not reflect the full field of view. Instead, a cropped-in section is shown, for better visibility. Scale bars reflect the actual size of each image."
"Note that in each case, the images do not reflect the full field of view. Instead, a cropped-in section is shown, for better visibility. Scale bars convey the actual size of each image."
]
},
{
Expand Down Expand Up @@ -919,9 +929,9 @@
"id": "936588c2",
"metadata": {},
"source": [
"Specifically, for each of the four imaging planes, 6 example ROIs were selected for each imaging plane, from all the session 1 recordings (aggregated across mice). These ROIs were selected if they showed consistent responses to the Gabor sequences across sequence presentations. The fluorescence responses (ΔF/F) of the ROIs to each inconsistent sequence presentation are plotted in light gray. The mean response across inconsistent sequences is plotted in color. \n",
"Specifically, for each of the four imaging planes, **six** example ROIs were selected for each imaging plane, from all the session 1 recordings (aggregated across mice). These ROIs were selected if they showed consistent responses to the Gabor sequences across sequence presentations. The fluorescence responses (ΔF/F) of the ROIs to each inconsistent sequence presentation are plotted in light gray. The mean response across inconsistent sequences is plotted in color. \n",
"\n",
"The ROI responses for each imaging plane are arranged in a 2 column x 3 row quadrant (top left: L2/3-D, bottom left: L2/3-S, top right: L5-D, bottom right: L5-S). The vertical gray dashed lines at 0 seconds mark the onset of U images in the A-B-C-U-G sequences (-0.9 to 0.3 seconds). Additional gray dashed lines are plotted horizontally at 0, but are largely hidden by the gray traces. \n",
"The ROI responses for each imaging plane are arranged in a 2 column x 3 row quadrant (top left: L2/3-D, bottom left: L2/3-S, top right: L5-D, bottom right: L5-S). The vertical gray dashed lines at 0 seconds mark the onset of U images in the A-B-C-U-G sequences (running from -0.9 to 0.3 seconds). Additional gray dashed lines are plotted horizontally at 0, but are largely hidden by the gray traces. \n",
"\n",
"Time, as a function of Gabor sequence image:\n",
"- A: -0.9 to -0.6 seconds \n",
Expand Down Expand Up @@ -1321,11 +1331,11 @@
"source": [
"Specifically, for each ROI in each recording session, a Gabor sequence selectivity index (USI) was calculated. This selectivity index reflects the degree to which an ROI selectively responds to inconsistent (=> positive USI) or consistent (=> negative USI) sequences. Null USIs (i.e., USIs close to 0) reflect no selectivity to either consistent or inconsistent sequences.\n",
"\n",
"To provide examples of the fluorescence responses of ROIs with differing USIs, three example ROIs were selected for each imaging plane: one with a USI significantly above 0 (top), one with a USI significantly below 0 (bottom) and one with a USI close to 0 (middle). For each ROI, the mean fluorescence response (ΔF/F) is plotted in gray for consistent sequences and in color for inconsistent sequences. \n",
"To provide examples of the fluorescence responses of ROIs with differing USIs, **three** example ROIs were selected for each imaging plane: one with a USI significantly above 0 (top), one with a USI significantly below 0 (bottom) and one with a USI close to 0 (middle). For each ROI, the mean fluorescence response (ΔF/F) is plotted in gray for consistent sequences and in color for inconsistent sequences. \n",
"\n",
"The same quadrant and color scheme is used for the imaging planes as in Replication 2. In addition, vertical gray dashed lines mark the onset of D/U images at 0 seconds in the A-B-C-U-G sequences (-0.9 to 0.3 seconds), while horizontal gray dashed lines mark 0. Each plot is labeled with its ROI's USI value.\n",
"The same quadrant and color scheme is used for the imaging planes as in Replication 2. In addition, vertical gray dashed lines mark the onset of D/U images at 0 seconds in the A-B-C-U-G sequences (running from -0.9 to 0.3 seconds), while horizontal gray dashed lines mark 0. Each plot is labeled with its ROI's USI value.\n",
"\n",
"Since USIs were computed on the D-G / U-G part of the sequences, where the stimulus patterns diverge, the differences between the mean traces relevant to the USI values occur _after_ the gray line, from 0 seconds on. \n",
"Since USIs were computed on the D-G vs U-G parts of the sequences, where the stimulus patterns diverge, the differences between the mean traces relevant to the USI values occur _after_ the gray line, from 0 seconds onwards. \n",
"\n",
"Time, as a function of Gabor sequence image:\n",
"- A : -0.9 to -0.6 seconds \n",
Expand Down

0 comments on commit a6211f3

Please sign in to comment.