junifer 0.0.6.dev538__py3-none-any.whl → 0.0.7.dev43__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.
Files changed (91) hide show
  1. junifer/_version.py +2 -2
  2. junifer/api/decorators.py +0 -1
  3. junifer/api/functions.py +1 -2
  4. junifer/api/queue_context/gnu_parallel_local_adapter.py +4 -7
  5. junifer/api/queue_context/htcondor_adapter.py +6 -10
  6. junifer/cli/tests/test_parser.py +66 -0
  7. junifer/data/_dispatch.py +5 -5
  8. junifer/data/coordinates/_ants_coordinates_warper.py +1 -1
  9. junifer/data/coordinates/_coordinates.py +1 -1
  10. junifer/data/coordinates/_fsl_coordinates_warper.py +1 -1
  11. junifer/data/coordinates/tests/test_coordinates.py +38 -16
  12. junifer/data/masks/_ants_mask_warper.py +1 -1
  13. junifer/data/masks/_fsl_mask_warper.py +1 -1
  14. junifer/data/masks/tests/test_masks.py +66 -33
  15. junifer/data/parcellations/_ants_parcellation_warper.py +1 -1
  16. junifer/data/parcellations/_fsl_parcellation_warper.py +1 -1
  17. junifer/data/parcellations/_parcellations.py +7 -7
  18. junifer/data/parcellations/tests/test_parcellations.py +162 -76
  19. junifer/data/tests/test_data_utils.py +0 -1
  20. junifer/data/utils.py +1 -1
  21. junifer/datagrabber/aomic/id1000.py +6 -0
  22. junifer/datagrabber/aomic/piop1.py +4 -3
  23. junifer/datagrabber/aomic/piop2.py +4 -3
  24. junifer/datagrabber/pattern_datalad.py +0 -1
  25. junifer/datagrabber/pattern_validation_mixin.py +0 -1
  26. junifer/datagrabber/tests/test_dmcc13_benchmark.py +4 -8
  27. junifer/external/nilearn/junifer_connectivity_measure.py +32 -3
  28. junifer/external/nilearn/tests/test_junifer_connectivity_measure.py +45 -1
  29. junifer/markers/base.py +3 -3
  30. junifer/markers/brainprint.py +5 -5
  31. junifer/markers/complexity/multiscale_entropy_auc.py +3 -3
  32. junifer/markers/complexity/range_entropy.py +3 -3
  33. junifer/markers/complexity/sample_entropy.py +3 -3
  34. junifer/markers/falff/falff_parcels.py +2 -6
  35. junifer/markers/falff/falff_spheres.py +2 -6
  36. junifer/markers/functional_connectivity/functional_connectivity_base.py +7 -5
  37. junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +2 -1
  38. junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +2 -1
  39. junifer/markers/reho/_afni_reho.py +1 -1
  40. junifer/markers/reho/reho_base.py +0 -1
  41. junifer/markers/reho/reho_parcels.py +0 -1
  42. junifer/markers/reho/reho_spheres.py +0 -1
  43. junifer/markers/temporal_snr/temporal_snr_base.py +0 -1
  44. junifer/markers/tests/test_markers_base.py +0 -1
  45. junifer/onthefly/_brainprint.py +3 -3
  46. junifer/onthefly/read_transform.py +1 -2
  47. junifer/onthefly/tests/test_read_transform.py +0 -1
  48. junifer/pipeline/tests/test_marker_collection.py +2 -1
  49. junifer/pipeline/workdir_manager.py +1 -2
  50. junifer/preprocess/confounds/fmriprep_confound_remover.py +1 -1
  51. junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +0 -1
  52. junifer/preprocess/smoothing/tests/test_smoothing.py +0 -1
  53. junifer/preprocess/warping/_ants_warper.py +2 -3
  54. junifer/preprocess/warping/_fsl_warper.py +1 -1
  55. junifer/preprocess/warping/space_warper.py +4 -2
  56. junifer/storage/pandas_base.py +3 -1
  57. junifer/storage/sqlite.py +3 -8
  58. junifer/storage/tests/test_pandas_base.py +6 -3
  59. junifer/storage/tests/test_storage_base.py +2 -1
  60. junifer/utils/logging.py +38 -128
  61. junifer/utils/tests/test_logging.py +12 -4
  62. {junifer-0.0.6.dev538.dist-info → junifer-0.0.7.dev43.dist-info}/METADATA +3 -2
  63. {junifer-0.0.6.dev538.dist-info → junifer-0.0.7.dev43.dist-info}/RECORD +68 -91
  64. {junifer-0.0.6.dev538.dist-info → junifer-0.0.7.dev43.dist-info}/WHEEL +1 -1
  65. junifer/data/coordinates/VOIs/meta/AutobiographicalMemory_VOIs.txt +0 -23
  66. junifer/data/coordinates/VOIs/meta/CogAC_VOIs.txt +0 -19
  67. junifer/data/coordinates/VOIs/meta/CogAR_VOIs.txt +0 -8
  68. junifer/data/coordinates/VOIs/meta/DMNBuckner_VOIs.txt +0 -6
  69. junifer/data/coordinates/VOIs/meta/Dosenbach2010_MNI_VOIs.txt +0 -160
  70. junifer/data/coordinates/VOIs/meta/Empathy_VOIs.txt +0 -22
  71. junifer/data/coordinates/VOIs/meta/Motor_VOIs.txt +0 -10
  72. junifer/data/coordinates/VOIs/meta/MultiTask_VOIs.txt +0 -9
  73. junifer/data/coordinates/VOIs/meta/PhysioStress_VOIs.txt +0 -18
  74. junifer/data/coordinates/VOIs/meta/Power2011_MNI_VOIs.txt +0 -264
  75. junifer/data/coordinates/VOIs/meta/Power2013_MNI_VOIs.tsv +0 -264
  76. junifer/data/coordinates/VOIs/meta/Rew_VOIs.txt +0 -25
  77. junifer/data/coordinates/VOIs/meta/Somatosensory_VOIs.txt +0 -10
  78. junifer/data/coordinates/VOIs/meta/ToM_VOIs.txt +0 -15
  79. junifer/data/coordinates/VOIs/meta/VigAtt_VOIs.txt +0 -16
  80. junifer/data/coordinates/VOIs/meta/WM_VOIs.txt +0 -23
  81. junifer/data/coordinates/VOIs/meta/eMDN_VOIs.txt +0 -17
  82. junifer/data/coordinates/VOIs/meta/eSAD_VOIs.txt +0 -12
  83. junifer/data/coordinates/VOIs/meta/extDMN_VOIs.txt +0 -16
  84. junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz +0 -0
  85. junifer/data/masks/vickery-patil/CAT12_IXI555_MNI152_TMP_GS_GMprob0.2_clean.nii.gz +0 -0
  86. junifer/data/masks/vickery-patil/CAT12_IXI555_MNI152_TMP_GS_GMprob0.2_clean_3mm.nii.gz +0 -0
  87. junifer/data/masks/vickery-patil/GMprob0.2_cortex_3mm_NA_rm.nii.gz +0 -0
  88. {junifer-0.0.6.dev538.dist-info → junifer-0.0.7.dev43.dist-info}/entry_points.txt +0 -0
  89. {junifer-0.0.6.dev538.dist-info → junifer-0.0.7.dev43.dist-info}/licenses/AUTHORS.rst +0 -0
  90. {junifer-0.0.6.dev538.dist-info → junifer-0.0.7.dev43.dist-info}/licenses/LICENSE.md +0 -0
  91. {junifer-0.0.6.dev538.dist-info → junifer-0.0.7.dev43.dist-info}/top_level.txt +0 -0
