This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(oro.dicom) | |
library(oro.nifti) | |
library(shiny) | |
library(shinyIncubator) | |
options(shiny.maxRequestSize = -1) | |
shinyServer(function(input, output, session) { | |
# output$filetable <- renderTable({ | |
makenii = reactive({ | |
rimg = c(0, 100) | |
nii = NULL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gistup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' @title <brief desc> | |
#' | |
#' @description <full description> | |
#' @param <what param does> | |
#' @param <what param does> | |
#' @param <what param does> | |
#' @export | |
#' @keywords | |
#' @seealso | |
#' @return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' @name fslmask | |
#' @title Mask image using FSL | |
#' @param file (character) image to be masked | |
#' @param mask (character) mask given for image | |
#' @param outfile (character) resultant masked image name | |
#' @param retimg (logical) return image of class nifti | |
#' @param reorient (logical) If retimg, should file be reoriented when read in? | |
#' Passed to \code{\link{readNIfTI}}. | |
#' @param intern (logical) to be passed to \code{\link{system}} | |
#' @param opts (character) additional options to be passed to fslmask |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> t(t(coef(SuBLIME_model))) | |
[,1] | |
(Intercept) -9.828049e+00 | |
FLAIR 6.859367e-01 | |
PD 7.665177e-01 | |
T2 -3.484273e-01 | |
T1 5.850592e-01 | |
FLAIR_diff 1.699155e-01 | |
time_diff 2.533482e-03 | |
PD_diff 3.295134e-01 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So day 2 of the #JHUSMARTHack was last week, but I figured this would be a good time to discuss what was accomplished, but really discuss why I like using [RStudio](http://www.rstudio.com/) for making packages. | |
# What was accomplished? | |
I had spoken [before](http://hopstat.wordpress.com/2014/05/01/smart-hackathon-day-1/) about the [repositories](http://github.com/muschellij2/) I had worked on an also [Developing Packages in RStudio](http://www.rstudio.com/ide/docs/packages/overview). I'll discuss the workflow I settled into for for making a package. | |
## Workflow for an `R` package | |
I'm assuming `R` code is already available, presumably functions you had created during a project or analysis. If code is not available, GREAT! You can start your workflow for your new package or product all the same. I'll try to put command-line equivalents in double parentheses. | |
Workflow: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
df = data.frame(x = rnorm(100), x2 = rnorm(100, mean=2)) | |
g = ggplot(df, aes(x)) + geom_histogram( aes(x = x, y = ..density..), fill="blue") + | |
geom_histogram( aes(x = x2, y = -..density..), fill= "green") | |
print(g) | |
## using base | |
h1 = hist(df$x) | |
h2 = hist(df$x2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' @title Find matlab path | |
#' | |
#' @description This tries to find matlab's path using a system which | |
#' command, and then, if not found, looks at \code{getOption("matlab.path")}. If not path is found, it fails. | |
#' @export | |
#' @return Character of command for matlab | |
get_matlab = function(){ | |
find.matlab <- system("which matlab", ignore.stdout=TRUE) | |
matcmd <- 'matlab -nodesktop -nosplash -nodisplay -r ' | |
if (find.matlab != 0){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type="text/css"> | |
body { | |
background-image: url('figure/rplot_loess.png'); | |
background-color: #cccccc; | |
} | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title_desc = function(file) { | |
require(Hmisc) | |
desc = read.dcf(file) | |
title = desc[, "Title"] | |
ss = strsplit(title, " ")[[1]] | |
ss = capitalize(ss) | |
ss = paste(ss, collapse = " ") | |
desc[, "Title"] = ss | |
write.dcf(desc, file=file) | |
} |