Skip to content

Commit

Permalink
Merge pull request #1260 from girder/nd2-improvement
Browse files Browse the repository at this point in the history
Don't use dask threads when using nd2 to fetch tiles
manthey authored Aug 14, 2023
2 parents aca4877 + a767f6e commit 77a667f
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -12,7 +12,8 @@

### Changes
- Minor code changes based on suggestions from ruff linting ([#1257](../../pull/1257))
- Reduce pyvips log level ([#1258](../../pull/1258))
- Reduce pyvips log level ([#1259](../../pull/1259))
- Don't use dask threads when using nd2 to fetch tiles ([#1260](../../pull/1260))

### Bug Fixes
- Guard against ICC profiles that won't parse ([#1245](../../pull/1245))
6 changes: 2 additions & 4 deletions sources/nd2/large_image_source_nd2/__init__.py
Original file line number Diff line number Diff line change
@@ -131,8 +131,6 @@ def __init__(self, path, **kwargs):

self._largeImagePath = str(self._getLargeImagePath())

self._pixelInfo = {}

_lazyImport()
try:
self._nd2 = nd2.ND2File(self._largeImagePath, validate_frames=True)
@@ -205,7 +203,7 @@ def _validateArrayAccess(self):
axisSize = self._nd2.sizes[axis]
check[axisidx] = axisSize - 1
try:
self._nd2array[tuple(check)].compute()
self._nd2array[tuple(check)].compute(scheduler='single-threaded')
if axis not in {'X', 'Y', 'S'}:
count *= axisSize
continue
@@ -218,7 +216,7 @@ def _validateArrayAccess(self):
nextval = (minval + maxval) // 2
check[axisidx] = nextval
try:
self._nd2array[tuple(check)].compute()
self._nd2array[tuple(check)].compute(scheduler='single-threaded')
minval = nextval
except Exception:
maxval = nextval
2 changes: 1 addition & 1 deletion sources/tiff/large_image_source_tiff/__init__.py
Original file line number Diff line number Diff line change
@@ -651,7 +651,7 @@ def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False,
exception=e, **kwargs)

def _getDirFromCache(self, dirnum, subdir=None):
if not hasattr(self, '_directoryCache'):
if not hasattr(self, '_directoryCache') or not hasattr(self, '_directoryCacheMaxSize'):
self._directoryCache = {}
self._directoryCacheMaxSize = max(20, self.levels * (2 + (
self.metadata.get('IndexRange', {}).get('IndexC', 1))))

0 comments on commit 77a667f

Please sign in to comment.