Skip to content

Commit

Permalink
fix: 🎨 Make datasplit from csv consistent with DaCapo convention
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoadesScholar committed Apr 24, 2024
1 parent 5a55e84 commit 6de372c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cellmap_data/datasplit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import csv
import os
from typing import Callable, Dict, Iterable, Mapping, Optional, Sequence
import tensorstore
from .dataset import CellMapDataset
Expand Down Expand Up @@ -27,7 +28,6 @@ class CellMapDataSplit:
force_has_data: bool = False
context: Optional[tensorstore.Context] = None # type: ignore

# TODO: may want different transforms for different arrays
def __init__(
self,
input_arrays: dict[str, dict[str, Sequence[int | float]]],
Expand Down Expand Up @@ -116,7 +116,12 @@ def from_csv(self, csv_path):
for row in reader:
if row[0] not in dataset_dict:
dataset_dict[row[0]] = []
dataset_dict[row[0]].append({"raw": row[1], "gt": row[2]})
dataset_dict[row[0]].append(
{
"raw": os.path.join(row[1], row[2]),
"gt": os.path.join(row[3], row[4]),
}
)

self.dataset_dict = dataset_dict
self.construct(dataset_dict)
Expand Down
2 changes: 2 additions & 0 deletions src/cellmap_data/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(
target_voxel_shape: Sequence[int],
axis_order: str | Sequence[str] = "zyx",
value_transform: Optional[Callable] = None,
# TODO: Add global grid enforcement to ensure that all images are on the same grid
context: Optional[tensorstore.Context] = None, # type: ignore
):
"""Initializes a CellMapImage object.
Expand Down Expand Up @@ -98,6 +99,7 @@ def to(self, device: str) -> None:
"""Sets what device returned image data will be loaded onto."""
self.device = device

# TODO: move into __init__
def construct(self):
self._bounding_box = None
self._sampling_box = None
Expand Down

0 comments on commit 6de372c

Please sign in to comment.