Skip to content

Commit

Permalink
updates scripts and notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
sebi06 committed May 10, 2024
1 parent cdb73b0 commit 3de7851
Show file tree
Hide file tree
Showing 15 changed files with 330 additions and 440 deletions.
42 changes: 28 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,25 @@ pip install czitools[all]
Please check [use_metadata_tools.py](https://github.com/sebi06/czitools/blob/main/demo/scripts/use_metadata_tools.py) for some examples.

```python
from czitools.metadata_tools.czi_metadata import CziMetadata, writexml
from czitools.metadata_tools.dimension import CziDimensions
from czitools.metadata_tools.boundingbox import CziBoundingBox
from czitools.metadata_tools.channel import CziChannelInfo
from czitools.metadata_tools.scaling import CziScaling
from czitools.metadata_tools.sample import CziSampleInfo
from czitools.metadata_tools.objective import CziObjectives
from czitools.metadata_tools.microscope import CziMicroscope
from czitools.metadata_tools.add_metadata import CziAddMetaData
from czitools.metadata_tools.detector import CziDetector
from czitools.read_tools import read_tools
from czitools.napari_tools import napari_tools
import napari

# get the metadata_tools at once as one big class
mdata = czimd.CziMetadata(filepath)
mdata = CziMetadata(filepath)

# get only specific metadata_tools
czi_dimensions = czimd.CziDimensions(filepath)
czi_dimensions = CziDimensions(filepath)
print("SizeS: ", czi_dimensions.SizeS)
print("SizeT: ", czi_dimensions.SizeT)
print("SizeZ: ", czi_dimensions.SizeZ)
Expand All @@ -40,36 +54,36 @@ print("SizeY: ", czi_dimensions.SizeY)
print("SizeX: ", czi_dimensions.SizeX)

# try to write XML to file
xmlfile = czimd.writexml(filepath)
xmlfile = writexml(filepath)

# get info about the channels
czi_channels = czimd.CziChannelInfo(filepath)
czi_channels = CziChannelInfo(filepath)

# get the complete metadata_tools from the CZI as one big object
czimd_complete = czimd.get_metadata_as_object(filepath)
czimd_complete = get_metadata_as_object(filepath)

# get an object containing only the dimension information
czi_dimensions = czimd.CziDimensions(filepath)
czi_dimensions = CziDimensions(filepath)

# get an object containing only the dimension information
czi_scale = czimd.CziScaling(filepath)
czi_scale = CziScaling(filepath)

# get an object containing information about the sample
czi_sample = czimd.CziSampleInfo(filepath)
czi_sample = CziSampleInfo(filepath)

# get info about the objective, the microscope and the detectors
czi_objectives = czimd.CziObjectives(filepath)
czi_detectors = czimd.CziDetector(filepath)
czi_microscope = czimd.CziMicroscope(filepath)
czi_objectives = CziObjectives(filepath)
czi_detectors = CziDetector(filepath)
czi_microscope = CziMicroscope(filepath)

# get info about the sample carrier
czi_sample = czimd.CziSampleInfo(filepath)
czi_sample = CziSampleInfo(filepath)

# get additional metainformation
czi_addmd = czimd.CziAddMetaData(filepath)
czi_addmd = CziAddMetaData(filepath)

# get the complete data about the bounding boxes
czi_bbox = czimd.CziBoundingBox(filepath)
czi_bbox = CziBoundingBox(filepath)
```

## Reading CZI pixel data
Expand Down
Binary file modified data/CellDivision_T3_Z5_CH2_X240_Y170_comp1.czi
Binary file not shown.
Binary file modified data/CellDivision_T3_Z5_CH2_X240_Y170_comp2.czi
Binary file not shown.
120 changes: 80 additions & 40 deletions demo/notebooks/omezarr_from_czi_5d.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"id": "9873c5dc",
"metadata": {
"editable": true,
Expand All @@ -43,7 +43,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"id": "67c73f91",
"metadata": {
"editable": true,
Expand All @@ -62,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 11,
"id": "b236d2d9",
"metadata": {},
"outputs": [
Expand All @@ -72,19 +72,21 @@
"'2.15.0'"
]
},
"execution_count": 4,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from czitools import metadata_tools as czimd\n",
"from czitools import read_tools, write_tools\n",
"from czitools.read_tools import read_tools\n",
"from czitools.write_tools import write_tools\n",
"from czitools.metadata_tools import czi_metadata as czimd\n",
"import napari\n",
"from pathlib import Path\n",
"import ome_zarr.reader\n",
"import ome_zarr.scale\n",
"import ome_zarr.writer\n",
"import ome_zarr.format\n",
"from ome_zarr.io import parse_url\n",
"import shutil\n",
"import zarr\n",
Expand All @@ -99,7 +101,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"id": "5b96a0fa",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -130,7 +132,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"id": "2ab02d0c",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -162,28 +164,47 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"id": "68d184ed",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-02-11 14:19:52,010 - \u001b[0;30;42mINFO\u001b[0m - Reading Dimensions from CZI image data.\n",
"2024-02-11 14:19:52,020 - \u001b[0;30;42mINFO\u001b[0m - Reading BoundingBoxes from CZI image data.\n",
"2024-02-11 14:19:52,021 - \u001b[0;30;42mINFO\u001b[0m - Reading Channel Information from CZI image data.\n",
"2024-02-11 14:19:52,022 - \u001b[0;30;42mINFO\u001b[0m - Reading Scaling from CZI image data.\n",
"2024-02-11 14:19:52,023 - \u001b[0;30;42mINFO\u001b[0m - Reading Objective Information from CZI image data.\n",
"2024-02-11 14:19:52,023 - \u001b[0;30;42mINFO\u001b[0m - Reading Detector Information from CZI image data.\n",
"2024-02-11 14:19:52,024 - \u001b[0;30;42mINFO\u001b[0m - Reading Microscope Information from CZI image data.\n",
"2024-02-11 14:19:52,025 - \u001b[0;30;42mINFO\u001b[0m - Reading SampleCarrier Information from CZI image data.\n",
"2024-02-11 14:19:52,026 - \u001b[0;30;42mINFO\u001b[0m - Reading Dimensions from CZI image data.\n",
"2024-02-11 14:19:52,028 - \u001b[0;30;42mINFO\u001b[0m - No Scene or Well information found. Try to read XY Stage Coordinates from subblocks.\n",
"2024-02-11 14:19:52,281 - \u001b[0;30;42mINFO\u001b[0m - Reading Dimensions from CZI image data.\n",
"2024-02-11 14:19:52,291 - \u001b[0;30;42mINFO\u001b[0m - Reading additional Metedata from CZI image data.\n",
"2024-02-11 14:19:52,291 - \u001b[0;30;42mINFO\u001b[0m - No Layers information found.\n",
"2024-02-11 14:19:52,292 - \u001b[0;30;42mINFO\u001b[0m - Reading AttachmentImages from CZI image data.\n"
"2024-05-10 21:28:00,682 - \u001b[0;30;42mINFO\u001b[0m - Reading Dimensions from CZI image data.\n",
"2024-05-10 21:28:00,687 - \u001b[0;30;42mINFO\u001b[0m - Reading BoundingBoxes from CZI image data.\n",
"2024-05-10 21:28:00,688 - \u001b[0;30;42mINFO\u001b[0m - Reading Channel Information from CZI image data.\n",
"2024-05-10 21:28:00,689 - \u001b[0;30;42mINFO\u001b[0m - Reading Scaling from CZI image data.\n",
"2024-05-10 21:28:00,690 - \u001b[0;30;42mINFO\u001b[0m - Reading Objective Information from CZI image data.\n",
"2024-05-10 21:28:00,691 - \u001b[0;30;42mINFO\u001b[0m - Reading Detector Information from CZI image data.\n",
"2024-05-10 21:28:00,692 - \u001b[0;30;42mINFO\u001b[0m - Reading Microscope Information from CZI image data.\n",
"2024-05-10 21:28:00,692 - \u001b[0;30;42mINFO\u001b[0m - Reading SampleCarrier Information from CZI image data.\n",
"2024-05-10 21:28:00,693 - \u001b[0;30;42mINFO\u001b[0m - Reading Dimensions from CZI image data.\n",
"2024-05-10 21:28:00,694 - \u001b[0;30;42mINFO\u001b[0m - No Scene or Well information found. Try to read XY Stage Coordinates from subblocks.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "af4099e11f0549379c8fafba72149229",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Reading sublocks planes: 0 2Dplanes [00:00, ? 2Dplanes/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-05-10 21:28:00,721 - \u001b[0;30;42mINFO\u001b[0m - Reading additional Metedata from CZI image data.\n",
"2024-05-10 21:28:00,722 - \u001b[0;30;42mINFO\u001b[0m - No Layers information found.\n",
"2024-05-10 21:28:00,724 - \u001b[0;30;42mINFO\u001b[0m - Reading AttachmentImages from CZI image data.\n"
]
},
{
Expand All @@ -203,34 +224,53 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"id": "1e32b670",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-02-11 14:19:55,788 - \u001b[0;30;42mINFO\u001b[0m - Reading Dimensions from CZI image data.\n",
"2024-02-11 14:19:55,790 - \u001b[0;30;42mINFO\u001b[0m - Reading BoundingBoxes from CZI image data.\n",
"2024-02-11 14:19:55,792 - \u001b[0;30;42mINFO\u001b[0m - Reading Channel Information from CZI image data.\n",
"2024-02-11 14:19:55,792 - \u001b[0;30;42mINFO\u001b[0m - Reading Scaling from CZI image data.\n",
"2024-02-11 14:19:55,793 - \u001b[0;30;42mINFO\u001b[0m - Reading Objective Information from CZI image data.\n",
"2024-02-11 14:19:55,794 - \u001b[0;30;42mINFO\u001b[0m - Reading Detector Information from CZI image data.\n",
"2024-02-11 14:19:55,795 - \u001b[0;30;42mINFO\u001b[0m - Reading Microscope Information from CZI image data.\n",
"2024-02-11 14:19:55,796 - \u001b[0;30;42mINFO\u001b[0m - Reading SampleCarrier Information from CZI image data.\n",
"2024-02-11 14:19:55,797 - \u001b[0;30;42mINFO\u001b[0m - Reading Dimensions from CZI image data.\n",
"2024-02-11 14:19:55,798 - \u001b[0;30;42mINFO\u001b[0m - No Scene or Well information found. Try to read XY Stage Coordinates from subblocks.\n",
"2024-02-11 14:19:56,014 - \u001b[0;30;42mINFO\u001b[0m - Reading Dimensions from CZI image data.\n",
"2024-02-11 14:19:56,021 - \u001b[0;30;42mINFO\u001b[0m - Reading additional Metedata from CZI image data.\n",
"2024-02-11 14:19:56,022 - \u001b[0;30;42mINFO\u001b[0m - No Layers information found.\n",
"2024-02-11 14:19:56,023 - \u001b[0;30;42mINFO\u001b[0m - Reading AttachmentImages from CZI image data.\n"
"2024-05-10 21:28:05,818 - \u001b[0;30;42mINFO\u001b[0m - Reading Dimensions from CZI image data.\n",
"2024-05-10 21:28:05,820 - \u001b[0;30;42mINFO\u001b[0m - Reading BoundingBoxes from CZI image data.\n",
"2024-05-10 21:28:05,822 - \u001b[0;30;42mINFO\u001b[0m - Reading Channel Information from CZI image data.\n",
"2024-05-10 21:28:05,823 - \u001b[0;30;42mINFO\u001b[0m - Reading Scaling from CZI image data.\n",
"2024-05-10 21:28:05,824 - \u001b[0;30;42mINFO\u001b[0m - Reading Objective Information from CZI image data.\n",
"2024-05-10 21:28:05,825 - \u001b[0;30;42mINFO\u001b[0m - Reading Detector Information from CZI image data.\n",
"2024-05-10 21:28:05,827 - \u001b[0;30;42mINFO\u001b[0m - Reading Microscope Information from CZI image data.\n",
"2024-05-10 21:28:05,828 - \u001b[0;30;42mINFO\u001b[0m - Reading SampleCarrier Information from CZI image data.\n",
"2024-05-10 21:28:05,828 - \u001b[0;30;42mINFO\u001b[0m - Reading Dimensions from CZI image data.\n",
"2024-05-10 21:28:05,830 - \u001b[0;30;42mINFO\u001b[0m - No Scene or Well information found. Try to read XY Stage Coordinates from subblocks.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a5ad1763a40b41cdb280c7ac8a233fc7",
"model_id": "c33ef83c98ff4acbbb09d0c46f11fc74",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Reading sublocks planes: 0 2Dplanes [00:00, ? 2Dplanes/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-05-10 21:28:05,852 - \u001b[0;30;42mINFO\u001b[0m - Reading additional Metedata from CZI image data.\n",
"2024-05-10 21:28:05,853 - \u001b[0;30;42mINFO\u001b[0m - No Layers information found.\n",
"2024-05-10 21:28:05,853 - \u001b[0;30;42mINFO\u001b[0m - Reading AttachmentImages from CZI image data.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3bd107cbfc7d46d79459e7c2d376ee51",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -258,7 +298,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"id": "c670b17c",
"metadata": {},
"outputs": [
Expand Down
10 changes: 5 additions & 5 deletions demo/notebooks/read_czi_metadata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"outputs": [],
"source": [
"# import the required libraries\n",
"from czitools import metadata_tools as czimd\n",
"from czitools import misc_tools\n",
"from czitools.metadata_tools import czi_metadata as czimd\n",
"from czitools.utils import misc\n",
"from ipyfilechooser import FileChooser\n",
"from IPython.display import display, HTML\n",
"from pathlib import Path\n",
Expand Down Expand Up @@ -93,12 +93,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ef4de5102fe04391b5fd8bbf669ab8f9",
"model_id": "3ce83a82c5fa4dee807a5606fdd7a373",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FileChooser(path='F:\\Github\\czitools\\data', filename='', title='', show_hidden=False, select_desc='Select', ch…"
"FileChooser(path='E:\\Github\\czitools\\data', filename='', title='', show_hidden=False, select_desc='Select', ch…"
]
},
"metadata": {},
Expand Down Expand Up @@ -376,7 +376,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.10.13"
},
"vscode": {
"interpreter": {
Expand Down
Loading

0 comments on commit 3de7851

Please sign in to comment.