Made regions_to_network flexible to work with noncontiguous phase labels
@@ -117,8 +117,8 @@ def regions_to_network(regions, phases=None, voxel_size=1, accuracy='standard'):
if im.size != phases.size:
raise Exception('regions and phase are different sizes, probably ' +
'because boundary regions were not added to phases')
- dt = edt(phases == 1)
- for i in range(2, phases.max()+1):
+ dt = np.zeros_like(phases, dtype="float32") # since edt returns float32
+ for i in np.unique(phases[phases.nonzero()]):
dt += edt(phases == i)
# Get 'slices' into im for each pore region
