algorithm/vol_tools.py
def makemask_rgrowth(self, valuemap, coordinate, voxnum):
        """
        Make masks using region growth method
        -----------------------------------
        Parameters:
            valuemap: nifti data. Z map, cope map, etc.
            coordinate: region growth origin points
            voxnum: voxel numbers, integer or list
        -----------------------------------
        Example:
            >>> outdata = INS.makemask_rgrowth(data, [[22,23,31], [22,22,31], [54,55,67]], 15)
        """
        import warnings
        warnings.simplefilter('always', UserWarning)       
 
        if isinstance(voxnum, int):
            voxnum = [voxnum]
        if len(voxnum) == 1:
            voxnum = voxnum*len(coordinate)
        if len(voxnum)!=len(coordinate):
            raise Exception('Voxnum length unequal to coodinate length.')
        rgmask = np.zeros_like(valuemap)
        for i,e in enumerate(coordinate):
            rg_image, loc = region_growing(valuemap, e, voxnum[i])
            rg_image[rg_image!=0] = i+1
            if ~np.any(rgmask[rg_image!=0]):
                # all zeros
                rgmask += rg_image
            else:
                warnings.warn('coordinate {} has been overlapped! Label {} will missing'.format(e, i+1))
        return rgmask

        Make masks using region growth method
        -----------------------------------
        Parameters:
            valuemap: nifti data. Z map, cope map, etc.
            coordinate: region growth origin points
            voxnum: voxel numbers, integer or list
        -----------------------------------
        Example:
            >>> outdata = INS.makemask_rgrowth(data, [[22,23,31], [22,22,31], [54,55,67]], 15)
        
Make masks using region growth method
Make masks using region growth method
def makemask_rgrowth(self, valuemap, coordinate, voxnum):
        import warnings
        warnings.simplefilter('always', UserWarning)       
        if isinstance(voxnum, int):
            voxnum = [voxnum]
        if len(voxnum) == 1:
            voxnum = voxnum*len(coordinate)
        if len(voxnum)!=len(coordinate):
            raise Exception('Voxnum length unequal to coodinate length.')
        rgmask = np.zeros_like(valuemap)
        for i,e in enumerate(coordinate):
            rg_image, loc = region_growing(valuemap, e, voxnum[i])
            rg_image[rg_image!=0] = i+1
            if ~np.any(rgmask[rg_image!=0]):
                rgmask += rg_image
            else:
                warnings.warn('coordinate {} has been overlapped! Label {} will missing'.format(e, i+1))
        return rgmask
def makemask_rgrowth ( self , valuemap , coordinate , voxnum ) : import warnings warnings . simplefilter ( 'always' , UserWarning ) if isinstance ( voxnum , int ) : voxnum = [ voxnum ] if len ( voxnum ) == 1 : voxnum = voxnum * len ( coordinate ) if len ( voxnum ) != len ( coordinate ) : raise Exception ( 'Voxnum length unequal to coodinate length.' ) rgmask = np . zeros_like ( valuemap ) for i , e in enumerate ( coordinate ) : rg_image , loc = region_growing ( valuemap , e , voxnum [ i ] ) rg_image [ rg_image != 0 ] = i + 1 if ~ np . any ( rgmask [ rg_image != 0 ] ) : rgmask += rg_image else : warnings . warn ( 'coordinate {} has been overlapped! Label {} will missing' . format ( e , i + 1 ) ) return rgmask
Make masks using region growth method
Make masks using region growth method
"""
        Make masks using region growth method
        -----------------------------------
        Parameters:
            valuemap: nifti data. Z map, cope map, etc.
            coordinate: region growth origin points
            voxnum: voxel numbers, integer or list
        -----------------------------------
        Example:
            >>> outdata = INS.makemask_rgrowth(data, [[22,23,31], [22,22,31], [54,55,67]], 15)
        """ # all zeros
self
valuemap
nifti data. Z map, cope map, etc.
nifti data . Z map cope map etc .
coordinate
region growth origin points
region growth origin points
voxnum
voxel numbers, integer or list
voxel numbers integer or list
examples
None