Skip to content

Commit

Permalink
auto adjust T1 brightness when ploting slices
Browse files Browse the repository at this point in the history
  • Loading branch information
dipterix committed Dec 20, 2023
1 parent 28767b2 commit b28a22f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: threeBrain
Type: Package
Title: 3D Brain Visualization
Version: 1.0.1.9021
Version: 1.0.1.9022
Authors@R: c(
person("Zhengjia", "Wang", email = "[email protected]", role = c("aut", "cre", "cph")),
person("John", "Magnotti", email = "[email protected]", role = c("aut", "res")),
Expand Down
12 changes: 9 additions & 3 deletions R/class_brain.R
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,8 @@ Brain2 <- R6::R6Class(

plot_electrodes_on_slices = function(
electrodes_to_plot = "all", volume = NULL, elec_table = NULL,
zoom = 1, electrode_color = "green", electrode_size = 2, ...,
zoom = 1, adjust_brightness = NA,
electrode_color = "green", electrode_size = 2, ...,
decoration = function(i, j) {
graphics::points(0, 0, pch = 20, col = electrode_color,
cex = electrode_size)
Expand Down Expand Up @@ -936,14 +937,19 @@ Brain2 <- R6::R6Class(


# load up volume and adjust brightness
adjust_brightness <- TRUE

if(is.null(volume)) {
volume <- self$volumes$T1$object$group$group_data$volume_data$absolute_path
adjust_brightness <- FALSE
if(is.na(adjust_brightness)) {
adjust_brightness <- FALSE
}
}
if(!inherits(volume, "threeBrain.volume")) {
volume <- read_volume(volume)
}
if(is.na(adjust_brightness)) {
adjust_brightness <- TRUE
}
if( adjust_brightness ) {
qt <- quantile(volume$data, c(0, 0.95), na.rm = TRUE)
volume$data[] <- (volume$data - qt[[1]]) / (qt[[2]] - qt[[1]]) * 255
Expand Down

0 comments on commit b28a22f

Please sign in to comment.