junifer 0.0.5.dev145__py3-none-any.whl → 0.0.5.dev161__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 CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.0.5.dev145'
16
- __version_tuple__ = version_tuple = (0, 0, 5, 'dev145')
15
+ __version__ = version = '0.0.5.dev161'
16
+ __version_tuple__ = version_tuple = (0, 0, 5, 'dev161')
@@ -4,3 +4,6 @@
4
4
  # License: AGPL
5
5
 
6
6
  from .junifer_nifti_spheres_masker import JuniferNiftiSpheresMasker
7
+
8
+
9
+ __all__ = ["JuniferNiftiSpheresMasker"]
@@ -10,9 +10,9 @@ from nilearn import image, masking
10
10
  from nilearn._utils.class_inspect import get_params
11
11
  from nilearn._utils.niimg import img_data_dtype
12
12
  from nilearn._utils.niimg_conversions import (
13
- _safe_get_data,
14
13
  check_niimg_3d,
15
14
  check_niimg_4d,
15
+ safe_get_data,
16
16
  )
17
17
  from nilearn.maskers import NiftiSpheresMasker
18
18
  from nilearn.maskers.base_masker import _filter_and_extract
@@ -29,9 +29,12 @@ if TYPE_CHECKING:
29
29
  from pandas import DataFrame
30
30
 
31
31
 
32
+ __all__ = ["JuniferNiftiSpheresMasker"]
33
+
34
+
32
35
  # New BSD License
33
36
 
34
- # Copyright (c) 2007 - 2022 The nilearn developers.
37
+ # Copyright (c) The nilearn developers.
35
38
  # All rights reserved.
36
39
 
37
40
 
