def test_mroi1(verbose=0): nim = load(RefImage) mroi = MultipleROI(affine=nim.get_affine(), shape=nim.get_shape()) pos = 1.0*np.array([[10,10,10],[0,0,0],[20,0,20],[0,0,35]]) rad = np.array([5.,6.,7.,8.0]) mroi.as_multiple_balls(pos,rad) mroi.append_balls(np.array([[-10.,0.,10.]]),np.array([7.0])) roiPath = os.path.join(WriteDir,"mroi.nii") mroi.make_image(roiPath) assert(os.path.isfile(roiPath))
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][0], position[0][1], position[0][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', input_image) 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)) mroi.from_labelled_image(blobPath,np.arange(31,50)) roiPath5 = os.path.join(swd,"roi_some_blobs.nii") mroi.set_discrete_feature_from_image('activ',input_image) mroi.discrete_to_roi_features('activ') valid = mroi.get_roi_feature('activ')>4.0 mroi.clean(valid) mroi.make_image(roiPath5)
# contrast_path = op.join(swd, 'zmap.nii') # save(contrast_image, contrast_path) ######################################## # Create ROIs ######################################## positions = np.array([[60, -30, 5],[50, 27, 5]]) # in mm (here in the MNI space) radii = np.array([8,6]) mroi = MultipleROI( affine=mask.get_affine(), shape=mask.get_shape()) mroi.as_multiple_balls(positions, radii) # to save an image of the ROIs mroi.make_image((op.join(swd, "roi.nii"))) # exact the time courses with ROIs mroi.set_discrete_feature_from_image('signal', image=fmri_data) # ROI average time courses mroi.discrete_to_roi_features('signal') # roi-level contrast average mroi.set_discrete_feature_from_image('contrast', image=contrast_image) mroi.discrete_to_roi_features('contrast') ######################################## # GLM analysis on the ROI average time courses ########################################