igm-team / meaRtools

An R package for the Comprehensive Analysis of Neuronal Networks Recorded on Microelectrode Arrays
GNU General Public License v3.0
5 stars 5 forks source link

no detection of the first and last NB of the recordings #55

Open sofiapuvogelvittini opened 1 year ago

sofiapuvogelvittini commented 1 year ago

Hello, I wonder why the algorithm, in general, doesn't detect the network bursts that start very early or at the final stage of the recordings. I would like to ask what parameter I can change to solve this. I am attaching some raster plots. The vertical red lines indicate the start and the end of NB. You can see that the first and last NB are not detected. A4_raster_NB A2_raster_NB

sje30 commented 1 year ago

Good catch.

I can think of a couple of explanations:

  1. its a bug (although odd that it happens at both beg and end).
  2. it may be that the Gaussian smoothing window is quite broad?

are you able to provide an example data file and script so that I can investigate sometime?

sofiapuvogelvittini commented 1 year ago

Changing the Gaussian smoothing window did not solved the problem. playing with the meRfunctions, I changed the skip parameter of .nb_extract_features from 10 to 1. Honestly, I don't really know what this parameter does, but this solved the problem.

code:

similar to .nb_extract_features of meaRtools

min_electrodes=parameters$min_electrodes local_region_min_nae=parameters$local_region_min_nae duration =0 bin = 25 #this might be modified , but then we need to change inside parameters sf = 12500 skip = 1 #this one I changed from 10 to 1 df.spikes <- .nb_prepare(s) wells <- unique(substr(colnames(df.spikes), 1, 2))#check if it is 2 or 5 output <- list()

sbegin <- floor(min(df.spikes[df.spikes > 0] / skip)) skip + skip send <- floor(max(df.spikes[df.spikes > 0] / skip)) skip timespan <- send - sbegin

bin_time <- bin / sf nb_times <- list() length(nb_times) <- length(wells) names(nb_times) <- wells cat(paste0("calculating network bursts for recording ", basename(s$file), "\n")) for (well.index in 1: length(wells)) { well <- wells[well.index] temp_return <- .nb_select_and_bin(df.spikes, well, sbegin, send, bin) offset2 <- temp_return[[2]] well_data <- temp_return[[1]] f <- list() for (i in 1: length(sigmas)) { f[[i]] <- .nb_gaussian_filter(sigmas[i], well_data, min_electrodes)

}
names(f) <- sigmas

stat0 <- .nb_get_spike_stats(well_data, timespan)
res1 <- .nb_get_burst_stats_intensities(well_data,
        f, timespan, bin_time, local_region_min_nae,
  sbegin, send, offset2)
stat1 <- res1[[1]]
nb_times[[well.index]] <- res1[[2]]

output[[well.index]] <- list()
output[[well.index]]$stat0 <- stat0
output[[well.index]]$stat1 <- stat1
output[[well.index]]$well <- well

} extractfeatures<-list(data = output, div = unlist(strsplit(unlist( strsplit(basename(s$file), ""))[4], "[.]"))[1], nb_times = nb_times) ####################### If you think this is worth a deeper look, I'll be very happy to share the full script and my data with you! Thank you very much for your kind help.