Skip to content

Commit 9ead8f9

Browse files
authored
Merge pull request #16 from CBroz1/master
NB name imply order, ERD->Diagram, make /notebooks/ as working directory
2 parents 4d27e4b + 0dd1fac commit 9ead8f9

24 files changed

+214
-497
lines changed

.gitignore

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
# OSX and python intermediate files
12
__pycache__/
23
.DS_Store
34
~*
45
*~
56
*.pyc
67
.ipynb_checkpoints/
7-
dj_local_conf.json
8-
9-
.idea/
8+
debug.log
109

10+
# DataJoint and setup files
11+
dj_local_con*.json
1112
julia/setup.jl
12-
debug.log
13+
.idea/
14+
temp*

00-Getting started.ipynb renamed to 00-Getting_started/00-Getting started.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"Congratulations! If you are reading this, then you have successfully connected to the workshop JupyterHub and opened up your very first workshop notebook!\n",
14+
"Congratulations! If you are reading this, then you have successfully connected to the workshop JupyterHub and opened up your very first workshop notebook! These notebooks are oranized with numbers to highlight what should come next. First, we'll walk through the startup process. Next, you'll see an introduction to DataJoint, and how to structure a data pipeline. The Calcium Imaging and Electrophysiology folders show example data structures and analysis techniques from common experimental techniques. We've included some fill-in-the-blank sections for you to code yourself. If you want to see completed notebooks, see the folder of completed exercises.\n",
1515
"\n",
1616
"Before we start, remember that all of the edits you make in these tutorial notebooks are ***not persistent*** - they will be reset to the original content everytime you restart the server. However, you can easily download the notebooks that you're interested in keeping the changes."
1717
]
@@ -316,18 +316,18 @@
316316
"The next step in the tutorial is to:\n",
317317
"1. learn the basic of the DataJoint framework with [01-DataJoint Basics](./01-DataJoint%20Basics%20-%20Interactive.ipynb)\n",
318318
"2. data ingestion in a pipeline, with practical examples in 2 domains:\n",
319-
" + [02-electrophysiology](./electrophysiology/02-Imported%20Tables%20-%20Interactive.ipynb)\n",
320-
" + [02-calcium imaging](./calcium_imaging/02-Imported%20Tables%20-%20Interactive.ipynb)\n",
319+
" + [02-electrophysiology](/02-Electrophysiology/02-Imported%20Tables%20-%20Interactive.ipynb)\n",
320+
" + [02-calcium imaging](./01-Calcium_Imaging/02-Imported%20Tables%20-%20Interactive.ipynb)\n",
321321
"3. more advanced topics on built-in automatic computation of the pipeline with DataJoint, also with practical examples from:\n",
322-
" + [03-electrophysiology](./electrophysiology/03-Computed%20Table%2C%20Lookup%20Table%2C%20and%20Part%20Table%20-%20Completed.ipynb)\n",
323-
" + [03-calcium imaging](./calcium_imaging/03-Computed%20Table%2C%20Lookup%20Table%2C%20and%20Part%20Table%20-%20Completed.ipynb)"
322+
" + [03-electrophysiology](/02-Electrophysiology/03-Computed%20Table%2C%20Lookup%20Table%2C%20and%20Part%20Table%20-%20Completed.ipynb)\n",
323+
" + [03-calcium imaging](./01-Calcium_Imaging/03-Computed%20Table%2C%20Lookup%20Table%2C%20and%20Part%20Table%20-%20Completed.ipynb)"
324324
]
325325
},
326326
{
327327
"cell_type": "markdown",
328328
"metadata": {},
329329
"source": [
330-
"As you will find out that these tutorial notebooks are meant to be interactive. There will be empty cells meant for you to write the code yourself, as mini exercises. To access the notebooks with complete solutions, visit this [folder](./completed)."
330+
"As you will find out that these tutorial notebooks are meant to be interactive. There will be empty cells meant for you to write the code yourself, as mini exercises. To access the notebooks with complete solutions, visit this [folder](../03-Completed_Exercises)."
331331
]
332332
}
333333
],

