-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
admin/4.0-release-prep-and-benchmark-upgrades #244
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0c16e1d
Ignore presentations dir from language
b7204f5
Try double star for ignore lang
f7b36ef
Add benchmark for chunk size variability
3098989
Fix default and lif bench, add chunk compare
3b620b4
Benchmark aicsimageio against other libs
1f59734
Use variance cfe instead of pipeline 4
2eca5a7
Configure better lib compare bench
77f3511
Remove extra deps from benchmark deps
3671839
Cleanup lib compare
9e7f80f
Reduce the amount of files checked during benchs
c7567fb
Fix benchmark params on TIFF like
6e23218
Fix comment in random sample
a2dbc6f
Fix typo
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
presentations/** linguist-documentation |
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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import dask.array as da | ||
import random | ||
from pathlib import Path | ||
|
||
from aicsimageio import AICSImage | ||
|
||
from .benchmark_image_containers import _ImageContainerTimeSuite | ||
|
||
############################################################################### | ||
|
||
# We only benchmark against local files as remote files are covered by unit tests | ||
# and are generally slower than local but scale at a similar rate. | ||
LOCAL_RESOURCES_DIR = ( | ||
Path(__file__).parent.parent / "aicsimageio" / "tests" / "resources" | ||
) | ||
|
||
############################################################################### | ||
|
||
|
||
class ChunkSuite(_ImageContainerTimeSuite): | ||
# This suite measures the effect that changing the default chunk dims | ||
# has on the duration of various reads. | ||
# We would expect that processing speed can be optimized based off of the | ||
# dimensions of the file and what the user is trying to do with said file. | ||
# i.e. If the user wants to nrmalize each channel and make a max projection | ||
# through Z, then the default of 'ZYX' is preferred over just 'YX'. | ||
# During this suite we not only benchmark the above example but also | ||
# file reading under the various chunk configurations as a monitor | ||
# for general read performance. | ||
|
||
params = ( | ||
[ | ||
str(LOCAL_RESOURCES_DIR / "pre-variance-cfe.ome.tiff"), | ||
str(LOCAL_RESOURCES_DIR / "variance-cfe.ome.tiff"), | ||
], | ||
# We don't go above chunking by three dims because it would be rare | ||
# to do so... if you can read four-plus dims in a single chunk why can't you | ||
# just read in the whole image at once. | ||
# We also use CYX here to show that chunking with the _wrong_ dimensions can | ||
# result in longer processing times. | ||
[ | ||
"YX", | ||
"ZYX", | ||
"CYX", | ||
], | ||
) | ||
|
||
def time_norm_and_project(self, img_path, chunk_dims): | ||
""" | ||
Benchmark how long a norm and project through Z takes | ||
under various chunk dims configurations. | ||
""" | ||
# Init image container | ||
r = self.ImageContainer(img_path, chunk_dims=chunk_dims) | ||
|
||
# Store all delayed projections | ||
projs = [] | ||
|
||
# Only run a random sample of two channels instead of all | ||
selected_channels = random.sample(r.channel_names, 2) | ||
for i, channel_name in enumerate(r.channel_names): | ||
if channel_name in selected_channels: | ||
# Select each channel | ||
data = r.get_image_dask_data("ZYX", C=i) | ||
|
||
# Get percentile norm by values | ||
min_px_val, max_px_val = da.percentile( | ||
data.flatten(), | ||
[50.0, 99.8], | ||
).compute() | ||
|
||
# Norm | ||
normed = (data - min_px_val) / (max_px_val - min_px_val) | ||
|
||
# Clip any values outside of 0 and 1 | ||
clipped = da.clip(normed, 0, 1) | ||
|
||
# Scale them between 0 and 255 | ||
scaled = clipped * 255 | ||
|
||
# Create max project | ||
projs.append(scaled.max(axis=0)) | ||
|
||
# Compute all projections | ||
projs = da.stack(projs) | ||
projs.compute() | ||
|
||
def setup(self, img_path, chunk_dims): | ||
random.seed(42) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🌌 |
||
self.ImageContainer = AICSImage |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.