Skip to content

Commit

Permalink
Change load type
Browse files Browse the repository at this point in the history
Before these tabs only plotted .Rda files
  • Loading branch information
loye16 committed Aug 21, 2023
1 parent 9842150 commit 23f8718
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion UIs/ui_binning_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ binning_params <- tabPanel(
status = "danger",
solidHeader = TRUE,
title = "Choose a directory of raster data files",
helpText("We only accept .mat and .Rda format"),
helpText("We only accept .mat, .Rda, .csv formats"),
shinyFiles::shinyDirButton("bin_chosen_raster", "Browse", ""),
helpText("Loaded raster data: "),
textOutput("bin_show_chosen_raster")),
Expand Down
10 changes: 7 additions & 3 deletions servers/server_binning_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ observe({
req(input$bin_chosen_raster)
# Set current directory name to the base directory
rv$selected_rasters <- shinyFiles::parseDirPath(c(wd=rv$raster_base_dir), input$bin_chosen_raster)
rv$mat_raster_list <- list.files(rv$selected_rasters, pattern = "\\.mat$")
rv$rda_raster_list <- list.files(rv$selected_rasters, pattern = "\\.[rR]da$")
rv$raster_num_neuron <- length(rv$rda_raster_list)
#rv$mat_raster_list <- list.files(rv$selected_rasters, pattern = "\\.mat$")
#rv$rda_raster_list <- list.files(rv$selected_rasters, pattern = "\\.[rR]da$")
rv$raster_list <- list.files(rv$selected_rasters,
pattern = "\\.[rR]da$|\\.csv$|\\.mat$")

rv$raster_num_neuron <- length(rv$raster_list) #- elisa
#rv$raster_num_neuron <- length(rv$rda_raster_list)
})


Expand Down
13 changes: 10 additions & 3 deletions servers/server_plot_raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ observeEvent(list(rv$selected_rasters, rv$raster_cur_neuron),{
req(rv$raster_num_neuron)
if(rv$raster_num_neuron > 0){
# Find the current file to view
rv$raster_cur_file_name <- rv$rda_raster_list[rv$raster_cur_neuron]
#rv$raster_cur_file_name <- rv$rda_raster_list[rv$raster_cur_neuron]
rv$raster_cur_file_name <- rv$raster_list[rv$raster_cur_neuron] #elisa

# Load in the data and save time cols into matrix
#NeuroDecodeR::read_raster_data() - elisa
load(file.path(rv$selected_rasters, rv$raster_cur_file_name))
raster_data <- NeuroDecodeR::read_raster_data(file.path(rv$selected_rasters, rv$raster_cur_file_name))
#load(file.path(rv$selected_rasters, rv$raster_cur_file_name)) #elisa
raster_df <- select(raster_data, starts_with("time."))
raster_matrix <- as.matrix(raster_df)

# Reformat matrix and save as random variable
rownames(raster_matrix) <- 1:dim(raster_matrix)[1]
colnames(raster_matrix) <- gsub("time.", "", colnames(raster_matrix))
colnames(raster_matrix) <- gsub("^(-?[0-9]+)_.*", "\\1", colnames(raster_matrix)) #Elisa
rv$cur_raster_matrix <- raster_matrix
}
})
Expand Down Expand Up @@ -75,6 +77,11 @@ output$bin_PSTH <- renderPlot({
req(rv$cur_raster_matrix)
# Create column means and turn into a df to plot
cur_raster_col_means <- colMeans(rv$cur_raster_matrix, na.rm = FALSE)

# Removing the ranges

#raster_means_df <- data.frame(time = time,
# spike_mean_over_trials = cur_raster_col_means)
raster_means_df <- data.frame(time = as.numeric(names(cur_raster_col_means)),
spike_mean_over_trials = cur_raster_col_means)

Expand Down

0 comments on commit 23f8718

Please sign in to comment.