-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from BiAPoL/execution_from_folder
Execution from folder
- Loading branch information
Showing
4 changed files
with
2,577 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "bd8803c6-ba71-44c0-a009-20e0dd6627ef", | ||
"metadata": {}, | ||
"source": [ | ||
"# 1. Working with czi-files" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "102fccdb-71e4-40ec-a8bd-d505cf0826b5", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<Intel(R) UHD Graphics 620 on Platform: Intel(R) OpenCL HD Graphics (1 refs)>" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import os\n", | ||
"import pyclesperanto_prototype as cle\n", | ||
"import napari\n", | ||
"from aicsimageio import AICSImage\n", | ||
"from aicsimageio.readers import BioformatsReader\n", | ||
"\n", | ||
"cle.select_device(\"Intel(R) Iris(TM) Plus Graphics 640\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "cafd56ae-6051-48f6-8de6-dcc59fd45071", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"image_folder = 'crops/'\n", | ||
"tif_folder = 'crops/tif-files/'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "de607dcb-a0a8-4d53-8f85-ab61d7944558", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"os.makedirs(tif_folder, exist_ok=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "8962be97-6f36-49ae-bb10-9ec3f5718bee", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"['.ipynb_checkpoints',\n", | ||
" '2021-5-7_wt_72hpf_lysosensor_1.czi',\n", | ||
" '2022-8-19 et358 pnp4a gRNA 72hpf 1.czi',\n", | ||
" 'Crop vs. CZI file.ipynb',\n", | ||
" 'tif-files']" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"file_list = os.listdir(image_folder)\n", | ||
"file_list" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "6885ae59-9bbe-486b-828f-d2fe192ea8e2", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"WARNING: QWindowsWindow::setGeometry: Unable to set geometry 1090x686+7+31 (frame: 1108x733-2-7) on QWidgetWindow/\"_QtMainWindowClassWindow\" on \"\\\\.\\DISPLAY1\". Resulting geometry: 1365x859+8+38 (frame: 1383x906-1+0) margins: 9, 38, 9, 9 minimum size: 612x589 MINMAXINFO maxSize=0,0 maxpos=0,0 mintrack=630,636 maxtrack=0,0)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"viewer = napari.Viewer()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "bbf5cbe3-8f26-4253-83dc-73f7f7f3db6c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def data_selection(filename, image_folder, viewer, channel):\n", | ||
" '''\n", | ||
" this function loads one channel of an image slice by slice in napari\n", | ||
" '''\n", | ||
" \n", | ||
" from aicsimageio import AICSImage\n", | ||
" from aicsimageio.readers import BioformatsReader\n", | ||
" \n", | ||
" #load image\n", | ||
" image = AICSImage(image_folder + filename, reader = BioformatsReader)\n", | ||
" original = image.data\n", | ||
" \n", | ||
" #select reflection channel\n", | ||
" channel_specified = original[0, channel]\n", | ||
" \n", | ||
" #add every slice of the stack to napari\n", | ||
" for slc in range(channel_specified.shape[0]):\n", | ||
" layer = viewer.add_image(channel_specified[slc], colormap = 'cyan', blending = 'translucent')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d3b2dd75-2ac4-42ac-b5da-dbe012aac151", | ||
"metadata": {}, | ||
"source": [ | ||
"Now you can say which image inside the `file_list` you want to display in napari. When you just say `filename = file_list`, you will open all images slice by slice." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"id": "4bfb64ab-e5b7-4e03-bf78-07d463811f39", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data_selection(filename=file_list[2], image_folder=image_folder, viewer=viewer, channel = 2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ad37d69b-4b9e-4f40-8840-449ee4b56662", | ||
"metadata": {}, | ||
"source": [ | ||
"You can save the slices of the stack you want to keep under File -> Save Selected Layer(s) (Shortcut: `Ctrl + S`) and direct into the tif_folder" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.15" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
1,263 changes: 1,263 additions & 0 deletions
1,263
demo/2. Executing guanine-crystal-analysis-plugin from a jupyter notebook.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.