def generate_synthetic_liver(return_dataplus=False):
    """
    Create synthetic data. There is some liver and porta -like object.
    :return data3d, segmentation, voxelsize_mm, slab, seeds_liver, seeds_porta:
    """
    # data
    slab = {"none": 0, "liver": 1, "porta": 2}
    voxelsize_mm = np.array([1.0, 1.0, 1.2])

    segm = np.zeros([80, 256, 250], dtype=np.int16)

    # liver
    segm[30:60, 70:180, 40:190] = slab["liver"]

    # porta
    segm[40:45, 120:130, 70:190] = slab["porta"]
    segm[41:44, 122:127, 68:70] = slab[
        "porta"
    ]  # hack to fix stability of skeleton algorithm
    #
    segm[40:45, 80:130, 100:110] = slab["porta"]
    segm[42:44, 77:80, 103:106] = slab[
        "porta"
    ]  # hack to fix stability of skeleton algorithm
    # segm[41:44, 78:80, 101:109] = slab['porta']
    # vertical branch under main branch
    segm[40:44, 120:170, 130:135] = slab["porta"]

    data3d = np.zeros(segm.shape)
    data3d[segm == slab["liver"]] = 146
    data3d[segm == slab["porta"]] = 206
    noise = np.random.normal(0, 10, segm.shape)  # .astype(np.int16)
    data3d = (data3d + noise).astype(np.int16)

    seeds_liver = np.zeros(data3d.shape, np.int8)
    seeds_liver[40:55, 90:120, 70:110] = 1
    seeds_liver[30:45, 190:200, 40:90] = 2

    seeds_porta = np.zeros(data3d.shape, np.int8)
    seeds_porta[40:45, 121:139, 80:95] = 1

    if return_dataplus:
        datap = {
            "data3d": data3d,
            "voxelsize_mm": voxelsize_mm,
            "slab": slab,
            "seeds_liver": seeds_liver,
            "seeds_porta": seeds_porta,
            "segmentation": segm,
        }
        return datap
    else:
        return data3d, segm, voxelsize_mm, slab, seeds_liver, seeds_porta
def generate_synthetic_liver ( return_dataplus = False ) : slab = { "none" : 0 , "liver" : 1 , "porta" : 2 } voxelsize_mm = np . array ( [ 1.0 , 1.0 , 1.2 ] ) segm = np . zeros ( [ 80 , 256 , 250 ] , dtype = np . int16 ) segm [ 30 : 60 , 70 : 180 , 40 : 190 ] = slab [ "liver" ] segm [ 40 : 45 , 120 : 130 , 70 : 190 ] = slab [ "porta" ] segm [ 41 : 44 , 122 : 127 , 68 : 70 ] = slab [ "porta" ] segm [ 40 : 45 , 80 : 130 , 100 : 110 ] = slab [ "porta" ] segm [ 42 : 44 , 77 : 80 , 103 : 106 ] = slab [ "porta" ] segm [ 40 : 44 , 120 : 170 , 130 : 135 ] = slab [ "porta" ] data3d = np . zeros ( segm . shape ) data3d [ segm == slab [ "liver" ] ] = 146 data3d [ segm == slab [ "porta" ] ] = 206 noise = np . random . normal ( 0 , 10 , segm . shape ) data3d = ( data3d + noise ) . astype ( np . int16 ) seeds_liver = np . zeros ( data3d . shape , np . int8 ) seeds_liver [ 40 : 55 , 90 : 120 , 70 : 110 ] = 1 seeds_liver [ 30 : 45 , 190 : 200 , 40 : 90 ] = 2 seeds_porta = np . zeros ( data3d . shape , np . int8 ) seeds_porta [ 40 : 45 , 121 : 139 , 80 : 95 ] = 1 if return_dataplus : datap = { "data3d" : data3d , "voxelsize_mm" : voxelsize_mm , "slab" : slab , "seeds_liver" : seeds_liver , "seeds_porta" : seeds_porta , "segmentation" : segm , } return datap else : return data3d , segm , voxelsize_mm , slab , seeds_liver , seeds_porta
Create synthetic data. There is some liver and porta -like object.
    :return data3d, segmentation, voxelsize_mm, slab, seeds_liver, seeds_porta: