|
62 | 62 | #' output$delete() |
63 | 63 | #' |
64 | 64 | #' # Calculate the maximum of x1/x2 for every 100 elements |
| 65 | +#' # total 60 batches/loops (`.buffer_count`) |
65 | 66 | #' output <- filearray_create(tempfile(), dimension = c(20,3)) |
66 | 67 | #' fmap(list(x1, x2), function(input){ |
67 | 68 | #' max(input[[1]] / input[[2]]) |
68 | | -#' }, output, .input_size = 100, .output_size = 1) |
| 69 | +#' }, .y = output, .buffer_count = 60) |
69 | 70 | #' |
70 | 71 | #' # check |
71 | 72 | #' range(output[] - apply(x1[] / x2[], c(2,3), max)) |
|
81 | 82 | #' Time = 1:301, |
82 | 83 | #' Location = 1:4 |
83 | 84 | #' ) |
84 | | -#' |
| 85 | +#' |
85 | 86 | #' for(i in 1:4){ |
86 | 87 | #' x[,,,i] <- runif(8638700) |
87 | 88 | #' } |
88 | 89 | #' # Step 1: |
89 | 90 | #' # for each location, trial, and marker, calibrate (baseline) |
90 | 91 | #' # according to first 50 time-points |
91 | | -#' |
| 92 | +#' |
92 | 93 | #' output <- filearray_create(tempfile(), dimension = dim(x)) |
93 | | -#' |
| 94 | +#' |
94 | 95 | #' # baseline-percentage change |
95 | 96 | #' fmap( |
96 | | -#' list(x), |
| 97 | +#' list(x), |
97 | 98 | #' function(input){ |
98 | 99 | #' # get locational data |
99 | 100 | #' location_data <- input[[1]] |
100 | 101 | #' dim(location_data) <- c(287, 100, 301) |
101 | | -#' |
102 | | -#' # collapse over first 50 time points for |
| 102 | +#' |
| 103 | +#' # collapse over first 50 time points for |
103 | 104 | #' # each trial, and marker |
104 | 105 | #' baseline <- apply(location_data[,,1:50], c(1,2), mean) |
105 | | -#' |
| 106 | +#' |
106 | 107 | #' # calibrate |
107 | | -#' calibrated <- sweep(location_data, c(1,2), baseline, |
| 108 | +#' calibrated <- sweep(location_data, c(1,2), baseline, |
108 | 109 | #' FUN = function(data, bl){ |
109 | 110 | #' (data / bl - 1) * 100 |
110 | 111 | #' }) |
111 | 112 | #' return(calibrated) |
112 | | -#' }, |
113 | | -#' |
| 113 | +#' }, |
| 114 | +#' |
114 | 115 | #' .y = output, |
115 | | -#' |
| 116 | +#' |
116 | 117 | #' # input dimension is 287 x 100 x 301 for each location |
117 | | -#' .input_size = 8638700, |
118 | | -#' |
119 | | -#' # output dimension is 287 x 100 x 301 |
120 | | -#' .output_size = 8638700 |
| 118 | +#' # hence 4 loops in total |
| 119 | +#' .buffer_count = 4 |
121 | 120 | #' ) |
122 | | -#' |
| 121 | +#' |
123 | 122 | #' # cleanup |
124 | 123 | #' x$delete() |
125 | | -#' |
| 124 | +#' |
126 | 125 | #' } |
127 | 126 | #' |
128 | 127 | #' # cleanup |
|
0 commit comments