Skip to content

Commit 4784e31

Browse files
Merge pull request #67 from CSAFE-ISU/65-fix-crosscut-nas
65 fix crosscut nas
2 parents 501df7c + c6d6149 commit 4784e31

File tree

8 files changed

+56
-50
lines changed

8 files changed

+56
-50
lines changed

NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
export("%>%")
44
export(bulletAnalyzrApp)
5-
export(reportMainUI)
65
export(reportServer)
7-
export(reportSidebarUI)
86
importFrom(magrittr,"%>%")
97
importFrom(stats,predict)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Bullet-to-bullet similarity scores
1212
- Land-to-land score matrices
1313
- Aligned signal comparisons and other diagnostic metrics
14+
* **Display settings**: Users can adjust the down-sampling performed on display images.
1415

1516
## Current Requirements
1617

R/app.R

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,32 @@
55
#' @name bulletAnalyzrApp
66
#' @rdname bulletAnalyzrApp
77
#' @keywords Shiny
8-
#'
8+
#'
99
#' @param run_interactive TRUE allows the user to adjust the crosscut and groove
1010
#' locations. FALSE uses the crosscut and grooves automatically chosen by the
1111
#' app.
12+
#' @param sample_m An integer value by which to downsample the x3p scan for
13+
#' display. High-resolution scans that are 15+ MB require more memory and
14+
#' might crash the app unless down-sampled. On the other hand,
15+
#' lower-resolution scans can appear too smooth if too much down-sampling is
16+
#' performed. The default of sample_m = 10 was optimized for 15+ MB scans.
17+
#' Downsampling is only performed on the displayed scans. All computations use
18+
#' the original resolution.
1219
#' @param ... Other arguments passed on to 'onStart', 'options', 'uiPattern', or
1320
#' 'enableBookmarking' of 'shiny::shinyApp'
14-
#'
21+
#'
1522
#' @returns No return value, called to launch 'shiny' app
16-
#'
23+
#'
1724
#' @export
1825
#' @importFrom stats predict
19-
#'
26+
#'
2027
#' @examples
2128
#' \dontrun{
2229
#' bulletAnalyzrApp()
2330
#' }
2431
#'
2532
#' @returns A Shiny app
26-
bulletAnalyzrApp <- function(run_interactive = TRUE, ...){
33+
bulletAnalyzrApp <- function(run_interactive = TRUE, sample_m = 10, ...){
2734

2835
## Config
2936
options(rgl.useNULL = TRUE)
@@ -38,7 +45,6 @@ bulletAnalyzrApp <- function(run_interactive = TRUE, ...){
3845
text = ggplot2::element_text(size = 22),
3946
plot.title = ggplot2::element_text(size = 22, face = "bold")
4047
)
41-
sample_m = 10
4248

4349
ui <- shiny::shinyUI({
4450
shiny::fluidPage(title = "BulletAnalyzr",

R/process-wrappers.R

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,40 @@ get_default_cc_wrapper <- function(bullets, ylimits = c(150, NA)) {
8484

8585
bullets$crosscut <- sapply(bullets$x3p, bulletxtrctr::x3p_crosscut_optimize, ylimits = ylimits)
8686

87-
# Check for NA values
88-
na_idx <- is.na(bullets$crosscut)
89-
if (any(na_idx)) {
90-
bullet_land <- paste("Bullet", bullets$bullet, "Land", bullets$land)
87+
# If any of the crosscut values are NA, this means that bulletxtrctr could not
88+
# find a stable region, where the minimum ccf allowed is 0.9. Try
89+
# incrementally lowering the permitted minimum ccf by 0.05 each time. If a
90+
# minimum ccf of 0.6 still does not yield a stable region, throw an error.
91+
if (any(is.na(bullets$crosscut))) {
92+
# Get indices of any lands where the crosscut location is NA
93+
missing_cc_indx <- which(is.na(bullets$crosscut))
9194

92-
stop(paste("x3p_crosscut_optimize could not find a stable region in land:",
93-
paste(bullet_land[na_idx], collapse = ", ")))
95+
for (i in missing_cc_indx) {
96+
current_cc <- bullets$crosscut[i]
97+
current_minccf <- 0.85
98+
99+
while (current_minccf >= 0.6) {
100+
current_cc <- bulletxtrctr::x3p_crosscut_optimize(
101+
x3p = bullets$x3p[[i]],
102+
ylimits = ylimits,
103+
minccf = current_minccf
104+
)
105+
if (is.na(current_cc) && current_minccf == 0.6) {
106+
# Error if a stable region still can't be found
107+
bullet_land <- paste("Bullet", bullets$bullet[i], "Land", bullets$land[i])
108+
stop(paste("x3p_crosscut_optimize could not find a stable region in land:",
109+
paste(bullet_land, collapse = ", ")))
110+
} else if (is.na(current_cc)) {
111+
current_minccf <- current_minccf - 0.05
112+
next
113+
} else {
114+
break
115+
}
116+
}
117+
118+
# Update crosscut in bullets data frame
119+
bullets$crosscut[i] <- current_cc
120+
}
94121
}
95122

96123
return(bullets)

R/report-module.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ reportServer <- function(id, bullet_data = NULL, comp_bul1 = NULL, comp_bul2 = N
218218
)
219219
})
220220

221-
downloadDataServer("data1", bullet_data = bullet_data, phase_test_results = phase_test_results, drop_x3p = FALSE)
221+
downloadDataServer("data1", bullet_data = bullet_data, phase_test_results = phase_test_results, drop_x3p = TRUE)
222222

223223
# OUTPUT - Phase test score ----
224224
output$bull_comp_score <- shiny::renderText({

man/bulletAnalyzrApp.Rd

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/reportMainUI.Rd

Lines changed: 0 additions & 17 deletions
This file was deleted.

man/reportSidebarUI.Rd

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)