Migrating from 2.x to 3.0#

spectral_connectivity 3.0 corrects several numerical definitions, so it is a major version. Recompute affected results rather than comparing them directly with results from 2.x. The changelog lists everything that was added and fixed; this page lists what code written for 2.x has to change.

If you only change five things#

  1. Swap the indices of directed results. The Connectivity methods of the spectral Granger family, directed_transfer_function, directed_coherence, partial_directed_coherence, generalized_partial_directed_coherence, and direct_directed_transfer_function return [..., source, target]: result[..., i, j] is now i -> j, where 2.x returned j -> i. In the wrapper results, multitaper_connectivity(...).sel(source="a", target="b") of pairwise and subset spectral Granger prediction is now a -> b, where 2.x returned b -> a. Code written for 2.x still runs but reads the opposite direction, so swap its indices and recompute stored results. phase_slope_index, group_delay, and delay were already source first: do not swap them. Until 3.2 the Connectivity methods that existed in 2.x (pairwise and subset spectral Granger, directed transfer function, directed coherence, (generalized) partial directed coherence, and direct directed transfer function), Connectivity.jackknife of those measures, and multitaper_connectivity and connectivity_to_xarray for pairwise and subset spectral Granger prediction emit a DirectedOrientationWarning as a reminder, once per Python session for each measure (and once more if the same measure is computed both through a wrapper and through its Connectivity method). Show it at every call with warnings.simplefilter("always", spectral_connectivity.DirectedOrientationWarning), or silence it with warnings.filterwarnings("ignore", category=spectral_connectivity.DirectedOrientationWarning).

  2. Expect one-sided power. Connectivity.power() returns the one-sided density: the bins between 0 Hz and Nyquist are twice the 2.x values. power(one_sided=False) returns the 2.x values. Until 3.2, calling Connectivity.power() without one_sided on two-sided coefficients emits a SidednessWarning, once per Python session (warnings.simplefilter("always", spectral_connectivity.SidednessWarning) shows it at every call); pass one_sided=True to silence it. The power in multitaper_connectivity and connectivity_to_xarray results changed the same way without a warning: halve its interior bins to compare with 2.x. Connectivity.global_coherence returns the non-negative frequencies only, and emits the same SidednessWarning notice (Other measures, power, and statistics).

  3. Recompute results whose values changed without an error. Besides direction and power, other changes give code written for 2.x different numbers without an error. Among them (the tables below list them all):

    • windows are labeled by their center time, not their first sample, and a window step given in seconds is rounded to the nearest sample rather than truncated, which can change the number of windows, their time coordinates, and averaged values;

    • phase_slope_index sums adjacent frequency bins only, so its values are much smaller: re-derive any threshold;

    • delay returns seconds, not cycles;

    • multitaper_connectivity takes the axis roles of an xarray.DataArray from its dimension names, not their positions;

    • several measures’ values were corrected, among them every spectral Granger and transfer-function measure on an even FFT length, directed_coherence, direct_directed_transfer_function, global_coherence (whose components also now come strongest first for every max_rank), canonical_coherence for groups with a dead or duplicated channel, and power_confidence_intervals (Directed measures and Other measures, power, and statistics).

  4. Read magnitude_squared_coherence, not coherence_magnitude. The default multitaper_connectivity Dataset has no coherence_magnitude variable, so indexing it by the old name raises KeyError or AttributeError. Requesting method="coherence_magnitude" or calling Connectivity.coherence_magnitude() still works through 3.x, with a DeprecationWarning.

  5. Replace the deprecated spellings. Each old spelling still works through 3.x with a DeprecationWarning that names its replacement, and is removed in 4.0:

    • Connectivity.from_multitaper(m) → Connectivity.from_transform(m);

    • frequencies_of_interest=(low, high) → frequency_range=(low, high) for phase_slope_index, group_delay, and delay. frequency_range includes both endpoints, where frequencies_of_interest excluded a bin on either edge;

    • power_confidence_intervals(n_tapers=n, ...) → n_observations=n, and its ci= → confidence_level=;

    • suggest_parameters(desired_freq_resolution=...) → frequency_resolution=...;

    • method="coherence_magnitude" and Connectivity.coherence_magnitude() → magnitude_squared_coherence (item 4);

    • advanced settings passed to the wrappers as plain keyword arguments (multitaper_connectivity(x, fs, n_fft_samples=1024)) → transform_kwargs={"n_fft_samples": 1024} or connectivity_kwargs={...}.

