junifer 0.0.6.dev536__py3-none-any.whl → 0.0.7.dev18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- junifer/_version.py +2 -2
- junifer/external/nilearn/junifer_connectivity_measure.py +32 -3
- junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +45 -1
- junifer/markers/functional_connectivity/functional_connectivity_base.py +7 -4
- {junifer-0.0.6.dev536.dist-info → junifer-0.0.7.dev18.dist-info}/METADATA +1 -1
- {junifer-0.0.6.dev536.dist-info → junifer-0.0.7.dev18.dist-info}/RECORD +11 -11
- {junifer-0.0.6.dev536.dist-info → junifer-0.0.7.dev18.dist-info}/WHEEL +1 -1
- {junifer-0.0.6.dev536.dist-info → junifer-0.0.7.dev18.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.6.dev536.dist-info → junifer-0.0.7.dev18.dist-info}/licenses/AUTHORS.rst +0 -0
- {junifer-0.0.6.dev536.dist-info → junifer-0.0.7.dev18.dist-info}/licenses/LICENSE.md +0 -0
- {junifer-0.0.6.dev536.dist-info → junifer-0.0.7.dev18.dist-info}/top_level.txt +0 -0
junifer/_version.py
CHANGED
@@ -17,5 +17,5 @@ __version__: str
|
|
17
17
|
__version_tuple__: VERSION_TUPLE
|
18
18
|
version_tuple: VERSION_TUPLE
|
19
19
|
|
20
|
-
__version__ = version = '0.0.
|
21
|
-
__version_tuple__ = version_tuple = (0, 0,
|
20
|
+
__version__ = version = '0.0.7.dev18'
|
21
|
+
__version_tuple__ = version_tuple = (0, 0, 7, 'dev18')
|
@@ -3,6 +3,8 @@
|
|
3
3
|
# Authors: Synchon Mandal <s.mandal@fz-juelich.de>
|
4
4
|
# License: AGPL
|
5
5
|
|
6
|
+
import sys
|
7
|
+
from itertools import product
|
6
8
|
from typing import Callable, Optional
|
7
9
|
|
8
10
|
import numpy as np
|
@@ -322,11 +324,13 @@ class JuniferConnectivityMeasure(ConnectivityMeasure):
|
|
322
324
|
The covariance estimator
|
323
325
|
(default ``EmpiricalCovariance(store_precision=False)``).
|
324
326
|
kind : {"covariance", "correlation", "spearman correlation", \
|
325
|
-
"partial correlation", "
|
327
|
+
"partial correlation", "xi correlation", "tangent", \
|
328
|
+
"precision"}, optional
|
326
329
|
The matrix kind. The default value uses Pearson's correlation.
|
327
330
|
If ``"spearman correlation"`` is used, the data will be ranked before
|
328
|
-
estimating the covariance. For
|
329
|
-
|
331
|
+
estimating the covariance. For ``"xi correlation"``, the coefficient
|
332
|
+
is not symmetric and should be interpreted as a measure of dependence
|
333
|
+
[2]_ . For the use of ``"tangent"`` see [1]_ (default "correlation").
|
330
334
|
vectorize : bool, optional
|
331
335
|
If True, connectivity matrices are reshaped into 1D arrays and only
|
332
336
|
their flattened lower triangular parts are returned (default False).
|
@@ -372,6 +376,12 @@ class JuniferConnectivityMeasure(ConnectivityMeasure):
|
|
372
376
|
Springer.
|
373
377
|
doi:10/cn2h9c.
|
374
378
|
|
379
|
+
.. [2] Chatterjee, S.
|
380
|
+
A new coefficient of correlation.
|
381
|
+
Journal of the American Statistical Association 116.536 (2021):
|
382
|
+
2009-2022.
|
383
|
+
doi:10.1080/01621459.2020.1758115.
|
384
|
+
|
375
385
|
"""
|
376
386
|
|
377
387
|
def __init__(
|
@@ -420,6 +430,25 @@ class JuniferConnectivityMeasure(ConnectivityMeasure):
|
|
420
430
|
covariances_std.append(self.cov_estimator_.fit(x).covariance_)
|
421
431
|
|
422
432
|
connectivities = [cov_to_corr(cov) for cov in covariances_std]
|
433
|
+
elif self.kind == "xi correlation":
|
434
|
+
if sys.version_info < (3, 10): # pragma: no cover
|
435
|
+
raise_error(
|
436
|
+
klass=RuntimeError,
|
437
|
+
msg=(
|
438
|
+
"scipy.stats.chatterjeexi is available from "
|
439
|
+
"scipy 1.15.0 and that requires Python 3.10 and above."
|
440
|
+
),
|
441
|
+
)
|
442
|
+
connectivities = []
|
443
|
+
for x in X:
|
444
|
+
n_rois = x.shape[1]
|
445
|
+
connectivity = np.ones((n_rois, n_rois))
|
446
|
+
for i, j in product(range(n_rois), range(n_rois)):
|
447
|
+
if i != j:
|
448
|
+
connectivity[i, j] = stats.chatterjeexi(
|
449
|
+
x[:, i], x[:, j], y_continuous=True
|
450
|
+
).statistic
|
451
|
+
connectivities.append(connectivity)
|
423
452
|
else:
|
424
453
|
covariances = [self.cov_estimator_.fit(x).covariance_ for x in X]
|
425
454
|
if self.kind in ("covariance", "tangent"):
|
@@ -4,6 +4,7 @@
|
|
4
4
|
# License: AGPL
|
5
5
|
|
6
6
|
import copy
|
7
|
+
import sys
|
7
8
|
import warnings
|
8
9
|
from math import cosh, exp, log, sinh, sqrt
|
9
10
|
from typing import TYPE_CHECKING, Optional, Union
|
@@ -12,7 +13,11 @@ import numpy as np
|
|
12
13
|
import pytest
|
13
14
|
from nilearn.connectome.connectivity_matrices import sym_matrix_to_vec
|
14
15
|
from nilearn.tests.test_signal import generate_signals
|
15
|
-
from numpy.testing import
|
16
|
+
from numpy.testing import (
|
17
|
+
assert_allclose,
|
18
|
+
assert_array_almost_equal,
|
19
|
+
assert_array_equal,
|
20
|
+
)
|
16
21
|
from pandas import DataFrame
|
17
22
|
from scipy import linalg
|
18
23
|
from sklearn.covariance import EmpiricalCovariance, LedoitWolf
|
@@ -1088,3 +1093,42 @@ def test_connectivity_measure_standardize(
|
|
1088
1093
|
).fit_transform(signals)
|
1089
1094
|
for m in record:
|
1090
1095
|
assert match not in m.message
|
1096
|
+
|
1097
|
+
|
1098
|
+
@pytest.mark.skipif(
|
1099
|
+
sys.version_info > (3, 9),
|
1100
|
+
reason="will have correct scipy version so no error",
|
1101
|
+
)
|
1102
|
+
def test_xi_correlation_error() -> None:
|
1103
|
+
"""Check xi correlation according to paper."""
|
1104
|
+
with pytest.raises(RuntimeError, match="scipy.stats.chatterjeexi"):
|
1105
|
+
JuniferConnectivityMeasure(kind="xi correlation").fit_transform(
|
1106
|
+
np.zeros((2, 2))
|
1107
|
+
)
|
1108
|
+
|
1109
|
+
|
1110
|
+
@pytest.mark.skipif(
|
1111
|
+
sys.version_info < (3, 10),
|
1112
|
+
reason=(
|
1113
|
+
"needs scipy 1.15.0 and above which in turn requires "
|
1114
|
+
"python 3.10 and above"
|
1115
|
+
),
|
1116
|
+
)
|
1117
|
+
def test_xi_correlation() -> None:
|
1118
|
+
"""Check xi correlation according to paper."""
|
1119
|
+
rng = np.random.default_rng(25982435982346983)
|
1120
|
+
x = rng.random(size=10)
|
1121
|
+
y = rng.random(size=10)
|
1122
|
+
arr = np.column_stack((x, y))
|
1123
|
+
expected = np.array(
|
1124
|
+
[
|
1125
|
+
[
|
1126
|
+
[1.0, -0.3030303],
|
1127
|
+
[-0.18181818, 1.0],
|
1128
|
+
]
|
1129
|
+
]
|
1130
|
+
)
|
1131
|
+
got = JuniferConnectivityMeasure(kind="xi correlation").fit_transform(
|
1132
|
+
[arr]
|
1133
|
+
)
|
1134
|
+
assert_allclose(expected, got)
|
@@ -143,14 +143,17 @@ class FunctionalConnectivityBase(BaseMarker):
|
|
143
143
|
},
|
144
144
|
)
|
145
145
|
# Create dictionary for output
|
146
|
+
labels = aggregation["aggregation"]["col_names"]
|
146
147
|
return {
|
147
148
|
"functional_connectivity": {
|
148
149
|
"data": connectivity.fit_transform(
|
149
150
|
[aggregation["aggregation"]["data"]]
|
150
151
|
)[0],
|
151
|
-
|
152
|
-
"
|
153
|
-
|
154
|
-
"matrix_kind":
|
152
|
+
"row_names": labels,
|
153
|
+
"col_names": labels,
|
154
|
+
# xi correlation coefficient is not symmetric
|
155
|
+
"matrix_kind": (
|
156
|
+
"full" if self.conn_method == "xi correlation" else "tril"
|
157
|
+
),
|
155
158
|
},
|
156
159
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: junifer
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.7.dev18
|
4
4
|
Summary: JUelich NeuroImaging FEature extractoR
|
5
5
|
Author-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
|
6
6
|
Maintainer-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
junifer/__init__.py,sha256=2McgH1yNue6Z1V26-uN_mfMjbTcx4CLhym-DMBl5xA4,266
|
2
2
|
junifer/__init__.pyi,sha256=SsTvgq2Dod6UqJN96GH1lCphH6hJQQurEJHGNhHjGUI,508
|
3
|
-
junifer/_version.py,sha256=
|
3
|
+
junifer/_version.py,sha256=GyAsN4t__QNl7uIDhLy7GlyhnLiTFiaNd9nlKJfEFik,526
|
4
4
|
junifer/conftest.py,sha256=PWYkkRDU8ly2lYwv7VBKMHje4et6HX7Yey3Md_I2KbA,613
|
5
5
|
junifer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
junifer/stats.py,sha256=e9aaagMGtgpRfW3Wdpz9ocpnYld1IWylCDcjFUgX9Mk,6225
|
@@ -173,10 +173,10 @@ junifer/external/h5io/h5io/chunked_array.py,sha256=K1HWf7R2Jc7gCzBqAoBjx0ZnMmUhT
|
|
173
173
|
junifer/external/h5io/h5io/chunked_list.py,sha256=1Y5BbuWzurJlEFQzJNuDdC3fNZ39ENEMba99X_4VeSM,1952
|
174
174
|
junifer/external/nilearn/__init__.py,sha256=pvDmJMwOBki2oaEw-bsniMQ9UXvzecwu6EwJvbVxD50,210
|
175
175
|
junifer/external/nilearn/__init__.pyi,sha256=bcCz7O02UameBxbtPjhUal-Z9rI01pv3iktPs_Nq7Ts,208
|
176
|
-
junifer/external/nilearn/junifer_connectivity_measure.py,sha256=
|
176
|
+
junifer/external/nilearn/junifer_connectivity_measure.py,sha256=oP7JyggH0w4V9FlEXSn0wCApXYy9zBj-XSawOBmMniY,18588
|
177
177
|
junifer/external/nilearn/junifer_nifti_spheres_masker.py,sha256=1CqtGFpfgVR2sK_pDYsBlgAEg-fIG5CkKzXzTTXG7EY,16533
|
178
178
|
junifer/external/nilearn/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
179
|
-
junifer/external/nilearn/tests/test_junifer_connectivity_measure.py,sha256=
|
179
|
+
junifer/external/nilearn/tests/test_junifer_connectivity_measure.py,sha256=CVUA1AV4syIMWq3S-cqXYvuBPzHZHiZLeTi_sAkuI6g,35042
|
180
180
|
junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py,sha256=9UvBAVO-uo0nMIHYfAQ85kJMrwpBxpVRsN1-mHLk7ik,12244
|
181
181
|
junifer/markers/__init__.py,sha256=wHAxljlZppxgXimSJw21mp9oUYYyaID4LYfeBolva30,310
|
182
182
|
junifer/markers/__init__.pyi,sha256=9a72D9k6esTzLvmvULXHOeaQtIchjtN7VELpCeaddsM,957
|
@@ -221,7 +221,7 @@ junifer/markers/functional_connectivity/__init__.pyi,sha256=qfw6WVyE65u-5NZNi0xP
|
|
221
221
|
junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py,sha256=uLdVGywmL7qrzloh1YBL4g4tPiamA47MgHF2DQH0JTU,5733
|
222
222
|
junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py,sha256=pMKGRdhjs_KXMonmQxI71v6-w93DFTzgTlrvouY9kIg,4724
|
223
223
|
junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py,sha256=TnwG1uF1PH2mN6n6ZhEvYsn9mEnhKVshRLHuI36kwqI,5393
|
224
|
-
junifer/markers/functional_connectivity/functional_connectivity_base.py,sha256=
|
224
|
+
junifer/markers/functional_connectivity/functional_connectivity_base.py,sha256=4bE95pHSZ2Ju0q2pXjHyPqBYwEpoba2YPBGkF4f_QPY,5783
|
225
225
|
junifer/markers/functional_connectivity/functional_connectivity_parcels.py,sha256=yjXPcpXmleHWlwxNEEL_1EuW_clsjq1qCcnCCLa576c,4192
|
226
226
|
junifer/markers/functional_connectivity/functional_connectivity_spheres.py,sha256=2JczueAU31fh6sW0Ecn8ap2lZhEG19oUvuR7w2mFDuE,4927
|
227
227
|
junifer/markers/functional_connectivity/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -341,10 +341,10 @@ junifer/utils/tests/test_config.py,sha256=7ltIXuwb_W4Mv_1dxQWyiyM10XgUAfsWKV6D_i
|
|
341
341
|
junifer/utils/tests/test_fs.py,sha256=WQS7cKlKEZ742CIuiOYYpueeAhY9PqlastfDVpVVtvE,923
|
342
342
|
junifer/utils/tests/test_helpers.py,sha256=k5qqfxK8dFyuewTJyR1Qn6-nFaYNuVr0ysc18bfPjyU,929
|
343
343
|
junifer/utils/tests/test_logging.py,sha256=duO4ou365hxwa_kwihFtKPLaL6LC5XHiyhOijrrngbA,8009
|
344
|
-
junifer-0.0.
|
345
|
-
junifer-0.0.
|
346
|
-
junifer-0.0.
|
347
|
-
junifer-0.0.
|
348
|
-
junifer-0.0.
|
349
|
-
junifer-0.0.
|
350
|
-
junifer-0.0.
|
344
|
+
junifer-0.0.7.dev18.dist-info/licenses/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
|
345
|
+
junifer-0.0.7.dev18.dist-info/licenses/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
|
346
|
+
junifer-0.0.7.dev18.dist-info/METADATA,sha256=CUXcvLUz6uv5RXTxeF45miX5qqdHSnOrbqHu1h9luRY,8441
|
347
|
+
junifer-0.0.7.dev18.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
348
|
+
junifer-0.0.7.dev18.dist-info/entry_points.txt,sha256=6O8ru0BP-SP7YMUZiizFNoaZ2HvJpadO2G7nKk4PwjI,48
|
349
|
+
junifer-0.0.7.dev18.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
|
350
|
+
junifer-0.0.7.dev18.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|