Skip to content

Commit 9006dbb

Browse files
committed
Make the flow of calcium imaging similar to that of ephys.
1 parent 1be593d commit 9006dbb

9 files changed

+8036
-2133
lines changed

calcium_imaging/02-Imported Tables - Completed.ipynb

Lines changed: 1917 additions & 0 deletions
Large diffs are not rendered by default.

calcium_imaging/02-Imported Tables - Interactive.ipynb

Lines changed: 1917 additions & 0 deletions
Large diffs are not rendered by default.

calcium_imaging/02-Imported and Computed tables.ipynb

Lines changed: 0 additions & 2080 deletions
This file was deleted.

calcium_imaging/03-Computed Table, Lookup Table, and Part Table - Completed.ipynb

Lines changed: 3087 additions & 0 deletions
Large diffs are not rendered by default.

calcium_imaging/03-Computed Table, Lookup Table, and Part Table - Interactive.ipynb

Lines changed: 1041 additions & 0 deletions
Large diffs are not rendered by default.
3.14 MB
Binary file not shown.

calcium_imaging/experiment.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

tutorial_pipeline/imaging.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import datajoint as dj
2+
import numpy as np
3+
import os
4+
from skimage import io
5+
6+
# import the mouse-session schema
7+
from tutorial_pipeline.mouse_session import schema, Mouse, Session
8+
9+
10+
# Table definitions
11+
12+
@schema
13+
class Scan(dj.Manual):
14+
definition = """
15+
-> Session
16+
scan_idx : int # scan index
17+
---
18+
depth : float # depth of this scan
19+
wavelength : float # wavelength used
20+
laser_power : float # power of the laser used
21+
fps : float # frames per second
22+
file_name : varchar(128) # name of the tif file
23+
"""
24+
25+
26+
@schema
27+
class AverageFrame(dj.Imported):
28+
definition = """
29+
-> Scan
30+
---
31+
average_frame : longblob # average fluorescence across frames
32+
"""
33+
def make(self, key): # key is the primary key of one of the entries in the table `Scan`
34+
# fetch data directory from table Session
35+
data_path = (Session & key).fetch1('data_path')
36+
37+
# fetch data file name from table Scan
38+
file_name = (Scan & key).fetch1('file_name')
39+
40+
# load the file
41+
im = io.imread(os.path.join(data_path, file_name))
42+
# compute the average image across the frames
43+
avg_image = np.mean(im, axis=0)
44+
45+
# Now prepare the entry as a dictionary with all fields defined in the table.
46+
key['average_frame'] = avg_image # inherit the primary key from the table Scan
47+
48+
# insert entry with the method `insert1()`
49+
self.insert1(key)
50+
51+
print('\tPopulated Scan {mouse_id} - {session_date} - {scan_idx}'.format(**key))
52+
53+
Scan.insert([
54+
{'mouse_id': 0, 'session_date': '2017-05-15', 'scan_idx': 1,
55+
'depth': 150, 'wavelength': 920, 'laser_power': 26, 'fps': 15, 'file_name': 'example_scan_01.tif'},
56+
{'mouse_id': 0, 'session_date': '2017-05-15', 'scan_idx': 2,
57+
'depth': 200, 'wavelength': 920, 'laser_power': 24, 'fps': 15, 'file_name': 'example_scan_02.tif'},
58+
{'mouse_id': 100, 'session_date': '2017-05-25', 'scan_idx': 1,
59+
'depth': 150, 'wavelength': 920, 'laser_power': 25, 'fps': 15, 'file_name': 'example_scan_03.tif'}],
60+
skip_duplicates=True)
61+
62+
AverageFrame.populate()

tutorial_pipeline/mouse_session.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,27 @@ class Session(dj.Manual):
4848
{'experiment_setup': 0,
4949
'experimenter': 'Edgar Y. Walker',
5050
'mouse_id': 0,
51-
'session_date': "2017-05-15"},
51+
'session_date': "2017-05-15",
52+
'data_path': 'data'
53+
},
5254
{'experiment_setup': 0,
5355
'experimenter': 'Edgar Y. Walker',
5456
'mouse_id': 0,
55-
'session_date': "2017-05-19"},
57+
'session_date': "2017-05-19",
58+
'data_path': 'data'
59+
},
5660
{'experiment_setup': 1,
5761
'experimenter': 'Fabian Sinz',
5862
'mouse_id': 5,
59-
'session_date': "2017-01-05"},
63+
'session_date': "2017-01-05",
64+
'data_path': 'data'
65+
},
6066
{'experiment_setup': 100,
6167
'experimenter': 'Jacob Reimer',
6268
'mouse_id': 100,
63-
'session_date': "2017-05-25"}
69+
'session_date': "2017-05-25",
70+
'data_path': 'data'
71+
}
6472
]
6573

6674
Mouse.insert(mouse_data, skip_duplicates=True)

0 commit comments

Comments
 (0)