nimare 0.5.3rc1__py3-none-any.whl → 0.5.4rc1__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.
nimare/_version.py CHANGED
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2025-07-26T17:24:25-0500",
11
+ "date": "2025-07-30T11:49:13-0500",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "096951f4879c2b5f508463c2efc4a3da9ebaf9bc",
15
- "version": "0.5.3rc1"
14
+ "full-revisionid": "aa29fabbe739d247d1502bd7825a670018651aa5",
15
+ "version": "0.5.4rc1"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
nimare/io.py CHANGED
@@ -63,31 +63,53 @@ def convert_nimads_to_dataset(studyset, annotation=None):
63
63
  },
64
64
  }
65
65
 
66
- sample_sizes = analysis.metadata.get("sample_sizes")
67
- sample_size = None
66
+ sample_sizes = analysis.metadata.get("sample_sizes", None)
67
+ sample_size = analysis.metadata.get("sample_size", None)
68
68
 
69
69
  # Validate sample sizes if present
70
70
  if sample_sizes is not None and not isinstance(sample_sizes, (list, tuple)):
71
- raise TypeError(
72
- f"Expected sample_sizes to be list or tuple, but got {type(sample_sizes)}"
71
+ LGR.warning(
72
+ f"Expected sample_sizes to be list or tuple, but got {type(sample_sizes)}."
73
73
  )
74
-
75
- if not sample_sizes:
76
- # Try to get single sample size from analysis or study metadata
77
- sample_size = analysis.metadata.get("sample_size")
78
- if sample_size is None:
79
- sample_size = study.metadata.get("sample_size")
80
-
74
+ sample_sizes = None
75
+ elif sample_sizes is not None:
76
+ # Validate each sample size in the list
77
+ for i, ss in enumerate(sample_sizes):
78
+ if not isinstance(ss, (int, float)):
79
+ LGR.warning(
80
+ f"Expected sample_sizes[{i}] to be numeric, but got {type(ss)}."
81
+ " Attempting to convert to numeric."
82
+ )
83
+ try:
84
+ sample_sizes[i] = int(ss)
85
+ except (ValueError, TypeError):
86
+ try:
87
+ sample_sizes[i] = float(ss)
88
+ except (ValueError, TypeError):
89
+ LGR.warning(f"Could not convert {ss} to numeric from type {type(ss)}.")
90
+ sample_sizes = None
91
+ break
92
+
93
+ if not sample_sizes and sample_size:
81
94
  # Validate single sample size if present
82
- if sample_size is not None and not isinstance(sample_size, (int, float)):
83
- raise TypeError(f"Expected sample_size to be numeric, but got {type(sample_size)}")
84
-
85
- # Add sample size info to result if available
86
- if sample_sizes or sample_size is not None:
95
+ if not isinstance(sample_size, (int, float)):
96
+ LGR.warning(
97
+ f"Expected sample_size to be numeric, but got {type(sample_size)}."
98
+ " Attempting to convert to numeric."
99
+ )
87
100
  try:
88
- result["metadata"]["sample_sizes"] = sample_sizes or [sample_size]
89
- except TypeError as e:
90
- raise TypeError(f"Error converting sample size data to list: {str(e)}") from e
101
+ sample_sizes = [int(sample_size)]
102
+ except (ValueError, TypeError):
103
+ try:
104
+ sample_sizes = [float(sample_size)]
105
+ except (ValueError, TypeError):
106
+ LGR.warning(
107
+ f"Could not convert {sample_size} to"
108
+ f" numeric from type {type(sample_size)}."
109
+ )
110
+ sample_sizes = None
111
+ if sample_sizes:
112
+ result["metadata"]["sample_sizes"] = sample_sizes
91
113
 
92
114
  # Handle annotations if present
93
115
  if analysis.annotations:
nimare/tests/test_io.py CHANGED
@@ -1,5 +1,6 @@
1
1
  """Test nimare.io (Dataset IO/transformations)."""
2
2
 
3
+ import copy
3
4
  import os
4
5
 
5
6
  import pytest
@@ -52,16 +53,107 @@ def test_convert_nimads_to_dataset_single_sample_size(
52
53
  assert "sample_sizes" in dset.metadata.columns
53
54
 
54
55
 
55
- def test_analysis_to_dict_invalid_sample_sizes_type(example_nimads_studyset):
56
- """Test _analysis_to_dict raises ValueError when sample_sizes is not a list/tuple."""
56
+ @pytest.mark.parametrize(
57
+ "sample_sizes_val,sample_size_val,expect_col,expect_warning",
58
+ [
59
+ (5, None, False, True),
60
+ ([5, "6", "7.3", "not_a_number"], None, False, True),
61
+ (None, 10, True, False),
62
+ (None, 10.5, True, False),
63
+ (None, "12", True, True),
64
+ (None, "13.5", True, True),
65
+ (None, "not_a_number", False, True),
66
+ (None, None, False, False),
67
+ ([], 7, True, False),
68
+ ([], None, False, False),
69
+ ],
70
+ )
71
+ def test_analysis_to_dict_sample_size(
72
+ example_nimads_studyset, sample_sizes_val, sample_size_val, expect_col, expect_warning, caplog
73
+ ):
74
+ """Test conversion of nimads JSON to nimare dataset with different sample_size(s) values."""
57
75
  studyset = Studyset(example_nimads_studyset)
58
- # Set sample_sizes to an int rather than list/tuple
59
76
  for study in studyset.studies:
60
77
  for analysis in study.analyses:
61
- analysis.metadata["sample_sizes"] = 5
62
- with pytest.raises(TypeError):
63
- # Trigger conversion which internally calls _analysis_to_dict
64
- io.convert_nimads_to_dataset(studyset)
78
+ analysis.metadata.clear()
79
+ if sample_sizes_val is not None:
80
+ analysis.metadata["sample_sizes"] = sample_sizes_val
81
+ if sample_size_val is not None:
82
+ analysis.metadata["sample_size"] = sample_size_val
83
+
84
+ with caplog.at_level("WARNING"):
85
+ dset = io.convert_nimads_to_dataset(studyset)
86
+ assert isinstance(dset, nimare.dataset.Dataset)
87
+ if expect_col:
88
+ assert "sample_sizes" in dset.metadata.columns
89
+ else:
90
+ assert "sample_sizes" not in dset.metadata.columns
91
+ if expect_warning:
92
+ assert any(
93
+ "sample_size" in record.message or "sample_sizes" in record.message
94
+ for record in caplog.records
95
+ )
96
+ else:
97
+ assert not any(
98
+ "sample_size" in record.message or "sample_sizes" in record.message
99
+ for record in caplog.records
100
+ )
101
+
102
+
103
+ @pytest.mark.parametrize(
104
+ "annotation_mod,expect_success,expect_typeerror",
105
+ [
106
+ # No annotation at all
107
+ (None, True, False),
108
+ # Annotation with empty notes
109
+ (lambda ann: ann.update({"notes": []}), True, False),
110
+ # Annotation with extra irrelevant key
111
+ (lambda ann: ann.update({"extra_key": 123}), True, False),
112
+ # Annotation with missing 'notes' key (should fail)
113
+ (lambda ann: ann.pop("notes", None), False, True),
114
+ # Annotation with mismatched analysis id in notes (should warn/fail)
115
+ (
116
+ lambda ann: ann["notes"].append(
117
+ {
118
+ "analysis_name": "Fake",
119
+ "publication": "Fake",
120
+ "study": ann["notes"][0]["study"],
121
+ "study_year": 2025,
122
+ "analysis": "not_in_studyset",
123
+ "authors": "Nobody",
124
+ "note": {"include": False},
125
+ "study_name": "Fake",
126
+ }
127
+ ),
128
+ True,
129
+ True,
130
+ ),
131
+ ],
132
+ )
133
+ def test_analysis_to_dict_annotation(
134
+ example_nimads_studyset,
135
+ example_nimads_annotation,
136
+ annotation_mod,
137
+ expect_success,
138
+ expect_typeerror,
139
+ ):
140
+ """Test conversion of nimads JSON to nimare dataset with various annotation modifications."""
141
+ studyset = Studyset(example_nimads_studyset)
142
+ if annotation_mod is not None:
143
+ annotation = copy.deepcopy(example_nimads_annotation)
144
+ annotation_mod(annotation)
145
+ if expect_typeerror:
146
+ with pytest.raises((TypeError, ValueError, KeyError)):
147
+ studyset.annotations = annotation
148
+ io.convert_nimads_to_dataset(studyset)
149
+ else:
150
+ studyset.annotations = annotation
151
+ dset = io.convert_nimads_to_dataset(studyset)
152
+ assert expect_success
153
+ else:
154
+ # No annotation
155
+ dset = io.convert_nimads_to_dataset(studyset)
156
+ assert isinstance(dset, nimare.dataset.Dataset)
65
157
 
66
158
 
67
159
  def test_convert_sleuth_to_dataset_smoke():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nimare
3
- Version: 0.5.3rc1
3
+ Version: 0.5.4rc1
4
4
  Summary: NiMARE: Neuroimaging Meta-Analysis Research Environment
5
5
  Home-page: https://github.com/neurostuff/NiMARE
6
6
  Author: NiMARE developers
@@ -1,7 +1,7 @@
1
1
  benchmarks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  benchmarks/bench_cbma.py,sha256=fg_EER8hohi6kD1Hno_uXsFntKuCLTvseu-6OqkHkoU,1382
3
3
  nimare/__init__.py,sha256=HHIq3EimSZSf3zJSDwuTjBig1GbRwHGYfRLSqI3yleE,802
4
- nimare/_version.py,sha256=cTtTgV3QoHjAwvIOfB-51ttLjBig-3By0hQuB3n913w,500
4
+ nimare/_version.py,sha256=0QsSePWeesPbnty5wVQ3UhwyCdb4TCd3E9PodF2E8Z4,500
5
5
  nimare/base.py,sha256=9DlcRB2mW759p7XqpKG3wRE-MmPsEPiYTbq6V1Yile4,7826
6
6
  nimare/cli.py,sha256=Zvy5jN2KopH_MBke-gm8A0DbBZmIFGvnE1tjhbYib9I,3695
7
7
  nimare/correct.py,sha256=2eI0jR6_odND-2CzSlaxRU2um6ccLSapd7ERAYteBnE,17110
@@ -9,7 +9,7 @@ nimare/dataset.py,sha256=pSEccmbqQCYiwfjoy45tgYRTBt1CEFqmKFz_T8p95cA,24814
9
9
  nimare/diagnostics.py,sha256=sCatkXUM9rvrY9MMz6Q66njWSiWGifWwSNEMu3ldnVs,20263
10
10
  nimare/estimator.py,sha256=DtsSIyPDrKkpi-KNv2m-cZMvJO7CCfHLXHRhCT73sbY,5063
11
11
  nimare/generate.py,sha256=L4_c2sLAlF7XDKTm-3q4oOx8pLID2NaxG9YET5KSIZw,12475
12
- nimare/io.py,sha256=76T9KLOorquImy-01cLG3pwuJLJm_UD_hAhK3_0qj7g,27299
12
+ nimare/io.py,sha256=OKB9qYOto0NSeWHdz5VRBQwO_9aLGzIT6OeNUPwDeLA,28235
13
13
  nimare/nimads.py,sha256=2s5QnaLvrBt-kMrImGhG_p6r0unysufIIcPczr2bG0c,24342
14
14
  nimare/results.py,sha256=7szcyR6PkZAXBqbIGGWrw1nW9j9QCdpdl4MxUK_1Wzc,8190
15
15
  nimare/stats.py,sha256=XhXfFj6KHTPVSTXhbEid0qt8HLqJD82Bl5T23qmaf40,10098
@@ -74,7 +74,7 @@ nimare/tests/test_diagnostics.py,sha256=VrfR_8nQKn2VF7dFdnTM7ZQy3Ou5eHdpaLhml5T6
74
74
  nimare/tests/test_estimator_performance.py,sha256=tbK2Qr83rB0in-pB6MccnjLg4iHSyfilx-hTNDWQfe4,12749
75
75
  nimare/tests/test_extract.py,sha256=nPaL07G9paLRCJzPOv79jH3mhOPs2YvQdghoLfcDz5A,2348
76
76
  nimare/tests/test_generate.py,sha256=LSh2APJsg87u2s2zydkrre3RVk_ZGpoB4d7uuvIPWYE,7318
77
- nimare/tests/test_io.py,sha256=QKr_zRGu8tyrpiLoLAjCV9ektxCTHRlKPWgyJRqQ9T8,10397
77
+ nimare/tests/test_io.py,sha256=a4n9kMHx2wPIHsQZ1OoMkQq4y5dbhLqecUX3HOOzua8,13618
78
78
  nimare/tests/test_meta_ale.py,sha256=hccXSNzLGUgj6E4tCsiHZpuUFoBxXkP293-vtUS5jdE,11791
79
79
  nimare/tests/test_meta_cbmr.py,sha256=cl_pUA1dxXpDD5Ci_tllSVG0uKykuneHDbUxGY4w7Ks,9776
80
80
  nimare/tests/test_meta_ibma.py,sha256=Yw4F0_pr3cpVSe7oeMlK0-btg1Uw58cenklOsIw87Pc,7775
@@ -111,9 +111,9 @@ nimare/workflows/cbma.py,sha256=2jYJs9kH7_LzFP6d7-oTHiTTgAFbtmiBNtBXSCSZPjg,7052
111
111
  nimare/workflows/ibma.py,sha256=lAkWtqSqnZiUUV460Bh046U9LeGhnry3bl8BFi-tx7s,4289
112
112
  nimare/workflows/macm.py,sha256=mVUBeKbTawhU93ApnkunZSUXZWo7qBPrM3dMGWfl0ik,2531
113
113
  nimare/workflows/misc.py,sha256=OWgHlSAnRI0-5Seii-bd48piIYsfEAF_aNKGorH1yJQ,1827
114
- nimare-0.5.3rc1.dist-info/LICENSE,sha256=PWPXnCGWh-FMiBZ61OnQ2BHFjPPlJJ7F0kFx_ryzp-M,1074
115
- nimare-0.5.3rc1.dist-info/METADATA,sha256=ya3k7tn7Hqy8EiKhtPL5uDhoKRiUCHVL5SVFCdhOOpU,4706
116
- nimare-0.5.3rc1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
117
- nimare-0.5.3rc1.dist-info/entry_points.txt,sha256=3w_hk9N2PWnKZkCaJyDlc0_kdn3rh35aiI21rSdvsuA,44
118
- nimare-0.5.3rc1.dist-info/top_level.txt,sha256=XnOcEXMs0BxdI8t3_ksTl96T8hykn9L7-bxLLraVrTI,18
119
- nimare-0.5.3rc1.dist-info/RECORD,,
114
+ nimare-0.5.4rc1.dist-info/LICENSE,sha256=PWPXnCGWh-FMiBZ61OnQ2BHFjPPlJJ7F0kFx_ryzp-M,1074
115
+ nimare-0.5.4rc1.dist-info/METADATA,sha256=dNA3sh-eO-z8-eRLBP7_uNyosSa7mMZgqJfM4LFgogg,4706
116
+ nimare-0.5.4rc1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
117
+ nimare-0.5.4rc1.dist-info/entry_points.txt,sha256=3w_hk9N2PWnKZkCaJyDlc0_kdn3rh35aiI21rSdvsuA,44
118
+ nimare-0.5.4rc1.dist-info/top_level.txt,sha256=XnOcEXMs0BxdI8t3_ksTl96T8hykn9L7-bxLLraVrTI,18
119
+ nimare-0.5.4rc1.dist-info/RECORD,,