The tables below list every change, including that Multitaper now requires sampling_frequency (2.x defaulted it to 1000 Hz).

Changes for code written against 2.0.1#

If your code was written against 2.0.1 or earlier, this section covers your changes; you can skip the development-builds section after it.

Directed measures#

The spectral Granger and transfer-function measures: their orientation, and the values corrected in their Wilson factorization.

Previous behavior

New behavior / required action

multitaper_connectivity labeled pairwise and subset spectral Granger prediction with source/target transposed (sel(source=a, target=b) gave b -> a); it rejected the transfer-function measures and could not return phase_slope_index, group_delay, or delay (all three raised), whose Connectivity arrays were already source first

sel(source=a, target=b) is now a -> b — recompute any directed results (e.g. pairwise_spectral_granger_prediction) obtained through the wrapper

Connectivity Granger and directed-transfer-function methods returned [..., target, source] (result[i, j] was j -> i)

All directed Connectivity arrays are [..., source, target], matching the wrapper’s sel(source, target): swap the last two indices in indexing code for these methods (0 -> 1 is now [..., 0, 1]) and the axis of any normalization check (DTF and directed coherence sum to 1 over axis -2, PDC and gPDC over axis -1). np.swapaxes(old, -1, -2) gives stored 2.x DTF, PDC, gPDC, and spectral Granger arrays the new orientation. It reproduces the 3.0 values (to 1e-9 relative with 25 or more observations, and to 1e-6 with as few observations as signals, in the cases run) only where the FFT length was odd and there were at least as many observations (trials x tapers) as signals; on an even FFT length the values changed too (next row). Directed coherence and dDTF values also changed (see their rows). With fewer observations than signals (a single observation, for pairwise and subset Granger) 2.x returned finite values from a Wilson factorization that had not converged, where 3.0 returns NaN with a warning: discard those stored arrays

Every measure built on the Wilson factorization (the spectral Granger family, DTF, directed coherence, PDC, gPDC, dDTF) used, on an even FFT length, a factor that did not reproduce the spectrum: it ignored the lag n_fft_samples / 2, missing the spectrum by 0.2-10% in simulations and adding a bin-to-bin alternation to the measures

The factor reproduces the spectrum on even and odd FFT lengths alike. Recompute directed measures that used an even FFT length (the default length is often even). In long, well-resolved simulated recordings the largest change at any frequency was typically 0.1% to 5% of the measure’s largest value in the recording (5e-4 to 1e-2 in absolute terms for DTF and PDC, which lie in [0, 1]); for short windows, few observations, or highly correlated channels it reached the whole range of DTF. Values from an odd FFT length are unchanged

The spectral Granger and transfer-function measures (DTF, PDC, directed coherence) depended on the data’s units, through an absolute convergence threshold: values changed by 1e-4 to 0.1 for data at 1e-6 of unit variance (microvolt signals stored in volts), and by more below that

Invariant to the data’s scale. Recompute directed results obtained from small-amplitude data

direct_directed_transfer_function returned |ffDTF| * sqrt(PDC)

Returns the squared dDTF of Korzeniewska et al. (2003), ffDTF^2 * partial_coherence^2, from the model’s inverse spectral matrix; take the square root for the amplitude form |ffDTF| * |partial coherence| — recompute dDTF results

directed_coherence returned |H_ij|^2 / sqrt(sum_k |H_ik|^2) for target i and source j: its noise variance, placed on the target axis, cancelled, so the result ignored the noise covariance, was not normalized, and exceeded 1

Uses the correct source-axis noise variance and is bounded in [0, 1] — recompute directed-coherence results

Spectral Granger measures returned NaN wherever the estimate was <= 0

Exact zeros and roundoff-negative values are returned as 0.0 (no influence); only materially negative, degenerate bins are NaN. Replace np.isnan(...) checks for “no influence” with == 0, and expect nanmean over a direction to include those zeros

