Metadata-Version: 2.4
Name: wsiradiomics
Version: 0.1.2
Summary: WSI radiomics feature extraction from cell polygons (GeoJSON) and WSI slides
Author: D.N. Huang
License: MIT License Copyright (c) 2025 AGI&FBHC
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is furnished
        to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice (including the next
        paragraph) shall be included in all copies or substantial portions of the
        Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
        FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
        OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
        WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
        OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
Keywords: WSI,radiomics,pathology,openslide,geojson
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: pyyaml
Requires-Dist: scipy
Requires-Dist: scikit-image
Requires-Dist: shapely
Provides-Extra: wsi
Requires-Dist: openslide-python; extra == "wsi"
Requires-Dist: pyvips; extra == "wsi"
Provides-Extra: geo
Requires-Dist: geopandas; extra == "geo"
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Dynamic: license-file

# WSIRadiomics

**WSIRadiomics** 是一个用于 **全视野病理切片（Whole Slide Image, WSI）** 的 **细胞级 → WSI 级放射组学特征提取工具包**。

它支持从 **细胞实例分割结果（GeoJSON）** 出发，计算细胞级特征，并进一步聚合为 **WSI 级特征**，适用于计算病理、数字病理与多模态研究。

## ✨ Features

- 🧬 Cell-level → WSI-level 特征计算流程
- 🧠 支持 first-order、shape 等基础放射组学特征
- 🧩 基于 YAML 的灵活参数配置
- 🏷 支持按细胞类型（cell_type）聚合
- 📦 模块化设计，易于二次开发
- 📝 使用 Python logging，不使用 print
- 🚫 核心 API **不写文件**，完全由用户控制输出

## **📦 Installation**

### 方法一：通过 PyPI 安装（推荐）

```
pip install wsiradiomics
```

适合 直接使用 / 服务器环境 / 虚拟环境。

### 方法二：通过 Conda / Mamba 环境（推荐科研环境）

项目提供了完整的环境文件：

```
conda env create -f environment.yaml
conda activate wsiradiomics
```

或使用 mamba（更快）：

```
mamba env create -f environment.yaml
mamba activate wsiradiomics
```

> 该方式特别适合 **WSI / OpenSlide / Linux 服务器** 环境。

## 🚀 Quick Start

> 建议先参考 examples/ 文件夹中的示例代码和配置文件

### 示例文件说明

```
examples/
├── example_file.csv        # 批量处理 CSV 示例
├── extract_from_pandas.py  # 批量特征提取示例
└── params.yaml             # 参数配置示例
```

### 1️⃣ 单张 WSI 特征提取（API 方式）

```
from wsiradiomics.extractor import extract

res = extract(
    svs_path="example.svs",
    geojson_path="cells.geojson",
    params_path="params.yaml",
)

wsi_features = res["wsi_features"]
```

### 2️⃣ 批量处理（CSV 驱动，推荐）

CSV 示例（见 examples/example_file.csv）：

```
wsi_path,mask_path
/path/to/wsi_001.svs,/path/to/wsi_001_cells.geojson
/path/to/wsi_002.svs,/path/to/wsi_002_cells.geojson
```

运行示例脚本：

```
python examples/extract_from_pandas.py \
  --input_csv examples/example_file.csv \
  --params examples/params.yaml \
  --out_dir result/
```

输出结果：

```
result/
├── wsi_features.csv
└── run_wsi_feature_extract.log
```

## 📄 License

MIT License

## 📬 Contact

欢迎通过 GitHub Issues 提交问题或建议
