Skip to content

Commit 43e84f7

Browse files
committed
Change default axis names / units
1 parent a463c78 commit 43e84f7

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

funlib/persistence/arrays/array.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class Array(Freezable):
3232
The name of each axis. If not provided, the axis names
3333
are given names ["c1", "c2", "c3", ...]
3434
35+
units (``Optional[Iterable[str]]``):
36+
37+
The units of each spatial dimension.
38+
3539
chunk_shape (`tuple`, optional):
3640
3741
The size of a chunk of the underlying data container in voxels.
@@ -67,13 +71,15 @@ def __init__(
6771
self.offset = (
6872
Coordinate(offset) if offset is not None else (0,) * len(data.shape)
6973
)
70-
self.axis_names = (
71-
tuple(axis_names)
72-
if axis_names is not None
73-
else tuple("d{i}" for i in range(len(data.shape)))
74-
)
74+
# assign default axis names, if not given
75+
if axis_names is None:
76+
channel_names = [f"c{i}^" for i in range(self.channel_dims)]
77+
spatial_names = [f"d{i}" for i in range(self.spatial_dims)]
78+
axis_names = channel_names + spatial_names
79+
self.axis_names = tuple(axis_names)
80+
# assign unknown unit to each spatial dim, if not given
7581
self.units = (
76-
tuple(units) if units is not None else ("voxels",) * self.voxel_size.dims
82+
tuple(units) if units is not None else ("",) * self.spatial_dims
7783
)
7884
self.chunk_shape = Coordinate(chunk_shape) if chunk_shape is not None else None
7985
self._source_data = data
@@ -109,6 +115,10 @@ def dims(self):
109115
def channel_dims(self):
110116
return self.dims - self.voxel_size.dims
111117

118+
@property
119+
def spatial_dims(self):
120+
return self.voxel_size.dims
121+
112122
@property
113123
def shape(self):
114124
"""Get the shape in voxels of this array,

0 commit comments

Comments
 (0)