minimum_phase_decomposition(S) stopped after 60 Wilson iterations by default, logged “Maximum iterations reached”, and returned the unconverged factor

The default max_iterations is 500, so spectra that need more iterations converge. A sub-spectrum still unconverged at the cap is returned as NaN with a UserWarning, not as the unconverged factor, so max_iterations=60 restores the 2.x cap but not 2.x’s output. tolerance and max_iterations keep their positions and still work positionally or by keyword

Other measures, power, and statistics#

Values that changed for the functional, lead/lag, and group measures, the power spectrum, and the statistics helpers.

Previous behavior

New behavior / required action

global_coherence returned the squared singular values of the observations’ coefficient matrix divided by the number of observations, and its default call raised for some inputs with one or two observations (three signals with one observation; six signals with two)

Returns each component’s fraction of the total coherent power, in [0, 1], for any number of observations. It is unchanged when every signal is rescaled by the same factor, but not when signals are rescaled separately (one of four channels x10 moved values by up to 0.6): put signals on a common scale first

global_coherence(max_rank=k) returned its components weakest first when 1 < k < n_signals - 1 (the sparse solver’s order) and strongest first otherwise

Always strongest first, the values and their vectors alike, so [..., 0] is the largest component. Code that indexed a component of such a result now reads a different one: reverse the component axis of stored 2.x results, or re-index

Connectivity.global_coherence returned every bin of the two-sided transform, (n_time_windows, n_fft_samples, ...), labelled by all_frequencies

Returns only the non-negative frequencies, labelled by Connectivity.frequencies, like every other measure. They are unchanged, and for a real signal the negative bins repeated them (the same fractions, conjugated vectors), so [..., :len(conn.frequencies), :] of a 2.x result is the 3.0 result. Label the frequency axis with frequencies, and drop indexing from the end of the axis ([..., -1, :] was the most negative bin). Until 3.2 a call on two-sided coefficients emits a SidednessWarning (once per Python session). multitaper_connectivity and connectivity_to_xarray returned the non-negative bins already and are unchanged. See also the next row

Connectivity.global_coherence ignored expectation_type: every setting decomposed each time window’s trials and tapers

Follows expectation_type for the settings that average the tapers, as the other measures do: "time_trials_tapers" pools every window, trial, and taper into one value per frequency, "time_tapers" gives one value per trial, and "tapers" one per window and trial. "time", "trials", and "time_trials" raise ValueError. The default expectation_type, "trials_tapers", gives the 2.x values (on the non-negative frequencies; see the previous row): build the Connectivity with it for the 2.x result

weighted_phase_lag_index was about 0 for small-amplitude data, whatever the true value: at 1 kHz it began to fail at a standard deviation of 1e-6 and was about 1e-17 at every frequency by 3e-7 (MEG in tesla, for example)

Invariant to the data’s amplitude. Recompute weighted phase-lag results obtained from data stored in small units

A zero-lag pair (a channel and a scaled copy of it) gave a phase_lag_index up to +-1, a debiased_squared_phase_lag_index up to 1, and a debiased_squared_weighted_phase_lag_index anywhere in [-1, 1], read from the sign of rounding noise (largest with few observations)

0 for all three, and 0.5 for directed_phase_lag_index: “no phase lag” is judged relative to the pair’s power

canonical_coherence overstated the coherence of a group containing a dead, duplicated, or collinear channel, by more the fewer the observations (0.4-0.7 with 6, 0.25-0.35 with 20, 0.06-0.07 with 100 in the cases run)

Equals the value for the group’s independent channels, with a warning naming the group. Recompute canonical coherence for groups that may contain such a channel

One-sided power omitted the negative-frequency contribution

Interior positive-frequency bins are doubled; DC and Nyquist are unchanged. Connectivity.power(one_sided=False) returns the 2.x values, for formulas written for a two-sided density. Until 3.2, Connectivity.power() without one_sided on two-sided coefficients emits a SidednessWarning (once per Python session); pass one_sided=True to silence it. The power in multitaper_connectivity and connectivity_to_xarray results (including by default) changed the same way without a warning: halve its interior bins to compare with 2.x

