Skip to content

Commit 44be522

Browse files
author
Yifan Yu
committed
Fix CBMR lint formatting
1 parent 4a3ab1c commit 44be522

2 files changed

Lines changed: 25 additions & 15 deletions

File tree

nimare/meta/cbmr.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from nimare import _version
2222
from nimare.estimator import Estimator
2323
from nimare.meta import models
24+
from nimare.meta.utils import fit_spatial_cbmr_approximate
2425
from nimare.results import MetaResult
2526
from nimare.utils import (
2627
DEFAULT_FLOAT_DTYPE,
@@ -34,7 +35,6 @@
3435
seed_torch,
3536
validate_coordinate_spaces,
3637
)
37-
from nimare.meta.utils import fit_spatial_cbmr_approximate
3838

3939
LGR = logging.getLogger(__name__)
4040
__version__ = _version.get_versions()["version"]
@@ -1095,8 +1095,13 @@ def __init__(
10951095
self.moderators = None
10961096

10971097
if self.moderator_effect == "global":
1098-
self._validate_global_pipeline_options(method, sandwich_meat, sandwich_correction, ridge)
1099-
else: # voxelwise
1098+
self._validate_global_pipeline_options(
1099+
method,
1100+
sandwich_meat,
1101+
sandwich_correction,
1102+
ridge,
1103+
)
1104+
else: # voxelwise
11001105
if method is None:
11011106
method = "sandwich"
11021107
self.method = self._validate_method(method)
@@ -1186,7 +1191,7 @@ def _reset_inference_caches(self):
11861191
self._moderator_covariance = None
11871192
self._moderator_variance = None
11881193
self._moderator_coef_table = None
1189-
else: # voxelwise
1194+
else: # voxelwise
11901195
self._group_covariance_cache = {}
11911196
self._group_coefficient_cache = {}
11921197

@@ -1196,7 +1201,7 @@ def _get_group_log_intensity(self, group):
11961201
if group_log_intensity is None:
11971202
if self.moderator_effect == "global":
11981203
group_log_intensity = np.log(self.result.maps[f"spatialIntensity_group-{group}"])
1199-
else: # voxelwise
1204+
else: # voxelwise
12001205
bases = self.estimator.inputs_["coef_spline_bases"]
12011206
coefficient = self._get_group_coefficient_matrix(group)
12021207
group_log_intensity = bases @ coefficient[-1]
@@ -1217,7 +1222,7 @@ def _get_group_null_log_intensity(self, group):
12171222
group_null_log_intensity = np.log(
12181223
np.sum(group_foci_per_voxel) / (n_voxels * n_experiments)
12191224
)
1220-
else: # voxelwise
1225+
else: # voxelwise
12211226
foci = self.estimator.inputs_["foci_by_experiment_voxel"][group]
12221227
total_foci = foci.sum()
12231228
n_experiments, n_voxels = foci.shape
@@ -1959,12 +1964,12 @@ def _store_moderator_inference_result(
19591964
self.result.maps[f"chiSquare_svModerator_{contrast_name}_group-{group}"] = (
19601965
moderator_stats["chi_square"]
19611966
)
1962-
self.result.maps[f"p_svModerator_{contrast_name}_group-{group}"] = (
1963-
moderator_stats["p"]
1964-
)
1965-
self.result.maps[f"z_svModerator_{contrast_name}_group-{group}"] = (
1966-
moderator_stats["z"]
1967-
)
1967+
self.result.maps[f"p_svModerator_{contrast_name}_group-{group}"] = moderator_stats[
1968+
"p"
1969+
]
1970+
self.result.maps[f"z_svModerator_{contrast_name}_group-{group}"] = moderator_stats[
1971+
"z"
1972+
]
19681973
else:
19691974
if moderator_stats["contrast_count"] > 1:
19701975
self.result.maps[
@@ -2327,4 +2332,3 @@ def _compute_spatial_coefficient_statistics(cls, coefficient, covariance, contra
23272332
"p": p_vals,
23282333
"z": z_stats,
23292334
}
2330-

nimare/tests/test_meta_cbmr.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,10 @@ def test_cbmr_mask_lookup_and_coordinate_filtering_use_mask_indices():
980980

981981
assert n_mask_voxels == 4
982982
assert filtered["id"].tolist() == ["kept-0", "kept-1"]
983-
expected_flat_indices = np.ravel_multi_index(np.array([[0, 1], [0, 1], [0, 0]]), mask_data.shape)
983+
expected_flat_indices = np.ravel_multi_index(
984+
np.array([[0, 1], [0, 1], [0, 0]]),
985+
mask_data.shape,
986+
)
984987
np.testing.assert_array_equal(
985988
filtered["_cbmr_mask_index"].to_numpy(),
986989
mask_lookup[expected_flat_indices],
@@ -997,7 +1000,10 @@ def test_cbmr_group_label_validation_and_multicolumn_formatting():
9971000
"drug_status": ["yes", "no"],
9981001
}
9991002
)
1000-
estimator = CBMREstimator(moderator_effect="global", group_categories=["diagnosis", "drug_status"])
1003+
estimator = CBMREstimator(
1004+
moderator_effect="global",
1005+
group_categories=["diagnosis", "drug_status"],
1006+
)
10011007

10021008
grouped = estimator._assign_group_labels(annotations.copy())
10031009

0 commit comments

Comments
 (0)