Skip to content
This repository was archived by the owner on Dec 8, 2023. It is now read-only.

Commit c04a031

Browse files
committed
Move import statements, black format notebooks
1 parent ddd2359 commit c04a031

14 files changed

+302
-578
lines changed

notebooks/04-automate-optional.ipynb

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,24 @@
2727
}
2828
],
2929
"source": [
30-
"import os\n",
31-
"os.chdir('..') \n",
30+
"import os"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": null,
36+
"metadata": {},
37+
"outputs": [],
38+
"source": [
39+
"os.chdir(\"..\")"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": null,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
3248
"import numpy as np\n",
3349
"from workflow_array_ephys.pipeline import lab, subject, session, probe, ephys"
3450
]
@@ -166,13 +182,14 @@
166182
" \"nSkipCov\": 25,\n",
167183
" \"scaleproc\": 200,\n",
168184
" \"nPCs\": 3,\n",
169-
" \"useRAM\": 0\n",
185+
" \"useRAM\": 0,\n",
170186
"}\n",
171187
"ephys.ClusteringParamSet.insert_new_params(\n",
172-
" clustering_method='kilosort2',\n",
188+
" clustering_method=\"kilosort2\",\n",
173189
" paramset_idx=0,\n",
174190
" params=params_ks,\n",
175-
" paramset_desc='Spike sorting using Kilosort2')"
191+
" paramset_desc=\"Spike sorting using Kilosort2\",\n",
192+
")"
176193
]
177194
},
178195
{
@@ -301,10 +318,16 @@
301318
"metadata": {},
302319
"outputs": [],
303320
"source": [
304-
"session_key = session.Session.fetch1('KEY')\n",
321+
"session_key = session.Session.fetch1(\"KEY\")\n",
305322
"ephys.ClusteringTask.insert1(\n",
306-
" dict(session_key, insertion_number=0, paramset_idx=0,\n",
307-
" clustering_output_dir='subject6/session1/towersTask_g0_imec0'), skip_duplicates=True)"
323+
" dict(\n",
324+
" session_key,\n",
325+
" insertion_number=0,\n",
326+
" paramset_idx=0,\n",
327+
" clustering_output_dir=\"subject6/session1/towersTask_g0_imec0\",\n",
328+
" ),\n",
329+
" skip_duplicates=True,\n",
330+
")"
308331
]
309332
},
310333
{
@@ -330,7 +353,7 @@
330353
"metadata": {},
331354
"outputs": [],
332355
"source": [
333-
"key = (ephys.ClusteringTask & session_key).fetch1('KEY')\n",
356+
"key = (ephys.ClusteringTask & session_key).fetch1(\"KEY\")\n",
334357
"ephys.Curation().create1_from_clustering_task(key)"
335358
]
336359
},

notebooks/05-explore.ipynb

Lines changed: 42 additions & 479 deletions
Large diffs are not rendered by default.

