Here we will skull strip an image using ROBEX (Robust Brain Extraction). First, let's load in the packages.
library(robex) library(kirby21.t1) library(neurobase)
The kirby21.t1
package downloads or loads T1-weighted iamges. Here we will load a filename into the file infile
:
infile = kirby21.t1::get_t1_filenames(id = "113", visit = 1) if (is.null(infile)) { infile = "" } if (!file.exists(infile)) { outdir = tempdir() try({kirby21.t1::download_t1_data(outdir = outdir)}) infile = kirby21.t1::get_t1_filenames( id = "113", visit = 1, outdir = outdir) }
We will read in the file using neurobase
:
img = readnii(infile) ortho2(img)
We will then run robex::robex
to perform the skull stripping
if (!is.null(infile)) { if (file.exists(infile)) { result = robex(infile = infile) stopifnot(file.exists(result$outfile)) } } print(result)
output = readnii(result$outfile) ortho2(output) double_ortho(img, output) ortho2(robust_window(img), output > 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.