Skip to content

Commit

Permalink
Added PVLE
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaffo committed Aug 16, 2013
1 parent 265b685 commit 35f59a5
Show file tree
Hide file tree
Showing 22 changed files with 232 additions and 13 deletions.
16 changes: 16 additions & 0 deletions PVLE/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Package: PVLE
Version: 0.1.0
Date: 2013-08-14
Title: Parallel Voxel Level Everything
Description: Parallel voxel-level analysis for neuro-images
Suggests: stats
Author: Xiaoqiang Xu <cppexp@gmail.com>, Brian Caffo <bcaffo@gmail.com>
Maintainer: Brian Caffo <bcaffo@gmail.com>
Depends: R (>= 3.0.1), methods, fmri, tools, Matrix, gdata, stringr,
parallel, AnalyzeFMRI
License: GPL-3
URL: http://www.bcaffo.com
Packaged: 2013-04-14 11:58:52 UTC; bcaffo
Repository: github
Collate: 'PVLE.R'
Built: R 3.0.1; ; 2013-08-16 03:33:41 UTC; windows
8 changes: 8 additions & 0 deletions PVLE/INDEX
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
AddImageFile Add image file to the project.
LoadArrayMask Load mask from an array.
LoadMask Load mask from file.
LoadPvleProj Load a previously saved Pvle project
PvleProj Constructor for S4 class PvleProj
PvleProj-class Parallel Voxel Level Everything Project
RetrieveMaskArray return a previously loaded mask
RunPvle Execute voxel level analysis
20 changes: 20 additions & 0 deletions PVLE/MD5
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
469937497e7e817da7eee24b788284b2 *DESCRIPTION
4442ca07afa4756e24aa0cbe59d1cc36 *INDEX
03b4c3091124d3019850edd7f75e0a02 *Meta/Rd.rds
367f92ef1e516170a6d074cb330f5e98 *Meta/demo.rds
02d5987d0dfa2cdc2f1a12af6701aaca *Meta/hsearch.rds
c5f8c93fd26658676dd07813550c06f2 *Meta/links.rds
629424384c97d8858aecaabb04c8a9f9 *Meta/nsInfo.rds
93420f608c14deeea9e00c463aec9e6f *Meta/package.rds
20e88f84d0d9ade64549949370a7b46a *NAMESPACE
ebf0fc819595d631b8bf280c4b049940 *R/PVLE
7c4ff98aee661f751ddef29f84a03586 *R/PVLE.rdb
4f297f60b5a1405783058ed5c8c408ef *R/PVLE.rdx
1860924a4b5694a74ffb141b9b24b3e2 *demo/face.R
6bdbbec017e313784a46c60d910e4e3d *help/AnIndex
d90316a35bab94ac8cdf3026fb61b820 *help/PVLE.rdb
e73573609d9c368ebb21912ed4b1b275 *help/PVLE.rdx
af181ed78002c9c6603c96074faae9ad *help/aliases.rds
40189a3ae495652f406192aea18a874a *help/paths.rds
065bce8f5dc610af438a9f0ef1711f02 *html/00Index.html
444535b9cb76ddff1bab1e1865a3fb14 *html/R.css
Binary file added PVLE/Meta/Rd.rds
Binary file not shown.
Binary file added PVLE/Meta/demo.rds
Binary file not shown.
Binary file added PVLE/Meta/hsearch.rds
Binary file not shown.
Binary file added PVLE/Meta/links.rds
Binary file not shown.
Binary file added PVLE/Meta/nsInfo.rds
Binary file not shown.
Binary file added PVLE/Meta/package.rds
Binary file not shown.
4 changes: 4 additions & 0 deletions PVLE/NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export(PvleProj)
exportClasses (PvleProj)
exportMethods (LoadMask,LoadArrayMask,RetrieveMaskArray,AddImageFile,RunPvle)
export (LoadPvleProj)
27 changes: 27 additions & 0 deletions PVLE/R/PVLE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# File share/R/nspackloader.R
# Part of the R package, http://www.R-project.org
#
# Copyright (C) 1995-2012 The R Core Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# A copy of the GNU General Public License is available at
# http://www.r-project.org/Licenses/

