Example #1
0
def test_roi1(verbose=0):
    nim = load(RefImage)
    affine = nim.get_affine()
    shape = nim.get_shape()
    lroi = DiscreteROI("myroi", affine, shape)
    lroi.from_position(np.array([0,0,0]),5.0)
    roiPath = os.path.join(WriteDir,"myroi.nii")
    lroi.make_image(roiPath)
    assert(os.path.isfile(roiPath))
Example #2
0
# paths
swd = tempfile.mkdtemp()
data_dir = os.path.expanduser(os.path.join('~', '.nipy', 'tests', 'data'))
InputImage = os.path.join(data_dir,'spmT_0029.nii.gz')
MaskImage = os.path.join(data_dir,'mask.nii.gz')

# -----------------------------------------------------
# example 1: create the ROI froma a given position
# -----------------------------------------------------

position = [0,0,0]
nim = load(MaskImage)
affine = nim.get_affine()
shape = nim.get_shape()
roi = DiscreteROI("myroi", affine,shape)
roi.from_position(np.array(position), 5.0)
roi.make_image(os.path.join(swd,"myroi.nii"))
roi.set_feature_from_image('activ',InputImage)
roi.plot_feature('activ')

print 'Wrote an ROI mask image in %s' %os.path.join(swd,"myroi.nii")


# ----------------------------------------------------
# ---- example 2: create ROIs from a blob image ------
# ----------------------------------------------------

# --- 2.a create the  blob image
import nipy.neurospin.graph.field as ff
import nipy.neurospin.spatial_models.hroi as hroi