Spaces:
Sleeping
Sleeping
Merge pull request #10 from pathology-data-mining/copilot/sub-pr-7-another-one
Browse files- src/mosaic/inference/data.py +20 -2
src/mosaic/inference/data.py
CHANGED
|
@@ -210,6 +210,9 @@ def get_tissue_site_map():
|
|
| 210 |
|
| 211 |
Returns:
|
| 212 |
dict: Mapping of tissue site names to indices (0-56)
|
|
|
|
|
|
|
|
|
|
| 213 |
"""
|
| 214 |
global _TISSUE_SITE_MAP
|
| 215 |
if _TISSUE_SITE_MAP is None:
|
|
@@ -217,7 +220,13 @@ def get_tissue_site_map():
|
|
| 217 |
import pandas as pd
|
| 218 |
|
| 219 |
csv_path = Path(__file__).parent.parent.parent.parent / "data" / "tissue_site_original_to_idx.csv"
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
_TISSUE_SITE_MAP = {}
|
| 223 |
for _, row in df.iterrows():
|
|
@@ -244,6 +253,9 @@ def get_sex_map():
|
|
| 244 |
|
| 245 |
Returns:
|
| 246 |
dict: Mapping of sex values to indices (0-2)
|
|
|
|
|
|
|
|
|
|
| 247 |
"""
|
| 248 |
global _SEX_MAP
|
| 249 |
if _SEX_MAP is None:
|
|
@@ -251,7 +263,13 @@ def get_sex_map():
|
|
| 251 |
import pandas as pd
|
| 252 |
|
| 253 |
csv_path = Path(__file__).parent.parent.parent.parent / "data" / "sex_original_to_idx.csv"
|
| 254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
|
| 256 |
_SEX_MAP = {}
|
| 257 |
for _, row in df.iterrows():
|
|
|
|
| 210 |
|
| 211 |
Returns:
|
| 212 |
dict: Mapping of tissue site names to indices (0-56)
|
| 213 |
+
|
| 214 |
+
Raises:
|
| 215 |
+
FileNotFoundError: If the tissue site CSV file is not found
|
| 216 |
"""
|
| 217 |
global _TISSUE_SITE_MAP
|
| 218 |
if _TISSUE_SITE_MAP is None:
|
|
|
|
| 220 |
import pandas as pd
|
| 221 |
|
| 222 |
csv_path = Path(__file__).parent.parent.parent.parent / "data" / "tissue_site_original_to_idx.csv"
|
| 223 |
+
try:
|
| 224 |
+
df = pd.read_csv(csv_path)
|
| 225 |
+
except FileNotFoundError as e:
|
| 226 |
+
raise FileNotFoundError(
|
| 227 |
+
f"Tissue site mapping file not found at {csv_path}. "
|
| 228 |
+
f"Please ensure the data directory contains 'tissue_site_original_to_idx.csv'."
|
| 229 |
+
) from e
|
| 230 |
|
| 231 |
_TISSUE_SITE_MAP = {}
|
| 232 |
for _, row in df.iterrows():
|
|
|
|
| 253 |
|
| 254 |
Returns:
|
| 255 |
dict: Mapping of sex values to indices (0-2)
|
| 256 |
+
|
| 257 |
+
Raises:
|
| 258 |
+
FileNotFoundError: If the sex mapping CSV file is not found
|
| 259 |
"""
|
| 260 |
global _SEX_MAP
|
| 261 |
if _SEX_MAP is None:
|
|
|
|
| 263 |
import pandas as pd
|
| 264 |
|
| 265 |
csv_path = Path(__file__).parent.parent.parent.parent / "data" / "sex_original_to_idx.csv"
|
| 266 |
+
try:
|
| 267 |
+
df = pd.read_csv(csv_path)
|
| 268 |
+
except FileNotFoundError as e:
|
| 269 |
+
raise FileNotFoundError(
|
| 270 |
+
f"Sex mapping file not found at {csv_path}. "
|
| 271 |
+
f"Please ensure the data directory contains 'sex_original_to_idx.csv'."
|
| 272 |
+
) from e
|
| 273 |
|
| 274 |
_SEX_MAP = {}
|
| 275 |
for _, row in df.iterrows():
|