Example #1
0
 def split_regions(self, binary=False):
     '''Split regions id into separate Label instance'''
     indices = self.regions_indices()
     split = dict()
     for i, idx in indices.iteritems():
         split[i] = Label(data=np.zeros(self.data.shape, dtype=self.dtype))
         if binary:
             split[i].data[idx] = 1
         else:
             split[i].data[idx] = i
     return split
Example #2
0
 def find_regions_with_labels(self, label_dic):
     ''' Return a binary labeled volume.
         Voxels whose original label is listed in label_dic will be set to 1 
         in the output volume.
 
         Keyword arguments:
         label_dic -- Dictionary of labels which will be used as reference.   
     '''
     indices = self.regions_indices()
     
     outLabel = Label(data=np.zeros(self.data.shape, dtype=self.dtype))
     
     for i, idx in indices.iteritems():
         if i in label_dic.values():
             outLabel.data[idx] = 1;
     
     return outLabel