Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #39 #40

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ Imports:
igraph,
digest,
rappdirs,
memoise
memoise,
purrr
Suggests:
testthat (>= 0.10),
git2r (>= 0.22.1),
nabor
URL: https://github.com/jefferislab/nat.templatebrains
RoxygenNote: 6.1.1
RoxygenNote: 6.1.1.9000
Encoding: UTF-8
7 changes: 4 additions & 3 deletions R/templatebrain.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ print.templatebrain <- function(x, ...) {
cat("Sex: ", x$sex, "\n")
cat(sprintf("Dimensions:%d x %d x %d voxels\n", x$dims[1], x$dims[2], x$dims[3]))
cat(paste0("Voxel size:\n"))
cat(" x =", paste0(x$voxdims[1], " ", x$units[1], "\n"))
cat(" y =", paste0(x$voxdims[2], " ", x$units[2], "\n"))
cat(" z =", paste0(x$voxdims[3], " ", x$units[3], "\n"))
dimension_names = c('x','y','z')
Copy link
Contributor

Choose a reason for hiding this comment

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

in base R, this is prob enough

if(length(x$units)==1) x$units=rep(x$units, 3)

for (dimidx in 1:length(x$voxdims)) {
cat(" ",dimension_names[dimidx] ,"=", paste0(x$voxdims[dimidx], " ",
purrr::pluck(x$units,dimidx,.default = x$units[1]), "\n")) }
cat(paste0("Bounding box (", x$units[1], "):\n"))
cat(" x =", paste0(x$BoundingBox[1, 1], ", y = ", x$BoundingBox[1, 2], ", z = ", x$BoundingBox[1, 3], ",\n"))
cat(" x =", paste0(x$BoundingBox[2, 1], ", y = ", x$BoundingBox[2, 2], ", z = ", x$BoundingBox[2, 3], ".\n"))
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-template-brain-data.r
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,9 @@ test_that("as.templatebrain.im3d works", {

test_that("print.templatebrain",{
expect_output(print(FCWB.demo), "Name: FlyCircuit Whole Brain")

#Check if it can cycle through units that are not explicity given (for e.g. y and z direction units)
dummy_templatebrain <- as.templatebrain(im3d(dims = c(3,4),voxdims = c(2,3,4)), regName="FAFB", name='Full Adult')
dummy_templatebrain$units = 'nm'
expect_output(print(dummy_templatebrain), "\\nVoxel size:\\n x = 2 nm\\n y = 3 nm\\n z = 4 nm")
})