junifer 0.0.5.dev152__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.dev152'
16
- __version_tuple__ = version_tuple = (0, 0, 5, 'dev152')
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"]
@@ -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,6 +102,17 @@ 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
 
@@ -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.dev152
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>
@@ -1,5 +1,5 @@
1
1
  junifer/__init__.py,sha256=-T9XmiCCL0j3YLx-0Pph15sPfL5FlcBDscajjJ-V4sU,604
2
- junifer/_version.py,sha256=YEKUDK7au3qW4ScztaosLY-XtlLg7Y8o26fPONml4S8,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=D3Sf78zJx-bArO2tbUbvjDdnOv2T7HCcNtvfcEL6lCU,16267
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.dev152.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
267
- junifer-0.0.5.dev152.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
268
- junifer-0.0.5.dev152.dist-info/METADATA,sha256=saDs-CMpk_pn8L2kDcN_1KLtE3-YB8CCB87K5XgUTik,8281
269
- junifer-0.0.5.dev152.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
270
- junifer-0.0.5.dev152.dist-info/entry_points.txt,sha256=DxFvKq0pOqRunAK0FxwJcoDfV1-dZvsFDpD5HRqSDhw,48
271
- junifer-0.0.5.dev152.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
272
- junifer-0.0.5.dev152.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,,