local({
info <- loadingNamespaceInfo()
pkg <- info$pkgname
ns <- .getNamespace(as.name(pkg))
if (is.null(ns))
stop("cannot find namespace environment for ", pkg, domain = NA);
dbbase <- file.path(info$libname, pkg, "R", pkg)
lazyLoad(dbbase, ns, filter = function(n) n != ".__NAMESPACE__.")
})
Binary file added PVLE/R/PVLE.rdb
Binary file not shown.
Binary file added PVLE/R/PVLE.rdx
Binary file not shown.
34 changes: 34 additions & 0 deletions PVLE/demo/face.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
facePath<-"e:/Pvle_proj/pvle/demo"
faceProjFolder<-paste(facePath,"/FaceProj",sep="")

unlink(faceProjFolder,recursive=TRUE)
system.time(faceProj<-PvleProj("FaceProj",facePath,"FaceProj"))

#Create mask array from the image files.
files <- dir(paste(facePath,"/rawImgs",sep=""), pattern = "*.img", full.names= TRUE)
imageDim <- f.read.analyze.header(files[1])$dim[2 : 4]
mask3D <- array(1, imageDim)

files<-files
for (file in files)
{
img <- f.read.analyze.volume(file)[,,,1]
mask3D <- mask3D * ( !is.na(img) )
}
faceProj<-LoadArrayMask(faceProj,mask3D)

#Load image files
for (file in files)
faceProj<-AddImageFile(faceProj,file)



interceptModel<-function(y,show) #Return a vector of coefficient estimate, standard error, t value, and p value
{
return(coef(summary(lm(formula=y~1))))
}

system.time(testRst<-RunPvle(faceProj,interceptModel,8))



8 changes: 8 additions & 0 deletions PVLE/help/AnIndex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
AddImageFile AddImageFile
LoadArrayMask LoadArrayMask
LoadMask LoadMask
LoadPvleProj LoadPvleProj
PvleProj PvleProj
PvleProj-class PvleProj-class
RetrieveMaskArray RetrieveMaskArray
RunPvle RunPvle
Binary file added PVLE/help/PVLE.rdb
Binary file not shown.
Binary file added PVLE/help/PVLE.rdx
Binary file not shown.
Binary file added PVLE/help/aliases.rds
Binary file not shown.
Binary file added PVLE/help/paths.rds
Binary file not shown.
40 changes: 40 additions & 0 deletions PVLE/html/00Index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Parallel Voxel Level Everything</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="R.css">
</head><body>
<h1> Parallel Voxel Level Everything
<img class="toplogo" src="../../../doc/html/logo.jpg" alt="[R logo]">
</h1>
<hr>
<div align="center">
<a href="../../../doc/html/packages.html"><img src="../../../doc/html/left.jpg" alt="[Up]" width="30" height="30" border="0"></a>
<a href="../../../doc/html/index.html"><img src="../../../doc/html/up.jpg" alt="[Top]" width="30" height="30" border="0"></a>
</div><h2>Documentation for package &lsquo;PVLE&rsquo; version 0.1.0</h2>

<ul><li><a href="../DESCRIPTION">DESCRIPTION file</a>.</li>
<li><a href="../demo">Code demos</a>. Use <a href="../../utils/help/demo">demo()</a> to run them.</li>
</ul>

<h2>Help Pages</h2>


<table width="100%">
<tr><td width="25%"><a href="AddImageFile.html">AddImageFile</a></td>
<td>Add image file to the project.</td></tr>
<tr><td width="25%"><a href="LoadArrayMask.html">LoadArrayMask</a></td>
<td>Load mask from an array.</td></tr>
<tr><td width="25%"><a href="LoadMask.html">LoadMask</a></td>
<td>Load mask from file.</td></tr>
<tr><td width="25%"><a href="LoadPvleProj.html">LoadPvleProj</a></td>
<td>Load a previously saved Pvle project</td></tr>
<tr><td width="25%"><a href="PvleProj.html">PvleProj</a></td>
<td>Constructor for S4 class PvleProj</td></tr>
<tr><td width="25%"><a href="PvleProj-class.html">PvleProj-class</a></td>
<td>Parallel Voxel Level Everything Project</td></tr>
<tr><td width="25%"><a href="RetrieveMaskArray.html">RetrieveMaskArray</a></td>
<td>return a previously loaded mask</td></tr>
<tr><td width="25%"><a href="RunPvle.html">RunPvle</a></td>
<td>Execute voxel level analysis</td></tr>
</table>
</body></html>
57 changes: 57 additions & 0 deletions PVLE/html/R.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
BODY{ background: white;
color: black }

