--- license: cc-by-nc-sa-4.0 --- # Pathomics An extension of the HEST dataset with cell-level segmentation, embeddings, and additional WSI samples. ## Relationship with HEST This dataset is designed as a **companion layer** to HEST-1k. For samples originating from HEST, you need to download the base data from the original HEST repository. Pathomics only stores the additional analyses (cell segmentation, embeddings, etc.). ## Quick Start To use this dataset, you need to gain access to both the **pathomics** and **HEST** repositories. Please follow these steps: ### 1. Request Access * **pathomics Access**: Click the **"Request Access"** button at the top of this page. * **HEST Data Access**: Navigate to the [HEST Repository](https://huggingface.co/datasets/MahmoodLab/hest) and click **"Request Access"** (Access is granted automatically). > 💡 *Note: Once granted, you can manually inspect files via the "Files and versions" tab.* ### 2. Configure Hugging Face Token To load the data programmatically, you need a **Write** access token: 1. Go to [Hugging Face Settings > Tokens](https://huggingface.co/settings/tokens). 2. Click **New token**, name it (e.g., `hest_access`), and set the role to **Write**. 3. **Copy** the token. ### 3. Environment Setup & Login Install the necessary library and authenticate your session: ```bash pip install huggingface-hub ``` ```python from huggingface_hub import login # Replace 'YOUR_HF_TOKEN' with the token you just created login(token="YOUR_HF_TOKEN") ``` ## Download script: ```python from huggingface_hub import snapshot_download import pandas as pd import glob import os def download_pathomics(ids=None, pathomics_dir='pathomics_data', hest_dir='pathomics_data', download_hest_base=True): """ Download pathomics data, optionally downloading the corresponding HEST basic data at the same time. """ # 1. Download pathomics if ids is None: patterns = '*' else: # patterns = [f"*{sid}[_./]**" for sid in ids] + ['*.csv', '*.md', 'scripts/*'] patterns = [f"*{sid}[_./]**" for sid in ids] + ['*.csv'] snapshot_download( repo_id='Boyoungc/pathomics', allow_patterns=patterns, repo_type='dataset', local_dir=pathomics_dir, ) # 2. Optional: Automatically download the corresponding HEST basic data. if download_hest_base: csv_path = sorted([f for f in os.listdir(pathomics_dir) if f.startswith('PATHOMICS_v')])[-1] meta = pd.read_csv(os.path.join(pathomics_dir, csv_path)) if ids: meta = meta[meta['id'].isin(ids)] hest_ids = meta[meta['source'] == 'hest']['hest_id'].dropna().tolist() if hest_ids: hest_patterns = [f"*{hid}[_.]**" for hid in hest_ids] snapshot_download( repo_id='MahmoodLab/hest', allow_patterns=hest_patterns, repo_type='dataset', local_dir=hest_dir, ) print(f"Downloaded {len(hest_ids)} HEST base samples") download_pathomics(ids=['NCBI689', 'MEND62']) ``` # usage download the data by specific IDs, please refer to the PATHOMICS_v.csv file ```python download_pathomics(ids=['NCBI689', 'MEND62']) ``` or download all the data: ```python download_pathomics() ```