coherence_rate_adjustment(rate1, rate2, power, ...) was given 2.x’s power(), a two-sided density

Say which density the spectrum is. With 3.0’s one-sided power() pass is_one_sided=True: the factor is the same as in 2.x at interior frequencies (with no added Poisson spikes; see the next row) and differs at 0 Hz and Nyquist, where a one-sided density is not doubled. Leave 0 Hz out in any case; at Nyquist pass the two-sided density. With a two-sided spectrum (your own, or power(one_sided=False)) pass is_one_sided=False. Without the keyword the call warns and assumes one-sided

coherence_rate_adjustment with homogeneous_poisson_noise non-zero read firing_rate_condition2 as the rate of the kept spikes only (documented as the condition’s rate; given that, the factor was 30-62% too large in the case run)

Pass the second condition’s measured rate, added spikes included. A call with a non-zero noise rate warns about this until 4.0. Calls with the default noise of 0 are unchanged and silent

Multitaper accepted a complex-valued time series, although its outputs cover only the non-negative frequencies and the one-sided quantities assume the negative ones mirror them

Multitaper, ShortTimeFourierTransform, Welch, MorletWavelet, and multitaper_connectivity raise TypeError for a complex time series. Pass its real and imaginary parts as separate real signals, or compute the Fourier coefficients yourself and pass them to Connectivity, whose power(one_sided=True) and cross_spectral_density() add each interior negative frequency to its positive one, S(f) + conj(S(-f)). That doubles the bin for a real signal, as 3.0 does, but no longer counts a complex tone at +f twice (one-sided total 2 for unit power) and one at -f not at all (total 0)

phase_slope_index combined every ordered frequency pair

Uses adjacent frequency bins, following Nolte et al. (2008). The sign is unchanged, but the sum has far fewer terms, so values are smaller by one to several orders of magnitude: recompute, and re-derive any threshold

delay returned cycles (where it returned estimates at all: see the group_delay and delay row below)

Returns seconds; DC is NaN

coherence_fisher_z_transform(coherency, n_obs1) without a second sample returned NaN for three or more observations and ±inf for two, and raised ZeroDivisionError for one, because its n_obs2=0 default was used as a sample size. group_delay and delay found their significant frequencies with it, so with three or more observations they found none: group_delay returned NaN delays and slopes, and delay returned only the constants 2πk between signals

The one-sample z-score has no second-sample terms, and group_delay and delay use the exact zero-coherence null distribution, so both return estimates at the frequencies with significant coherence. 2.x output of these two methods with three or more observations is not usable: recompute (a dead-channel pair also no longer penalizes valid pairs in the BH/Bonferroni family). With exactly two observations, where 2.x passed every frequency, 3.0 finds none significant and returns NaN. significance_threshold must lie strictly between 0 and 1; 2.x accepted 1.0

power_confidence_intervals covered ~90% at a nominal 95%; power_bias / power_variance were ~2× off

Corrected formulas — recompute power confidence intervals and log-power z-tests

Multi-component CaCoh from mne-connectivity 0.9 (method="cacoh", n_components > 1)

canonical_coherency component 1 matches mne-connectivity’s cacoh wherever both optimizers reach the global phase optimum; components 2 and above are deflated in whitened space (uncorrelated within each group, invariant to invertible real within-group mixing) and differ from mne-connectivity’s channel-space deflation — do not compare them directly

debiased_squared_phase_lag_index was -1/(n-1) where there is no phase lag (the diagonal, and the purely real DC and Nyquist bins), and debiased_squared_weighted_phase_lag_index was NaN there

Both are 0 there; elsewhere the values agree to rounding. Code that dropped self-pairs or real bins with np.isnan on dsWPLI, or by their negative dsPLI value, now keeps them: mask the diagonal explicitly (cookbook, “Mask or fill the diagonal”). dsWPLI’s recorded diagonal_policy is constant with diagonal_value 0. With a single observation, where 2.x returned -inf and NaN, both raise ValueError

power_fisher_z_transform(spectrum1, n_obs1) returned NaN for every one-sample call, with spectrum2 omitted (its default was 0) or given, whenever n_obs2 was omitted

