Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Feature/physical pixel size#43

Merged
toloudis merged 3 commits into
masterfrom
feature/physical-pixel-size
Oct 31, 2019
Merged

Feature/physical pixel size#43
toloudis merged 3 commits into
masterfrom
feature/physical-pixel-size

Conversation

@toloudis

Copy link
Copy Markdown
Collaborator

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.

@codecov-io

codecov-io commented Oct 31, 2019

Copy link
Copy Markdown

Codecov Report

Merging #43 into master will increase coverage by 0.2%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
aicsimageio/readers/ome_tiff_reader.py 89.02% <100%> (+0.56%) ⬆️
aicsimageio/tests/readers/test_czi_reader.py 100% <100%> (ø) ⬆️
aicsimageio/tests/readers/test_ome_tiff_reader.py 93.93% <100%> (+0.39%) ⬆️
aicsimageio/readers/czi_reader.py 97.82% <100%> (+0.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 45d93f4...925e8c0. Read the comment docs.

@evamaxfield evamaxfield left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🎉

Comment thread aicsimageio/readers/czi_reader.py Outdated
return default
return ref.text

def get_physical_pixel_size(self, scene: int = 0):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nitpicky things: I personally think this should be a tuple over a list and we should have a return type hint.

Suggested change
def get_physical_pixel_size(self, scene: int = 0):
def get_physical_pixel_size(self, scene: int = 0) -> Tuple(int):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or if we wanted to be fancy lads, a NamedTuple so that people can say im.get_physical_pixel_size().x

Comment thread aicsimageio/readers/ome_tiff_reader.py Outdated
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):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Suggested change
def get_physical_pixel_size(self, scene: int = 0):
def get_physical_pixel_size(self, scene: int = 0) -> Tuple(int):

Comment thread aicsimageio/readers/czi_reader.py Outdated
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]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return [px, py, pz]
return (px, py, pz)

Comment thread aicsimageio/readers/ome_tiff_reader.py Outdated

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()]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we switch to Tuples:

Suggested change
(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])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(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],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we switch to tuples:

Suggested change
[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],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[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],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you just found a bug in OMEXML and randomly fixed it?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 evamaxfield left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for changing to Tuple

@heeler heeler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@toloudis toloudis merged commit 59dd52c into master Oct 31, 2019
@evamaxfield evamaxfield deleted the feature/physical-pixel-size branch October 31, 2019 23:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants