|
1 | 1 | import warnings |
2 | 2 |
|
3 | 3 | import numpy as np |
| 4 | +from hdmf.common import VectorData |
4 | 5 |
|
5 | 6 | from pynwb.base import TimeSeries, ProcessingModule |
6 | 7 | from pynwb.device import Device |
@@ -142,7 +143,7 @@ def test_manifold_deprecated(self): |
142 | 143 | indicator='indicator', |
143 | 144 | location='location', |
144 | 145 | manifold=(1, 1, (2, 2, 2))) |
145 | | - |
| 146 | + |
146 | 147 | # create object with deprecated argument |
147 | 148 | with self.assertRaisesWith(ValueError, msg): |
148 | 149 | ImagingPlane(**kwargs) |
@@ -227,7 +228,7 @@ def test_init_description_optional(self): |
227 | 228 | 'indicator', |
228 | 229 | 'location', |
229 | 230 | ) |
230 | | - |
| 231 | + |
231 | 232 | def test_init_missing_required_args(self): |
232 | 233 | """Check that ImagingPlane raises an error if required args are missing.""" |
233 | 234 | oc, device = self.set_up_dependencies() |
@@ -527,7 +528,7 @@ def test_init(self): |
527 | 528 | self.assertEqual(iS.name, 'test_iS') |
528 | 529 | self.assertEqual(iS.plane_segmentations[ps.name], ps) |
529 | 530 | self.assertEqual(iS[ps.name], iS.plane_segmentations[ps.name]) |
530 | | - |
| 531 | + |
531 | 532 | def test_add_segementation(self): |
532 | 533 | ps = create_plane_segmentation() |
533 | 534 | iS = ImageSegmentation(name='test_iS') |
@@ -594,6 +595,45 @@ def test_init_no_name(self): |
594 | 595 | ) |
595 | 596 | self.assertEqual(pS.name, ip.name) |
596 | 597 |
|
| 598 | + def test_init_missing_roi_col_with_ids(self): |
| 599 | + """If no roi column is provided and ids were provided, an error should be raised""" |
| 600 | + iSS, ip = self.set_up_dependencies() |
| 601 | + msg = "Must provide at least one of 'image_mask', 'pixel_mask', or 'voxel_mask' columns" |
| 602 | + with self.assertRaises(ValueError, msg=msg): |
| 603 | + PlaneSegmentation( |
| 604 | + description='description', |
| 605 | + imaging_plane=ip, |
| 606 | + name='test_name', |
| 607 | + reference_images=iSS, |
| 608 | + id=[1, 2, 3], |
| 609 | + ) |
| 610 | + |
| 611 | + def test_init_missing_roi_col_with_columns(self): |
| 612 | + """If no roi column is provided and other non-empty columns are provided, an error should be raised""" |
| 613 | + iSS, ip = self.set_up_dependencies() |
| 614 | + msg = "Must provide at least one of 'image_mask', 'pixel_mask', or 'voxel_mask' columns" |
| 615 | + with self.assertRaises(ValueError, msg=msg): |
| 616 | + PlaneSegmentation( |
| 617 | + description='description', |
| 618 | + imaging_plane=ip, |
| 619 | + name='test_name', |
| 620 | + reference_images=iSS, |
| 621 | + columns=[VectorData(name="custom_col", description="custom col", data=[1, 2, 3])], |
| 622 | + id=[1, 2, 3], |
| 623 | + ) |
| 624 | + |
| 625 | + def test_init_missing_roi_col_with_empty_columns(self): |
| 626 | + """If no roi column is provided and other columns are empty, no error should be raised""" |
| 627 | + iSS, ip = self.set_up_dependencies() |
| 628 | + pS = PlaneSegmentation( |
| 629 | + description='description', |
| 630 | + imaging_plane=ip, |
| 631 | + name='test_name', |
| 632 | + reference_images=iSS, |
| 633 | + columns=[VectorData(name="custom_col", description="custom col")], |
| 634 | + ) |
| 635 | + self.assertEqual(len(pS), 0) |
| 636 | + |
597 | 637 | def test_add_pixel_mask(self): |
598 | 638 | pix_mask = [[1, 2, 1.0], [3, 4, 1.0], [5, 6, 1.0], |
599 | 639 | [7, 8, 2.0], [9, 10, 2.0]] |
@@ -659,7 +699,6 @@ def test_add_roi_missing_params(self): |
659 | 699 | with self.assertRaises(ValueError, msg=msg): |
660 | 700 | pS.add_roi() |
661 | 701 |
|
662 | | - |
663 | 702 | def test_conversion_of_2d_pixel_mask_to_image_mask(self): |
664 | 703 | pixel_mask = [[0, 0, 1.0], [1, 0, 2.0], [2, 0, 2.0]] |
665 | 704 |
|
|
0 commit comments