Feature/physical pixel size#43
Conversation
bonus fix for set_Description from CellProfiler/python-bioformats#112
Codecov Report
@@ Coverage Diff @@
## master #43 +/- ##
=========================================
+ Coverage 87.96% 88.16% +0.2%
=========================================
Files 27 27
Lines 1113 1132 +19
=========================================
+ Hits 979 998 +19
Misses 134 134
Continue to review full report at Codecov.
|
evamaxfield
left a comment
There was a problem hiding this comment.
Looks great. I tried out the "suggest changes" thing. Let me know if you hate them.
The only debate for me is NamedTuple, Tuple, or List.
Also, this raises codecov to 88% woooo 🎉
| return default | ||
| return ref.text | ||
|
|
||
| def get_physical_pixel_size(self, scene: int = 0): |
There was a problem hiding this comment.
Two nitpicky things: I personally think this should be a tuple over a list and we should have a return type hint.
| def get_physical_pixel_size(self, scene: int = 0): | |
| def get_physical_pixel_size(self, scene: int = 0) -> Tuple(int): |
There was a problem hiding this comment.
Or if we wanted to be fancy lads, a NamedTuple so that people can say im.get_physical_pixel_size().x
| def get_channel_names(self, scene: int = 0): | ||
| return self.metadata.image(scene).Pixels.get_channel_names() | ||
|
|
||
| def get_physical_pixel_size(self, scene: int = 0): |
There was a problem hiding this comment.
Same here.
| def get_physical_pixel_size(self, scene: int = 0): | |
| def get_physical_pixel_size(self, scene: int = 0) -> Tuple(int): |
| px = float(self._getmetadataxmltext("./Metadata/Scaling/Items/Distance[@Id='X']/Value", "1.0")) | ||
| py = float(self._getmetadataxmltext("./Metadata/Scaling/Items/Distance[@Id='Y']/Value", "1.0")) | ||
| pz = float(self._getmetadataxmltext("./Metadata/Scaling/Items/Distance[@Id='Z']/Value", "1.0")) | ||
| return [px, py, pz] |
There was a problem hiding this comment.
| return [px, py, pz] | |
| return (px, py, pz) |
|
|
||
| def get_physical_pixel_size(self, scene: int = 0): | ||
| p = self.metadata.image(scene).Pixels | ||
| return [p.get_PhysicalSizeX(), p.get_PhysicalSizeY(), p.get_PhysicalSizeZ()] |
There was a problem hiding this comment.
| return [p.get_PhysicalSizeX(), p.get_PhysicalSizeY(), p.get_PhysicalSizeZ()] | |
| return (p.get_PhysicalSizeX(), p.get_PhysicalSizeY(), p.get_PhysicalSizeZ()) |
|
|
||
|
|
||
| @pytest.mark.parametrize("test_input, expected", [ | ||
| (TWO_DIM_CZI, [1.0833333333333333e-06, 1.0833333333333333e-06, 1.0]), |
There was a problem hiding this comment.
If we switch to Tuples:
| (TWO_DIM_CZI, [1.0833333333333333e-06, 1.0833333333333333e-06, 1.0]), | |
| (TWO_DIM_CZI, (1.0833333333333333e-06, 1.0833333333333333e-06, 1.0)), |
|
|
||
| @pytest.mark.parametrize("test_input, expected", [ | ||
| (TWO_DIM_CZI, [1.0833333333333333e-06, 1.0833333333333333e-06, 1.0]), | ||
| (SIX_DIM_CZI, [1.0833333333333333e-06, 1.0833333333333333e-06, 1e-06]) |
There was a problem hiding this comment.
| (SIX_DIM_CZI, [1.0833333333333333e-06, 1.0833333333333333e-06, 1e-06]) | |
| (SIX_DIM_CZI, (1.0833333333333333e-06, 1.0833333333333333e-06, 1e-06)) |
| "ZCYX", | ||
| ] | ||
| physical_pixel_sizes = [ | ||
| [1.0833333333333333, 1.0833333333333333, 1.0], |
There was a problem hiding this comment.
If we switch to tuples:
| [1.0833333333333333, 1.0833333333333333, 1.0], | |
| (1.0833333333333333, 1.0833333333333333, 1.0), |
| ] | ||
| physical_pixel_sizes = [ | ||
| [1.0833333333333333, 1.0833333333333333, 1.0], | ||
| [1.0, 1.0, 1.0], |
There was a problem hiding this comment.
| [1.0, 1.0, 1.0], | |
| (1.0, 1.0, 1.0), |
| physical_pixel_sizes = [ | ||
| [1.0833333333333333, 1.0833333333333333, 1.0], | ||
| [1.0, 1.0, 1.0], | ||
| [1.0833333333333333, 1.0833333333333333, 1.0], |
There was a problem hiding this comment.
| [1.0833333333333333, 1.0833333333333333, 1.0], | |
| (1.0833333333333333, 1.0833333333333333, 1.0), |
|
|
||
| def set_Description(self, text): | ||
| make_text_node(self.node, NS_SPW, "Description", test) | ||
| make_text_node(self.node, self.ns['spw'], "Description", text) |
There was a problem hiding this comment.
I think you just found a bug in OMEXML and randomly fixed it?
There was a problem hiding this comment.
LOL, followed the commit message to the bioformats merge. Makes me think we should really be pulling in their omexml object every so often to update ours. Or use a git submodule?
There was a problem hiding this comment.
The problem is that this version of the file has lots of mods. But this was clearly a big bug in the file that I just noticed and thought it was cheap to throw it in.
There was a problem hiding this comment.
could we create a repo of our own for this that pulls from the original repo and then has a branch that integrates the diffs of what's been added so that we have a path to update it via 1 submodule PR that we would reapply every time we have to update.
evamaxfield
left a comment
There was a problem hiding this comment.
Thanks for changing to Tuple
heeler
left a comment
There was a problem hiding this comment.
Thanks for this! My one request is could we put in a TODO to refactor the vendor code into a submodule so we have a method of reapplying our changes.
|
|
||
| def set_Description(self, text): | ||
| make_text_node(self.node, NS_SPW, "Description", test) | ||
| make_text_node(self.node, self.ns['spw'], "Description", text) |
There was a problem hiding this comment.
could we create a repo of our own for this that pulls from the original repo and then has a branch that integrates the diffs of what's been added so that we have a path to update it via 1 submodule PR that we would reapply every time we have to update.
Another functionality patch: AICS internal code needs to be able to get the physical pixel size in x, y, and z for volume data. I implement this on the volume file format readers, and left it out of AICSImage for now. It can be accessed via the reader. As with prior PRs, this is probably subject to refactoring into a metadata wrapper class.