{"id":24780674,"url":"https://github.com/rendeirolab/wsi","last_synced_at":"2026-02-26T18:38:39.186Z","repository":{"id":262621876,"uuid":"530206088","full_name":"rendeirolab/wsi","owner":"rendeirolab","description":"A Python package for the processing of whole slide histopathological images","archived":false,"fork":false,"pushed_at":"2025-02-19T14:04:11.000Z","size":48091,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T04:02:54.371Z","etag":null,"topics":["histopathology","openslide-python","package","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rendeirolab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-29T12:17:43.000Z","updated_at":"2025-04-04T14:19:18.000Z","dependencies_parsed_at":"2024-11-13T12:29:35.049Z","dependency_job_id":"7d4fd1c5-5366-47d7-bda5-67956c92daed","html_url":"https://github.com/rendeirolab/wsi","commit_stats":null,"previous_names":["rendeirolab/wsi"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/rendeirolab/wsi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rendeirolab%2Fwsi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rendeirolab%2Fwsi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rendeirolab%2Fwsi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rendeirolab%2Fwsi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rendeirolab","download_url":"https://codeload.github.com/rendeirolab/wsi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rendeirolab%2Fwsi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29867574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T18:27:06.972Z","status":"ssl_error","status_checked_at":"2026-02-26T18:26:57.848Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["histopathology","openslide-python","package","python"],"created_at":"2025-01-29T10:50:24.748Z","updated_at":"2026-02-26T18:38:39.153Z","avatar_url":"https://github.com/rendeirolab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"WSI\n====\n\n[![Documentation Status](https://readthedocs.org/projects/wsi/badge/?version=latest\u0026style=flat-square)](https://wsi.readthedocs.io/en/latest)\n\n\nThis is a fork of the repository from [Mahmood lab's CLAM repository](https://github.com/mahmoodlab/CLAM).\nIt is made available under the GPLv3 License and is available for non-commercial academic purposes.\n\n\n## Changes from original repository\n\nThe purpose of the fork is to compartimentalize the features related with processing of whole-slide images (WSI) from the CLAM model.\n\nThe package has been renamed to `wsi`.\n\n\n## Installation\n\nUsing `pip` (make sure you have a recent enough version with `pip install pip -U`:\n```bash\npip install git+https://github.com/rendeirolab/wsi.git\n```\n\nNote that the package uses setuptols-scm for version control and therefore the installation source needs to be a git repository (a zip file of source code won't work).\n\n## Usage\n\nThe only exposed class is `WholeSlideImage` enables all the functionalities of the package.\n\n### Quick start - segmentation, tiling and feature extraction\n```python\nfrom wsi import WholeSlideImage    \n\nurl = \"https://brd.nci.nih.gov/brd/imagedownload/GTEX-O5YU-1426\"\nslide = WholeSlideImage(url)\nslide.segment()\nslide.tile()\nfeats, coords = slide.inference(\"resnet18\")\n```\n\n### Full example\n\nThis package is meant for both interactive use and for use in a pipeline at scale.\nBy default actions do not return anything, but instead save the results to disk in files relative to the slide file.\n\nAll major functions have sensible defaults but allow for customization.\nPlease check the docstring of each function for more information.\n\n```python\nfrom wsi import WholeSlideImage\nfrom wsi.utils import Path\n\n# Get example slide image\nslide_file = Path(\"GTEX-12ZZW-2726.svs\")\nif not slide_file.exists():\n    import requests\n    url = f\"https://brd.nci.nih.gov/brd/imagedownload/{slide_file.stem}\"\n    with open(slide_file, \"wb\") as handle:\n        req = requests.get(url)\n        handle.write(req.content)\n\n# Instantiate slide object\n# # from a local file\nslide = WholeSlideImage(slide_file)\n# # from a URL (will be saved in temporary folder)\nslide = WholeSlideImage(\"https://brd.nci.nih.gov/brd/imagedownload/GTEX-O5YU-1426\")\n# # instantiation can be done with custom attributes as well\nslide = WholeSlideImage(slide_file, attributes=dict(donor=\"GTEX-12ZZW\", tissue='Ileum', sex='Male'))\n\n# Segment tissue (segmentation mask is stored as polygons in slide.contours_tissue)\nslide.segment()\n\n# Visualize segmentation (PNG file is saved in same directory as slide_file)\nslide.plot_segmentation()\n\n# Generate coordinates for tiling in h5 file (highest resolution, non-overlapping tiles)\nslide.tile()\n\n# Get coordinates (from h5 file)\nslide.get_tile_coordinates()\n\n# Get image of single tile using lower level OpenSlide handle (`wsi` object)\nslide.wsi.read_region((1_000, 2_000), level=0, size=(224, 224))\n\n# Get tile images for all tiles (as a generator)\nimages = slide.get_tile_images()\nfor img in images:\n    ...\n\n# Save tile images to disk as individual jpg files\nslide.save_tile_images(output_dir=slide_file.parent / (slide_file.stem + \"_tiles\"))\n\n# Use in a torch dataloader\nloader = slide.as_data_loader(with_coords=True)\n\n# Extract features \"manually\"\nimport torch\nfrom tqdm import tqdm\nmodel = torch.hub.load(\"pytorch/vision\", \"resnet18\", weights=\"DEFAULT\")\nfeats = list()\ncoords = list()\nfor count, (batch, yx) in tqdm(enumerate(loader), total=len(loader)):\n    with torch.no_grad(): \n        f = model(batch).numpy()\n    feats.append(f)\n    coords.append(yx)\n\nfeats = np.concatenate(feats, axis=0)\ncoords = np.concatenate(coords, axis=0)\n\n# Extract features \"automatically\"\nfeats, coords = slide.inference('resnet18')\n\n# Additional parameters can also be specified\nfeats, coords = slide.inference('resnet18', device='cuda', data_loader_kws=dict(batch_size=512))\n\n# Generate a torch_geometric data object\ngdata = slide.as_torch_geometric_data(feats, coords)  # from existing features and coordinates\ngdata = slide.as_torch_geometric_data(model_name='resnet18')  # without\n```\n\n## Development\n\n`wsi` will not be providing new features and future maintenance will be restricted to bugs. Please refer to our newer project [Lazyslide](https://github.com/rendeirolab/LazySlide) for a more modern, interoperable package for the analysis of whole-slide images.\n\n\nTo contribute bug maintenance, clone the repository, open an issue in the [issue tracker](https://github.com/rendeirolab/wsi/issues), and submit a pull request.\n```\ngit clone git@github.com:rendeirolab/wsi.git\n```\n\n## Reference\nPlease cite the [paper of the original authors](https://www.nature.com/articles/s41551-020-00682-w):\n\nLu, M.Y., Williamson, D.F.K., Chen, T.Y. et al. Data-efficient and weakly supervised computational pathology on whole-slide images. Nat Biomed Eng 5, 555–570 (2021). https://doi.org/10.1038/s41551-020-00682-w\n\n```bibtex\n@article{lu2021data,\n  title={Data-efficient and weakly supervised computational pathology on whole-slide images},\n  author={Lu, Ming Y and Williamson, Drew FK and Chen, Tiffany Y and Chen, Richard J and Barbieri, Matteo and Mahmood, Faisal},\n  journal={Nature Biomedical Engineering},\n  volume={5},\n  number={6},\n  pages={555--570},\n  year={2021},\n  publisher={Nature Publishing Group}\n}\n```\n\u003c!-- For the current code, please cite also the following paper: --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frendeirolab%2Fwsi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frendeirolab%2Fwsi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frendeirolab%2Fwsi/lists"}