|
45 | 45 | "source": [
|
46 | 46 | "import itk\n",
|
47 | 47 | "import pooch\n",
|
48 |
| - "from ngff_zarr import to_multiscales, ngff_image_to_itk_image, Methods\n", |
49 |
| - "from itkwidgets import view" |
| 48 | + "from ngff_zarr import ngff_image_to_itk_image\n", |
| 49 | + "from itkwidgets import view\n", |
| 50 | + "import zarr" |
50 | 51 | ]
|
51 | 52 | },
|
52 | 53 | {
|
|
235 | 236 | "name": "stdout",
|
236 | 237 | "output_type": "stream",
|
237 | 238 | "text": [
|
238 |
| - "Slices for loaded scale: (slice(0, 250, None), slice(0, 350, None), slice(120, 173, None))\n", |
239 |
| - "Slices with default parameter: (slice(0, 250, None), slice(0, 350, None), slice(120, 173, None))\n" |
| 239 | + "Slices for loaded scale: (slice(0, 250, None), slice(0, 350, None), slice(122, 170, None))\n", |
| 240 | + "Slices with default parameter: (slice(0, 250, None), slice(0, 350, None), slice(122, 170, None))\n" |
240 | 241 | ]
|
241 | 242 | }
|
242 | 243 | ],
|
|
246 | 247 | "print(f'Slices with default parameter: {default_roi_slices}')"
|
247 | 248 | ]
|
248 | 249 | },
|
| 250 | + { |
| 251 | + "cell_type": "markdown", |
| 252 | + "metadata": {}, |
| 253 | + "source": [ |
| 254 | + "#### The ROI region will return the physical, world coordinates for the selection" |
| 255 | + ] |
| 256 | + }, |
249 | 257 | {
|
250 | 258 | "cell_type": "code",
|
251 | 259 | "execution_count": 10,
|
|
256 | 264 | },
|
257 | 265 | "outputs": [],
|
258 | 266 | "source": [
|
259 |
| - "# Create a new viewer using only the data in the ROI determined above\n", |
260 |
| - "# get_roi_image will return a dict of ngff images with the keys representing the names for each\n", |
261 |
| - "# For our example we should have one entry under \"Image\"\n", |
262 |
| - "roi_image = viewer.get_roi_image(loaded_scale)" |
| 267 | + "# Get the selected region for the current level\n", |
| 268 | + "roi_region = viewer.get_roi_region()" |
263 | 269 | ]
|
264 | 270 | },
|
265 | 271 | {
|
|
274 | 280 | {
|
275 | 281 | "data": {
|
276 | 282 | "text/plain": [
|
277 |
| - "NgffImage(data=dask.array<getitem, shape=(250, 350, 53), dtype=int16, chunksize=(128, 128, 45), chunktype=numpy.ndarray>, dims=['z', 'y', 'x'], scale={'z': 0.2734, 'y': 0.2734, 'x': 0.2734}, translation={'x': 25.973146382696534, 'y': -6.971699714660643, 'z': -6.971699953079224}, name='Image', axes_units={'z': None, 'y': None, 'x': None}, computed_callbacks=[])" |
| 283 | + "[{'x': 26.70976023219073, 'y': -6.971699714660643, 'z': -6.971699953079224},\n", |
| 284 | + " {'x': 39.35382616126007, 'y': 88.71824073791504, 'z': 61.378257513046265}]" |
278 | 285 | ]
|
279 | 286 | },
|
280 | 287 | "execution_count": 11,
|
|
283 | 290 | }
|
284 | 291 | ],
|
285 | 292 | "source": [
|
286 |
| - "roi_image" |
287 |
| - ] |
288 |
| - }, |
289 |
| - { |
290 |
| - "cell_type": "markdown", |
291 |
| - "metadata": {}, |
292 |
| - "source": [ |
293 |
| - "#### The ROI region will return the physical, world coordinates for the selection" |
| 293 | + "roi_region" |
294 | 294 | ]
|
295 | 295 | },
|
296 | 296 | {
|
|
303 | 303 | },
|
304 | 304 | "outputs": [],
|
305 | 305 | "source": [
|
306 |
| - "# Get the selected region for the current level\n", |
307 |
| - "roi_region = viewer.get_roi_region()" |
| 306 | + "# get_roi_image will return an ngff image for the currently selected image\n", |
| 307 | + "# optionally a name can also be passed in to select a specific image if more than one image or label is loaded\n", |
| 308 | + "roi_image = viewer.get_roi_image(loaded_scale)" |
308 | 309 | ]
|
309 | 310 | },
|
310 | 311 | {
|
|
319 | 320 | {
|
320 | 321 | "data": {
|
321 | 322 | "text/plain": [
|
322 |
| - "[{'x': 25.973146382696534, 'y': -6.971699714660643, 'z': -6.971699953079224},\n", |
323 |
| - " {'x': 40.14316091031731, 'y': 88.71824073791504, 'z': 61.378257513046265}]" |
| 323 | + "NgffImage(data=dask.array<getitem, shape=(250, 350, 48), dtype=int16, chunksize=(128, 128, 42), chunktype=numpy.ndarray>, dims=['z', 'y', 'x'], scale={'z': 0.2734, 'y': 0.2734, 'x': 0.2734}, translation={'x': 26.70976023219073, 'y': -6.971699714660643, 'z': -6.971699953079224}, name='Image', axes_units={'z': None, 'y': None, 'x': None}, computed_callbacks=[])" |
324 | 324 | ]
|
325 | 325 | },
|
326 | 326 | "execution_count": 13,
|
|
329 | 329 | }
|
330 | 330 | ],
|
331 | 331 | "source": [
|
332 |
| - "roi_region" |
| 332 | + "roi_image" |
333 | 333 | ]
|
334 | 334 | },
|
335 | 335 | {
|
|
342 | 342 | },
|
343 | 343 | "outputs": [],
|
344 | 344 | "source": [
|
345 |
| - "# Create an itk image from the ngff image returned from get_roi_image\n", |
346 |
| - "itk_image = ngff_image_to_itk_image(roi_image)" |
| 345 | + "# Optionally we can also grab the ngff images for all scales\n", |
| 346 | + "roi_multiscales = viewer.get_roi_multiscale()" |
347 | 347 | ]
|
348 | 348 | },
|
349 | 349 | {
|
|
354 | 354 | "skip-execution"
|
355 | 355 | ]
|
356 | 356 | },
|
| 357 | + "outputs": [ |
| 358 | + { |
| 359 | + "data": { |
| 360 | + "text/plain": [ |
| 361 | + "Multiscales(images=[NgffImage(data=dask.array<rechunk-merge, shape=(250, 350, 48), dtype=int16, chunksize=(128, 128, 48), chunktype=numpy.ndarray>, dims=['z', 'y', 'x'], scale={'z': 0.2734, 'y': 0.2734, 'x': 0.2734}, translation={'x': 26.70976023219073, 'y': -6.971699714660643, 'z': -6.971699953079224}, name='Image', axes_units={'z': None, 'y': None, 'x': None}, computed_callbacks=[]), NgffImage(data=dask.array<rechunk-merge, shape=(250, 175, 48), dtype=int16, chunksize=(128, 128, 48), chunktype=numpy.ndarray>, dims=['z', 'y', 'x'], scale={'z': 0.2734, 'y': 0.5468, 'x': 0.2734}, translation={'z': -6.971699953079224, 'y': -6.8349997146606425, 'x': 26.70976023219073}, name='image', axes_units=None, computed_callbacks=[])], metadata=Metadata(axes=[Axis(name='z', type='space', unit=None), Axis(name='y', type='space', unit=None), Axis(name='x', type='space', unit=None)], datasets=[Dataset(path='scale0/Image', coordinateTransformations=[Scale(scale=[0.2734, 0.2734, 0.2734], type='scale'), Translation(translation=[-6.971699953079224, -6.971699714660643, 26.70976023219073], type='translation')]), Dataset(path='scale1/Image', coordinateTransformations=[Scale(scale=[0.2734, 0.5468, 0.2734], type='scale'), Translation(translation=[-6.971699953079224, -6.8349997146606425, 26.70976023219073], type='translation')])], coordinateTransformations=None, name='Image', version='0.4'), scale_factors=[{'x': 1, 'y': 2, 'z': 1}], method=<Methods.DASK_IMAGE_GAUSSIAN: 'dask_image_gaussian'>, chunks={'z': 128, 'y': 128, 'x': 128})" |
| 362 | + ] |
| 363 | + }, |
| 364 | + "execution_count": 15, |
| 365 | + "metadata": {}, |
| 366 | + "output_type": "execute_result" |
| 367 | + } |
| 368 | + ], |
| 369 | + "source": [ |
| 370 | + "roi_multiscales" |
| 371 | + ] |
| 372 | + }, |
| 373 | + { |
| 374 | + "cell_type": "code", |
| 375 | + "execution_count": 16, |
| 376 | + "metadata": { |
| 377 | + "tags": [ |
| 378 | + "skip-execution" |
| 379 | + ] |
| 380 | + }, |
357 | 381 | "outputs": [
|
358 | 382 | {
|
359 | 383 | "data": {
|
|
402 | 426 | }
|
403 | 427 | ],
|
404 | 428 | "source": [
|
405 |
| - "viewer2 = view(itk_image, rotate=True)" |
| 429 | + "# Create a new viewer using only the data in the ROI determined above\n", |
| 430 | + "viewer2 = view(roi_multiscales, rotate=True)" |
406 | 431 | ]
|
407 | 432 | },
|
408 | 433 | {
|
|
416 | 441 | },
|
417 | 442 | {
|
418 | 443 | "cell_type": "code",
|
419 |
| - "execution_count": 16, |
| 444 | + "execution_count": 17, |
420 | 445 | "metadata": {
|
421 | 446 | "tags": [
|
422 | 447 | "skip-execution"
|
|
0 commit comments