A:link{ background: white;
color: blue }
A:visited{ background: white;
color: rgb(50%, 0%, 50%) }

H1{ background: white;
color: rgb(55%, 55%, 55%);
font-family: monospace;
font-size: x-large;
text-align: center }

H2{ background: white;
color: rgb(40%, 40%, 40%);
font-family: monospace;
font-size: large;
text-align: center }

H3{ background: white;
color: rgb(40%, 40%, 40%);
font-family: monospace;
font-size: large }

H4{ background: white;
color: rgb(40%, 40%, 40%);
font-family: monospace;
font-style: italic;
font-size: large }

H5{ background: white;
color: rgb(40%, 40%, 40%);
font-family: monospace }

H6{ background: white;
color: rgb(40%, 40%, 40%);
font-family: monospace;
font-style: italic }

IMG.toplogo{ vertical-align: middle }

IMG.arrow{ width: 30px;
height: 30px;
border: 0 }

span.acronym{font-size: small}
span.env{font-family: monospace}
span.file{font-family: monospace}
span.option{font-family: monospace}
span.pkg{font-weight: bold}
span.samp{font-family: monospace}

div.vignettes a:hover {
background: rgb(85%, 85%, 85%);
}

31 changes: 18 additions & 13 deletions rsfmriGraph/R/groupMatrixPermutationTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ groupMatrixPermutationTest <- function(group1MatrixData, group2MatrixData,
##if paired, they have to have the same number of subjects in the same order
if (paired) stopifnot(nrow(group1MatrixData) == nrow(group2MatrixData))

v <- ncol(group1Matrix)
n <- nrow(group1Matrix)
m <- nrow(group2Matrix)
v <- ncol(group1MatrixData)
n <- nrow(group1MatrixData)
m <- nrow(group2MatrixData)

##the observed statistics value
observedStat <- sapply(1 : ncol(group1MatrixData),
Expand All @@ -29,15 +29,15 @@ groupMatrixPermutationTest <- function(group1MatrixData, group2MatrixData,
##permutations are generated at first
if (paired){
##each column is an indicator of whether that pair should switch groups
permIDs <- matrix(sample(c(1, 0), size = n * permutations, replace = TRUE), n, permutations)
permIDXs <- matrix(sample(c(1, 0), size = n * permutations, replace = TRUE), n, permutations)
}
else {
##each column is a reshuffling of the subject IDs
permIDs <- sapply(1 : permutations, function(x) sample(1 : (m + n)))
permIDXs <- sapply(1 : permutations, function(x) sample(1 : (m + n)))
}

##a parallel function
myApply <- function(cl, cores, X, FUN){
myApply <- function(X, FUN){
if (cores > 1){
parApply(cl, X, 2, FUN)
}
Expand All @@ -47,12 +47,12 @@ groupMatrixPermutationTest <- function(group1MatrixData, group2MatrixData,
}

if (cores == 1) cl <- NULL
else makeCluster(getOption("cl.cores", cores))
else cl <-makeCluster(getOption("cl.cores", cores))

permutationDistribution <- myApply(permID,
##for each permutation take the maximum statistic value
max(
function(perm){
permutationDistribution <- myApply(permIDXs,
function(perm){
##for each permutation take the maximum statistic value
max(
##loop over all v
sapply(1 : v,
function(i) {
Expand All @@ -70,9 +70,14 @@ groupMatrixPermutationTest <- function(group1MatrixData, group2MatrixData,
return(stat(x, y))
}
)
}
)
)
}
)
if (cores > 1) stopCluster(cl)

out <- list(pvalues = sapply(observedStat, function(x) mean(x > permutationDistribution)),
observedStat = observedStat,
permutationDistribution = permutationDistribution)

return(out)
}

1 comment on commit 35f59a5

@sspade330
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is twoBinomialPost along with other data sets missing from the course

Please sign in to comment.