spectrum2 defaults to 1.0 and a one-sample call returns a finite z for any positive baseline: the bias-corrected log(spectrum1) minus log(spectrum2), over its standard deviation. spectrum2=0 raises ValueError

Windows, time labels, inputs, and result attributes#

How time series are read and windowed, and what the results record.

Previous behavior

New behavior / required action

Multitaper windows were labeled by their first sample

Windows are labeled by their center time, the midpoint of the window’s first and last samples: the 2.x label plus (n_time_samples_per_window - 1) / (2 * sampling_frequency) (0.245 s, not 0.25 s, for the first 50-sample window at 100 Hz)

multitaper_connectivity and Multitaper read an xarray.DataArray by position, as (time, trial, signal), whatever its dimension names (2-D input raised ValueError)

multitaper_connectivity assigns axis roles from the DataArray’s dimension names and transposes the input itself; it also accepts 2-D (time, signal) input. Names it cannot map (such as the default dim_0, dim_1, dim_2) raise ValueError: pass time_dim, trial_dim, and signal_dim. Multitaper itself still reads a DataArray by position and takes no *_dim arguments, but now raises ValueError for one whose dimension names put time, trials, or signals on another axis (2.x transformed it along the wrong axis without a sign): transpose to (time, trial, signal) before constructing it

Multitaper defaulted sampling_frequency to 1000 Hz

sampling_frequency is required; pass your rate

Multitaper(...) with an invalid window (longer than the recording, rounding to 0 samples, or too short for DPSS tapers at its time_halfbandwidth_product) was constructed and failed at its first fft(); 2.0.1 returned an empty transform or raised ZeroDivisionError or SciPy’s select_range error there. An unknown detrend_type (e.g. "quadratic") was likewise accepted and failed at the first fft() with detrend’s message about its type argument

The constructor raises the ValueError, because it now computes the DPSS tapers, once (0.11 s for a 100,000-sample window in the case run, time fft() no longer spends). An unknown detrend_type raises a ValueError naming detrend_type at construction too, in Multitaper, ShortTimeFourierTransform, Welch, and multitaper_connectivity. In code that catches these errors, wrap the constructor rather than fft()

Result attributes mt_sampling_frequency, mt_n_trials, mt_n_signals, mt_frequency_resolution, and the other scalar mt_* settings

Read sampling_frequency, n_trials, n_signals, spectral_bandwidth (with spectral_bandwidth_definition="full_dpss_concentration_bandwidth" for generated DPSS tapers; custom tapers record none, while their mt_frequency_resolution stays the nominal NW-based value), nyquist_frequency (for mt_nyquist_frequency), and the estimator and execution records of transform_parameters_json for the other settings (optional settings as JSON null); see the result schema reference. 15 of the 16 mt_* keys 2.0.1 wrote stay on Multitaper results as compatibility copies through 3.x and are removed in 4.0; attribute dictionaries cannot warn when read, so search your code for mt_. The copies hold the values 3.0 computes, which equal 2.0.1’s except mt_n_time_samples_per_step where 2.x’s truncated step differs from the rounded one (56 → 57 for 0.57 s at 100 Hz), mt_time_window_duration, mt_time_window_step, and mt_frequency_resolution where the window or step is not a whole number of samples (they follow the realized window; next row), mt_n_tapers, which counts the tapers used (the number supplied for custom tapers; for DPSS tapers, excluding any low-bias filtering dropped, next to requested_n_tapers in transform_parameters_json), and NetCDF-safe types (cookbook). The 16th, mt_summarize_parameters, held a bound method and is no longer written

Window durations and steps given in seconds: 2.x truncated a step to whole samples (time_window_step=0.57 at 100 Hz stepped 56 samples, giving 17 one-second windows over a 1000-sample recording) and reported the requested window (time_window_duration=0.505 at 100 Hz analyzed 50 samples but reported 0.505 s and frequency_resolution 11.88 Hz for NW=3). It also truncated a step it derived itself: given only time_window_duration, a Multitaper stepped by the rounded window on first use but by int(time_window_duration * sampling_frequency) samples once time_window_step had been read, which every connectivity_to_xarray(m, ...) call does (0.57 s at 100 Hz: 57-sample windows every 56 samples from the second result on)

