Example #1
0
def make_subdomain():
    """Create a multiple ROI instance
    """
    labels = np.zeros(shape)
    labels[4:,5:,6:] = 1
    labels[:2,:2,:2] = 2
    labels[:2, 5:, 6:] = 3
    labels[:2, :2, 6:] = 4
    labels[4:, :2, 6:] = 5
    labels[4:, :2, :2] = 6
    labels[4:, 5:, :2] = 7
    labels[:2, 5:, :2] = 8
    mroi = subdomain_from_array(labels-1, affine=None)
    return mroi
Example #2
0
def make_hroi():
    """Create a mulmtiple ROI instance
    """
    labels = np.zeros(shape)
    labels[4:,5:,6:] = 1
    labels[:2,:2,:2] = 2
    labels[:2, 5:, 6:] = 3
    labels[:2, :2, 6:] = 4
    labels[4:, :2, 6:] = 5
    labels[4:, :2, :2] = 6
    labels[4:, 5:, :2] = 7
    labels[:2, 5:, :2] = 8
    parents = np.zeros(9)
    sd = subdomain_from_array(labels, affine=None, nn=0)
    hroi = make_hroi_from_subdomain(sd, parents)
    return hroi 
Example #3
0
# compute the  nested roi object
nroi = hroi.HROI_as_discrete_domain_blobs(domain, values,
                                          threshold=threshold, smin=smin)

# saving the blob image,i. e. a label image 
wlabel = -2*np.ones(shape)
wlabel[data!=0] = nroi.label
blobPath = os.path.join(swd, "blob.nii")

wim = Nifti1Image(wlabel, affine)
wim.get_header()['descrip'] = 'blob image extracted from %s'%input_image
save(wim, blobPath)

# --- 2.b take blob labelled "1" as an ROI
roi = mroi.subdomain_from_array((wlabel==1)-1, affine=affine)
roi_path_2 = os.path.join(swd, "roi_blob_1.nii")
roi.to_image(roi_path_2)

# --- 2.c take the blob closest to 'position as an ROI'
roi_path_3 = os.path.join(swd, "blob_closest_to_%d_%d_%d.nii")%\
           (position[0][0], position[0][1], position[0][2])
roi = mroi.subdomain_from_position_and_image(wim, position[0])
roi.to_image(roi_path_3)


# --- 2.d make a set of ROIs from all the blobs
roi = mroi.subdomain_from_image(blobPath)
roi_path_4 = os.path.join(swd, "roi_all_blobs.nii")
roi.to_image(roi_path_4)
roi.make_feature('activ', load(input_image).get_data().ravel())