algorithm/surf_tools.py
def randomize_ROI(rawdata, mask=None):
    """
    Randomize the averaged data in ROI that defined by the mask
    if mask is None, randomized original data in global brain (but not cross the ROIs)

    Parameters:
    ------------
    rawdata: original activation data
    mask: mask to define ROIs

    Return:
    -------
    rand_data: randomized data
    """
    masklabel = np.unique(mask[mask!=0])
    rawshape = rawdata.shape
    if mask is None:
        rawdata_flatten = rawdata.flatten()
        rddata_flatten = np.random.choice(rawdata_flatten, len(rawdata_flatten), replace=False)
        rand_data = rddata_flatten.reshape(rawshape)
    else:
        rawdata = rawdata[:,np.newaxis,:]
        rand_data = np.zeros_like(rawdata)
        randomized_masklabel = np.random.choice(masklabel, len(masklabel), replace=False)
        for i, masklbl in enumerate(masklabel):
            avg_rdroi = np.mean(rawdata[:,(mask==randomized_masklabel[i])],axis=1)
            rand_data[:,(mask==masklbl)] = np.tile(avg_rdroi[:,np.newaxis],(len(mask[mask==masklbl])))
        rand_data = rand_data[:,0,:]
    return rand_data

    Randomize the averaged data in ROI that defined by the mask
    if mask is None, randomized original data in global brain (but not cross the ROIs)

    Parameters:
    ------------
    rawdata: original activation data
    mask: mask to define ROIs

    Return:
    -------
    rand_data: randomized data
    
Randomize the averaged data in ROI that defined by the mask
if mask is None, randomized original data in global brain (but not cross the ROIs)



original activation data
mask: mask to define ROIs



randomized data
Randomize the averaged data in ROI that defined by the mask if mask is None randomized original data in global brain ( but not cross the ROIs ) original activation data mask : mask to define ROIs randomized data
def randomize_ROI(rawdata, mask=None):
    masklabel = np.unique(mask[mask!=0])
    rawshape = rawdata.shape
    if mask is None:
        rawdata_flatten = rawdata.flatten()
        rddata_flatten = np.random.choice(rawdata_flatten, len(rawdata_flatten), replace=False)
        rand_data = rddata_flatten.reshape(rawshape)
    else:
        rawdata = rawdata[:,np.newaxis,:]
        rand_data = np.zeros_like(rawdata)
        randomized_masklabel = np.random.choice(masklabel, len(masklabel), replace=False)
        for i, masklbl in enumerate(masklabel):
            avg_rdroi = np.mean(rawdata[:,(mask==randomized_masklabel[i])],axis=1)
            rand_data[:,(mask==masklbl)] = np.tile(avg_rdroi[:,np.newaxis],(len(mask[mask==masklbl])))
        rand_data = rand_data[:,0,:]
    return rand_data
def randomize_ROI ( rawdata , mask = None ) : masklabel = np . unique ( mask [ mask != 0 ] ) rawshape = rawdata . shape if mask is None : rawdata_flatten = rawdata . flatten ( ) rddata_flatten = np . random . choice ( rawdata_flatten , len ( rawdata_flatten ) , replace = False ) rand_data = rddata_flatten . reshape ( rawshape ) else : rawdata = rawdata [ : , np . newaxis , : ] rand_data = np . zeros_like ( rawdata ) randomized_masklabel = np . random . choice ( masklabel , len ( masklabel ) , replace = False ) for i , masklbl in enumerate ( masklabel ) : avg_rdroi = np . mean ( rawdata [ : , ( mask == randomized_masklabel [ i ] ) ] , axis = 1 ) rand_data [ : , ( mask == masklbl ) ] = np . tile ( avg_rdroi [ : , np . newaxis ] , ( len ( mask [ mask == masklbl ] ) ) ) rand_data = rand_data [ : , 0 , : ] return rand_data
Randomize the averaged data in ROI that defined by the mask
if mask is None, randomized original data in global brain (but not cross the ROIs)
Randomize the averaged data in ROI that defined by the mask if mask is None randomized original data in global brain ( but not cross the ROIs )
"""
    Randomize the averaged data in ROI that defined by the mask
    if mask is None, randomized original data in global brain (but not cross the ROIs)

    Parameters:
    ------------
    rawdata: original activation data
    mask: mask to define ROIs

    Return:
    -------
    rand_data: randomized data
    """
rawdata
mask