A step is rounded to the nearest sample (57 samples, 16 windows above), so window counts, time coordinates, and averaged values change. The window length is rounded as in 2.x and needs no change. time_window_duration, time_window_step, frequency_resolution, and their mt_* copies describe the realized window (0.5 s and 12 Hz above). To analyze 2.x’s windows, keep time_window_duration and replace time_window_step with n_time_samples_per_step=int(time_window_step * sampling_frequency), 2.x’s own truncation. A Multitaper now gives the same windows on every use; to reproduce 2.x’s second and later results from one Multitaper built without a step, pass n_time_samples_per_step=int(time_window_duration * sampling_frequency)

Assigning Multitaper settings after construction (m.sampling_frequency = 500, m.time_series = ..., m.start_time, m.detrend_type, m.is_low_bias, m.time_halfbandwidth_product)

Settings are read-only and assignment raises AttributeError, so cached tapers and FFTs cannot go stale: construct a new Multitaper with the new settings

API spellings and removed options#

Renamed, deprecated, and removed arguments, names, and defaults.

Previous behavior

New behavior / required action

blocks of Connectivity and Connectivity.from_multitaper: by keyword, or positionally (fifth in Connectivity(fc, expectation_type, frequencies, time, blocks, dtype), third in from_multitaper(m, expectation_type, blocks, dtype))

Drop it: memory is now bounded automatically. Recompute phase-lag-index results that were obtained with blocks. In 2.x blocks=1 returned phase_lag_index and weighted_phase_lag_index with the opposite sign; a larger value below the number of signal pairs, n_signals * (n_signals + 1) / 2, raised IndexError for all four phase-lag-index measures; and a value from that number up returned 0 for those two, -1 / (n_observations - 1) for debiased_squared_phase_lag_index, and NaN for debiased_squared_weighted_phase_lag_index. Results obtained without blocks are unaffected by its removal, and every other measure agreed with and without it to rounding. Every such call raises a TypeError that names blocks and says to drop it and to recompute those results; in the positional form dtype has moved into blocks’ slot, so pass dtype by keyword

dpss_windows(..., interp_from=..., interp_kind=...)

Remove both arguments (passing either raises TypeError). Tapers are always SciPy’s exact DPSS: equal to 2.x’s non-interpolated tapers to rounding, but not to its interpolated ones (1e-3 to 2e-2 per sample in the cases run), so estimates made with interpolated tapers change slightly

partial_directed_coherence(keep_cupy=...)

Remove keep_cupy; public measures consistently return NumPy arrays

multitaper_connectivity(method=None) computed every public measure outside a short exclusion list, including pairwise_spectral_granger_prediction and the complex coherency

method=None computes DEFAULT_METHODS, which holds no directed measure and not coherency (complex arrays do not serialize portably across xarray versions and NetCDF engines), so result["coherency"] on a default result raises KeyError; request method=[..., "coherency"] or method="pairwise_spectral_granger_prediction" (or any directed measure; the blockwise measure also needs group_labels and the subset measure pairs) by name. With a single observation (one trial and one taper) method=None raises ValueError, because debiased_squared_phase_lag_index, debiased_squared_weighted_phase_lag_index, and pairwise_phase_consistency need two; 2.x returned its Dataset with non-finite values there. Request the other measures by name. coherence_magnitude is now magnitude_squared_coherence (row below)

SciPy 1.10 / CuPy 12 GPU extra

Upgrade to scipy>=1.11.1 and, for GPU use, cupy-cuda12x>=13.0

multitaper_connectivity(x, fs).coherence_magnitude or result["coherence_magnitude"] on a default result

Use .magnitude_squared_coherence or result["magnitude_squared_coherence"]. The old variable is absent from the new default Dataset, so old indexing fails loudly (KeyError/AttributeError). During 3.x, explicitly requesting method="coherence_magnitude" (or calling Connectivity.coherence_magnitude()) keeps the old variable name, returns the same values, and emits a DeprecationWarning; the alias is removed in 4.0. connectivity_to_xarray’s default method is now "magnitude_squared_coherence" too. (fs is a local variable passed as sampling_frequency.)

delay, group_delay, and phase_slope_index took frequencies_of_interest=(low, high) (also as their first positional argument), which excludes a bin lying on either edge

Pass frequency_range=(low, high), which includes both endpoints. The old keyword still works through 3.x with its exclusive selection and a DeprecationWarning whose message gives the frequency_range that keeps the same bins (the lowest and highest bins it selected); it is removed in 4.0

power_confidence_intervals(n_tapers=n, ...)

Pass the same count as n_observations=n (or positionally): it is the number of averaged observations, tapers x trials. Positional calls do not warn; n_tapers= still works through 3.x with a DeprecationWarning and is removed in 4.0. Both forms return the corrected interval (the power_confidence_intervals row above), not 2.x’s numbers: the interval 2.0.1 returned for ci=c is 3.0’s confidence_level=2c-1 (2.0.1’s ci=0.95 is 3.0’s confidence_level=0.9), for 2.0.1 levels c >= 0.75, since 3.0 accepts levels in [0.5, 1)

power_confidence_intervals(n, power, ci=c)

Pass confidence_level=c (or the level third, positionally), the name Connectivity.jackknife and jackknife_confidence_interval use. Positional calls do not warn; ci= still works through 3.x with a DeprecationWarning and is removed in 4.0. Both return 3.0’s corrected interval, not 2.0.1’s (previous row). Before: power_confidence_intervals(25, power, ci=0.95); after: power_confidence_intervals(25, power, confidence_level=0.95)

suggest_parameters(fs, duration, desired_freq_resolution=r)

Pass frequency_resolution=r (or the resolution third, positionally), the name Multitaper and estimate_frequency_resolution use. Positional calls do not warn; desired_freq_resolution= still works through 3.x with a DeprecationWarning, gives the same suggestion, and is removed in 4.0. Before: suggest_parameters(500, 10.0, desired_freq_resolution=2.0); after: suggest_parameters(500, 10.0, frequency_resolution=2.0)

multitaper_connectivity(x, fs, n_fft_samples=1024, start_time=0.5) or connectivity_to_xarray(m, "subset_pairwise_spectral_granger_prediction", pairs=[(0, 1)]): advanced settings as plain keyword arguments

Pass them as transform_kwargs={"n_fft_samples": 1024, "start_time": 0.5} or connectivity_kwargs={"pairs": [(0, 1)]}, which give the same result. The common settings (sampling_frequency, time_window_duration, time_window_step, time_halfbandwidth_product, n_tapers, detrend_type, group_labels, and frequency_range) stay named arguments of every wrapper that takes them and do not warn. The plain-keyword route still works through 3.x with a DeprecationWarning and is removed in 4.0. n_fft_samples must be at least the window length in samples: 2.x accepted a shorter one (the call above on a recording longer than 1024 samples with no time_window_duration), and 3.0 raises ValueError in either spelling, so give a window no longer than n_fft_samples or drop it

Connectivity.from_multitaper(m), or a Connectivity subclass overriding from_multitaper

Use Connectivity.from_transform(m), which takes the same arguments (the first is named transform, not multitaper_instance) and builds the same instance from any spectral transform. Neither name calls the other, so move a subclass’s override to from_transform and change its super().from_multitaper(...) to super().from_transform(...) (an override still calling super().from_multitaper works but warns). from_multitaper still works through 3.x with a DeprecationWarning and is removed in 4.0

multitaper_connectivity(..., method=[...], squeeze=True) with two signals and several measures returned each pairwise variable’s [..., 0, 1] pair as (time, frequency) (power kept its source axis)

squeeze=True applies only to a single-method (DataArray) request, which keeps the selected pair as scalar source/target coordinates; for several measures it is ignored with a UserWarning and the variables keep their source/target axes: request one method at a time, or select with .sel(source=..., target=...). A squeezed spectral Granger result holds the first signal’s influence on the second, where 2.x held the second’s on the first (wrapper orientation row above)

