Correlograms
pynapple.process.correlograms
cross_correlogram
Performs the discrete cross-correlogram of two time series. The units should be in s for all arguments. Return the firing rate of the series t2 relative to the timings of t1. See compute_crosscorrelogram, compute_autocorrelogram and compute_eventcorrelogram for wrappers of this function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t1 |
ndarray
|
The timestamps of the reference time series (in seconds) |
required |
t2 |
ndarray
|
The timestamps of the target time series (in seconds) |
required |
binsize |
float
|
The bin size (in seconds) |
required |
windowsize |
float
|
The window size (in seconds) |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The cross-correlogram |
ndarray
|
Center of the bins (in s) |
Source code in pynapple/process/correlograms.py
compute_autocorrelogram
Computes the autocorrelogram of a group of Ts/Tsd objects. The group can be passed directly as a TsGroup object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
TsGroup
|
The group of Ts/Tsd objects to auto-correlate |
required |
binsize |
float
|
The bin size. Default is second. If different, specify with the parameter time_units ('s' [default], 'ms', 'us'). |
required |
windowsize |
float
|
The window size. Default is second. If different, specify with the parameter time_units ('s' [default], 'ms', 'us'). |
required |
ep |
IntervalSet
|
The epoch on which auto-corrs are computed. If None, the epoch is the time support of the group. |
None
|
norm |
bool
|
If True, autocorrelograms are normalized to baseline (i.e. divided by the average rate) If False, autoorrelograms are returned as the rate (Hz) of the time series (relative to itself) |
True
|
time_units |
str
|
The time units of the parameters. They have to be consistent for binsize and windowsize. ('s' [default], 'ms', 'us'). |
's'
|
Returns:
Type | Description |
---|---|
DataFrame
|
_ |
Raises:
Type | Description |
---|---|
RuntimeError
|
group must be TsGroup |
Source code in pynapple/process/correlograms.py
compute_crosscorrelogram
compute_crosscorrelogram(
group,
binsize,
windowsize,
ep=None,
norm=True,
time_units="s",
reverse=False,
)
Computes all the pairwise cross-correlograms for TsGroup or list/tuple of two TsGroup.
If input is TsGroup only, the reference Ts/Tsd and target are chosen based on the builtin itertools.combinations function. For example if indexes are [0,1,2], the function computes cross-correlograms for the pairs (0,1), (0, 2), and (1, 2). The left index gives the reference time series. To reverse the order, set reverse=True.
If input is tuple/list of TsGroup, for example group=(group1, group2), the reference for each pairs comes from group1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
TsGroup or tuple/list of two TsGroups
|
|
required |
binsize : float The bin size. Default is second. If different, specify with the parameter time_units ('s' [default], 'ms', 'us'). windowsize : float The window size. Default is second. If different, specify with the parameter time_units ('s' [default], 'ms', 'us'). ep : IntervalSet The epoch on which cross-corrs are computed. If None, the epoch is the time support of the group. norm : bool, optional If True (default), cross-correlograms are normalized to baseline (i.e. divided by the average rate of the target time series) If False, cross-orrelograms are returned as the rate (Hz) of the target time series ((relative to the reference time series) time_units : str, optional The time units of the parameters. They have to be consistent for binsize and windowsize. ('s' [default], 'ms', 'us'). reverse : bool, optional To reverse the pair order if input is TsGroup
Returns:
Type | Description |
---|---|
DataFrame
|
_ |
Raises:
Type | Description |
---|---|
RuntimeError
|
group must be TsGroup or tuple/list of two TsGroups |
Source code in pynapple/process/correlograms.py
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 191 192 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 |
|
compute_eventcorrelogram
Computes the correlograms of a group of Ts/Tsd objects with another single Ts/Tsd object The time of reference is the event times.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
TsGroup
|
The group of Ts/Tsd objects to correlate with the event |
required |
event |
Ts / Tsd
|
The event to correlate the each of the time series in the group with. |
required |
binsize |
float
|
The bin size. Default is second. If different, specify with the parameter time_units ('s' [default], 'ms', 'us'). |
required |
windowsize |
float
|
The window size. Default is second. If different, specify with the parameter time_units ('s' [default], 'ms', 'us'). |
required |
ep |
IntervalSet
|
The epoch on which cross-corrs are computed. If None, the epoch is the time support of the event. |
None
|
norm |
bool
|
If True (default), cross-correlograms are normalized to baseline (i.e. divided by the average rate of the target time series) If False, cross-orrelograms are returned as the rate (Hz) of the target time series (relative to the event time series) |
True
|
time_units |
str
|
The time units of the parameters. They have to be consistent for binsize and windowsize. ('s' [default], 'ms', 'us'). |
's'
|
Returns:
Type | Description |
---|---|
DataFrame
|
_ |
Raises:
Type | Description |
---|---|
RuntimeError
|
group must be TsGroup |