@@ -20,7 +20,14 @@ from nilearn.masking import (
20
20
  )
21
21
  from numpy.testing import assert_array_almost_equal, assert_array_equal
22
22
 
23
- from junifer.data import MaskRegistry
23
+ from junifer.data import (
24
+ MaskRegistry,
25
+ deregister_data,
26
+ get_data,
27
+ list_data,
28
+ load_data,
29
+ register_data,
30
+ )
24
31
  from junifer.data.masks import compute_brain_mask
25
32
  from junifer.data.masks._masks import (
26
33
  _load_ukb_mask,
@@ -112,7 +119,8 @@ def test_compute_brain_mask_for_native(mask_type: str) -> None:
112
119
  def test_register_built_in_check() -> None:
113
120
  """Test mask registration check for built-in masks."""
114
121
  with pytest.raises(ValueError, match=r"built-in mask"):
115
- MaskRegistry().register(
122
+ register_data(
123
+ kind="mask",
116
124
  name="GM_prob0.2",
117
125
  mask_path="testmask.nii.gz",
118
126
  space="MNI",
@@ -122,36 +130,39 @@ def test_register_built_in_check() -> None:
122
130
 
123
131
  def test_list_incorrect() -> None:
124
132
  """Test incorrect information check for list masks."""
125
- assert "testmask" not in MaskRegistry().list
133
+ assert "testmask" not in list_data(kind="mask")
126
134
 
127
135
 
128
136
  def test_register_already_registered() -> None:
129
137
  """Test mask registration check for already registered."""
130
138
  # Register custom mask
131
- MaskRegistry().register(
139
+ register_data(
140
+ kind="mask",
132
141
  name="testmask",
133
142
  mask_path="testmask.nii.gz",
134
143
  space="MNI",
135
144
  )
136
- out = MaskRegistry().load("testmask", path_only=True)
145
+ out = load_data(kind="mask", name="testmask", path_only=True)
137
146
  assert out[1] is not None
138
147
  assert out[1].name == "testmask.nii.gz"
139
148
 
140
149
  # Try registering again
141
150
  with pytest.raises(ValueError, match=r"already registered."):
142
- MaskRegistry().register(
151
+ register_data(
152
+ kind="mask",
143
153
  name="testmask",
144
154
  mask_path="testmask.nii.gz",
145
155
  space="MNI",
146
156
  )
147
- MaskRegistry().register(
157
+ register_data(
158
+ kind="mask",
148
159
  name="testmask",
149
160
  mask_path="testmask2.nii.gz",
150
161
  space="MNI",
151
162
  overwrite=True,
152
163
  )
153
164
 
154
- out = MaskRegistry().load("testmask", path_only=True)
165
+ out = load_data(kind="mask", name="testmask", path_only=True)
155
166
  assert out[1] is not None
156
167
  assert out[1].name == "testmask2.nii.gz"
157
168
 
@@ -185,16 +196,17 @@ def test_register(
185
196
 
186
197
  """
187
198
  # Register custom mask
188
- MaskRegistry().register(
199
+ register_data(
200
+ kind="mask",
189
201
  name=name,
190
202
  mask_path=mask_path,
191
203
  space=space,
192
204
  overwrite=overwrite,
193
205
  )
194
206
  # List available mask and check registration
195
- assert name in MaskRegistry().list
207
+ assert name in list_data(kind="mask")
196
208
  # Load registered mask
197
- _, fname, mask_space = MaskRegistry().load(name=name, path_only=True)
209
+ _, fname, mask_space = load_data(kind="mask", name=name, path_only=True)
198
210
  # Check values for registered mask
199
211
  assert fname is not None
200
212
  assert fname.name == f"{name}.nii.gz"
@@ -218,7 +230,7 @@ def test_list_correct(mask_name: str) -> None:
218
230
  The parametrized mask name.
219
231
 
220
232
  """
221
- assert mask_name in MaskRegistry().list
233
+ assert mask_name in list_data(kind="mask")
222
234
 
223
235
 
224
236
  def test_load_incorrect() -> None:
@@ -270,9 +282,12 @@ def test_vickery_patil(
270
282
  The parametrized name of the mask file.
271
283
 
272
284
  """
273
- mask, mask_fname, space = MaskRegistry().load(name, resolution=resolution)
285
+ mask, mask_fname, space = load_data(
286
+ kind="mask", name=name, resolution=resolution
287
+ )
274
288
  assert_array_almost_equal(
275
- mask.header["pixdim"][1:4], pixdim # type: ignore
289
+ mask.header["pixdim"][1:4],
290
+ pixdim, # type: ignore
276
291
  )
277
292
  assert space == "IXI549Space"
278
293
  assert mask_fname is not None
@@ -287,7 +302,9 @@ def test_vickery_patil_error() -> None:
287
302
 
288
303
  def test_ukb() -> None:
289
304
  """Test UKB mask."""
290
- mask, mask_fname, space = MaskRegistry().load("UKB_15K_GM", resolution=2.0)
305
+ mask, mask_fname, space = load_data(
306
+ kind="mask", name="UKB_15K_GM", resolution=2.0
307
+ )
291
308
  assert_array_almost_equal(mask.header["pixdim"][1:4], 2.0) # type: ignore
292
309
  assert space == "MNI152NLin6Asym"
293
310
  assert mask_fname is not None
@@ -306,8 +323,8 @@ def test_get() -> None:
306
323
  element_data = DefaultDataReader().fit_transform(dg["sub-01"])
307
324
  vbm_gm = element_data["VBM_GM"]
308
325
  vbm_gm_img = vbm_gm["data"]
309
- mask = MaskRegistry().get(
310
- masks="compute_brain_mask", target_data=vbm_gm
326
+ mask = get_data(
327
+ kind="mask", names="compute_brain_mask", target_data=vbm_gm
311
328
  )
312
329
 
313
330
  assert mask.shape == vbm_gm_img.shape
@@ -355,28 +372,33 @@ def test_get_errors() -> None:
355
372
  vbm_gm = element_data["VBM_GM"]
356
373
  # Test wrong masks definitions (more than one key per dict)
357
374
  with pytest.raises(ValueError, match=r"only one key"):
358
- MaskRegistry().get(
359
- masks={"GM_prob0.2": {}, "Other": {}}, target_data=vbm_gm
375
+ get_data(
376
+ kind="mask",
377
+ names={"GM_prob0.2": {}, "Other": {}},
378
+ target_data=vbm_gm,
360
379
  )
361
380
 
362
381
  # Test wrong masks definitions (pass paramaeters to non-callable mask)
363
382
  with pytest.raises(ValueError, match=r"callable params"):
364
- MaskRegistry().get(
365
- masks={"GM_prob0.2": {"param": 1}}, target_data=vbm_gm
383
+ get_data(
384
+ kind="mask",
385
+ names={"GM_prob0.2": {"param": 1}},
386
+ target_data=vbm_gm,
366
387
  )
367
388
 
368
389
  # Pass only parameters to the intersection function
369
390
  with pytest.raises(
370
391
  ValueError, match=r" At least one mask is required."
371
392
  ):
372
- MaskRegistry().get(masks={"threshold": 1}, target_data=vbm_gm)
393
+ get_data(kind="mask", names={"threshold": 1}, target_data=vbm_gm)
373
394
 
374
395
  # Pass parameters to the intersection function when only one mask
375
396
  with pytest.raises(
376
397
  ValueError, match=r"parameters to the intersection"
377
398
  ):
378
- MaskRegistry().get(
379
- masks=["compute_brain_mask", {"threshold": 1}],
399
+ get_data(
400
+ kind="mask",
401
+ names=["compute_brain_mask", {"threshold": 1}],
380
402
  target_data=vbm_gm,
381
403
  )
382
404
 
@@ -423,7 +445,7 @@ def test_nilearn_compute_masks(
423
445
  else:
424
446
  mask_spec = {mask_name: params}
425
447
 
426
- mask = MaskRegistry().get(masks=mask_spec, target_data=bold)
448
+ mask = get_data(kind="mask", names=mask_spec, target_data=bold)
427
449
 
428
450
  assert_array_equal(mask.affine, bold_img.affine)
429
451
 
@@ -449,8 +471,9 @@ def test_get_inherit() -> None:
449
471
  gm_mask = compute_brain_mask(element_data["BOLD"], threshold=0.2)
450
472
 
451
473
  # Get mask using the compute_brain_mask function
452
- mask1 = MaskRegistry().get(
453
- masks={"compute_brain_mask": {"threshold": 0.2}},
474
+ mask1 = get_data(
475
+ kind="mask",
476
+ names={"compute_brain_mask": {"threshold": 0.2}},
454
477
  target_data=element_data["BOLD"],
455
478
  )
456
479
 
@@ -461,8 +484,9 @@ def test_get_inherit() -> None:
461
484
  "data": gm_mask,
462
485
  "space": element_data["BOLD"]["space"],
463
486
  }
464
- mask2 = MaskRegistry().get(
465
- masks="inherit",
487
+ mask2 = get_data(
488
+ kind="mask",
489
+ names="inherit",
466
490
  target_data=bold_dict,
467
491
  )
468
492
 
@@ -503,8 +527,8 @@ def test_get_multiple(
503
527
  target_img = element_data["BOLD"]["data"]
504
528
  resolution = np.min(target_img.header.get_zooms()[:3])
505
529
 
506
- computed = MaskRegistry().get(
507
- masks=junifer_masks, target_data=element_data["BOLD"]
530
+ computed = get_data(
531
+ kind="mask", names=junifer_masks, target_data=element_data["BOLD"]
508
532
  )
509
533
 
510
534
  masks_names = [
@@ -523,8 +547,11 @@ def test_get_multiple(
523
547
  ]
524
548
 
525
549
  mask_imgs = [
526
- MaskRegistry().load(
527
- t_mask, path_only=False, resolution=resolution
550
+ load_data(
551
+ kind="mask",
552
+ name=t_mask,
553
+ path_only=False,
554
+ resolution=resolution,
528
555
  )[0]
529
556
  for t_mask in mask_files
530
557
  ]
@@ -554,3 +581,9 @@ def test_get_multiple(
554
581
 
555
582
  expected = intersect_masks(mask_imgs, **params)
556
583
  assert_array_equal(computed.get_fdata(), expected.get_fdata())
584
+
585
+
586
+ def test_deregister() -> None:
587
+ """Test mask deregistration."""
588
+ deregister_data(kind="mask", name="testmask")
589
+ assert "testmask" not in list_data(kind="mask")
@@ -84,7 +84,7 @@ class ANTsParcellationWarper:
84
84
  )
85
85
 
86
86
  # Native space warping
87
- if dst == "native":
87
+ if dst == "native": # pragma: no cover
88
88
  # Warp data check
89
89
  if warp_data is None:
90
90
  raise_error("No `warp_data` provided")
@@ -32,7 +32,7 @@ class FSLParcellationWarper:
32
32
  parcellation_img: "Nifti1Image",
33
33
  target_data: dict[str, Any],
34
34
  warp_data: dict[str, Any],
35
- ) -> "Nifti1Image":
35
+ ) -> "Nifti1Image": # pragma: no cover
36
36
  """Warp ``parcellation_img`` to correct space.
37
37
 
38
38
  Parameters
@@ -1035,17 +1035,17 @@ def _retrieve_shen(
1035
1035
  )
1036
1036
  if n_rois in (268, 368) and year == 2013:
1037
1037
  raise_error(
1038
- f"The parameter combination `resolution = {resolution}` and "
1038
+ f"The parameter combination `n_rois = {n_rois}` and "
1039
1039
  "`year = 2013` is invalid"
1040
1040
  )
1041
1041
  if n_rois in (50, 100, 150) and year in (2015, 2019):
1042
1042
  raise_error(
1043
- f"The parameter combination `resolution = {resolution}` and "
1043
+ f"The parameter combination `n_rois = {n_rois}` and "
1044
1044
  f"`year = {year}` is invalid"
1045
1045
  )
1046
1046
  if (n_rois == 268 and year == 2019) or (n_rois == 368 and year == 2015):
1047
1047
  raise_error(
1048
- f"The parameter combination `resolution = {resolution}` and "
1048
+ f"The parameter combination `n_rois = {n_rois}` and "
1049
1049
  f"`year = {year}` is invalid"
1050
1050
  )
1051
1051
 
@@ -1312,11 +1312,11 @@ def merge_parcellations(
1312
1312
  parcellations_names: list[str],
1313
1313
  labels_lists: list[list[str]],
1314
1314
  ) -> tuple["Nifti1Image", list[str]]:
1315
- """Merge all parcellations from a list into one parcellation.
1315
+ """Merge multiple parcellations.
1316
1316
 
1317
1317
  Parameters
1318
1318
  ----------
1319
- parcellations_list : list of niimg-like object
1319
+ parcellations_list : list of Niimg-like object
1320
1320
  List of parcellations to merge.
1321
1321
  parcellations_names: list of str
1322
1322
  List of names for parcellations at the corresponding indices.
@@ -1326,10 +1326,10 @@ def merge_parcellations(
1326
1326
 
1327
1327
  Returns
1328
1328
  -------
1329
- parcellation : niimg-like object
1329
+ Niimg-like object
1330
1330
  The parcellation that results from merging the list of input
1331
1331
  parcellations.
1332
- labels : list of str
1332
+ list of str
1333
1333
  List of labels for the resultant parcellation.
1334
1334
 
1335
1335
  """