|
11 | 11 | "outputs": [], |
12 | 12 | "source": [ |
13 | 13 | "%matplotlib widget\n", |
14 | | - "from pathlib import Path\n", |
15 | | - "import sys\n", |
16 | | - "import os\n", |
17 | | - "import warnings\n", |
18 | 14 | "\n", |
19 | 15 | "import matplotlib.pyplot as plt\n", |
20 | 16 | "plt.ioff()\n", |
|
26 | 22 | "cell_type": "code", |
27 | 23 | "execution_count": 2, |
28 | 24 | "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": {}, |
39 | 25 | "outputs": [ |
40 | 26 | { |
41 | 27 | "name": "stdout", |
42 | 28 | "output_type": "stream", |
43 | 29 | "text": [ |
44 | 30 | "smFRET analysis software version 2.1\n", |
45 | | - "(git revision 2.1-56-g70f9081)\n", |
| 31 | + "(git revision 2.1-66-gb0db9c8)\n", |
46 | 32 | "Output version 11\n", |
47 | | - "Using sdt-python version 14.1\n" |
| 33 | + "Using sdt-python version 14.3.2\n" |
48 | 34 | ] |
49 | 35 | } |
50 | 36 | ], |
|
54 | 40 | }, |
55 | 41 | { |
56 | 42 | "cell_type": "code", |
57 | | - "execution_count": 4, |
| 43 | + "execution_count": 3, |
58 | 44 | "metadata": { |
59 | 45 | "nbpresent": { |
60 | 46 | "id": "0b4b7b88-8234-4a09-9ec6-7d6a88a2e944" |
61 | 47 | } |
62 | 48 | }, |
63 | 49 | "outputs": [], |
64 | 50 | "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", |
65 | 55 | "load = False\n", |
66 | 56 | "\n", |
67 | 57 | "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", |
71 | 68 | " 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", |
80 | 75 | " 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", |
82 | 77 | " 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", |
88 | 83 | "else:\n", |
89 | | - " # load\n", |
| 84 | + " # Load\n", |
90 | 85 | " tr = Tracker.load()" |
91 | 86 | ] |
92 | 87 | }, |
93 | 88 | { |
94 | 89 | "cell_type": "code", |
95 | | - "execution_count": 5, |
| 90 | + "execution_count": 4, |
96 | 91 | "metadata": {}, |
97 | 92 | "outputs": [ |
98 | 93 | { |
99 | 94 | "data": { |
100 | 95 | "application/vnd.jupyter.widget-view+json": { |
101 | | - "model_id": "2865ab06928d41f498c19348169b04cd", |
| 96 | + "model_id": "b0b6f1c308a245e49cc5081162dc31ac", |
102 | 97 | "version_major": 2, |
103 | 98 | "version_minor": 0 |
104 | 99 | }, |
|
111 | 106 | } |
112 | 107 | ], |
113 | 108 | "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\")" |
115 | 114 | ] |
116 | 115 | }, |
117 | 116 | { |
118 | 117 | "cell_type": "code", |
119 | | - "execution_count": 9, |
| 118 | + "execution_count": 5, |
120 | 119 | "metadata": {}, |
121 | 120 | "outputs": [ |
122 | 121 | { |
123 | 122 | "data": { |
124 | 123 | "application/vnd.jupyter.widget-view+json": { |
125 | | - "model_id": "a05e9b720fc74c8cb62576d5c54cc1b4", |
| 124 | + "model_id": "29dd3bf000f74d78b8b59d7a4b07b2e9", |
126 | 125 | "version_major": 2, |
127 | 126 | "version_minor": 0 |
128 | 127 | }, |
|
136 | 135 | { |
137 | 136 | "data": { |
138 | 137 | "application/vnd.jupyter.widget-view+json": { |
139 | | - "model_id": "57edc3f24e7248e9ace42a3da08a9da1", |
| 138 | + "model_id": "4151286db6d3482aa96a10c1e5200281", |
140 | 139 | "version_major": 2, |
141 | 140 | "version_minor": 0 |
142 | 141 | }, |
143 | 142 | "text/plain": [ |
144 | | - "FigureCanvasNbAgg()" |
| 143 | + "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …" |
145 | 144 | ] |
146 | 145 | }, |
147 | 146 | "metadata": {}, |
148 | 147 | "output_type": "display_data" |
149 | 148 | } |
150 | 149 | ], |
151 | 150 | "source": [ |
| 151 | + "# Calculate the coordinate transform from bead localizations\n", |
152 | 152 | "tr.make_chromatic()" |
153 | 153 | ] |
154 | 154 | }, |
155 | 155 | { |
156 | 156 | "cell_type": "code", |
157 | | - "execution_count": 10, |
| 157 | + "execution_count": 6, |
158 | 158 | "metadata": {}, |
159 | 159 | "outputs": [ |
160 | 160 | { |
161 | 161 | "data": { |
162 | 162 | "application/vnd.jupyter.widget-view+json": { |
163 | | - "model_id": "be9a527331b641ce8879d22c7a8c1173", |
| 163 | + "model_id": "47fa8ca530b546838cd83fc4404cafff", |
164 | 164 | "version_major": 2, |
165 | 165 | "version_minor": 0 |
166 | 166 | }, |
167 | 167 | "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=…" |
169 | 169 | ] |
170 | 170 | }, |
171 | 171 | "metadata": {}, |
172 | 172 | "output_type": "display_data" |
173 | 173 | } |
174 | 174 | ], |
175 | 175 | "source": [ |
| 176 | + "# Set localization options upon donor excitation\n", |
176 | 177 | "tr.set_loc_opts(\"donor\")" |
177 | 178 | ] |
178 | 179 | }, |
179 | 180 | { |
180 | 181 | "cell_type": "code", |
181 | | - "execution_count": 11, |
| 182 | + "execution_count": 7, |
182 | 183 | "metadata": {}, |
183 | 184 | "outputs": [ |
184 | 185 | { |
185 | 186 | "data": { |
186 | 187 | "application/vnd.jupyter.widget-view+json": { |
187 | | - "model_id": "582c24aa4b164f92bd0a08546e64df56", |
| 188 | + "model_id": "1c6d128b336a4f5fb9016bf0f9e74d52", |
188 | 189 | "version_major": 2, |
189 | 190 | "version_minor": 0 |
190 | 191 | }, |
191 | 192 | "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=…" |
193 | 194 | ] |
194 | 195 | }, |
195 | 196 | "metadata": {}, |
196 | 197 | "output_type": "display_data" |
197 | 198 | } |
198 | 199 | ], |
199 | 200 | "source": [ |
| 201 | + "# Set localization options upon acceptor excitation\n", |
200 | 202 | "tr.set_loc_opts(\"acceptor\")" |
201 | 203 | ] |
202 | 204 | }, |
203 | 205 | { |
204 | 206 | "cell_type": "code", |
205 | | - "execution_count": 12, |
| 207 | + "execution_count": 8, |
206 | 208 | "metadata": { |
207 | 209 | "scrolled": true |
208 | 210 | }, |
209 | 211 | "outputs": [ |
210 | 212 | { |
211 | 213 | "data": { |
212 | 214 | "application/vnd.jupyter.widget-view+json": { |
213 | | - "model_id": "1e0f12d6598f42b59905d836fef4b4db", |
| 215 | + "model_id": "d06fa01d30c04e83a51f0524d6461309", |
214 | 216 | "version_major": 2, |
215 | 217 | "version_minor": 0 |
216 | 218 | }, |
|
223 | 225 | } |
224 | 226 | ], |
225 | 227 | "source": [ |
| 228 | + "# Run localization algorithm. This can take a while.\n", |
226 | 229 | "tr.locate()" |
227 | 230 | ] |
228 | 231 | }, |
229 | 232 | { |
230 | 233 | "cell_type": "code", |
231 | | - "execution_count": 5, |
| 234 | + "execution_count": 9, |
232 | 235 | "metadata": {}, |
233 | 236 | "outputs": [ |
234 | 237 | { |
235 | 238 | "data": { |
236 | 239 | "application/vnd.jupyter.widget-view+json": { |
237 | | - "model_id": "25ef68687c954867993e4052dd0e3ecc", |
| 240 | + "model_id": "c407017e2a2548e4af48cbdcf9d545cf", |
238 | 241 | "version_major": 2, |
239 | 242 | "version_minor": 0 |
240 | 243 | }, |
|
247 | 250 | } |
248 | 251 | ], |
249 | 252 | "source": [ |
| 253 | + "# Track the localizations. \n", |
250 | 254 | "tr.track(feat_radius=4, bg_frame=3, link_radius=5, link_mem=3, min_length=4, bg_estimator=\"mean\")" |
251 | 255 | ] |
252 | 256 | }, |
253 | 257 | { |
254 | 258 | "cell_type": "code", |
255 | | - "execution_count": 6, |
| 259 | + "execution_count": 10, |
256 | 260 | "metadata": {}, |
257 | 261 | "outputs": [], |
258 | 262 | "source": [ |
| 263 | + "# Get the images of the cells\n", |
259 | 264 | "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)" |
262 | 269 | ] |
263 | 270 | }, |
264 | 271 | { |
265 | 272 | "cell_type": "code", |
266 | | - "execution_count": 7, |
| 273 | + "execution_count": 11, |
267 | 274 | "metadata": {}, |
268 | 275 | "outputs": [], |
269 | 276 | "source": [ |
| 277 | + "# Save data\n", |
270 | 278 | "tr.save()" |
271 | 279 | ] |
272 | 280 | }, |
|
0 commit comments