@@ -41,8 +41,8 @@ class GridSelection(ROISelection):
4141
4242 `split_columns` has the same effect on columns as `split_rows` has on rows.
4343
44- Regions are ordered according to C indexing order. The `matrix_layout()` method provides a map
45- showing how the regions are ordered.
44+ Regions are ordered according to C indexing order. The `matrix_layout` attribute provides a map
45+ showing how these regions are ordered.
4646
4747 Common grids are pre-defined:
4848 - VentralAndDorsal: vertically divided into ventral and dorsal;
@@ -66,7 +66,7 @@ class GridSelection(ROISelection):
6666 [16, 17, 18]])
6767 >>> gs = GridSelection(3, 1, split_rows=False)
6868 >>> rois = gs.find_grid(pixel_map)
69- >>> gs.matrix_layout()
69+ >>> gs.matrix_layout
7070 array([[0],
7171 [1],
7272 [2]])
@@ -86,7 +86,7 @@ class GridSelection(ROISelection):
8686 [0, 0, 0]])
8787 >>> gs2 = GridSelection(2, 2, split_columns=True)
8888 >>> rois2 = gs.find_grid(pixel_map)
89- >>> gs2.matrix_layout()
89+ >>> gs2.matrix_layout
9090 array([[0, 1],
9191 [2, 3]])
9292 >>> rois2[2]
@@ -316,11 +316,15 @@ def _create_grouping_vector_split_pixels( # pylint: disable=too-many-locals
316316
317317 return final
318318
319- def matrix_layout (self ) -> NDArray :
319+ @property
320+ def _matrix_layout (self ) -> NDArray :
320321 """Returns a 2D array showing the layout of the matrices returned by
321322 `find_grid`."""
322323 n_regions = self .v_split * self .h_split
323324 return np .reshape (np .arange (n_regions ), (self .v_split , self .h_split ))
325+ @_matrix_layout .getter # private attribute with getter avoids users overriding this property
326+ def matrix_layout (self ):
327+ return self ._matrix_layout
324328
325329
326330class InvalidDivision (Exception ):
0 commit comments