Skip to content

Commit

Permalink
add mappings to datamodel
Browse files Browse the repository at this point in the history
  • Loading branch information
melonora committed Apr 3, 2024
1 parent 1017f3d commit 9c7e2c0
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/cell_gater/model/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dataclasses import dataclass, field
from pathlib import Path
from typing import Sequence
from typing import Mapping, Sequence

import pandas as pd
from napari.utils.events import EmitterGroup, Event
Expand All @@ -17,6 +17,8 @@ class DataModel:
_regionprops_df: pd.DataFrame = field(default_factory=pd.DataFrame, init=False)
_regionprops_columns: Sequence[str] = field(default_factory=list, init=False)
_image_paths: Sequence[Path] = field(default_factory=list, init=False)
_sample_image_mapping: dict[str, Path] = field(default_factory=dict, init=False)
_sample_mask_mapping: dict[str, Path] = field(default_factory=dict, init=False)
_mask_paths: Sequence[Path] = field(default_factory=list, init=False)
_lower_bound_marker: str | None = field(default=None, init=False)
_upper_bound_marker: str | None = field(default=None, init=False)
Expand All @@ -34,6 +36,24 @@ def __post_init__(self) -> None:
"""Allow fields in the dataclass to emit events when changed."""
self.events = EmitterGroup(source=self, samples=Event, regionprops_df=Event, validated=Event)

@property
def sample_image_mapping(self) -> Mapping[str, Path]:
"""Mapping sample names to image paths."""
return self._sample_image_mapping

@sample_image_mapping.setter
def sample_image_mapping(self, mapping: dict[str, Path]) -> None:
self._sample_image_mapping = mapping

@property
def sample_mask_mapping(self) -> Mapping[str, Path]:
"""Mapping of sample names to mask paths."""
return self._sample_mask_mapping

@sample_mask_mapping.setter
def sample_mask_mapping(self, mapping: dict[str, Path]) -> None:
self._sample_mask_mapping = mapping

@property
def samples(self):
"""Samples derived from the regionprops csv file names."""
Expand Down Expand Up @@ -118,6 +138,7 @@ def marker_filter(self, marker_filter: str) -> None:

@property
def validated(self):
"""Whether the data is validated."""
return self._validated

@validated.setter
Expand Down

0 comments on commit 9c7e2c0

Please sign in to comment.