Perievent
pynapple.process.perievent
Perievent functions
compute_perievent
Center the timestamps of a time series object or a time series group around the timestamps given by the tref
argument.
minmax
indicates the start and end of the window. If minmax=(-5, 10)
, the window will be from -5 second to 10 second.
If minmax=10
, the window will be from -10 second to 10 second.
To center continuous time series around a set of timestamps, you can use compute_perievent_continuous
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
(Ts, Tsd or TsGroup)
|
The data to align to tref. If Ts/Tsd, returns a TsGroup. If TsGroup, returns a dictionary of TsGroup |
required |
tref |
Ts or Tsd
|
The timestamps of the event to align to |
required |
minmax |
(tuple, int or float)
|
The window size. Can be unequal on each side i.e. (-500, 1000). |
required |
time_unit |
str
|
Time units of the minmax ('s' [default], 'ms', 'us'). |
's'
|
Returns:
Type | Description |
---|---|
dict
|
A TsGroup if data is a Ts/Tsd or a dictionary of TsGroup if data is a TsGroup. |
Raises:
Type | Description |
---|---|
RuntimeError
|
if tref is not a Ts/Tsd object or if data is not a Ts/Tsd or TsGroup |
Source code in pynapple/process/perievent.py
compute_perievent_continuous
Center continuous time series around the timestamps given by the 'tref' argument.
minmax
indicates the start and end of the window. If minmax=(-5, 10)
, the window will be from -5 second to 10 second.
If minmax=10
, the window will be from -10 second to 10 second.
To realign timestamps around a set of timestamps, you can use compute_perievent_continuous
.
This function assumes a constant sampling rate of the time series.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
(Tsd, TsdFrame or TsdTensor)
|
The data to align to tref. |
required |
tref |
Ts or Tsd
|
The timestamps of the event to align to |
required |
minmax |
tuple or int or float
|
The window size. Can be unequal on each side i.e. (-500, 1000). |
required |
ep |
IntervalSet
|
The epochs to perform the operation. If None, the default is the time support of the data. |
None
|
time_unit |
str
|
Time units of the minmax ('s' [default], 'ms', 'us'). |
's'
|
Returns:
Type | Description |
---|---|
(TsdFrame, TsdTensor)
|
If |
Raises:
Type | Description |
---|---|
RuntimeError
|
if tref is not a Ts/Tsd object or if data is not a Tsd/TsdFrame/TsdTensor object. |
Source code in pynapple/process/perievent.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
compute_event_trigger_average
Bin the event timestamps within binsize and compute the Event Trigger Average (ETA) within windowsize.
If C is the event count matrix and feature
is a Tsd array, the function computes
the Hankel matrix H from windowsize=(-t1,+t2) by offseting the Tsd array.
The ETA is then defined as the dot product between H and C divided by the number of events.
The object feature can be any dimensions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
TsGroup
|
The group of Ts/Tsd objects that hold the trigger time. |
required |
feature |
(Tsd, TsdFrame or TsdTensor)
|
The feature to average. |
required |
binsize |
float or int
|
The bin size. Default is second. If different, specify with the parameter time_unit ('s' [default], 'ms', 'us'). |
required |
windowsize |
tuple of float/int or float/int
|
The window size. Default is second. For example windowsize = (-1, 1) is equivalent to windowsize = 1 If different, specify with the parameter time_unit ('s' [default], 'ms', 'us'). |
None
|
ep |
IntervalSet
|
The epochs on which the average is computed |
None
|
time_unit |
str
|
The time unit of the parameters. They have to be consistent for binsize and windowsize. ('s' [default], 'ms', 'us'). |
's'
|
Source code in pynapple/process/perievent.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|