Skip to content

Commit

Permalink
Using single-sided selections when getting channels with end specified
Browse files Browse the repository at this point in the history
  • Loading branch information
dipterix committed Dec 18, 2024
1 parent fdce8bc commit 308fc52
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion R/bci2000-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ BCI2000Cache <- R6::R6Class(
arr <- private$.filearray
signals <- subset(arr,
Time ~ Time >= begin &
Time <= end,
Time < end,
ChannelOrder ~ ChannelOrder == x,
drop = FALSE)
time <- as.numeric(rownames(signals))
Expand Down
2 changes: 1 addition & 1 deletion R/brainvis-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ BrainVisionCache <- R6::R6Class(
arr <- private$.filearray
signals <- subset(arr,
Time ~ Time >= begin &
Time <= end,
Time < end,
ChannelOrder ~ ChannelOrder == x,
drop = FALSE)
time <- as.numeric(rownames(signals))
Expand Down
2 changes: 1 addition & 1 deletion R/edf-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ EBDFCache <- R6::R6Class(
arr <- filearray::filearray_load(file_path(private$.root_path, sprintf("Ch%d", chan)), mode = "readonly")
# select time
time <- arr[, 2]
sel <- time >= begin & time <= end
sel <- time >= begin & time < end

# load data
time <- time[sel]
Expand Down
6 changes: 3 additions & 3 deletions R/edf.R
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ internal_read_edf_signal <- function(con, channels, begin = 0, end = Inf, conver
# trying to obtain the timestamp
# estimate earliest start
earliest_start <- env$previous_finish
if( earliest_start > end ) { return() }
if( earliest_start >= end ) { return() }

record <- read_next_record()

Expand Down Expand Up @@ -636,7 +636,7 @@ internal_read_edf_signal <- function(con, channels, begin = 0, end = Inf, conver
slice_finish <- slice_start + record_duration

env$previous_finish <- slice_finish
if( slice_finish < begin || slice_start > end ) { return() }
if( slice_finish < begin || slice_start >= end ) { return() }

# annot$duration <- slice_duration

Expand Down Expand Up @@ -688,7 +688,7 @@ internal_read_edf_signal <- function(con, channels, begin = 0, end = Inf, conver
time <- seg_start + time_0

# cut time later
# if( time[[1]] < begin || time[[length(time)]] > end ) {
# if( time[[1]] < begin || time[[length(time)]] >= end ) {
# sel <- time >= begin & time < end
# seg <- seg[sel]
# time <- time[sel]
Expand Down
2 changes: 1 addition & 1 deletion R/nsx-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ NSXCache <- R6::R6Class(

slen <- length(part$data)
time <- seq(part$meta$relative_time, length.out = slen, by = 1 / sample_rate)
sel <- time >= begin & time <= end
sel <- time >= begin & time < end

if(!any(sel)) { return() }

Expand Down

0 comments on commit 308fc52

Please sign in to comment.