notebooks/06-drop-optional.ipynb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,15 @@
5151
}
5252
],
5353
"source": [
54-
"from workflow_array_ephys.pipeline import *\n",
55-
"\n",
54+
"from workflow_array_ephys.pipeline import *"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"metadata": {},
61+
"outputs": [],
62+
"source": [
5663
"# ephys.schema.drop()\n",
5764
"# probe.schema.drop()\n",
5865
"# session.schema.drop()\n",

notebooks/07-downstream-analysis.ipynb

Lines changed: 106 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,43 @@
3535
"metadata": {},
3636
"outputs": [],
3737
"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": [
3948
"# 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": [
4363
"# 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"
4575
]
4676
},
4777
{
@@ -75,8 +105,7 @@
75105
"cell_type": "markdown",
76106
"id": "04616e30-c9f8-468c-bed1-0d233ab76617",
77107
"metadata": {
78-
"incorrectly_encoded_metadata": "jp-MarkdownHeadingCollapsed=true",
79-
"jp-MarkdownHeadingCollapsed": true,
108+
"incorrectly_encoded_metadata": "jp-MarkdownHeadingCollapsed=true jp-MarkdownHeadingCollapsed=true",
80109
"tags": []
81110
},
82111
"source": [
@@ -88,9 +117,9 @@
88117
"id": "a1451602-df01-4c33-b4bf-e280d3d0742c",
89118
"metadata": {},
90119
"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",
92121
"- 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",
94123
"- Events may occur within or outside of conditions, either instantaneous or continuous.\n",
95124
"\n",
96125
"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,8 +156,12 @@
127156
"metadata": {},
128157
"outputs": [],
129158
"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+
")"
132165
]
133166
},
134167
{
@@ -177,7 +210,9 @@
177210
}
178211
],
179212
"source": [
180-
"ingest_subjects(); ingest_sessions(); ingest_events()"
213+
"ingest_subjects()\n",
214+
"ingest_sessions()\n",
215+
"ingest_events()"
181216
]
182217
},
183218
{
@@ -506,7 +541,7 @@
506541
}
507542
],
508543
"source": [
509-
"trial.TrialEvent() & 'trial_id<5'"
544+
"trial.TrialEvent() & \"trial_id<5\""
510545
]
511546
},
512547
{
@@ -801,10 +836,14 @@
801836
"metadata": {},
802837
"outputs": [],
803838
"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\")"
808847
]
809848
},
810849
{
@@ -1003,8 +1042,12 @@
10031042
"metadata": {},
10041043
"outputs": [],
10051044
"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+
")"
10081051
]
10091052
},
10101053
{
@@ -1027,16 +1070,21 @@
10271070
},
10281071
"outputs": [],
10291072
"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",
10351082
"analysis.SpikesAlignmentCondition.insert1(alignment_condition, skip_duplicates=True)\n",
1036-
"alignment_condition.pop('bin_size')\n",
1083+
"alignment_condition.pop(\"bin_size\")\n",
10371084
"analysis.SpikesAlignmentCondition.Trial.insert(\n",
10381085
" (analysis.SpikesAlignmentCondition * ctrl_trials & alignment_condition).proj(),\n",
1039-
" skip_duplicates=True)"
1086+
" skip_duplicates=True,\n",
1087+
")"
10401088
]
10411089
},
10421090
{
@@ -1249,14 +1297,18 @@
12491297
"outputs": [],
12501298
"source": [
12511299
"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",
12551306
"analysis.SpikesAlignmentCondition.insert1(alignment_condition, skip_duplicates=True)\n",
1256-
"alignment_condition.pop('bin_size')\n",
1307+
"alignment_condition.pop(\"bin_size\")\n",
12571308
"analysis.SpikesAlignmentCondition.Trial.insert(\n",
12581309
" (analysis.SpikesAlignmentCondition * stim_trials & alignment_condition).proj(),\n",
1259-
" skip_duplicates=True)"
1310+
" skip_duplicates=True,\n",
1311+
")"
12601312
]
12611313
},
12621314
{
@@ -1624,12 +1676,17 @@
16241676
"metadata": {},
16251677
"outputs": [],
16261678
"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+
")"
16331690
]
16341691
},
16351692
{
@@ -1654,16 +1711,19 @@
16541711
}
16551712
],
16561713
"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)"
16591720
]
16601721
},
16611722
{
16621723
"cell_type": "code",
16631724
"execution_count": 12,
16641725
"id": "e144df4c-87c1-4646-9d4b-b0009216bca1",
16651726
"metadata": {
1666-
"lines_to_next_cell": 0,
16671727
"title": "a set of trials of interest to perform the analysis on - `stim` trials"
16681728
},
16691729
"outputs": [
@@ -1681,17 +1741,13 @@
16811741
}
16821742
],
16831743
"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)"
16861750
]
1687-
},
1688-
{
1689-
"cell_type": "code",
1690-
"execution_count": null,
1691-
"id": "1e6407b3",
1692-
"metadata": {},
1693-
"outputs": [],
1694-
"source": []
16951751
}
16961752
],
16971753
"metadata": {

0 commit comments

Comments
 (0)