Skip to content

Commit

Permalink
Merge pull request #18 from sebi06/work_in_progress
Browse files Browse the repository at this point in the history
Work in progress
  • Loading branch information
sebi06 authored Dec 20, 2022
2 parents 38c9426 + 1898b62 commit 9285258
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
Binary file added data/DAPI_GFP.czi
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = czitools
version = 0.1.2
version = 0.1.3
author = Sebastian Rhode
author_email = [email protected]
url = https://github.com/sebi06/czitools
Expand Down
2 changes: 1 addition & 1 deletion src/czitools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# __init__.py
# version of the czitools package
__version__ = "0.1.2"
__version__ = "0.1.3"
24 changes: 24 additions & 0 deletions src/czitools/_tests/test_md_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,27 @@ def test_get_image_dimensions():
for d, v in zip(dimensions, results):
print((d, v))
assert (dim_dict[d] == v)


def test_scaling():

# get the CZI filepath
filepath = os.path.join(basedir, r"data/DAPI_GFP.czi")
md = czimd.CziMetadata(filepath)

assert(md.scale.X == 1.0)
assert(md.scale.Y == 1.0)
assert(md.scale.Z == 1.0)
assert(md.scale.ratio == {'xy': 1.0, 'zx': 1.0})

scaling = czimd.CziScaling(filepath, dim2none=True)
assert(scaling.X is None)
assert(scaling.Y is None)
assert(scaling.Z is None)
assert(scaling.ratio == {'xy': None, 'zx': None})

scaling = czimd.CziScaling(filepath, dim2none=False)
assert(scaling.X == 1.0)
assert(scaling.Y == 1.0)
assert(scaling.Z == 1.0)
assert(scaling.ratio == {'xy': 1.0, 'zx': 1.0})
9 changes: 6 additions & 3 deletions src/czitools/pylibczirw_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def __init__(self, filename: str) -> None:


class CziScaling:
def __init__(self, filename: str, dim2none: bool = True) -> None:
def __init__(self, filename: str, dim2none: bool = False) -> None:

# get metadata dictionary using pylibCZIrw
self.scalefactorXY = None
Expand Down Expand Up @@ -622,8 +622,11 @@ def get_scale_ratio(scalex: float = 1.0,
scaley: float = 1.0,
scalez: float = 1.0) -> Dict:

# set default scale factor to 1.0
scale_ratio = {"xy": np.round(scalex / scaley, 3), "zx": np.round(scalez / scalex, 3)}
if scalex is None or scaley is None or scalez is None:
scale_ratio = {"xy": None, "zx": None}
else:
# set default scale factor to 1.0
scale_ratio = {"xy": np.round(scalex / scaley, 3), "zx": np.round(scalez / scalex, 3)}

# get the factor between XY scaling
# get the scale factor between XZ scaling
Expand Down

0 comments on commit 9285258

Please sign in to comment.