| spm_bwlabel | R Documentation | 
Get Cluster of certain size from spm_bwlabel
spm_bwlabel(
  infile,
  outfile = NULL,
  retimg = TRUE,
  k = NULL,
  topN = NULL,
  margin = NULL,
  binary = TRUE,
  spmdir = spm_dir(verbose = verbose, install_dir = install_dir),
  reorient = FALSE,
  verbose = TRUE,
  install_dir = NULL
)
infile | 
 input filename  | 
outfile | 
 output filename  | 
retimg | 
 Return the image instead of matlab output  | 
k | 
 Minimum cluster size needed  | 
topN | 
 Top number of clusters kept (used if k is   | 
margin | 
 Margin to loop over if wanted in 2D  | 
binary | 
 (logical) Should the result be binary or numbered with cluster.  | 
spmdir | 
 SPM directory (for MATLAB)  | 
reorient | 
 If   | 
verbose | 
 Print Diagnostics  | 
install_dir | 
 directory to download SPM12  | 
Output from run_matlab_script or nifti object,
depending on retimg
Result from run_matlab_script
Taken from http://en.wikibooks.org/wiki/SPM/How-to#How_to_remove_clusters_under_a_certain_size_in_a_binary_mask.3F
if (matlabr::have_matlab()) { 
d = rep(25, 3)
arr = array(rbinom(prod(d), size = 1, prob = 0.5), dim = d)
nim = oro.nifti::nifti(arr)
res = spm_bwlabel(nim, k = 1, binary = FALSE, install_dir = tempdir())
tab = table(c(res))
tab
out_arr = as(res, "array")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.