def getBoundingBox(center,cs,size):

    """  
    Obtaining the bounding box for center cropping 
    center : center of the image (voxel index), 
    cs : crop size in voxels 
    size : size of the image in voxels
    """

    startz = int(center[0]-cs[2]); endz = int(center[0]+cs[2]);
    starty = int(center[1]-cs[1]); endy = int(center[1]+cs[1]);
    startx = int(center[2]-cs[0]); endx = int(center[2]+cs[0]);

    # limit the crop size within the image size 
    if startx < 0:
        startx = 0 
    if starty < 0 :
        starty = 0 
    if startz < 0:
        startz = 0 

    if endx > size[0]-1:
        endx = size[0]-1
    if endy > size[1]-1:
        endy = size[1]-1
    if endz > size[2]-1:
        endz = size[2]-1

    return startx,starty,startz,endx,endy,endz