Skip to content

hotfix: enable wsi factory to create cucim#135

Merged
guillaumejaume merged 2 commits intomainfrom
gja/fix/cucimreader
Apr 16, 2026
Merged

hotfix: enable wsi factory to create cucim#135
guillaumejaume merged 2 commits intomainfrom
gja/fix/cucimreader

Conversation

@guillaumejaume
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown

@tunakasif tunakasif left a comment

Choose a reason for hiding this comment

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

Hello, thank you for your prompt update. It is a progress, but it did not solve the issue entirely. Now, CuImage is handled, but since mpp is not passed, it generates a RuntimeError.

I provided necessary changes as comments, I believe if you update them, it will be solved.

Comment thread src/hest/trident_compat.py Outdated
"CuImage object does not expose a usable source path; "
"please pass a file path (str/Path) to wsi_factory."
)
loaded = trident_load_wsi(str(path_like), reader_type=reader_type or "cucim")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This line is raising the following RuntimeError, it is probably caused by not passing the mpp to trident_load_wsi(...) and trident cannot extract it from metadata.

RuntimeError: Failed to initialize WSI using CuCIM: Unable to extract MPP from CuCIM metadata for: '/mnt/lts4-dislearn/scratch/data/hest-1k/hest_data/wsis/TENX95.tif'.
Suggestions:
- Provide `custom_keys` with metadata key mappings for 'mpp_x' and 'mpp_y'.
- Set the MPP manually when constructing the CuCIMWSI object.

I believe Line 94 should be updated as:

loaded = trident_load_wsi(str(path_like), reader_type=reader_type or "cucim", mpp=mpp)

Comment thread src/hest/trident_compat.py Outdated

try:
from cucim import CuImage as _CuImage # type: ignore
except Exception:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similar to rest of the code, it may be better to switch this to:

except Exception: -> except ImportError:

Copy link
Copy Markdown

@tunakasif tunakasif left a comment

Choose a reason for hiding this comment

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

This change fixes the problem. Thank you for your updates!

@guillaumejaume guillaumejaume merged commit 3ddb5ea into main Apr 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants