Skip to content

Commit

Permalink
more flexibility for options
Browse files Browse the repository at this point in the history
  • Loading branch information
wincowgerDEV committed Jun 5, 2024
1 parent b3e16cc commit f2550ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion R/def_features.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def_features.OpenSpecy <- function(x, features, shape_kernel = c(3,3), img = NUL
"indicate that there are no distinct features", call. = F)

features_df <- rbindlist(lapply(unique(features),
function(y) .def_features(x, features == y, shape_kernel = shape_kernel, img, bottom_left, top_right, name = y))
function(y) .def_features(x, features == y, shape_kernel = shape_kernel, img, bottom_left, top_right, name = y)),
fill = T #Allow for flexibility with convex hulls
)[!endsWith(feature_id, "-88"),]
} else {
stop("features needs to be a character or logical vector", call. = F)
Expand All @@ -150,6 +151,12 @@ def_features.OpenSpecy <- function(x, features, shape_kernel = c(3,3), img = NUL
# evaluation
md <- features_df[setDT(obj$metadata), on = c("x", "y")]
md[, feature_id := ifelse(is.na(feature_id), "-88", feature_id)]
if("snr" %in% names(md)){
md[, "mean_snr" := mean(snr), by = "feature_id"]
}
if("max_cor_val" %in% names(md)){
md[, "mean_cor" := mean(max_cor_val), by = "feature_id"]
}
md[, "centroid_x" := mean(x), by = "feature_id"]
md[, "centroid_y" := mean(y), by = "feature_id"]
md[, "first_x" := x[1], by = "feature_id"]
Expand Down
1 change: 1 addition & 0 deletions R/match_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ os_similarity.OpenSpecy <- function(x, y, method = "hamming", na.rm = T, ...) {
}

central_locs <- perform_combined_pca(spec_obj1 = spec_x, spec_obj2 = spec_y)

return(
1-mean(abs(central_locs[[1]] - central_locs[[2]])/central_locs[[3]])
)
Expand Down

0 comments on commit f2550ff

Please sign in to comment.