|
101 | 101 | "\n",
|
102 | 102 | "Additional file formats will be added in the future (and upon request). All files can be imported using the same {func}`load_video` function, with which it is also possible to load only a specific number of frames or range of the data (e.g. from a specific frame to another), see below. \n",
|
103 | 103 | "\n",
|
104 |
| - "### TIFF Images\n", |
| 104 | + "````{dropdown} TIFF Stacks\n", |
| 105 | + ":open:\n", |
105 | 106 | "\n",
|
106 |
| - "``optimap`` can read .tif / .tiff (TIFF) saved as an image stack (a single file) or an image series in a folder (8-bit and 16-bit). Simply provide the filename with the .tif or .tiff ending to load a single TIFF stack:" |
107 |
| - ] |
108 |
| - }, |
109 |
| - { |
110 |
| - "cell_type": "code", |
111 |
| - "execution_count": null, |
112 |
| - "metadata": { |
113 |
| - "tags": [ |
114 |
| - "skip-execution" |
115 |
| - ] |
116 |
| - }, |
117 |
| - "outputs": [], |
118 |
| - "source": [ |
119 |
| - "video = om.load_video('filename.tiff')" |
120 |
| - ] |
121 |
| - }, |
122 |
| - { |
123 |
| - "cell_type": "markdown", |
124 |
| - "metadata": {}, |
125 |
| - "source": [ |
126 |
| - "or the name of the folder containing the images to load a series of .tif images:" |
127 |
| - ] |
128 |
| - }, |
129 |
| - { |
130 |
| - "cell_type": "code", |
131 |
| - "execution_count": null, |
132 |
| - "metadata": { |
133 |
| - "tags": [ |
134 |
| - "skip-execution" |
135 |
| - ] |
136 |
| - }, |
137 |
| - "outputs": [], |
138 |
| - "source": [ |
139 |
| - "video = om.load_video('folder_containing_tif_images')" |
140 |
| - ] |
141 |
| - }, |
142 |
| - { |
143 |
| - "cell_type": "markdown", |
144 |
| - "metadata": {}, |
145 |
| - "source": [ |
146 |
| - "### PNG Images\n", |
| 107 | + "``optimap`` can read .tif / .tiff (TIFF) saved as an image stack (a single file):\n", |
147 | 108 | "\n",
|
148 |
| - "``optimap`` can read a series of .png (PNG) images stored in a folder. Simply provide the name of the folder containing the image series." |
149 |
| - ] |
150 |
| - }, |
151 |
| - { |
152 |
| - "cell_type": "code", |
153 |
| - "execution_count": null, |
154 |
| - "metadata": { |
155 |
| - "tags": [ |
156 |
| - "skip-execution" |
157 |
| - ] |
158 |
| - }, |
159 |
| - "outputs": [], |
160 |
| - "source": [ |
161 |
| - "video = om.load_video('folder_containing_png_images')" |
162 |
| - ] |
163 |
| - }, |
164 |
| - { |
165 |
| - "cell_type": "markdown", |
166 |
| - "metadata": {}, |
167 |
| - "source": [ |
168 |
| - "### SciMedia\n", |
| 109 | + "```python\n", |
| 110 | + "video = optimap.load_video(\"example.tif\")\n", |
| 111 | + "```\n", |
| 112 | + "````\n", |
169 | 113 | "\n",
|
170 |
| - "``optimap`` can read the different SciMedia file formats, including video files acquired with single- and dual-camera systems. To import Scimedia MiCAM ULTIMA video files you only need to provide the filename with the .rsh ending of the header file (assuming it is located in the same location as the .rsd files):" |
171 |
| - ] |
172 |
| - }, |
173 |
| - { |
174 |
| - "cell_type": "code", |
175 |
| - "execution_count": null, |
176 |
| - "metadata": { |
177 |
| - "tags": [ |
178 |
| - "skip-execution" |
179 |
| - ] |
180 |
| - }, |
181 |
| - "outputs": [], |
182 |
| - "source": [ |
183 |
| - "video = om.load_video('filename.rsh')" |
184 |
| - ] |
185 |
| - }, |
186 |
| - { |
187 |
| - "cell_type": "markdown", |
188 |
| - "metadata": {}, |
189 |
| - "source": [ |
190 |
| - "To import Scimedia MiCAM 05 video files you only need to provide the filename with the .gsh ending of the header file:" |
191 |
| - ] |
192 |
| - }, |
193 |
| - { |
194 |
| - "cell_type": "code", |
195 |
| - "execution_count": null, |
196 |
| - "metadata": { |
197 |
| - "tags": [ |
198 |
| - "skip-execution" |
199 |
| - ] |
200 |
| - }, |
201 |
| - "outputs": [], |
202 |
| - "source": [ |
203 |
| - "video = om.load_video('filename.gsh')" |
204 |
| - ] |
205 |
| - }, |
206 |
| - { |
207 |
| - "cell_type": "markdown", |
208 |
| - "metadata": {}, |
209 |
| - "source": [ |
210 |
| - "### MultiRecorder\n", |
211 | 114 | "\n",
|
212 |
| - "``optimap`` can import .dat video files acquired with MultiRecorder (developed by J. Schröder-Schetelig, Max Planck Institute for Dynamics and Self-Organization)." |
213 |
| - ] |
214 |
| - }, |
215 |
| - { |
216 |
| - "cell_type": "code", |
217 |
| - "execution_count": null, |
218 |
| - "metadata": { |
219 |
| - "tags": [ |
220 |
| - "skip-execution" |
221 |
| - ] |
222 |
| - }, |
223 |
| - "outputs": [], |
224 |
| - "source": [ |
225 |
| - "video = om.load_video('filename.dat')" |
226 |
| - ] |
227 |
| - }, |
228 |
| - { |
229 |
| - "cell_type": "markdown", |
230 |
| - "metadata": {}, |
231 |
| - "source": [ |
232 |
| - "### Numpy\n", |
| 115 | + "````{dropdown} Folder of TIFF/PNG Images\n", |
| 116 | + "Optimap can read a series of .tif / .tiff (TIFF) or .png (PNG) images stored in a folder. Simply provide the path to folder containing the image series. 16-bit TIFF or PNG images are supported.\n", |
| 117 | + " \n", |
| 118 | + "```python\n", |
| 119 | + "video = optimap.load_video(\"example_folder\")\n", |
| 120 | + "```\n", |
233 | 121 | "\n",
|
234 |
| - "Videos stored as numpy arrays can easily be imported using:" |
235 |
| - ] |
236 |
| - }, |
237 |
| - { |
238 |
| - "cell_type": "code", |
239 |
| - "execution_count": null, |
240 |
| - "metadata": { |
241 |
| - "tags": [ |
242 |
| - "skip-execution" |
243 |
| - ] |
244 |
| - }, |
245 |
| - "outputs": [], |
246 |
| - "source": [ |
247 |
| - "video = om.load_video('filename.npy')" |
| 122 | + "The images filenames in the folder will be sorted in natural order (i.e `frame_2.png` comes before `frame_10.png`) and loaded in that order.\n", |
| 123 | + "\n", |
| 124 | + "If a folder contains several image series, use {func}`video.load_image_folder` instead:\n", |
| 125 | + "```python\n", |
| 126 | + "video = optimap.load_image_folder(\"example_folder\", prefix=\"frame_\")\n", |
| 127 | + "```\n", |
| 128 | + "where `prefix` is the common prefix of the image series filenames.\n", |
| 129 | + "````\n", |
| 130 | + "\n", |
| 131 | + "````{dropdown} SciMedia\n", |
| 132 | + "Optimap can read the different SciMedia file formats, including video files acquired with single- and dual-camera systems.\n", |
| 133 | + "\n", |
| 134 | + "To import Scimedia MiCAM ULTIMA video files provide the path to an .rsh or .rsm file:\n", |
| 135 | + "\n", |
| 136 | + "```python\n", |
| 137 | + "video = optimap.load_video(\"example.rsh\")\n", |
| 138 | + "```\n", |
| 139 | + "\n", |
| 140 | + "See the {class}`video.MiCAM_ULTIMA_Importer` class for more details and options.\n", |
| 141 | + "\n", |
| 142 | + "For Scimedia MiCAM 05 video files provide the path to an .gsd or .gsh file:\n", |
| 143 | + "\n", |
| 144 | + "```python\n", |
| 145 | + "video = optimap.load_video(\"example.gsh\")\n", |
| 146 | + "```\n", |
| 147 | + "\n", |
| 148 | + "See the {class}`video.MiCAM05_Importer` class for more details and options.\n", |
| 149 | + "\n", |
| 150 | + "For both MiCAM Ultima or MiCam 05 you can load the metadata of the video file with {func}`video.load_metadata`:\n", |
| 151 | + "```python\n", |
| 152 | + "metadata = video.load_metadata(\"example.rsh\")\n", |
| 153 | + "print(metadata)\n", |
| 154 | + "```\n", |
| 155 | + "````\n", |
| 156 | + "\n", |
| 157 | + "````{dropdown} MultiRecorder\n", |
| 158 | + "optimap can import .dat video files acquired with MultiRecorder (developed by J. Schröder-Schetelig, Max Planck Institute for Dynamics and Self-Organization).\n", |
| 159 | + "```python\n", |
| 160 | + "video = optimap.load_video(\"example.dat\")\n", |
| 161 | + "```\n", |
| 162 | + "\n", |
| 163 | + "See the {class}`video.MultiRecorderImporter` class for more details and options.\n", |
| 164 | + "\n", |
| 165 | + "The metadata of the video file can be loaded with {func}`video.load_metadata`:\n", |
| 166 | + "```python\n", |
| 167 | + "metadata = video.load_metadata(\"example.dat\")\n", |
| 168 | + "print(metadata)\n", |
| 169 | + "```\n", |
| 170 | + "````\n", |
| 171 | + "\n", |
| 172 | + "````{dropdown} NumPy\n", |
| 173 | + "Videos stored as numpy arrays can easily be imported using:\n", |
| 174 | + "```python\n", |
| 175 | + "video = optimap.load_video(\"example.npy\")\n", |
| 176 | + "```\n", |
| 177 | + "````\n", |
| 178 | + "\n", |
| 179 | + "````{dropdown} MATLAB\n", |
| 180 | + "Videos stored as arrays in the Matlab file format (.mat) can easily be imported using\n", |
| 181 | + " \n", |
| 182 | + "```python\n", |
| 183 | + "video = optimap.load_video(\"example.mat\")\n", |
| 184 | + "```\n", |
| 185 | + "\n", |
| 186 | + "This will load the first field in the file. To load a specific field/variable, use the following syntax:\n", |
| 187 | + "\n", |
| 188 | + "```python\n", |
| 189 | + "video = optimap.load_video(\"example.mat\", fieldname=\"field_name\")\n", |
| 190 | + "```\n", |
| 191 | + "````" |
248 | 192 | ]
|
249 | 193 | },
|
250 | 194 | {
|
251 | 195 | "cell_type": "markdown",
|
252 | 196 | "metadata": {},
|
253 | 197 | "source": [
|
254 |
| - "### Matlab\n", |
| 198 | + "In all cases, it is possible to import only parts of a video to reduce loading times using the following optional arguments:\n", |
| 199 | + "\n", |
| 200 | + "* `start_frame`: The first frame to load (default: 0)\n", |
| 201 | + "* `frames`: Number of frames to load (default: all)\n", |
| 202 | + "* `step`: Load every `step`-th frame (default: 1)\n", |
255 | 203 | "\n",
|
256 |
| - "Videos stored as arrays in the Matlab file format (.mat) can easily be imported using:" |
| 204 | + "For instance, load 1000 frames and only every 2nd frame starting from frame 100:" |
257 | 205 | ]
|
258 | 206 | },
|
259 | 207 | {
|
|
266 | 214 | },
|
267 | 215 | "outputs": [],
|
268 | 216 | "source": [
|
269 |
| - "video = om.load_video('filename.mat')" |
| 217 | + "video = om.load_video(\"filename.tif\", start_frame=100, frames=1000, step=2)" |
270 | 218 | ]
|
271 | 219 | },
|
272 | 220 | {
|
273 | 221 | "cell_type": "markdown",
|
274 | 222 | "metadata": {},
|
275 | 223 | "source": [
|
276 |
| - "It is possible to import only parts of a video, for instance, only 1000 frames and only every 2nd frame starting from frame 100:" |
277 |
| - ] |
278 |
| - }, |
279 |
| - { |
280 |
| - "cell_type": "code", |
281 |
| - "execution_count": null, |
282 |
| - "metadata": { |
283 |
| - "tags": [ |
284 |
| - "skip-execution" |
285 |
| - ] |
286 |
| - }, |
287 |
| - "outputs": [], |
288 |
| - "source": [ |
289 |
| - "video = om.load_video('filename.npy', start_frame=100, frames=1000, step=2, use_mmap=False)" |
| 224 | + "This will load frames 100, 102, 104, 106, ..., 2098.\n", |
| 225 | + "\n", |
| 226 | + "Additionally, the `use_mmap` argument can be used to load the video using memory mapping. This will load the video as a read-only memory-mapped array, which means that the data is not loaded into memory until it is accessed. This can be useful to reduce memory usage or loading times when working with large or numerous video files.\n", |
| 227 | + "\n", |
| 228 | + "```python\n", |
| 229 | + "video = om.load_video(\"example.npy\", use_mmap=True)\n", |
| 230 | + "```\n", |
| 231 | + "\n", |
| 232 | + "`use_mmap` is disabled by default and only supported for TIFF stacks, MultiRecorder .dat files and NumPy .npy files." |
290 | 233 | ]
|
291 | 234 | },
|
292 | 235 | {
|
293 | 236 | "cell_type": "markdown",
|
294 | 237 | "metadata": {},
|
295 | 238 | "source": [
|
296 |
| - "This option is available for all file formats including image series. Please refer to the Documentation for more information.\n", |
297 |
| - "\n", |
298 | 239 | "## Saving / Exporting Videos\n",
|
299 | 240 | "\n",
|
300 | 241 | "The following file formats can be saved / exported with ``optimap``:\n",
|
|
0 commit comments