def clean(self, valid): """ remove the rois for which valid==0 and update the hierarchy accordingly In case sum(valid)==0, 0 is returned """ if np.sum(valid)==0: return None # fixme: is None a correct way of dealing with k=0 ? # first clean as a forest sf = self.subforest(valid) Forest.__init__(self, sf.V, sf.parents) # then clean as a multiple ROI MultipleROI.clean(self, valid) return self.V
def __init__(self, parents=None, affine=np.eye(4), shape=None, xyz=None, id='nroi'): """ Building the NROI Parameters ---------- parents=None: array of shape(k) providing the hierachical structure if parent==None, None is returned affine=np.eye(4), array of shape(4,4), coordinate-defining affine transformation shape=None, tuple of length 3 defining the size of the grid implicit to the discrete ROI definition xyz=None, list of arrays of shape (3, nvox) that yield the grid position of each grid guy. id='nroi', string, region identifier """ if parents==None: return None k = np.size(parents) Forest.__init__(self,k,parents) MultipleROI.__init__(self,id, k, affine, shape, xyz)