Skip to content

Commit 40f2100

Browse files
author
rky95813
committed
Improved comments/removed unnecessary ones, plus refactoring.
1 parent ecdacbc commit 40f2100

1 file changed

Lines changed: 16 additions & 32 deletions

File tree

bioformats/omexml.py

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
2-
# This file is a modified version of the python-bioformats omexml.py file.
3-
# New and modified sections have been clearly marked below.
4-
# Tom Fish 2019
5-
61
# Python-bioformats is distributed under the GNU General Public
72
# License, but this file is licensed under the more permissive BSD
83
# license. See the accompanying file LICENSE for details.
@@ -543,7 +538,7 @@ def set_SamplesPerPixel(self, value):
543538
SamplesPerPixel = property(get_SamplesPerPixel, set_SamplesPerPixel)
544539

545540
#---------------------
546-
# The following section was taken from the Allen Institute for Cell Science version of this file
541+
# The following section is from the Allen Institute for Cell Science version of this file
547542
# which can be found at https://github.com/AllenCellModeling/aicsimageio/blob/master/aicsimageio/vendor/omexml.py
548543
class TiffData(object):
549544
"""The OME/Image/Pixels/TiffData element
@@ -651,23 +646,13 @@ def set_DeltaT(self, value):
651646

652647
DeltaT = property(get_DeltaT, set_DeltaT)
653648

654-
#-------------
655-
# Added 3/9/2019 by Tom Fish
656-
def set_ExposureTime(self, value):
657-
self.node.set("ExposureTime", str(value))
658-
659649
def get_ExposureTime(self, value):
660650
self.node.get("ExposureTime")
661651

662-
#-------------
652+
def set_ExposureTime(self, value):
653+
self.node.set("ExposureTime", str(value))
663654

664-
@property
665-
def ExposureTime(self):
666-
'''Units are seconds. Duration of acquisition????'''
667-
exposure_time = self.node.get("ExposureTime")
668-
if exposure_time is not None:
669-
return float(exposure_time)
670-
return None
655+
ExposureTime = property(get_ExposureTime, set_ExposureTime)
671656

672657
def get_PositionX(self):
673658
'''X position of stage'''
@@ -699,8 +684,6 @@ def set_PositionZ(self, value):
699684

700685
PositionZ = property(get_PositionZ, set_PositionZ)
701686

702-
#-------------
703-
# Added 3/9/2019 by Tom Fish
704687
def get_PositionXUnit(self):
705688
self.node.get("PositionXUnit")
706689

@@ -725,7 +708,6 @@ def set_PositionZUnit(self, value):
725708

726709
PositionZUnit = property(get_PositionZUnit, set_PositionZUnit)
727710

728-
#-------------
729711
class Pixels(object):
730712
'''The OME/Image/Pixels element
731713
@@ -942,8 +924,9 @@ def Plane(self, index=0):
942924
plane = self.node.findall(qn(self.ns['ome'], "Plane"))[index]
943925
return OMEXML.Plane(plane)
944926

945-
#-------------
946-
# Added 3/9/2019 by Tom Fish
927+
def get_tiffdata_count(self):
928+
return len(self.node.findall(qn(self.ns['ome'], "TiffData")))
929+
947930
def set_tiffdata_count(self, value):
948931
assert value >= 0
949932
tiffdatas = self.node.findall(qn(self.ns['ome'], "TiffData"))
@@ -956,7 +939,6 @@ def set_tiffdata_count(self, value):
956939
def TiffData(self, index=0):
957940
data = self.node.findall(qn(self.ns['ome'], "TiffData"))[index]
958941
return OMEXML.TiffData(data)
959-
#-------------
960942

961943
class Instrument(object):
962944
'''Representation of the OME/Instrument element'''
@@ -1631,8 +1613,6 @@ def set_ImageRef(self, value):
16311613

16321614
ImageRef = property(get_ImageRef, set_ImageRef)
16331615

1634-
#-------------
1635-
# Added 9/9/2019 by Tom Fish
16361616
class ROIRef(object):
16371617

16381618
def __init__(self, node):
@@ -1645,7 +1625,7 @@ def get_ID(self):
16451625
def set_ID(self, value):
16461626
'''
16471627
ID will automatically be in the format "ROI:value"
1648-
and must match the ROI ID (which uses the same
1628+
and must match the ROI ID (that uses the same
16491629
formatting)
16501630
'''
16511631
self.node.set("ID", "ROI:" + str(value))
@@ -1677,7 +1657,6 @@ def set_roi_count(self, value):
16771657
new_Rectangle.set_TheZ(0)
16781658
new_Rectangle.set_TheC(0)
16791659
new_Rectangle.set_TheT(0)
1680-
16811660
new_Rectangle.set_StrokeColor(-16776961) # Default = Red
16821661
new_Rectangle.set_StrokeWidth(20)
16831662
new_Rectangle.set_Text(str(iteration))
@@ -1700,7 +1679,7 @@ def get_ID(self):
17001679
def set_ID(self, value):
17011680
'''
17021681
ID will automatically be in the format "ROI:value"
1703-
and must match the ROIRef ID (which uses the same
1682+
and must match the ROIRef ID (that uses the same
17041683
formatting)
17051684
'''
17061685
self.node.set("ID", "ROI:" + str(value))
@@ -1731,7 +1710,7 @@ def __init__(self, node):
17311710
self.ns = get_namespaces(self.node)
17321711

17331712
def Rectangle(self, index=0):
1734-
'''The OME/ROI/Union element. Currenly only rectangle ROIs are available.'''
1713+
'''The OME/ROI/Union element. Currently only rectangle ROIs are available.'''
17351714
return OMEXML.Rectangle(self.node.find(qn(self.ns['ome'], "Rectangle")))
17361715

17371716
class Rectangle(object):
@@ -1760,6 +1739,12 @@ def get_StrokeWidth(self):
17601739
return self.node.get("StrokeWidth")
17611740

17621741
def set_StrokeWidth(self, value):
1742+
'''
1743+
Colour is set using RGBA to integer conversion calculated using function from:
1744+
https://docs.openmicroscopy.org/omero/5.5.1/developers/Python.html
1745+
1746+
RGB colours: Red=-16776961, Green=16711935, Blue=65535
1747+
'''
17631748
self.node.set("StrokeWidth", str(value))
17641749

17651750
StrokeWidth = property(get_StrokeWidth, set_StrokeWidth)
@@ -1830,4 +1815,3 @@ def set_TheT(self, value):
18301815
self.node.set("TheT", str(value))
18311816

18321817
TheT = property(get_TheT, set_TheT)
1833-
#-------------

0 commit comments

Comments
 (0)