Skip to content

Commit 598b4d4

Browse files
committed
Fixed xform parser; added more template options
1 parent 1c8b54d commit 598b4d4

File tree

6 files changed

+54
-3
lines changed

6 files changed

+54
-3
lines changed

DESCRIPTION

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: threeBrain
22
Type: Package
33
Title: 3D Brain Visualization
4-
Version: 0.2.4.9002
4+
Version: 0.2.4.9003
55
Authors@R: c(
66
person("Zhengjia", "Wang", email = "[email protected]", role = c("aut", "cre", "cph")),
77
person("John", "Magnotti", email = "[email protected]", role = c("aut")),
@@ -33,6 +33,7 @@ Language: en-US
3333
URL: https://dipterix.org/threeBrain/ https://github.com/dipterix/threeBrain
3434
BugReports: https://github.com/dipterix/threeBrain/issues
3535
Imports:
36+
utils,
3637
grDevices,
3738
graphics,
3839
dipsaus,

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export(GeomGroup)
2222
export(SphereGeom)
2323
export(TubeGeom)
2424
export(add_voxel_cube)
25+
export(available_templates)
2526
export(brain_proxy)
2627
export(brain_setup)
2728
export(check_freesurfer_path)

R/fs_brain.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ freesurfer_brain <- function(fs_subject_folder, subject_name,
123123
has_volume <- FALSE
124124
if( file.exists(path_xform) ){
125125
ss <- readLines(path_xform)
126-
ss <- stringr::str_match(ss, '^([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+)[;]{0,1}$')
126+
ss <- stringr::str_match(ss, '^([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+)[;]{0,1}[ ]{0,}$')
127127
ss <- ss[!is.na(ss[,1]), -1, drop = FALSE]
128128
if( nrow(ss) >= 3 ){
129129
ss <- ss[1:3,1:4]

R/fs_import-xform.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import_fs.xform <- function(subject_name, fs_path, quiet = FALSE, dtype, sub_typ
1010
xfm <- diag(c(1,1,1,1))
1111
if( file.exists(path_xform) ){
1212
ss <- readLines(path_xform)
13-
ss <- stringr::str_match(ss, '^([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+)[;]{0,1}$')
13+
ss <- stringr::str_match(ss, '^([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+) ([-]{0,1}[0-9.]+)[;]{0,1}[ ]{0,}$')
1414
ss <- ss[!is.na(ss[,1]), -1, drop = FALSE]
1515
if( nrow(ss) >= 3 ){
1616
ss <- ss[1:3,1:4]

R/loaders.R

+46
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,49 @@ threebrain_finalize_installation <- function(upgrade = c('ask', 'always', 'never
179179
return(invisible())
180180
}
181181

182+
183+
#' @rdname template_subject
184+
#' @export
185+
available_templates <- function() {
186+
187+
url <- "https://api.github.com/repos/dipterix/threeBrain-sample/releases"
188+
tf <- tempfile()
189+
on.exit({
190+
if(file.exists(tf)) {
191+
unlink(tf)
192+
}
193+
})
194+
195+
res <- tryCatch({
196+
utils::download.file(url, destfile = tf, quiet = TRUE)
197+
res <- jsonlite::read_json(tf)[[1]]
198+
res <- lapply(res$assets, function(asset){
199+
list(
200+
subject_name = gsub("\\..*", "", asset$name),
201+
download_url = asset$browser_download_url
202+
)
203+
})
204+
205+
scodes <- vapply(res, FUN = '[[', FUN.VALUE = "", 'subject_name')
206+
urls <- lapply(res, FUN = '[[', 'download_url')
207+
208+
names(urls) <- scodes
209+
urls
210+
211+
}, error = function(e){
212+
# As of 2022-05-09
213+
list(
214+
bert = "https://github.com/dipterix/threeBrain-sample/releases/download/1.0.0/bert.zip",
215+
cvs_avg35 = "https://github.com/dipterix/threeBrain-sample/releases/download/1.0.0/cvs_avg35.zip",
216+
cvs_avg35_inMNI152 = "https://github.com/dipterix/threeBrain-sample/releases/download/1.0.0/cvs_avg35_inMNI152.zip",
217+
fsaverage = "https://github.com/dipterix/threeBrain-sample/releases/download/1.0.0/fsaverage.zip",
218+
fsaverage_sym = "https://github.com/dipterix/threeBrain-sample/releases/download/1.0.0/fsaverage_sym.zip",
219+
`N27-complete` = "https://github.com/dipterix/threeBrain-sample/releases/download/1.0.0/N27-complete.zip",
220+
N27 = "https://github.com/dipterix/threeBrain-sample/releases/download/1.0.0/N27.zip"
221+
)
222+
})
223+
224+
return(res)
225+
}
226+
227+

man/template_subject.Rd

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)