Example #1
0
blobPath = os.path.join(swd,"blob.nii")

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

# --- 2.b take blob labelled "1" as an ROI
roi = DiscreteROI( affine=affine, shape=shape)
roi.from_labelled_image(blobPath, 1)
roiPath2 = os.path.join(swd, "roi_blob_1.nii")
roi.make_image(roiPath2)

# --- 2.c take the blob closest to 'position as an ROI'
roiPath3 = os.path.join(swd, "blob_closest_to_%d_%d_%d.nii")%\
           (position[0], position[1], position[2])
roi.from_position_and_image(blobPath, np.array(position))
roi.make_image(roiPath3)

# --- 2.d make a set of ROIs from all the blobs
mroi = MultipleROI( affine=affine, shape=shape)
mroi.from_labelled_image(blobPath)
roiPath4 = os.path.join(swd, "roi_all_blobs.nii")
mroi.make_image(roiPath4)
mroi.set_discrete_feature_from_image('activ', InputImage)
mroi.discrete_to_roi_features('activ')
mroi.plot_roi_feature('activ')

# ---- 2.e the same, a bit more complex
mroi = MultipleROI( affine=affine, shape=shape)
mroi.as_multiple_balls(np.array([[-10.,0.,10.]]),np.array([7.0]))
mroi.from_labelled_image(blobPath,np.arange(1,20))