@@ -99,12 +102,23 @@ def _apply_mask_and_get_affinity(
99
102
  Contains the boolean indices for each sphere.
100
103
  shape: (number of seeds, number of voxels)
101
104
 
105
+ Raises
106
+ ------
107
+ ValueError
108
+ If ``niimg`` and ``mask_img`` are both provided or
109
+ if overlap is detected between spheres.
110
+
111
+ Warns
112
+ -----
113
+ RuntimeWarning
114
+ If the provided images contain NaN, they will be converted to zeroes.
115
+
102
116
  """
103
117
  seeds = list(seeds)
104
118
 
105
119
  # Compute world coordinates of all in-mask voxels.
106
120
  if niimg is None:
107
- mask, affine = masking._load_mask_img(mask_img)
121
+ mask, affine = masking.load_mask_img(mask_img)
108
122
  # Get coordinate for all voxels inside of mask
109
123
  mask_coords = np.asarray(np.nonzero(mask)).T.tolist()
110
124
  X = None
@@ -118,21 +132,21 @@ def _apply_mask_and_get_affinity(
118
132
  target_shape=niimg.shape[:3],
119
133
  interpolation="nearest",
120
134
  )
121
- mask, _ = masking._load_mask_img(mask_img)
135
+ mask, _ = masking.load_mask_img(mask_img)
122
136
  mask_coords = list(zip(*np.where(mask != 0)))
123
137
 
124
- X = masking._apply_mask_fmri(niimg, mask_img)
138
+ X = masking.apply_mask_fmri(niimg, mask_img)
125
139
 
126
140
  elif niimg is not None:
127
141
  affine = niimg.affine
128
- if np.isnan(np.sum(_safe_get_data(niimg))):
142
+ if np.isnan(np.sum(safe_get_data(niimg))):
129
143
  warn_with_log(
130
144
  "The imgs you have fed into fit_transform() contains NaN "
131
145
  "values which will be converted to zeroes."
132
146
  )
133
- X = _safe_get_data(niimg, True).reshape([-1, niimg.shape[3]]).T
147
+ X = safe_get_data(niimg, True).reshape([-1, niimg.shape[3]]).T
134
148
  else:
135
- X = _safe_get_data(niimg).reshape([-1, niimg.shape[3]]).T
149
+ X = safe_get_data(niimg).reshape([-1, niimg.shape[3]]).T
136
150
 
137
151
  mask_coords = list(np.ndindex(niimg.shape[:3]))
138
152
 
@@ -210,7 +224,7 @@ def _iter_signals_from_spheres(
210
224
  X, A = _apply_mask_and_get_affinity(
211
225
  seeds, niimg, radius, allow_overlap, mask_img=mask_img
212
226
  )
213
- for _, row in enumerate(A.rows):
227
+ for row in A.rows:
214
228
  yield X[:, row]
215
229
 
216
230
 
@@ -4,12 +4,14 @@
4
4
  # License: AGPL
5
5
 
6
6
  import warnings
7
+ from typing import List, Tuple
7
8
 
8
9
  import nibabel
9
10
  import numpy as np
10
11
  import pytest
11
12
  from nilearn._utils import data_gen
12
13
  from nilearn.image import get_data
14
+ from nilearn.maskers import NiftiSpheresMasker
13
15
  from numpy.testing import assert_array_equal
14
16
 
15
17
  from junifer.external.nilearn import JuniferNiftiSpheresMasker
@@ -17,7 +19,7 @@ from junifer.external.nilearn import JuniferNiftiSpheresMasker
17
19
 
18
20
  # New BSD License
19
21
 
20
- # Copyright (c) 2007 - 2022 The nilearn developers.
22
+ # Copyright (c) The nilearn developers.
21
23
  # All rights reserved.
22
24
 
23
25
 
@@ -331,3 +333,76 @@ def test_nifti_spheres_masker_io_shapes() -> None:
331
333
  )
332
334
  test_data = masker.transform(img_4d)
333
335
  assert test_data.shape == (n_volumes, n_regions)
336
+
337
+
338
+ @pytest.mark.parametrize(
339
+ "shape",
340
+ [
341
+ (10, 11, 12),
342
+ (10, 11, 12, 5),
343
+ ],
344
+ )
345
+ @pytest.mark.parametrize(
346
+ "radius, allow_overlap",
347
+ [
348
+ (2.0, True),
349
+ (2.0, False),
350
+ (3.0, True),
351
+ (4.0, True),
352
+ (5.0, True),
353
+ ],
354
+ )
355
+ @pytest.mark.parametrize(
356
+ "coords",
357
+ [
358
+ [(1, 1, 1)],
359
+ [(1, 1, 1), (4, 4, 4)],
360
+ [(1, 1, 1), (4, 4, 4), (10, 10, 10)],
361
+ ],
362
+ )
363
+ def test_junifer_and_nilearn_mean_agg_are_equal(
364
+ shape: Tuple[int, ...],
365
+ radius: float,
366
+ allow_overlap: bool,
367
+ coords: List[Tuple[int, int, int]],
368
+ ) -> None:
369
+ """Test junifer's masker behaves same as nilearn's when agg is mean.
370
+
371
+ Parameters
372
+ ----------
373
+ shape : tuple of int
374
+ The parametrized shape of the input image.
375
+ radius : float
376
+ The parametrized radius of the spheres.
377
+ allow_overlap : bool
378
+ The parametrized option to overlap spheres or not.
379
+ coords : list of tuple of int, int and int
380
+ The parametrized seeds.
381
+
382
+ """
383
+ # Set affine
384
+ affine = np.eye(4)
385
+ # Generate random image
386
+ input_img, mask_img = data_gen.generate_random_img(
387
+ shape=shape,
388
+ affine=affine,
389
+ )
390
+ # Compute junifer's version
391
+ junifer_masker = JuniferNiftiSpheresMasker(
392
+ seeds=coords,
393
+ radius=radius,
394
+ allow_overlap=allow_overlap,
395
+ mask_img=mask_img,
396
+ )
397
+ junifer_output = junifer_masker.fit_transform(input_img)
398
+ # Compute nilearn's version
399
+ nilearn_masker = NiftiSpheresMasker(
400
+ seeds=coords,
401
+ radius=radius,
402
+ allow_overlap=allow_overlap,
403
+ mask_img=mask_img,
404
+ )
405
+ nilearn_output = nilearn_masker.fit_transform(input_img)
406
+ # Checks
407
+ assert junifer_output.shape == nilearn_output.shape
408
+ np.testing.assert_almost_equal(junifer_output, nilearn_output)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: junifer
3
- Version: 0.0.5.dev145
3
+ Version: 0.0.5.dev161
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>
@@ -29,13 +29,13 @@ Description-Content-Type: text/markdown
29
29
  License-File: LICENSE.md
30
30
  License-File: AUTHORS.rst
31
31
  Requires-Dist: click <8.2,>=8.1.3
32
- Requires-Dist: numpy <1.27,>=1.24
33
- Requires-Dist: scipy <=1.11.4,>=1.9.0
34
- Requires-Dist: datalad <0.20,>=0.15.4
35
- Requires-Dist: pandas <2.2,>=1.4.0
36
- Requires-Dist: nibabel <5.11,>=3.2.0
37
- Requires-Dist: nilearn <=0.10.2,>=0.9.0
38
- Requires-Dist: sqlalchemy <=2.1.0,>=1.4.27
32
+ Requires-Dist: numpy <2.0.0,>=1.24.0
33
+ Requires-Dist: scipy <=1.14.0,>=1.10.0
34
+ Requires-Dist: datalad <1.2.0,>=1.0.0
35
+ Requires-Dist: pandas <2.3.0,>=2.0.0
36
+ Requires-Dist: nibabel <5.3.0,>=5.2.0
37
+ Requires-Dist: nilearn <=0.10.4,>=0.10.3
38
+ Requires-Dist: sqlalchemy <=2.1.0,>=2.0.25
39
39
  Requires-Dist: ruamel.yaml <0.18,>=0.17
40
40
  Requires-Dist: h5py >=3.10
41
41
  Requires-Dist: httpx[http2] ==0.26.0
@@ -53,14 +53,14 @@ Provides-Extra: dev
53
53
  Requires-Dist: tox ; extra == 'dev'
54
54
  Requires-Dist: pre-commit ; extra == 'dev'
55
55
  Provides-Extra: docs
56
- Requires-Dist: seaborn <0.13,>=0.11.2 ; extra == 'docs'
57
- Requires-Dist: sphinx <7.3,>=5.3.0 ; extra == 'docs'
58
- Requires-Dist: sphinx-gallery <0.15.0,>=0.11.0 ; extra == 'docs'
59
- Requires-Dist: furo <2023.10.0,>=2022.9.29 ; extra == 'docs'
60
- Requires-Dist: numpydoc <1.6,>=1.5.0 ; extra == 'docs'
61
- Requires-Dist: julearn <0.4,>=0.3.0 ; extra == 'docs'
56
+ Requires-Dist: seaborn <0.14.0,>=0.13.0 ; extra == 'docs'
57
+ Requires-Dist: sphinx <7.4.0,>=7.3.0 ; extra == 'docs'
58
+ Requires-Dist: sphinx-gallery <0.17.0,>=0.15.0 ; extra == 'docs'
59
+ Requires-Dist: furo <2024.6.0,>=2024.4.27 ; extra == 'docs'
60
+ Requires-Dist: numpydoc <1.8.0,>=1.6.0 ; extra == 'docs'
61
+ Requires-Dist: julearn ==0.3.3 ; extra == 'docs'
62
62
  Requires-Dist: sphinx-copybutton <0.5.3,>=0.5.1 ; extra == 'docs'
63
- Requires-Dist: towncrier <23.7,>=22.12.0 ; extra == 'docs'
63
+ Requires-Dist: towncrier <23.12.0,>=23.10.0 ; extra == 'docs'
64
64
  Requires-Dist: sphinxcontrib-mermaid <0.10,>=0.8.1 ; extra == 'docs'
65
65
  Provides-Extra: neurokit2
66
66
  Requires-Dist: neurokit2 >=0.1.7 ; extra == 'neurokit2'
@@ -1,5 +1,5 @@
1
1
  junifer/__init__.py,sha256=-T9XmiCCL0j3YLx-0Pph15sPfL5FlcBDscajjJ-V4sU,604
2
- junifer/_version.py,sha256=LLX_zE2hwuXoJcCrJFHp63l96uwV1o-_baS2uJTkq4Y,428
2
+ junifer/_version.py,sha256=UfXRLkQeUycPYOXVnbIPOq4a2hAaHq9EznoNGJMncyo,428
3
3
  junifer/stats.py,sha256=BjQb2lfTGDP9l4UuQYmJFcJJNRfbJDGlNvC06SJaDDE,6237
4
4
  junifer/api/__init__.py,sha256=lwyIF0hPc7fICuSoddJfay0LPqlTRxHJ_xbtizgFYZA,312
5
5
  junifer/api/cli.py,sha256=53pews3mXkJ7DUDSkV51PbitYnuVAdQRkWG-gjO08Uw,16142
@@ -132,9 +132,9 @@ junifer/external/h5io/h5io/_h5io.py,sha256=8dWZDYegoPcBkH_fHPdl0eXNWTaRdk9hfIQo8
132
132
  junifer/external/h5io/h5io/_version.py,sha256=mFY0GwwuN-a3M8w93_mskS6GZIvv9SNdjLfJaWNsm-I,22
133
133
  junifer/external/h5io/h5io/chunked_array.py,sha256=K1HWf7R2Jc7gCzBqAoBjx0ZnMmUhTe3iAO6RF6PdUO4,3338
134
134
  junifer/external/h5io/h5io/chunked_list.py,sha256=1Y5BbuWzurJlEFQzJNuDdC3fNZ39ENEMba99X_4VeSM,1952
135
- junifer/external/nilearn/__init__.py,sha256=a2Umwm3_WeqIC7DqPUmnUonYfX3LUdQ0ScDGZrNP6y4,180
136
- junifer/external/nilearn/junifer_nifti_spheres_masker.py,sha256=sA8fbdaTHk2omYidApNO1hN0ObwDJR_h26P9i3MhbvM,16274
137
- junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py,sha256=qlMFWjo9y8mNLrdmN2qCEK6_nplASv2OlomSfTxDcuw,10370
135
+ junifer/external/nilearn/__init__.py,sha256=Cx9SM-AHU2OmyC5n6YmRv2JMEYp3qoVnxl5bk4XYWjc,222
136
+ junifer/external/nilearn/junifer_nifti_spheres_masker.py,sha256=DbSK2hKrgpHZ_vCRLbVv3YJpLZNkEAG0HFfQQpG6zdU,16546
137
+ junifer/external/nilearn/tests/test_junifer_nifti_spheres_masker.py,sha256=zpvBYIvaNjUj9fIUg5K78LRzJqbyMYlUo2UQYS9_lo4,12275
138
138
  junifer/markers/__init__.py,sha256=u4BFgS_3GXAwFN2HfqdAhlBkyenLw4IYlMlwXwnjkVQ,1235
139
139
  junifer/markers/base.py,sha256=7_TLrz8dZH_3t1zgSSW2yCnDO2DGGAxFMZLHDkvJ_NM,6985
140
140
  junifer/markers/brainprint.py,sha256=On1M8Hp14g-S-o-3TVVYTGfviJEz-xjuAVg0mRHyxFg,21793
@@ -263,10 +263,10 @@ junifer/utils/logging.py,sha256=b02qVTdE-WNVo6uxCYdIHVmNfM7An0NdCJNq_2Gte8o,9355
263
263
  junifer/utils/tests/test_fs.py,sha256=WQS7cKlKEZ742CIuiOYYpueeAhY9PqlastfDVpVVtvE,923
264
264
  junifer/utils/tests/test_helpers.py,sha256=k5qqfxK8dFyuewTJyR1Qn6-nFaYNuVr0ysc18bfPjyU,929
265
265
  junifer/utils/tests/test_logging.py,sha256=l8oo-AiBV7H6_IzlsNcj__cLeZBUvgIGoaMszD9VaJg,7754
266
- junifer-0.0.5.dev145.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
267
- junifer-0.0.5.dev145.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
268
- junifer-0.0.5.dev145.dist-info/METADATA,sha256=wLNrUZogrVkFN8xbkxvaSa9uJys188Aq-NJ4OrWeUAU,8270
269
- junifer-0.0.5.dev145.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
270
- junifer-0.0.5.dev145.dist-info/entry_points.txt,sha256=DxFvKq0pOqRunAK0FxwJcoDfV1-dZvsFDpD5HRqSDhw,48
271
- junifer-0.0.5.dev145.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
272
- junifer-0.0.5.dev145.dist-info/RECORD,,
266
+ junifer-0.0.5.dev161.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
267
+ junifer-0.0.5.dev161.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
268
+ junifer-0.0.5.dev161.dist-info/METADATA,sha256=AFnrJ4D7WeYBR0_-Crevx4ezleXY3PX4hz5LR9VKvvo,8281
269
+ junifer-0.0.5.dev161.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
270
+ junifer-0.0.5.dev161.dist-info/entry_points.txt,sha256=DxFvKq0pOqRunAK0FxwJcoDfV1-dZvsFDpD5HRqSDhw,48
271
+ junifer-0.0.5.dev161.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
272
+ junifer-0.0.5.dev161.dist-info/RECORD,,