-
Notifications
You must be signed in to change notification settings - Fork 4
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 #28 from sebi06/work_in_progress
Work in progress
- Loading branch information
Showing
20 changed files
with
483 additions
and
436 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
Binary file not shown.
Binary file not shown.
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[metadata] | ||
name = czitools | ||
version = 0.2.0 | ||
version = 0.2.1 | ||
author = Sebastian Rhode | ||
author_email = [email protected] | ||
url = https://github.com/sebi06/czitools | ||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# __init__.py | ||
# version of the czitools package | ||
__version__ = "0.2.0" | ||
__version__ = "0.2.1" |
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 |
---|---|---|
@@ -1,38 +1,43 @@ | ||
from pathlib import Path | ||
from czitools import pylibczirw_metadata as czimd | ||
|
||
basedir = Path(__file__).resolve().parents[3] | ||
|
||
|
||
def test_channelinfo(): | ||
|
||
# get the CZI filepath | ||
filepath = basedir / r"data/CellDivision_T=3_Z=5_CH=2_X=240_Y=170.czi" | ||
czi_channels = czimd.CziChannelInfo(filepath) | ||
|
||
assert (czi_channels.clims == [[0.0, 0.05983062485694667], [0.0, 0.24975967040512703]]) | ||
assert (czi_channels.colors == ["#FFFF7E00", "#FF00FF33"]) | ||
assert (czi_channels.gamma == [0.7999999999999998, 0.7999999999999998]) | ||
assert (czi_channels.names == ["LED555", "LED470"]) | ||
assert (czi_channels.dyes == ["AF555", "AF488"]) | ||
|
||
# get the CZI filepath | ||
filepath = basedir / r"data/Al2O3_SE_020_sp.czi" | ||
czi_channels = czimd.CziChannelInfo(filepath) | ||
|
||
assert (czi_channels.clims == [[0.0, 0.5]]) | ||
assert (czi_channels.colors == ["#80808000"]) | ||
assert (czi_channels.gamma == [0.85]) | ||
assert (czi_channels.names == ["CH1"]) | ||
assert (czi_channels.dyes == ["Dye-CH1"]) | ||
import pytest | ||
from typing import List, Dict, Tuple, Optional, Type, Any, Union, Mapping | ||
|
||
basedir = Path(__file__).resolve().parents[3] / "data" | ||
|
||
@pytest.mark.parametrize( | ||
"czifile, clims, colors, gamma, names, dyes", | ||
[ | ||
("CellDivision_T=3_Z=5_CH=2_X=240_Y=170.czi", | ||
[[0.0, 0.05983062485694667],[0.0, 0.24975967040512703]], | ||
["#FFFF7E00", "#FF00FF33"], | ||
[0.7999999999999998, 0.7999999999999998], | ||
["LED555", "LED470"], | ||
["AF555", "AF488"]), | ||
("Al2O3_SE_020_sp.czi", | ||
[[0.0, 0.5]], | ||
["#80808000"], | ||
[0.85], | ||
["CH1"], | ||
["Dye-CH1"]), | ||
("w96_A1+A2.czi", | ||
[[0.000871455799315693, 0.044245974575704575], [0.000881881329185286, 0.05011349562051524]], | ||
['#FFFF1800', '#FF00FF33'], | ||
[0.7999999999999998, 0.7999999999999998], | ||
['AF568', 'AF488'], | ||
['AF568', 'AF488']) | ||
] | ||
) | ||
def test_channelinfo(czifile: str, clims: List, colors: List, gamma: List, names: List, dyes: List) -> None: | ||
|
||
# get the CZI filepath | ||
filepath = basedir / r"data/w96_A1+A2.czi" | ||
filepath = basedir / czifile | ||
czi_channels = czimd.CziChannelInfo(filepath) | ||
|
||
assert (czi_channels.clims == [[0.000871455799315693, 0.044245974575704575], [ | ||
0.000881881329185286, 0.05011349562051524]]) | ||
assert (czi_channels.colors == ['#FFFF1800', '#FF00FF33']) | ||
assert (czi_channels.gamma == [0.7999999999999998, 0.7999999999999998]) | ||
assert (czi_channels.names == ['AF568', 'AF488']) | ||
assert (czi_channels.dyes == ['AF568', 'AF488']) | ||
assert (czi_channels.clims == clims) | ||
assert (czi_channels.colors == colors) | ||
assert (czi_channels.gamma == gamma) | ||
assert (czi_channels.names == names) | ||
assert (czi_channels.dyes == dyes) |
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 |
---|---|---|
@@ -1,62 +1,68 @@ | ||
from czitools import pylibczirw_metadata as czimd | ||
from pathlib import Path, PurePath | ||
import pytest | ||
from typing import List, Dict, Tuple, Optional, Type, Any, Union, Mapping | ||
|
||
|
||
# adapt to your needs | ||
defaultdir = Path(__file__).resolve().parents[3] / "data" | ||
|
||
def test_general_attr(): | ||
|
||
@pytest.mark.parametrize( | ||
"attribute", | ||
[ | ||
"has_customattr", | ||
"has_exp", | ||
"has_disp", | ||
"has_hardware", | ||
"has_scale", | ||
"has_instrument", | ||
"has_microscopes", | ||
"has_detectors", | ||
"has_objectives", | ||
"has_tubelenses", | ||
"has_disp", | ||
"has_channels", | ||
"has_info", | ||
"has_app", | ||
"has_doc", | ||
"has_image", | ||
"has_scenes", | ||
"has_dims" | ||
] | ||
) | ||
def test_general_attr(attribute: str) -> None: | ||
|
||
filepath = defaultdir / "CellDivision_T=3_Z=5_CH=2_X=240_Y=170.czi" | ||
|
||
czibox = czimd.get_czimd_box(filepath) | ||
|
||
assert(hasattr(czibox, "has_customattr")) | ||
assert(hasattr(czibox, "has_exp = False")) | ||
assert(hasattr(czibox, "has_disp")) | ||
assert(hasattr(czibox, "has_hardware")) | ||
assert(hasattr(czibox, "has_scale")) | ||
assert(hasattr(czibox, "has_instrument")) | ||
assert(hasattr(czibox, "has_microscopes")) | ||
assert(hasattr(czibox, "has_detectors")) | ||
assert(hasattr(czibox, "has_objectives")) | ||
assert(hasattr(czibox, "has_tubelenses")) | ||
assert(hasattr(czibox, "has_disp")) | ||
assert(hasattr(czibox, "has_channels")) | ||
assert(hasattr(czibox, "has_info")) | ||
assert(hasattr(czibox, "has_app")) | ||
assert(hasattr(czibox, "has_doc")) | ||
assert(hasattr(czibox, "has_image")) | ||
assert(hasattr(czibox, "has_scenes")) | ||
assert(hasattr(czibox, "has_dims")) | ||
|
||
|
||
def test_box(): | ||
|
||
czifiles = ["CellDivision_T=3_Z=5_CH=2_X=240_Y=170.czi", | ||
"Al2O3_SE_020_sp.czi", | ||
"w96_A1+A2.czi", | ||
"Airyscan.czi", | ||
"newCZI_zloc.czi", | ||
"does_not_exist.czi", | ||
"FOV7_HV110_P0500510000.czi", | ||
"Tumor_HE_RGB.czi", | ||
"WP96_4Pos_B4-10_DAPI.czi", | ||
"S=3_1Pos_2Mosaic_T=2=Z=3_CH=2_sm.czi" | ||
] | ||
|
||
results = [True, True, True, True, True, False, True, True, True, True] | ||
|
||
for czifile, result in zip(czifiles, results): | ||
|
||
filepath = defaultdir / czifile | ||
|
||
try: | ||
czibox = czimd.get_czimd_box(filepath) | ||
ok = True | ||
except Exception: | ||
ok = False | ||
|
||
assert(ok == result) | ||
|
||
test_box() | ||
assert (hasattr(czibox, attribute)) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"czifile, expected", | ||
[ | ||
("CellDivision_T=3_Z=5_CH=2_X=240_Y=170.czi", True), | ||
("Al2O3_SE_020_sp.czi", True), | ||
("w96_A1+A2.czi", True), | ||
("Airyscan.czi", True), | ||
("newCZI_zloc.czi", True), | ||
("does_not_exist.czi", False), | ||
("FOV7_HV110_P0500510000.czi", True), | ||
("Tumor_HE_RGB.czi", True), | ||
("WP96_4Pos_B4-10_DAPI.czi", True), | ||
("S=3_1Pos_2Mosaic_T=2=Z=3_CH=2_sm.czi", True) | ||
] | ||
) | ||
def test_box(czifile: List[str], expected: bool) -> None: | ||
|
||
filepath = defaultdir / czifile | ||
|
||
try: | ||
czibox = czimd.get_czimd_box(filepath) | ||
ok = True | ||
except Exception: | ||
ok = False | ||
|
||
assert (ok == expected) |
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 |
---|---|---|
@@ -1,43 +1,40 @@ | ||
from czitools import pylibczirw_metadata as czimd | ||
from pathlib import Path | ||
import pytest | ||
from typing import List, Dict, Tuple, Optional, Type, Any, Union, Mapping | ||
|
||
basedir = Path(__file__).resolve().parents[3] | ||
|
||
|
||
def test_information(): | ||
|
||
to_test = {0: r"data/CellDivision_T=3_Z=5_CH=2_X=240_Y=170.czi", | ||
1: r"data/Airyscan.czi", | ||
2: r"data/newCZI_zloc.czi"} | ||
|
||
results = {0: ['ZEN 3.2 (blue edition)', | ||
'3.2.0.00001', | ||
'2016-02-12T09:41:02.4915604Z', | ||
True, | ||
'CellDivision_T=3_Z=5_CH=2_X=240_Y=170.czi'], | ||
1: ['ZEN (blue edition)', | ||
'3.5.093.00000', | ||
None, | ||
True, | ||
'Airyscan.czi'], | ||
2: ['pylibCZIrw', | ||
'3.2.1', | ||
None, | ||
True, | ||
'newCZI_zloc.czi'] | ||
} | ||
|
||
for t in range(len(to_test)): | ||
|
||
# get the filepath | ||
filepath = basedir / to_test[t] | ||
md = czimd.CziMetadata(filepath) | ||
|
||
assert (md.software_name == results[t][0]) | ||
assert (md.software_version == results[t][1]) | ||
assert (md.acquisition_date == results[t][2]) | ||
assert (Path.exists(Path(md.dirname)) == results[t][3]) | ||
assert (md.filename == results[t][4]) | ||
|
||
|
||
test_information() | ||
@pytest.mark.parametrize( | ||
"czifile, result", | ||
[ | ||
("CellDivision_T=3_Z=5_CH=2_X=240_Y=170.czi", ['ZEN 3.2 (blue edition)', | ||
'3.2.0.00001', | ||
'2016-02-12T09:41:02.4915604Z', | ||
True, | ||
'CellDivision_T=3_Z=5_CH=2_X=240_Y=170.czi']), | ||
("Airyscan.czi", ['ZEN (blue edition)', | ||
'3.5.093.00000', | ||
None, | ||
True, | ||
'Airyscan.czi']), | ||
("newCZI_zloc.czi", ['pylibCZIrw', | ||
'3.2.1', | ||
None, | ||
True, | ||
'newCZI_zloc.czi']) | ||
] | ||
) | ||
def test_information(czifile: str, result: List) -> None: | ||
|
||
filepath = basedir / "data" / czifile | ||
md = czimd.CziMetadata(filepath) | ||
|
||
assert (md.software_name == result[0]) | ||
assert (md.software_version == result[1]) | ||
assert (md.acquisition_date == result[2]) | ||
assert (Path.exists(Path(md.dirname)) == result[3]) | ||
assert (md.filename == result[4]) |
Oops, something went wrong.