Skip to content

Commit

Permalink
[MAINT] use updated black (#876)
Browse files Browse the repository at this point in the history
use updated black
  • Loading branch information
jdkent committed Feb 2, 2024
1 parent f182bbd commit 4b33efe
Show file tree
Hide file tree
Showing 64 changed files with 107 additions and 45 deletions.
1 change: 1 addition & 0 deletions nimare/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NiMARE: Neuroimaging Meta-Analysis Research Environment."""

import logging
import warnings

Expand Down
1 change: 1 addition & 0 deletions nimare/annotate/cogat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Automated annotation of Cognitive Atlas labels."""

import logging
import re

Expand Down
1 change: 1 addition & 0 deletions nimare/annotate/gclda.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Topic modeling with generalized correspondence latent Dirichlet allocation."""

import logging
import os.path as op

Expand Down
1 change: 1 addition & 0 deletions nimare/annotate/lda.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Topic modeling with latent Dirichlet allocation."""

import numpy as np
import pandas as pd
from sklearn.decomposition import LatentDirichletAllocation
Expand Down
1 change: 1 addition & 0 deletions nimare/annotate/text.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Text extraction tools."""

import logging
import os.path as op

Expand Down
1 change: 1 addition & 0 deletions nimare/annotate/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for ontology tools."""

import numpy as np
import pandas as pd

Expand Down
1 change: 1 addition & 0 deletions nimare/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base classes for NiMARE."""

import gzip
import inspect
import logging
Expand Down
1 change: 1 addition & 0 deletions nimare/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command-line interfaces for common workflows."""

import argparse
import os.path as op

Expand Down
7 changes: 4 additions & 3 deletions nimare/correct.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Multiple comparisons correction methods."""

import inspect
import logging
from abc import abstractproperty
Expand Down Expand Up @@ -142,9 +143,9 @@ def inspect(cls, result):
duplicate_methods = list(set(corr_methods) & set(est_methods))
for duplicate_method in duplicate_methods:
if duplicate_method in corr_methods:
corr_methods[
corr_methods.index(duplicate_method)
] = f"{duplicate_method} (overridden)"
corr_methods[corr_methods.index(duplicate_method)] = (
f"{duplicate_method} (overridden)"
)

LGR.info(
f"Available non-specific methods: {', '.join(corr_methods)}\n"
Expand Down
1 change: 1 addition & 0 deletions nimare/dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Classes for representing datasets of images and/or coordinates."""

import copy
import inspect
import json
Expand Down
1 change: 1 addition & 0 deletions nimare/decode/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base classes for the decode module."""

import logging
from abc import abstractmethod

Expand Down
1 change: 1 addition & 0 deletions nimare/decode/continuous.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Methods for decoding unthresholded brain maps into text."""

import inspect
import logging
import os
Expand Down
1 change: 1 addition & 0 deletions nimare/decode/discrete.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Methods for decoding subsets of voxels or experiments into text."""

import numpy as np
import pandas as pd
from nilearn._utils import load_niimg
Expand Down
1 change: 1 addition & 0 deletions nimare/decode/encode.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Methods for encoding text into brain maps."""

import numpy as np
from nilearn.masking import unmask
from sklearn.feature_extraction.text import CountVectorizer
Expand Down
1 change: 1 addition & 0 deletions nimare/decode/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for decoding/encoding."""

import numpy as np


Expand Down
9 changes: 6 additions & 3 deletions nimare/diagnostics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Methods for diagnosing problems in meta-analytic datasets or analyses."""

import copy
import logging
from abc import abstractmethod
Expand Down Expand Up @@ -154,9 +155,11 @@ def transform(self, result):
clusters_table = clusters_table.astype({"Cluster ID": "str"})
# Rename the clusters_table cluster IDs to match the contribution table columns
clusters_table["Cluster ID"] = [
f"{POSTAIL_LBL} {row['Cluster ID']}"
if row["Peak Stat"] > 0
else f"{NEGTAIL_LBL} {row['Cluster ID']}"
(
f"{POSTAIL_LBL} {row['Cluster ID']}"
if row["Peak Stat"] > 0
else f"{NEGTAIL_LBL} {row['Cluster ID']}"
)
for _, row in clusters_table.iterrows()
]

Expand Down
1 change: 1 addition & 0 deletions nimare/estimator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base class for estimators."""

from abc import abstractmethod

from joblib import Memory
Expand Down
1 change: 1 addition & 0 deletions nimare/extract/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Dataset and trained model downloading functions."""

from . import utils
from .extract import (
download_abstracts,
Expand Down
1 change: 1 addition & 0 deletions nimare/extract/extract.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tools for downloading datasets."""

import itertools
import json
import logging
Expand Down
1 change: 1 addition & 0 deletions nimare/extract/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for the extract module."""

from __future__ import division

import logging
Expand Down
1 change: 1 addition & 0 deletions nimare/generate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for generating data for testing."""

from itertools import zip_longest

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions nimare/io.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Input/Output operations."""

import json
import logging
import re
Expand Down
1 change: 1 addition & 0 deletions nimare/meta/cbma/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Coordinate-based meta-analytic estimators."""

from .ale import ALE, SCALE, ALESubtraction
from .mkda import KDA, MKDAChi2, MKDADensity

Expand Down
1 change: 1 addition & 0 deletions nimare/meta/cbma/ale.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CBMA methods from the activation likelihood estimation (ALE) family."""

import logging

import numpy as np
Expand Down
13 changes: 7 additions & 6 deletions nimare/meta/cbma/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CBMA methods from the ALE and MKDA families."""

import logging
from abc import abstractmethod

Expand Down Expand Up @@ -523,9 +524,9 @@ def _compute_null_montecarlo(self, n_iters, n_cores):
for perm in fwe_voxel_max:
histweights[perm] += 1

self.null_distributions_[
"histweights_level-voxel_corr-fwe_method-montecarlo"
] = histweights
self.null_distributions_["histweights_level-voxel_corr-fwe_method-montecarlo"] = (
histweights
)

def _correct_fwe_montecarlo_permutation(
self,
Expand Down Expand Up @@ -793,9 +794,9 @@ def correct_fwe_montecarlo(
# Voxel-level FWE
LGR.info("Using null distribution for voxel-level FWE correction.")
p_vfwe_values = null_to_p(stat_values, fwe_voxel_max, tail="upper")
self.null_distributions_[
"values_level-voxel_corr-fwe_method-montecarlo"
] = fwe_voxel_max
self.null_distributions_["values_level-voxel_corr-fwe_method-montecarlo"] = (
fwe_voxel_max
)

z_vfwe_values = p_to_z(p_vfwe_values, tail="one")
logp_vfwe_values = -np.log10(p_vfwe_values)
Expand Down
13 changes: 7 additions & 6 deletions nimare/meta/cbma/mkda.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CBMA methods from the multilevel kernel density analysis (MKDA) family."""

import logging

import nibabel as nib
Expand Down Expand Up @@ -884,9 +885,9 @@ def correct_fwe_montecarlo(self, result, voxel_thresh=0.001, n_iters=1000, n_cor
cmfwe_null=pAgF_cmfwe_null,
)

self.null_distributions_[
"values_desc-pAgF_level-voxel_corr-fwe_method-montecarlo"
] = pAgF_vfwe_null
self.null_distributions_["values_desc-pAgF_level-voxel_corr-fwe_method-montecarlo"] = (
pAgF_vfwe_null
)
self.null_distributions_[
"values_desc-pAgFsize_level-cluster_corr-fwe_method-montecarlo"
] = pAgF_csfwe_null
Expand All @@ -905,9 +906,9 @@ def correct_fwe_montecarlo(self, result, voxel_thresh=0.001, n_iters=1000, n_cor
cmfwe_null=pFgA_cmfwe_null,
)

self.null_distributions_[
"values_desc-pFgA_level-voxel_corr-fwe_method-montecarlo"
] = pFgA_vfwe_null
self.null_distributions_["values_desc-pFgA_level-voxel_corr-fwe_method-montecarlo"] = (
pFgA_vfwe_null
)
self.null_distributions_[
"values_desc-pFgAsize_level-cluster_corr-fwe_method-montecarlo"
] = pFgA_csfwe_null
Expand Down
30 changes: 15 additions & 15 deletions nimare/meta/cbmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,12 +835,12 @@ def _glh_con_group(self):
self.result.maps[
f"chiSquare_group-{self.t_con_groups_name[con_group_count]}"
] = chi_sq_spatial
self.result.maps[
f"p_group-{self.t_con_groups_name[con_group_count]}"
] = p_vals_spatial
self.result.maps[
f"z_group-{self.t_con_groups_name[con_group_count]}"
] = z_stats_spatial
self.result.maps[f"p_group-{self.t_con_groups_name[con_group_count]}"] = (
p_vals_spatial
)
self.result.maps[f"z_group-{self.t_con_groups_name[con_group_count]}"] = (
z_stats_spatial
)
else:
if m > 1: # GLH tests (with multiple contrasts)
self.result.maps[f"chiSquare_GLH_groups_{con_group_count}"] = chi_sq_spatial
Expand Down Expand Up @@ -950,17 +950,17 @@ def _glh_con_moderator(self):
self.result.tables[
f"chi_square_{self.t_con_moderators_name[con_moderator_count]}"
] = pd.DataFrame(data=np.array(chi_sq_moderator), columns=["chi_square"])
self.result.tables[
f"p_{self.t_con_moderators_name[con_moderator_count]}"
] = pd.DataFrame(data=np.array(p_vals_moderator), columns=["p"])
self.result.tables[
f"z_{self.t_con_moderators_name[con_moderator_count]}"
] = pd.DataFrame(data=np.array(z_stats_moderator), columns=["z"])
self.result.tables[f"p_{self.t_con_moderators_name[con_moderator_count]}"] = (
pd.DataFrame(data=np.array(p_vals_moderator), columns=["p"])
)
self.result.tables[f"z_{self.t_con_moderators_name[con_moderator_count]}"] = (
pd.DataFrame(data=np.array(z_stats_moderator), columns=["z"])
)
else:
if m_con_moderator > 1:
self.result.tables[
f"chi_square_GLH_moderators_{con_moderator_count}"
] = pd.DataFrame(data=np.array(chi_sq_moderator), columns=["chi_square"])
self.result.tables[f"chi_square_GLH_moderators_{con_moderator_count}"] = (
pd.DataFrame(data=np.array(chi_sq_moderator), columns=["chi_square"])
)
self.result.tables[f"p_GLH_moderators_{con_moderator_count}"] = pd.DataFrame(
data=np.array(p_vals_moderator), columns=["p"]
)
Expand Down
9 changes: 6 additions & 3 deletions nimare/meta/ibma.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Image-based meta-analysis estimators."""

from __future__ import division

import logging
Expand Down Expand Up @@ -102,9 +103,11 @@ def _preprocess_input(self, dataset):
if type_ == "image":
# Resampling will only occur if shape/affines are different
imgs = [
nib.load(img)
if _check_same_fov(nib.load(img), reference_masker=mask_img)
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
(
nib.load(img)
if _check_same_fov(nib.load(img), reference_masker=mask_img)
else resample_to_img(nib.load(img), mask_img, **self._resample_kwargs)
)
for img in self.inputs_[name]
]

Expand Down
1 change: 1 addition & 0 deletions nimare/meta/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
(Contrasts) from sets of foci and optional additional information (e.g., sample
size and test statistic values).
"""

from __future__ import division

import logging
Expand Down
14 changes: 5 additions & 9 deletions nimare/meta/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CBMR Models."""

import abc
import logging

Expand Down Expand Up @@ -290,9 +291,9 @@ def extract_optimized_params(self, coef_spline_bases, moderators_by_group):
group_spatial_intensity_estimation = np.exp(
np.matmul(coef_spline_bases, group_spatial_coef_linear_weight)
)
spatial_intensity_estimation[
"spatialIntensity_group-" + group
] = group_spatial_intensity_estimation
spatial_intensity_estimation["spatialIntensity_group-" + group] = (
group_spatial_intensity_estimation
)

# Extract optimized regression coefficient of study-level moderators from the model
if self.moderators_coef_dim:
Expand Down Expand Up @@ -913,12 +914,7 @@ def _log_likelihood_single_group(
).reshape((-1, 1))
mu_moderators = torch.exp(log_mu_moderators)
# parameter of a NB variable to approximate a sum of NB variables
r = (
1
/ group_overdispersion
* torch.sum(mu_moderators) ** 2
/ torch.sum(mu_moderators**2)
)
r = 1 / group_overdispersion * torch.sum(mu_moderators) ** 2 / torch.sum(mu_moderators**2)
p = 1 / (
1
+ torch.sum(mu_moderators)
Expand Down
1 change: 1 addition & 0 deletions nimare/meta/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for coordinate-based meta-analysis estimators."""

import warnings

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions nimare/reports/figures.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Plot figures for report."""

import matplotlib.colors as mcolors
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
Expand Down
1 change: 1 addition & 0 deletions nimare/results.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tools for managing meta-analytic results."""

import copy
import logging
import os
Expand Down
1 change: 1 addition & 0 deletions nimare/stats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Various statistical helper functions."""

import logging
import warnings

Expand Down
1 change: 1 addition & 0 deletions nimare/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generate fixtures for tests."""

import json
import os
from shutil import copyfile
Expand Down
1 change: 1 addition & 0 deletions nimare/tests/test_annotate_cogat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test nimare.annotate.cogat (Cognitive Atlas extraction methods)."""

import pandas as pd

from nimare import annotate, extract, utils
Expand Down
1 change: 1 addition & 0 deletions nimare/tests/test_annotate_gclda.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test nimare.annotate.gclda (GCLDA)."""

import nibabel as nib
import numpy as np
import pandas as pd
Expand Down
1 change: 1 addition & 0 deletions nimare/tests/test_annotate_lda.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test nimare.annotate.lda (LDA)."""

import numpy as np
import pandas as pd

Expand Down
1 change: 1 addition & 0 deletions nimare/tests/test_dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test nimare.dataset (Dataset IO/transformations)."""

import copy
import json
import os.path as op
Expand Down

0 comments on commit 4b33efe

Please sign in to comment.