from spectral_connectivity.transforms import tridisolve, tridi_inverse_iteration (public helpers of the 2.x DPSS solver)

Removed with that solver (the tapers now come from SciPy’s exact scipy.signal.windows.dpss); for tridiagonal problems use scipy.linalg.solve_banded or scipy.linalg.eigh_tridiagonal

Names reachable through spectral_connectivity.connectivity in 2.x: the EXPECTATION dict of averaging functions, and the re-imported minimum_phase_decomposition, coherence_fisher_z_transform, and get_normal_distribution_p_values

EXPECTATION_AXES maps each expectation_type to the axes it averages (tuples, not functions). Import the others from their own modules: spectral_connectivity.minimum_phase_decomposition and spectral_connectivity.statistics

Changes to interfaces that existed only in development builds#

Skip this section if you used only the 2.0.1 release. It covers interfaces of development builds after 2.0.1 that were renamed before their first release, with no compatibility path. Most old spellings raise an error or no longer exist. Two fail silently: a positional call to simulate_lagged_broadband still runs but now returns a trial axis, and the backend attribute is still present but lowercase, so comparing it with "CPU" or "GPU" is always false (see their rows).

Previous behavior

New behavior / required action

frequency_band_reduce(result, bands=..., reduction=...)

frequency_band_reduce(result, frequency_bands, frequency_reduction=...), the wrappers’ names; the band mapping stays the second positional argument and frequency_reduction/circular are keyword-only. The old keywords raise TypeError

Component results’ connection_seed_group coordinate and side=["seed", "target"]

connection_source_group and side=["source", "target"], the source/target vocabulary of every labeled result: .sel(side="seed") raises KeyError

Transform-prefixed result attributes (stft_*, welch_*, morlet_*, fourier_*), mt_* copies of settings 2.0.1 never recorded (mt_fft_workers, mt_taper_weighting, mt_adaptive_tolerance, mt_adaptive_max_iterations), and backend="CPU"/"GPU"

The shared keys of the result schema (transform, sampling_frequency, n_observations, …), settings in transform_parameters_json (fft_workers under execution), and lowercase backend="cpu"/"gpu". fourier_source became transform="external_fourier", and stft_n_tapers (always 1) has no replacement

frequency_band_lower/frequency_band_upper and frequency_range_json on interval results

selected_frequency_lower/_upper and frequency_interval_closed on every interval result and every variable a frequency_range applied to, plus requested_frequency_lower/_upper when a band was requested (a phase_slope_index result computed over every bin has none); measure_kwargs_json and arg_* still record the keyword as given

ShortTimeFourierTransform(...).frequency_resolution (Hann equivalent noise bandwidth)

equivalent_noise_bandwidth, also on Welch; only Multitaper has frequency_resolution, its DPSS concentration bandwidth

Settings of the new APIs passed by position: ShortTimeFourierTransform, Welch, and MorletWavelet after sampling_frequency; fourier_connectivity after signal_names; rank and regularization; global_coherence’s max_workspace_elements

Pass them by keyword; a positional value raises TypeError instead of binding to the wrong setting. Released positional orders (Multitaper, multitaper_connectivity, connectivity_to_xarray, global_coherence(max_rank), minimum_phase_decomposition) are unchanged

simulate_lagged_broadband(lags=..., ...), which returned (time, signal) unless n_trials was given

lags_samples=... (whole samples; for a delay in seconds pass round(delay * sampling_frequency), which sends an exact half to the even neighbour and makes a delay of half a sample or less 0). It returns (time, trial, signal) with n_trials=1 by default, like simulate_MVAR; pass n_trials=None for (time, signal). lags= raises TypeError, but a positional call such as simulate_lagged_broadband((0, 3), 0.1, 100) runs and returns (100, 1, 2) instead of (100, 2), so x[:, 0] now selects every signal of trial 0 rather than signal 0: index x[:, 0, k] or pass n_trials=None

simulate_shared_oscillation(frequency, sampling_frequency, n_time_samples, n_trials, amplitudes)

amplitudes is a required keyword (amplitudes=[...]) and n_trials defaults to 1; passing the amplitudes fifth raises TypeError. frequency and sampling_frequency are in Hz