|
9 | 9 |
|
10 | 10 | import numpy as np |
11 | 11 | import pandas as pd |
12 | | -import xarray as xr |
13 | 12 |
|
14 | 13 | from .. import core as nap |
15 | 14 |
|
@@ -183,6 +182,7 @@ def compute_tuning_curves( |
183 | 182 | occupancy: [100. 100. 100. 100. 100. 100. 100. 100. 100. 100.] |
184 | 183 | bin_edges: [array([0. , 0.09, 0.18, 0.27, 0.36, 0.45, 0.54, 0.63, 0.72,... |
185 | 184 | """ |
| 185 | + import xarray as xr |
186 | 186 |
|
187 | 187 | # check data |
188 | 188 | if not isinstance(data, (nap.TsdFrame, nap.TsGroup, nap.Ts, nap.Tsd)): |
@@ -367,6 +367,8 @@ def compute_response_per_epoch(data, epochs_dict, return_pandas=False): |
367 | 367 | * unit (unit) int64 24B 0 1 2 |
368 | 368 | * epochs (epochs) <U5 40B 'stim0' 'stim1' |
369 | 369 | """ |
| 370 | + import xarray as xr |
| 371 | + |
370 | 372 | # check data |
371 | 373 | if not isinstance(data, (nap.TsdFrame, nap.TsGroup, nap.Ts, nap.Tsd)): |
372 | 374 | raise TypeError("data should be a TsdFrame, TsGroup, Ts, or Tsd.") |
@@ -508,6 +510,8 @@ def compute_mutual_information(tuning_curves, rates=None): |
508 | 510 | 1 33.480966 3.301870 |
509 | 511 | 2 33.369159 3.310432 |
510 | 512 | """ |
| 513 | + import xarray as xr |
| 514 | + |
511 | 515 | if not isinstance(tuning_curves, xr.DataArray): |
512 | 516 | raise TypeError( |
513 | 517 | "tuning_curves should be an xr.DataArray as computed by compute_tuning_curves." |
@@ -763,6 +767,8 @@ def compute_2d_mutual_info(dict_tc, features, ep=None, minmax=None, bitssec=Fals |
763 | 767 | `compute_2d_mutual_info` will be removed in Pynapple 1.0.0, it is replaced by |
764 | 768 | `compute_mutual_information` because the latter works for N dimensions. |
765 | 769 | """ |
| 770 | + import xarray as xr |
| 771 | + |
766 | 772 | warnings.warn( |
767 | 773 | "compute_2d_mutual_info is deprecated and will be removed in a future version;" |
768 | 774 | "use compute_mutual_information instead.", |
@@ -820,6 +826,8 @@ def compute_1d_mutual_info(tc, feature, ep=None, minmax=None, bitssec=False): |
820 | 826 | `compute_1d_mutual_info` will be removed in Pynapple 1.0.0, it is replaced by |
821 | 827 | `compute_mutual_information` because the latter works for N dimensions. |
822 | 828 | """ |
| 829 | + import xarray as xr |
| 830 | + |
823 | 831 | warnings.warn( |
824 | 832 | "compute_1d_mutual_info is deprecated and will be removed in a future version;" |
825 | 833 | "use compute_mutual_information instead.", |
|
0 commit comments