01-DataJoint Basics - Interactive.ipynb renamed to 00-Getting_started/01-DataJoint Basics - Interactive.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@
555555
"source": [
556556
"Note that, to uniquely identify an experimental session (or simply a **session**), we need to know the mouse that the session was about. In other words, a session cannot existing without a corresponding mouse! \n",
557557
"\n",
558-
"With **mouse** already represented as a table in our pipeline, we say that the session **depends on** the mouse! We would graphically represent this in an **entity relationship diagram (ERD)** by drawing the line between two tables, with the one below (**session**) dependeing on the one above (**mouse**)."
558+
"With **mouse** already represented as a table in our pipeline, we say that the session **depends on** the mouse! We could graphically represent this in an **entity relationship diagram (ERD)** by drawing the line between two tables, with the one below (**session**) dependeing on the one above (**mouse**)."
559559
]
560560
},
561561
{
@@ -590,7 +590,7 @@
590590
"cell_type": "markdown",
591591
"metadata": {},
592592
"source": [
593-
"You can actually generate the entity relationship diagram (ERD) on the fly by calling `dj.ERD` with the schema object"
593+
"You can actually generate something similar to an entity relationship diagram (ERD) on the fly by calling `dj.Diagram` with the schema object. Many of the symbols and features are the same as the ERD standard."
594594
]
595595
},
596596
{
@@ -599,7 +599,7 @@
599599
"metadata": {},
600600
"outputs": [],
601601
"source": [
602-
"dj.ERD(schema)"
602+
"dj.Diagram(schema)"
603603
]
604604
},
605605
{
@@ -1535,8 +1535,8 @@
15351535
"In the next session, we are going to extend our data pipeline with tables to represent **imported data** and define new tables to **compute and hold analysis results**.\n",
15361536
"\n",
15371537
"We will use both ephys and calcium imaging as example pipelines:\n",
1538-
"+ [02-electrophysiology](./electrophysiology/02-Imported%20Tables%20-%20Interactive.ipynb)\n",
1539-
"+ [02-calcium imaging](./calcium_imaging/02-Imported%20Tables%20-%20Interactive.ipynb)"
1538+
"+ [02-electrophysiology](../02-Electrophysiology/02-Imported%20Tables%20-%20Interactive.ipynb)\n",
1539+
"+ [02-calcium imaging](../01-Calcium_Imaging/02-Imported%20Tables%20-%20Interactive.ipynb)"
15401540
]
15411541
},
15421542
{

01-DataJoint Basics - Interactive.py renamed to 00-Getting_started/01-DataJoint Basics - Interactive.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
#
4343
# Let's go ahead and build together a pipeline from scratch to better understand what a data pipeline is all about.
4444

45-
# # Building our first pipeline:
45+
# # Building our first pipeline:
4646

4747
# Let's build a pipeline to collect, store and process data and analysis for our hypothetical single electrode recording or calcium imaging recording in mice. To help us understand the project better, here is a brief description:
4848

4949
# > * Your lab houses many mice, and each mouse is identified by a unique ID. You also want to keep track of information about each mouse such as their date of birth, and gender.
5050
# > * As a hard working neuroscientist, you perform experiments every day, sometimes working with more than one mouse in a day! However, on any given day, a mouse undergoes at most one recording session.
51-
# > * For each experimental session, you would like to record what mouse you worked with and when you performed the experiment. You would also like to keep track of other helpful information such as the experimental setup you worked on.
51+
# > * For each experimental session, you would like to record what mouse you worked with and when you performed the experiment. You would also like to keep track of other helpful information such as the experimental setup you worked on.
5252
#
5353
# > * In a session of electrophysiology
5454
# >> * you record electrical activity from a single neuron. You use recording equipment that produces separate data files for each neuron you recorded.
@@ -64,7 +64,7 @@
6464

6565
# > * Your lab houses many **mice**, and each mouse is identified by a unique ID. You also want to keep track of information about each mouse such as their date of birth, and gender.
6666
# > * As a hard working neuroscientist, you perform experiments every day, sometimes working with more than one mouse in a day! However, on an any given day, a mouse undergoes at most one recording session.
67-
# > * For each **experimental session**, you would like to record what mouse you worked with and when you performed the experiment. You would also like to keep track of other helpful information such as the experimental setup you worked on.
67+
# > * For each **experimental session**, you would like to record what mouse you worked with and when you performed the experiment. You would also like to keep track of other helpful information such as the experimental setup you worked on.
6868
#
6969
# > * In a session of electrophysiology
7070
# >> * you record electrical activity from a **single neuron**. You use recording equipment that produces separate data files for each neuron you recorded.
@@ -92,7 +92,7 @@
9292

9393
# In the current notebook, we will design the tables for mouse and experimental sessions, the rest of the pipeline will be designed in the subdirectory `electrophysiology` and `calcium_imaging`
9494

95-
# In DataJoint data pipeline, we represent these **entities** as **tables**. Different *kinds* of entities become distinct tables, and each row of the table is a single example (instance) of the category of entity.
95+
# In DataJoint data pipeline, we represent these **entities** as **tables**. Different *kinds* of entities become distinct tables, and each row of the table is a single example (instance) of the category of entity.
9696
#
9797
# For example, if we have a `Mouse` table, then each row in the mouse table represents a single mouse!
9898

@@ -229,7 +229,7 @@ class Mouse(dj.Manual):
229229

230230
# ## Create tables with dependencies
231231

232-
# Congratulations! We have successfully created your first table! We are now ready to tackle and include other **entities** in the project into our data pipeline.
232+
# Congratulations! We have successfully created your first table! We are now ready to tackle and include other **entities** in the project into our data pipeline.
233233
#
234234
# Let's now take a look at representing an **experimental session**.
235235

@@ -245,11 +245,11 @@ class Mouse(dj.Manual):
245245
#
246246
# to uniquely identify a single experimental session.
247247

248-
# Note that, to uniquely identify an experimental session (or simply a **session**), we need to know the mouse that the session was about. In other words, a session cannot existing without a corresponding mouse!
248+
# Note that, to uniquely identify an experimental session (or simply a **session**), we need to know the mouse that the session was about. In other words, a session cannot existing without a corresponding mouse!
249249
#
250-
# With **mouse** already represented as a table in our pipeline, we say that the session **depends on** the mouse! We would graphically represent this in an **entity relationship diagram (ERD)** by drawing the line between two tables, with the one below (**session**) dependeing on the one above (**mouse**).
250+
# With **mouse** already represented as a table in our pipeline, we say that the session **depends on** the mouse! We could graphically represent this in an **entity relationship diagram (ERD)** by drawing the line between two tables, with the one below (**session**) dependeing on the one above (**mouse**).
251251

252-
# Thus we will need both **mouse** and a new attribute **session_date** to uniquely identify a single session.
252+
# Thus we will need both **mouse** and a new attribute **session_date** to uniquely identify a single session.
253253
#
254254
# Remember that a **mouse** is already uniquely identified by its primary key - **mouse_id**. In DataJoint, you can declare that **session** depends on the mouse, and DataJoint will automatically include the mouse's primary key (`mouse_id`) as part of the session's primary key, along side any additional attribute(s) you specificy.
255255

@@ -266,9 +266,9 @@ class Session(dj.Manual):
266266
"""
267267

268268

269-
# You can actually generate the entity relationship diagram (ERD) on the fly by calling `dj.ERD` with the schema object
269+
# You can actually generate something similar to an entity relationship diagram (ERD) on the fly by calling `dj.Diagram` with the schema object. Many of the symbols and features are the same as the ERD standard.
270270

271-
dj.ERD(schema)
271+
dj.Diagram(schema)
272272

273273
# Let's try inserting a few sessions manually.
274274

@@ -397,17 +397,17 @@ class Session(dj.Manual):
397397
# ENTER YOUR CODE
398398

399399

400-
# In computer science/math lingo, DataJoint operations are said to **satisfy closure property**. Practically speaking, this means that the result of a query can immediately be used in another query, allowing you to build more complex queries from simpler ones.
400+
# In computer science/math lingo, DataJoint operations are said to **satisfy closure property**. Practically speaking, this means that the result of a query can immediately be used in another query, allowing you to build more complex queries from simpler ones.
401401

402402
# ### Restriction one table with another
403403

404404
# All mice that have a session
405405

406-
Mouse & Session
406+
Mouse & Session
407407

408408
# ### Combining restrictions
409409

410-
# All the above queries could be combined
410+
# All the above queries could be combined
411411

412412
# Male mice that had a session
413413

@@ -452,7 +452,7 @@ class Session(dj.Manual):
452452
Mouse * Session & 'session_date > "2017-05-19"'
453453

454454
# ## Projection .proj(): focus on attributes of interest
455-
# Beside restriction (`&`) and join (`*`) operations, DataJoint offers another type of operation: projection (`.proj()`). Projection is used to select attributes (columns) from a table, to rename them, or to create new calculated attributes.
455+
# Beside restriction (`&`) and join (`*`) operations, DataJoint offers another type of operation: projection (`.proj()`). Projection is used to select attributes (columns) from a table, to rename them, or to create new calculated attributes.
456456

457457
# From the ***Mouse*** table, suppose we want to focus only on the `sex` attribute and ignore the others, this can be done as:
458458

@@ -556,7 +556,7 @@ class Session(dj.Manual):
556556
# In the next session, we are going to extend our data pipeline with tables to represent **imported data** and define new tables to **compute and hold analysis results**.
557557
#
558558
# We will use both ephys and calcium imaging as example pipelines:
559-
# + [02-electrophysiology](./electrophysiology/02-Imported%20Tables%20-%20Interactive.ipynb)
560-
# + [02-calcium imaging](./calcium_imaging/02-Imported%20Tables%20-%20Interactive.ipynb)
559+
# + [02-calcium imaging](.../01-Calcium_Imaging/02-Imported%20Tables%20-%20Interactive.ipynb)
560+
# + [02-electrophysiology](../02-Electrophysiology/02-Imported%20Tables%20-%20Interactive.ipynb)
561561

562562

calcium_imaging/02-Imported Tables - Interactive.ipynb renamed to 01-Calcium_Imaging/02-Imported Tables - Interactive.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
"metadata": {},
6868
"outputs": [],
6969
"source": [
70-
"import sys\n",
71-
"sys.path.append(\"..\")\n",
70+
"import os\n",
71+
"if os.path.basename(os.getcwd())!='notebooks': os.chdir('/home/notebooks')\n",
7272
"from tutorial_pipeline.mouse_session import schema, Mouse, Session"
7373
]
7474
},
@@ -142,7 +142,7 @@
142142
"cell_type": "markdown",
143143
"metadata": {},
144144
"source": [
145-
"This table is dependent on the table `Session`, inheriting its primary key attributes, with an additional primary key attribute `scan_idx`. One session could contain multiple scans, which is another example of **one-to-many** relationship. We could take a look at the ERD again."
145+
"This table is dependent on the table `Session`, inheriting its primary key attributes, with an additional primary key attribute `scan_idx`. One session could contain multiple scans, which is another example of **one-to-many** relationship. We could take a look at the Diagram again."
146146
]
147147
},
148148
{
@@ -151,7 +151,7 @@
151151
"metadata": {},
152152
"outputs": [],
153153
"source": [
154-
"dj.ERD(schema)"
154+
"dj.Diagram(schema)"
155155
]
156156
},
157157
{
@@ -296,7 +296,7 @@
296296
"metadata": {},
297297
"outputs": [],
298298
"source": [
299-
"dj.ERD(schema)"
299+
"dj.Diagram(schema)"
300300
]
301301
},
302302
{
@@ -333,9 +333,9 @@
333333
"source": [
334334
"In DataJoint, the tier of the table indicates **the nature of the data and the data source for the table**. So far we have encountered two table tiers: `Manual` and `Imported`, and we will encounter the two other major tiers in this session. \n",
335335
"\n",
336-
"DataJoint tables in `Manual` tier, or simply **Manual tables** indicate that its contents are **manually** entered by either experimenters or a recording system, and its content **do not depend on external data files or other tables**. This is the most basic table type you will encounter, especially as the tables at the beggining of the pipeline. In the ERD, `Manual` tables are depicted by green rectangles.\n",
336+
"DataJoint tables in `Manual` tier, or simply **Manual tables** indicate that its contents are **manually** entered by either experimenters or a recording system, and its content **do not depend on external data files or other tables**. This is the most basic table type you will encounter, especially as the tables at the beggining of the pipeline. In the Diagram, `Manual` tables are depicted by green rectangles.\n",
337337
"\n",
338-
"On the other hand, **Imported tables** are understood to pull data (or *import* data) from external data files, and come equipped with functionalities to perform this importing process automatically, as we will see shortly! In the ERD, `Imported` tables are depicted by blue ellipses."
338+
"On the other hand, **Imported tables** are understood to pull data (or *import* data) from external data files, and come equipped with functionalities to perform this importing process automatically, as we will see shortly! In the Diagram, `Imported` tables are depicted by blue ellipses."
339339
]
340340
},
341341
{
@@ -344,7 +344,7 @@
344344
"metadata": {},
345345
"outputs": [],
346346
"source": [
347-
"dj.ERD(schema)"
347+
"dj.Diagram(schema)"
348348
]
349349
},
350350
{
@@ -676,7 +676,7 @@
676676
"metadata": {},
677677
"outputs": [],
678678
"source": [
679-
"dj.ERD(schema)"
679+
"dj.Diagram(schema)"
680680
]
681681
},
682682
{

calcium_imaging/03-Computed Table, Lookup Table, and Part Table - Interactive.ipynb renamed to 01-Calcium_Imaging/03-Computed Table, Lookup Table, and Part Table - Interactive.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"Welcome back! In this session, we are going to continue working with the pipeline for the mouse electrophysiology example. \n",
14+
"Welcome back! In this session, we are going to continue working with the pipeline for the mouse calcium imaging example. \n",
1515
"\n",
1616
"In this session, we will learn to:\n",
1717
"\n",
@@ -69,8 +69,8 @@
6969
"metadata": {},
7070
"outputs": [],
7171
"source": [
72-
"import sys\n",
73-
"sys.path.append(\"..\")\n",
72+
"import os\n",
73+
"if os.path.basename(os.getcwd())!='notebooks': os.chdir('/home/notebooks')\n",
7474
"from tutorial_pipeline.imaging import schema, Mouse, Session, Scan, AverageFrame"
7575
]
7676
},
@@ -406,7 +406,7 @@
406406
"cell_type": "markdown",
407407
"metadata": {},
408408
"source": [
409-
"Let's define `Param` table to hold different parameter configuration for our spike detection algorithm. We are going to define this table as a `Lookup` table, rather than a `Manual` table. By now, you know that `Lookup` must be yet another **table tier** in DataJoint. `Lookup` tables are depicted by gray boxes in the ERD.\n",
409+
"Let's define `Param` table to hold different parameter configuration for our spike detection algorithm. We are going to define this table as a `Lookup` table, rather than a `Manual` table. By now, you know that `Lookup` must be yet another **table tier** in DataJoint. `Lookup` tables are depicted by gray boxes in the Diagram.\n",
410410
"\n",
411411
"This tier indicates that the table will contain information:\n",
412412
"* that will be referenced by other tables\n",
@@ -435,7 +435,7 @@
435435
"metadata": {},
436436
"outputs": [],
437437
"source": [
438-
"dj.ERD(schema)"
438+
"dj.Diagram(schema)"
439439
]
440440
},
441441
{
@@ -501,7 +501,7 @@
501501
"metadata": {},
502502
"outputs": [],
503503
"source": [
504-
"dj.ERD(schema)"
504+
"dj.Diagram(schema)"
505505
]
506506
},
507507
{
@@ -1006,14 +1006,14 @@
10061006
"metadata": {},
10071007
"outputs": [],
10081008
"source": [
1009-
"dj.ERD(schema)"
1009+
"dj.Diagram(schema)"
10101010
]
10111011
},
10121012
{
10131013
"cell_type": "markdown",
10141014
"metadata": {},
10151015
"source": [
1016-
"We have covered most of the building elements of data pipeline design. Using these elements, we could design more sophiscated pipelines that facillitates your experimental recordings and data analyses."
1016+
"We have covered most of the building elements of data pipeline design. Using these elements, we could design more sophiscated pipelines that facillitates your experimental recordings and data analyses. To see these concepts in the context of another methodology, see the next folder on [Electrophysiology](../02-Electrophysiology)"
10171017
]
10181018
}
10191019
],

0 commit comments

Comments
 (0)