|
35 | 35 | "metadata": {},
|
36 | 36 | "outputs": [],
|
37 | 37 | "source": [
|
38 |
| - "import os\n", |
| 38 | + "import os" |
| 39 | + ] |
| 40 | + }, |
| 41 | + { |
| 42 | + "cell_type": "code", |
| 43 | + "execution_count": null, |
| 44 | + "id": "a0ec4e38", |
| 45 | + "metadata": {}, |
| 46 | + "outputs": [], |
| 47 | + "source": [ |
39 | 48 | "# change to the upper level folder to detect dj_local_conf.json\n",
|
40 |
| - "if os.path.basename(os.getcwd())=='notebooks': os.chdir('..')\n", |
41 |
| - "assert os.path.basename(os.getcwd())=='workflow-array-ephys', (\"Please move to the \"\n", |
42 |
| - " + \"workflow directory\")\n", |
| 49 | + "if os.path.basename(os.getcwd()) == \"notebooks\":\n", |
| 50 | + " os.chdir(\"..\")\n", |
| 51 | + "assert os.path.basename(os.getcwd()) == \"workflow-array-ephys\", (\n", |
| 52 | + " \"Please move to the \" + \"workflow directory\"\n", |
| 53 | + ")" |
| 54 | + ] |
| 55 | + }, |
| 56 | + { |
| 57 | + "cell_type": "code", |
| 58 | + "execution_count": null, |
| 59 | + "id": "e69b8c23", |
| 60 | + "metadata": {}, |
| 61 | + "outputs": [], |
| 62 | + "source": [ |
43 | 63 | "# We'll be working with long tables, so we'll make visualization easier with a limit\n",
|
44 |
| - "import datajoint as dj; dj.config['display.limit']=10" |
| 64 | + "import datajoint as dj" |
| 65 | + ] |
| 66 | + }, |
| 67 | + { |
| 68 | + "cell_type": "code", |
| 69 | + "execution_count": null, |
| 70 | + "id": "4fcb0cda", |
| 71 | + "metadata": {}, |
| 72 | + "outputs": [], |
| 73 | + "source": [ |
| 74 | + "dj.config[\"display.limit\"] = 10" |
45 | 75 | ]
|
46 | 76 | },
|
47 | 77 | {
|
|
75 | 105 | "cell_type": "markdown",
|
76 | 106 | "id": "04616e30-c9f8-468c-bed1-0d233ab76617",
|
77 | 107 | "metadata": {
|
78 |
| - "incorrectly_encoded_metadata": "jp-MarkdownHeadingCollapsed=true", |
79 |
| - "jp-MarkdownHeadingCollapsed": true, |
| 108 | + "incorrectly_encoded_metadata": "jp-MarkdownHeadingCollapsed=true jp-MarkdownHeadingCollapsed=true", |
80 | 109 | "tags": []
|
81 | 110 | },
|
82 | 111 | "source": [
|
|
88 | 117 | "id": "a1451602-df01-4c33-b4bf-e280d3d0742c",
|
89 | 118 | "metadata": {},
|
90 | 119 | "source": [
|
91 |
| - "Tables in the `trial` and `event` schemas specify the structure of your experiment, including block, trial and event timing. \n", |
| 120 | + "Tables in the `trial` and `event` schemas specify the structure of your experiment, including block, trial and event timing.\n", |
92 | 121 | "- Session has a 1-to-1 mapping with a behavior recording\n",
|
93 |
| - "- A block is a continuous phase of an experiment that contains repeated instances of a condition, or trials. \n", |
| 122 | + "- A block is a continuous phase of an experiment that contains repeated instances of a condition, or trials.\n", |
94 | 123 | "- Events may occur within or outside of conditions, either instantaneous or continuous.\n",
|
95 | 124 | "\n",
|
96 | 125 | "The diagram below shows (a) the levels of hierarchy and (b) how the bounds may not completely overlap. A block may not fully capture trials and events may occur outside both blocks/trials."
|
|
127 | 156 | "metadata": {},
|
128 | 157 | "outputs": [],
|
129 | 158 | "source": [
|
130 |
| - "from workflow_array_ephys.ingest import ingest_subjects, ingest_sessions,\\\n", |
131 |
| - " ingest_events, ingest_alignment" |
| 159 | + "from workflow_array_ephys.ingest import (\n", |
| 160 | + " ingest_subjects,\n", |
| 161 | + " ingest_sessions,\n", |
| 162 | + " ingest_events,\n", |
| 163 | + " ingest_alignment,\n", |
| 164 | + ")" |
132 | 165 | ]
|
133 | 166 | },
|
134 | 167 | {
|
|
177 | 210 | }
|
178 | 211 | ],
|
179 | 212 | "source": [
|
180 |
| - "ingest_subjects(); ingest_sessions(); ingest_events()" |
| 213 | + "ingest_subjects()\n", |
| 214 | + "ingest_sessions()\n", |
| 215 | + "ingest_events()" |
181 | 216 | ]
|
182 | 217 | },
|
183 | 218 | {
|
|
506 | 541 | }
|
507 | 542 | ],
|
508 | 543 | "source": [
|
509 |
| - "trial.TrialEvent() & 'trial_id<5'" |
| 544 | + "trial.TrialEvent() & \"trial_id<5\"" |
510 | 545 | ]
|
511 | 546 | },
|
512 | 547 | {
|
|
801 | 836 | "metadata": {},
|
802 | 837 | "outputs": [],
|
803 | 838 | "source": [
|
804 |
| - "clustering_key = (ephys.CuratedClustering \n", |
805 |
| - " & {'subject': 'subject6', 'session_datetime': '2021-01-15 11:16:38',\n", |
806 |
| - " 'insertion_number': 0}\n", |
807 |
| - " ).fetch1('KEY')" |
| 839 | + "clustering_key = (\n", |
| 840 | + " ephys.CuratedClustering\n", |
| 841 | + " & {\n", |
| 842 | + " \"subject\": \"subject6\",\n", |
| 843 | + " \"session_datetime\": \"2021-01-15 11:16:38\",\n", |
| 844 | + " \"insertion_number\": 0,\n", |
| 845 | + " }\n", |
| 846 | + ").fetch1(\"KEY\")" |
808 | 847 | ]
|
809 | 848 | },
|
810 | 849 | {
|
|
1003 | 1042 | "metadata": {},
|
1004 | 1043 | "outputs": [],
|
1005 | 1044 | "source": [
|
1006 |
| - "(dj.Diagram(analysis) + dj.Diagram(event.AlignmentEvent) + dj.Diagram(trial.Trial) + \n", |
1007 |
| - " dj.Diagram(ephys.CuratedClustering))" |
| 1045 | + "(\n", |
| 1046 | + " dj.Diagram(analysis)\n", |
| 1047 | + " + dj.Diagram(event.AlignmentEvent)\n", |
| 1048 | + " + dj.Diagram(trial.Trial)\n", |
| 1049 | + " + dj.Diagram(ephys.CuratedClustering)\n", |
| 1050 | + ")" |
1008 | 1051 | ]
|
1009 | 1052 | },
|
1010 | 1053 | {
|
|
1027 | 1070 | },
|
1028 | 1071 | "outputs": [],
|
1029 | 1072 | "source": [
|
1030 |
| - "alignment_key = (event.AlignmentEvent & 'alignment_name = \"center_button\"'\n", |
1031 |
| - " ).fetch1('KEY')\n", |
1032 |
| - "alignment_condition = {**clustering_key, **alignment_key, \n", |
1033 |
| - " 'trial_condition': 'ctrl_center_button',\n", |
1034 |
| - " 'bin_size':.2}\n", |
| 1073 | + "alignment_key = (event.AlignmentEvent & 'alignment_name = \"center_button\"').fetch1(\n", |
| 1074 | + " \"KEY\"\n", |
| 1075 | + ")\n", |
| 1076 | + "alignment_condition = {\n", |
| 1077 | + " **clustering_key,\n", |
| 1078 | + " **alignment_key,\n", |
| 1079 | + " \"trial_condition\": \"ctrl_center_button\",\n", |
| 1080 | + " \"bin_size\": 0.2,\n", |
| 1081 | + "}\n", |
1035 | 1082 | "analysis.SpikesAlignmentCondition.insert1(alignment_condition, skip_duplicates=True)\n",
|
1036 |
| - "alignment_condition.pop('bin_size')\n", |
| 1083 | + "alignment_condition.pop(\"bin_size\")\n", |
1037 | 1084 | "analysis.SpikesAlignmentCondition.Trial.insert(\n",
|
1038 | 1085 | " (analysis.SpikesAlignmentCondition * ctrl_trials & alignment_condition).proj(),\n",
|
1039 |
| - " skip_duplicates=True)" |
| 1086 | + " skip_duplicates=True,\n", |
| 1087 | + ")" |
1040 | 1088 | ]
|
1041 | 1089 | },
|
1042 | 1090 | {
|
|
1249 | 1297 | "outputs": [],
|
1250 | 1298 | "source": [
|
1251 | 1299 | "stim_trials = trial.Trial & clustering_key & 'trial_type = \"stim\"'\n",
|
1252 |
| - "alignment_condition = {**clustering_key, **alignment_key, \n", |
1253 |
| - " 'trial_condition': 'stim_center_button',\n", |
1254 |
| - " 'bin_size':.2}\n", |
| 1300 | + "alignment_condition = {\n", |
| 1301 | + " **clustering_key,\n", |
| 1302 | + " **alignment_key,\n", |
| 1303 | + " \"trial_condition\": \"stim_center_button\",\n", |
| 1304 | + " \"bin_size\": 0.2,\n", |
| 1305 | + "}\n", |
1255 | 1306 | "analysis.SpikesAlignmentCondition.insert1(alignment_condition, skip_duplicates=True)\n",
|
1256 |
| - "alignment_condition.pop('bin_size')\n", |
| 1307 | + "alignment_condition.pop(\"bin_size\")\n", |
1257 | 1308 | "analysis.SpikesAlignmentCondition.Trial.insert(\n",
|
1258 | 1309 | " (analysis.SpikesAlignmentCondition * stim_trials & alignment_condition).proj(),\n",
|
1259 |
| - " skip_duplicates=True)" |
| 1310 | + " skip_duplicates=True,\n", |
| 1311 | + ")" |
1260 | 1312 | ]
|
1261 | 1313 | },
|
1262 | 1314 | {
|
|
1624 | 1676 | "metadata": {},
|
1625 | 1677 | "outputs": [],
|
1626 | 1678 | "source": [
|
1627 |
| - "clustering_key = (ephys.CuratedClustering \n", |
1628 |
| - " & {'subject': 'subject6', 'session_datetime': '2021-01-15 11:16:38',\n", |
1629 |
| - " 'insertion_number': 0}\n", |
1630 |
| - " ).fetch1('KEY')\n", |
1631 |
| - "alignment_key = (event.AlignmentEvent & 'alignment_name = \"center_button\"'\n", |
1632 |
| - " ).fetch1('KEY')" |
| 1679 | + "clustering_key = (\n", |
| 1680 | + " ephys.CuratedClustering\n", |
| 1681 | + " & {\n", |
| 1682 | + " \"subject\": \"subject6\",\n", |
| 1683 | + " \"session_datetime\": \"2021-01-15 11:16:38\",\n", |
| 1684 | + " \"insertion_number\": 0,\n", |
| 1685 | + " }\n", |
| 1686 | + ").fetch1(\"KEY\")\n", |
| 1687 | + "alignment_key = (event.AlignmentEvent & 'alignment_name = \"center_button\"').fetch1(\n", |
| 1688 | + " \"KEY\"\n", |
| 1689 | + ")" |
1633 | 1690 | ]
|
1634 | 1691 | },
|
1635 | 1692 | {
|
|
1654 | 1711 | }
|
1655 | 1712 | ],
|
1656 | 1713 | "source": [
|
1657 |
| - "alignment_condition = {**clustering_key, **alignment_key, 'trial_condition': 'ctrl_center_button'}\n", |
1658 |
| - "analysis.SpikesAlignment().plot(alignment_condition, unit=2);" |
| 1714 | + "alignment_condition = {\n", |
| 1715 | + " **clustering_key,\n", |
| 1716 | + " **alignment_key,\n", |
| 1717 | + " \"trial_condition\": \"ctrl_center_button\",\n", |
| 1718 | + "}\n", |
| 1719 | + "analysis.SpikesAlignment().plot(alignment_condition, unit=2)" |
1659 | 1720 | ]
|
1660 | 1721 | },
|
1661 | 1722 | {
|
1662 | 1723 | "cell_type": "code",
|
1663 | 1724 | "execution_count": 12,
|
1664 | 1725 | "id": "e144df4c-87c1-4646-9d4b-b0009216bca1",
|
1665 | 1726 | "metadata": {
|
1666 |
| - "lines_to_next_cell": 0, |
1667 | 1727 | "title": "a set of trials of interest to perform the analysis on - `stim` trials"
|
1668 | 1728 | },
|
1669 | 1729 | "outputs": [
|
|
1681 | 1741 | }
|
1682 | 1742 | ],
|
1683 | 1743 | "source": [
|
1684 |
| - "alignment_condition = {**clustering_key, **alignment_key, 'trial_condition': 'stim_center_button'}\n", |
1685 |
| - "analysis.SpikesAlignment().plot(alignment_condition, unit=2);" |
| 1744 | + "alignment_condition = {\n", |
| 1745 | + " **clustering_key,\n", |
| 1746 | + " **alignment_key,\n", |
| 1747 | + " \"trial_condition\": \"stim_center_button\",\n", |
| 1748 | + "}\n", |
| 1749 | + "analysis.SpikesAlignment().plot(alignment_condition, unit=2)" |
1686 | 1750 | ]
|
1687 |
| - }, |
1688 |
| - { |
1689 |
| - "cell_type": "code", |
1690 |
| - "execution_count": null, |
1691 |
| - "id": "1e6407b3", |
1692 |
| - "metadata": {}, |
1693 |
| - "outputs": [], |
1694 |
| - "source": [] |
1695 | 1751 | }
|
1696 | 1752 | ],
|
1697 | 1753 | "metadata": {
|
|
0 commit comments