Skip to content

Commit 2688edb

Browse files
author
Lukas Schrangl
committed
Fix and document Tracking notebook
1 parent b0db9c8 commit 2688edb

File tree

1 file changed

+64
-56
lines changed

1 file changed

+64
-56
lines changed

notebooks/01. Tracking.ipynb

Lines changed: 64 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
"outputs": [],
1212
"source": [
1313
"%matplotlib widget\n",
14-
"from pathlib import Path\n",
15-
"import sys\n",
16-
"import os\n",
17-
"import warnings\n",
1814
"\n",
1915
"import matplotlib.pyplot as plt\n",
2016
"plt.ioff()\n",
@@ -26,25 +22,15 @@
2622
"cell_type": "code",
2723
"execution_count": 2,
2824
"metadata": {},
29-
"outputs": [],
30-
"source": [
31-
"%load_ext autoreload\n",
32-
"%autoreload 2"
33-
]
34-
},
35-
{
36-
"cell_type": "code",
37-
"execution_count": 3,
38-
"metadata": {},
3925
"outputs": [
4026
{
4127
"name": "stdout",
4228
"output_type": "stream",
4329
"text": [
4430
"smFRET analysis software version 2.1\n",
45-
"(git revision 2.1-56-g70f9081)\n",
31+
"(git revision 2.1-66-gb0db9c8)\n",
4632
"Output version 11\n",
47-
"Using sdt-python version 14.1\n"
33+
"Using sdt-python version 14.3.2\n"
4834
]
4935
}
5036
],
@@ -54,51 +40,60 @@
5440
},
5541
{
5642
"cell_type": "code",
57-
"execution_count": 4,
43+
"execution_count": 3,
5844
"metadata": {
5945
"nbpresent": {
6046
"id": "0b4b7b88-8234-4a09-9ec6-7d6a88a2e944"
6147
}
6248
},
6349
"outputs": [],
6450
"source": [
51+
"# Create a Tracker instance\n",
52+
"\n",
53+
"# If starting fresh, set load = False. If there is already saved data from a previous run,\n",
54+
"# load = True can be used to load it.\n",
6555
"load = False\n",
6656
"\n",
6757
"if not load:\n",
68-
" # Start fresh\n",
69-
" data_dir = \"/media/lukas/LS-ext-blue/Data/Force sensor FRET/2018-11-21\"\n",
70-
" # donor origin, acceptor origin, size\n",
58+
" # Directory containing raw data\n",
59+
" data_dir = \"sm-data\"\n",
60+
" \n",
61+
" # Specify\n",
62+
" # - origin of donor channel\n",
63+
" # - origin of acceptor channel\n",
64+
" # - ROI size\n",
65+
" # - excitation sequence, where \"c\" means cell contours, \"a\" means acceptor excitation,\n",
66+
" # and \"d\" means donor excitation\n",
67+
" # - data directory\n",
7168
" tr = Tracker((201, 0), (0, 0), (190, 111), \"ce\" + \"da\" * 300 + \"c\", data_dir=data_dir)\n",
72-
" tr.add_dataset(\"DPPC sensor cells\",\n",
73-
" Path(\"^DPPC_sensor-J4\", r\"cells-\\d{2}_(\\d{3})_.SPE\"), cells=True)\n",
74-
" tr.add_dataset(\"DPPC sensor no-cells\",\n",
75-
" Path(\"^DPPC_sensor-J4\", r\"no-cells_(\\d{3})_.SPE\"), cells=False)\n",
76-
" tr.add_dataset(\"POPC sensor cells\",\n",
77-
" Path(\"^POPC_sensor-J4\", r\"cells-\\d{2}_(\\d{3})_.SPE\"), cells=True)\n",
78-
" tr.add_dataset(\"POPC sensor no-cells\",\n",
79-
" Path(\"^POPC_sensor-J4\", r\"no-cells_(\\d{3})_.SPE\"), cells=False)\n",
69+
" \n",
70+
" # Add datasets by giving\n",
71+
" # - an identifier\n",
72+
" # - a regular expression describing the file names relative to data_dir.\n",
73+
" # Use forward slashes as path separators even on Windows.\n",
74+
" # - cells = True or False depending on whether the sample contained cells\n",
8075
" tr.add_dataset(\"DPPC control cells\",\n",
81-
" Path(\"^DPPC_ctrl-J4\", r\"cells-\\d{2}_(\\d{3})_.SPE\"), cells=True)\n",
76+
" r\"^DPPC_ctrl-J4/cells-\\d{2}_\\d{3}_.tif\", cells=True)\n",
8277
" tr.add_dataset(\"DPPC control no-cells\",\n",
83-
" Path(\"^DPPC_ctrl-J4\", r\"no-cells_(\\d{3})_.SPE\"), cells=False)\n",
84-
" tr.add_dataset(\"POPC control cells\",\n",
85-
" Path(\"^POPC_ctrl-J4\", r\"cells-\\d{2}_(\\d{3})_.SPE\"), cells=True)\n",
86-
" tr.add_dataset(\"POPC control no-cells\",\n",
87-
" Path(\"^POPC_ctrl-J4\", r\"no-cells_(\\d{3})_.SPE\"), cells=False)\n",
78+
" r\"^DPPC_ctrl-J4/no-cells_\\d{3}_.tif\", cells=False)\n",
79+
" #tr.add_dataset(\"DPPC sensor cells\",\n",
80+
" # r\"^DPPC_sensor-J4/cells-\\d{2}_\\d{3}_.SPE\", cells=True)\n",
81+
" #tr.add_dataset(\"DPPC sensor no-cells\",\n",
82+
" # r\"^DPPC_sensor-J4/no-cells_\\d{3}_.SPE\", cells=False)\n",
8883
"else:\n",
89-
" # load\n",
84+
" # Load\n",
9085
" tr = Tracker.load()"
9186
]
9287
},
9388
{
9489
"cell_type": "code",
95-
"execution_count": 5,
90+
"execution_count": 4,
9691
"metadata": {},
9792
"outputs": [
9893
{
9994
"data": {
10095
"application/vnd.jupyter.widget-view+json": {
101-
"model_id": "2865ab06928d41f498c19348169b04cd",
96+
"model_id": "b0b6f1c308a245e49cc5081162dc31ac",
10297
"version_major": 2,
10398
"version_minor": 0
10499
},
@@ -111,18 +106,22 @@
111106
}
112107
],
113108
"source": [
114-
"tr.set_bead_loc_opts(Path(\"beads\", \"beads_\\d+_.SPE\"))"
109+
"# Set localization options for beads, which are used below to calculate the\n",
110+
"# coordinate transform between donor and acceptor channels\n",
111+
"# The argument is a regular expression matching the bead files' names with\n",
112+
"# forward slashes as path separators\n",
113+
"tr.set_bead_loc_opts(r\"beads/beads_\\d+_.tif\")"
115114
]
116115
},
117116
{
118117
"cell_type": "code",
119-
"execution_count": 9,
118+
"execution_count": 5,
120119
"metadata": {},
121120
"outputs": [
122121
{
123122
"data": {
124123
"application/vnd.jupyter.widget-view+json": {
125-
"model_id": "a05e9b720fc74c8cb62576d5c54cc1b4",
124+
"model_id": "29dd3bf000f74d78b8b59d7a4b07b2e9",
126125
"version_major": 2,
127126
"version_minor": 0
128127
},
@@ -136,81 +135,84 @@
136135
{
137136
"data": {
138137
"application/vnd.jupyter.widget-view+json": {
139-
"model_id": "57edc3f24e7248e9ace42a3da08a9da1",
138+
"model_id": "4151286db6d3482aa96a10c1e5200281",
140139
"version_major": 2,
141140
"version_minor": 0
142141
},
143142
"text/plain": [
144-
"FigureCanvasNbAgg()"
143+
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
145144
]
146145
},
147146
"metadata": {},
148147
"output_type": "display_data"
149148
}
150149
],
151150
"source": [
151+
"# Calculate the coordinate transform from bead localizations\n",
152152
"tr.make_chromatic()"
153153
]
154154
},
155155
{
156156
"cell_type": "code",
157-
"execution_count": 10,
157+
"execution_count": 6,
158158
"metadata": {},
159159
"outputs": [
160160
{
161161
"data": {
162162
"application/vnd.jupyter.widget-view+json": {
163-
"model_id": "be9a527331b641ce8879d22c7a8c1173",
163+
"model_id": "47fa8ca530b546838cd83fc4404cafff",
164164
"version_major": 2,
165165
"version_minor": 0
166166
},
167167
"text/plain": [
168-
"VBox(children=(Dropdown(description='dataset', options=('DPPC sensor cells', 'DPPC sensor no-cells', 'POPC sen…"
168+
"VBox(children=(Dropdown(description='dataset', options=('DPPC control cells', 'DPPC control no-cells'), value=…"
169169
]
170170
},
171171
"metadata": {},
172172
"output_type": "display_data"
173173
}
174174
],
175175
"source": [
176+
"# Set localization options upon donor excitation\n",
176177
"tr.set_loc_opts(\"donor\")"
177178
]
178179
},
179180
{
180181
"cell_type": "code",
181-
"execution_count": 11,
182+
"execution_count": 7,
182183
"metadata": {},
183184
"outputs": [
184185
{
185186
"data": {
186187
"application/vnd.jupyter.widget-view+json": {
187-
"model_id": "582c24aa4b164f92bd0a08546e64df56",
188+
"model_id": "1c6d128b336a4f5fb9016bf0f9e74d52",
188189
"version_major": 2,
189190
"version_minor": 0
190191
},
191192
"text/plain": [
192-
"VBox(children=(Dropdown(description='dataset', options=('DPPC sensor cells', 'DPPC sensor no-cells', 'POPC sen…"
193+
"VBox(children=(Dropdown(description='dataset', options=('DPPC control cells', 'DPPC control no-cells'), value=…"
193194
]
194195
},
195196
"metadata": {},
196197
"output_type": "display_data"
197198
}
198199
],
199200
"source": [
201+
"# Set localization options upon acceptor excitation\n",
200202
"tr.set_loc_opts(\"acceptor\")"
201203
]
202204
},
203205
{
204206
"cell_type": "code",
205-
"execution_count": 12,
207+
"execution_count": 8,
206208
"metadata": {
207209
"scrolled": true
208210
},
209211
"outputs": [
210212
{
211213
"data": {
212214
"application/vnd.jupyter.widget-view+json": {
213-
"model_id": "1e0f12d6598f42b59905d836fef4b4db",
215+
"model_id": "d06fa01d30c04e83a51f0524d6461309",
214216
"version_major": 2,
215217
"version_minor": 0
216218
},
@@ -223,18 +225,19 @@
223225
}
224226
],
225227
"source": [
228+
"# Run localization algorithm. This can take a while.\n",
226229
"tr.locate()"
227230
]
228231
},
229232
{
230233
"cell_type": "code",
231-
"execution_count": 5,
234+
"execution_count": 9,
232235
"metadata": {},
233236
"outputs": [
234237
{
235238
"data": {
236239
"application/vnd.jupyter.widget-view+json": {
237-
"model_id": "25ef68687c954867993e4052dd0e3ecc",
240+
"model_id": "c407017e2a2548e4af48cbdcf9d545cf",
238241
"version_major": 2,
239242
"version_minor": 0
240243
},
@@ -247,26 +250,31 @@
247250
}
248251
],
249252
"source": [
253+
"# Track the localizations. \n",
250254
"tr.track(feat_radius=4, bg_frame=3, link_radius=5, link_mem=3, min_length=4, bg_estimator=\"mean\")"
251255
]
252256
},
253257
{
254258
"cell_type": "code",
255-
"execution_count": 6,
259+
"execution_count": 10,
256260
"metadata": {},
257261
"outputs": [],
258262
"source": [
263+
"# Get the images of the cells\n",
259264
"tr.extract_cell_images()\n",
260-
"tr.make_flatfield(\"donor\", Path(\"profile\", r\"green_.*\"), bg=200, smooth_sigma=10)\n",
261-
"tr.make_flatfield(\"acceptor\", Path(\"profile\", r\"red_.*\"), bg=200, smooth_sigma=10)"
265+
"\n",
266+
"# Get the laser profiles from additional recordings of bulk samples\n",
267+
"tr.make_flatfield(\"donor\", \"profile/green_.*\", bg=200, smooth_sigma=10)\n",
268+
"tr.make_flatfield(\"acceptor\", \"profile/red_.*\", bg=200, smooth_sigma=10)"
262269
]
263270
},
264271
{
265272
"cell_type": "code",
266-
"execution_count": 7,
273+
"execution_count": 11,
267274
"metadata": {},
268275
"outputs": [],
269276
"source": [
277+
"# Save data\n",
270278
"tr.save()"
271279
]
272280
},

0 commit comments

Comments
 (0)