Skip to content
Snippets Groups Projects
Commit 9d0eb440 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

slice object is now tight bounding box, expanded_slice is post-expansion

parent 0d0a86bf
No related branches found
No related tags found
2 merge requests!18Completed (de)serialization of RoiSet,!16Completed (de)serialization of RoiSet
......@@ -199,6 +199,11 @@ class RoiSet(object):
assert np.all(df['rel_y1'] <= (df['ebb_y1'] - df['ebb_y0']))
df['slice'] = df.apply(
lambda r:
np.s_[int(r.y0): int(r.y1), int(r.x0): int(r.x1), :, int(r.zi): int(r.zi + 1) + 1],
axis=1
)
df['expanded_slice'] = df.apply(
lambda r:
np.s_[int(r.ebb_y0): int(r.ebb_y1), int(r.ebb_x0): int(r.ebb_x1), :, int(r.ebb_z0): int(r.ebb_z1) + 1],
axis=1
......@@ -349,7 +354,7 @@ class RoiSet(object):
def export_dataframe(self, csv_path: Path):
csv_path.parent.mkdir(parents=True, exist_ok=True)
self._df.drop(['slice', 'relative_slice', 'mask'], axis=1).to_csv(csv_path, index=False)
self._df.drop(['expanded_slice', 'slice', 'relative_slice', 'mask'], axis=1).to_csv(csv_path, index=False)
return csv_path
......
......@@ -92,7 +92,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
def test_rel_slices_are_valid(self):
roiset = self._make_roi_set()
for roi in roiset:
ebb = roiset.acc_raw.data[roi.slice]
ebb = roiset.acc_raw.data[roi.expanded_slice]
self.assertEqual(len(ebb.shape), 4)
self.assertTrue(np.all([si >= 1 for si in ebb.shape]))
rbb = ebb[roi.relative_slice]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment