Skip to content
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

Multiscale: Support project files containing an integer working_scale #2816

Merged
merged 1 commit into from Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions ilastik/applets/dataSelection/opDataSelection.py
Expand Up @@ -206,9 +206,20 @@
if "display_mode" in data:
params["display_mode"] = data["display_mode"][()].decode("utf-8")
if "working_scale" in data:
# This raises if working_scale is an int,
# which would be the case if anyone actually created a Precomputed project with ilastik1.4.1b13
params["working_scale"] = data["working_scale"][()].decode("utf-8")
try:
params["working_scale"] = data["working_scale"][()].decode("utf-8")
except AttributeError:

Check warning on line 211 in ilastik/applets/dataSelection/opDataSelection.py

View check run for this annotation

Codecov / codecov/patch

ilastik/applets/dataSelection/opDataSelection.py#L211

Added line #L211 was not covered by tests
# Support for projects created with ilastik 1.4.1b13
saved_scale = int(data["working_scale"][()])

Check warning on line 213 in ilastik/applets/dataSelection/opDataSelection.py

View check run for this annotation

Codecov / codecov/patch

ilastik/applets/dataSelection/opDataSelection.py#L213

Added line #L213 was not covered by tests
if saved_scale == 0: # 0 by default (in all project files).
params["working_scale"] = DEFAULT_LOWEST_SCALE_KEY

Check warning on line 215 in ilastik/applets/dataSelection/opDataSelection.py

View check run for this annotation

Codecov / codecov/patch

ilastik/applets/dataSelection/opDataSelection.py#L215

Added line #L215 was not covered by tests
elif saved_scale > 0: # Precomputed dataset with non-default scale selected
from lazyflow.utility.io_util.RESTfulPrecomputedChunkedVolume import RESTfulPrecomputedChunkedVolume

Check warning on line 217 in ilastik/applets/dataSelection/opDataSelection.py

View check run for this annotation

Codecov / codecov/patch

ilastik/applets/dataSelection/opDataSelection.py#L217

Added line #L217 was not covered by tests

url = params["url"] # Should have url in this case
remote_source = RESTfulPrecomputedChunkedVolume(url.lstrip("precomputed://"))
scales = remote_source.get_scales_list_legacy()
params["working_scale"] = scales[saved_scale]["key"]

Check warning on line 222 in ilastik/applets/dataSelection/opDataSelection.py

View check run for this annotation

Codecov / codecov/patch

ilastik/applets/dataSelection/opDataSelection.py#L219-L222

Added lines #L219 - L222 were not covered by tests
if "scale_locked" in data:
params["scale_locked"] = bool(data["scale_locked"][()])
return cls(**params)
Expand Down
4 changes: 4 additions & 0 deletions lazyflow/utility/io_util/RESTfulPrecomputedChunkedVolume.py
Expand Up @@ -227,6 +227,10 @@
url = f"{base_url}/{scale}/{min_x}-{max_x}_{min_y}-{max_y}_{min_z}-{max_z}"
return url, downloaded_block_shape

def get_scales_list_legacy(self):
"""Returns the list of scales as they were used in ilastik 1.4.1b13."""
return list(reversed(self._json_info["scales"]))

Check warning on line 232 in lazyflow/utility/io_util/RESTfulPrecomputedChunkedVolume.py

View check run for this annotation

Codecov / codecov/patch

lazyflow/utility/io_util/RESTfulPrecomputedChunkedVolume.py#L232

Added line #L232 was not covered by tests


if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
Expand Down