Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] regular expression for no moderators #821

Merged
merged 187 commits into from Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
153584d
add cbmr.py file
yifan0330 Jun 16, 2022
59a3742
create a design matrix function for cbmr
yifan0330 Jun 18, 2022
3371a98
add test file for cbmr
yifan0330 Jun 18, 2022
8d2a151
modify pre-process and training function in cbmr
yifan0330 Jul 15, 2022
d014234
modify the dataset.anotations in cbmr
yifan0330 Jul 15, 2022
f741eeb
add documentation in utils functions
yifan0330 Jul 15, 2022
e326758
update model structure
yifan0330 Jul 16, 2022
85a6d11
update optimizer function
yifan0330 Jul 16, 2022
fe80124
[skip ci][wip] update loss function
yifan0330 Jul 17, 2022
3edaa74
update _fit function in CBMR
yifan0330 Jul 22, 2022
cadffa6
[wip][skip ci] allow other data types as pre-process inputs
yifan0330 Jul 27, 2022
c632d29
use a sparse array instead of numpy
yifan0330 Jul 28, 2022
a22048d
[skip ci][wip] allow for multiple-group cbmr
yifan0330 Jul 29, 2022
ab450fa
[skip ci][wip] fix conflict to merge
yifan0330 Jul 31, 2022
0f2a93a
solve conflicts
yifan0330 Jul 31, 2022
b3ee6f1
[skip CI][wip] modify settings in pre_process
yifan0330 Aug 1, 2022
0262c66
[skip ci][wip] implemented group-wise CBMR and fix problems
yifan0330 Aug 3, 2022
7fd47bc
[skip ci][wip] add results as inputs to MetaResults
yifan0330 Aug 5, 2022
b2b84a4
Merge branch 'main' of https://github.com/neurostuff/NiMARE into enha…
yifan0330 Aug 6, 2022
48d4b57
[skip ci][wip] modify standardization of group moderators
yifan0330 Aug 6, 2022
5e6107f
[skip ci][wip] implement NB regression
yifan0330 Aug 7, 2022
c686558
[skip ci][wip]remove vox2idx function and simplify the code
yifan0330 Aug 25, 2022
171d5a6
[skip ci][wip]develp CNB model
yifan0330 Aug 26, 2022
b786a3d
adjustment to Firth penalty
Sep 19, 2022
f7cc042
Merge branch 'main' of https://github.com/neurostuff/NiMARE into enha…
Sep 19, 2022
1a822d6
Merge branch 'main' of https://github.com/neurostuff/NiMARE into enha…
Sep 24, 2022
e051015
[skip CI][wip] implement index2voxel function
Sep 24, 2022
c38aa31
[skip CI][wip] add implementation for SE of regression coefficient
Sep 24, 2022
27a8c8e
[skip CI][WIP] implementing CBMRInference
Sep 29, 2022
c0da20d
[skip CI][wip] implement spatial homogeneity test
Sep 30, 2022
8be35d8
[skip ci][wip] implement CBMRInference group-wise comparison
Oct 7, 2022
8e73380
formalize GLH contrast variable
Oct 28, 2022
e6c1b92
[skip ci][wip] implemented Cov in GLH for all three models
Oct 30, 2022
988c5b4
[skip CI][wip] add a demonstration for CBMREstimator & CBMRInference
Nov 6, 2022
a746b9a
Merge branch 'main' of https://github.com/neurostuff/NiMARE into enha…
Nov 20, 2022
f4cd61e
[skip CI][wip] modify example files for demonstrating CBMR
Nov 20, 2022
024797d
add documentation to functions.
Dec 2, 2022
7c1b8ad
solve some issues suggested by flake8
Dec 9, 2022
9882c51
[skip CI][WIP] fix a bug in log-likelihood function of CNB model
Dec 21, 2022
b0a5e2d
Merge branch 'enhance_cbmr' of github.com:yifan0330/NiMARE into yifan…
jdkent Dec 21, 2022
5824abb
Merge pull request #3 from jdkent/yifan/enhance_cbmr
yifan0330 Dec 21, 2022
f70e6ac
[skip CI][WIP] Update code according to comments
Jan 10, 2023
d103ceb
[skip CI][WIP] solve conflicts in code
Jan 10, 2023
7de6b78
restructure code
jdkent Jan 10, 2023
1253adb
[skip CI][WIP] replace variable name and remove study_level_moderators
Jan 11, 2023
e00a621
[skip CI][WIP] changed variables names to be more intuitive.
Jan 12, 2023
bd88e32
reorganize model classes to be partially initialized
jdkent Jan 12, 2023
f64ad48
[skip CI][WIP] set some params as attribute of CBMREstimator Class.
Jan 12, 2023
c5dfec6
restruct inference code to models
Jan 13, 2023
7a65550
add some code for overdispersion model class.
Jan 13, 2023
6b51276
change model to use optimizer
jdkent Jan 13, 2023
320a712
change model names
jdkent Jan 13, 2023
ea0ad27
refactor the optimizer functions into the model class
Jan 15, 2023
b55433d
create a fit method for models
jdkent Jan 16, 2023
b525887
resolve conflicts
jdkent Jan 16, 2023
a62f26c
add summary to model fit
Jan 16, 2023
2ec109f
function name suggestions
jdkent Jan 17, 2023
2f9ad20
make square_root an attribute
jdkent Jan 17, 2023
6e3f425
allow categorical variables in CBMR
Jan 19, 2023
dac6287
fix a bug
Jan 19, 2023
e1c801f
new changes on inference class
Jan 20, 2023
404ff61
solve conflict
Jan 22, 2023
e580951
restruct code in CBMRInference
Jan 24, 2023
5b19e4d
add documentation foor create_contrast function
Jan 26, 2023
ea73c72
add new steps: remove duplicate rows in contrast matrix
Jan 26, 2023
9c2e7aa
modify documentation and comments
Jan 26, 2023
02bc3fa
change function name to snake case
Jan 27, 2023
050d470
restruct code and remove repetition
Jan 28, 2023
a761b07
reconstruct code, remove repeated code
Jan 29, 2023
06629b8
correct testing cases of z_to_p function
Feb 1, 2023
17bd65e
add regular expression code to CBMRInference
Feb 1, 2023
3eb6432
[skip CI][WIP] update example file based on reconstructed code
Feb 11, 2023
e842394
[skip CI][WIP] Tried standardized categorical covariates
Feb 11, 2023
a07d359
Raise deprecation warnings with Python 3.6 and 3.7 (#754)
JulioAPeraza Jan 11, 2023
c87b134
[MAINT] Fix various errors due to major version changes in dependenci…
jdkent Jan 12, 2023
12ff95b
Remove "dataset" `return_type` option from kernel transformers (#752)
JulioAPeraza Jan 13, 2023
252ab43
[skip ci] Update CHANGELOG
jdkent Jan 13, 2023
cb3b1ac
Support nibabel 5.0.0 (#762)
JulioAPeraza Jan 31, 2023
d8918f6
Do not zero out one-tailed z-statistics for p-values > 0.5 (#693)
JulioAPeraza Feb 1, 2023
7a70ed3
Link to NeuroStars software support category instead of neuro questio…
tsalo Feb 6, 2023
6a986b2
Revert "Do not zero out one-tailed z-statistics for p-values > 0.5" (…
JulioAPeraza Feb 6, 2023
ea43cec
create a design matrix function for cbmr
yifan0330 Jun 18, 2022
dac143f
[skip CI][WIP] solve conflicts
Feb 11, 2023
2f14d55
update model structure
yifan0330 Jul 16, 2022
9d02762
use a sparse array instead of numpy
yifan0330 Jul 28, 2022
514166f
[skip CI][WIP] solve conflict
Feb 11, 2023
8e237a1
solve conflicts.
Feb 11, 2023
5b4df2c
[skip ci][wip] modify standardization of group moderators
yifan0330 Aug 6, 2022
a4f67c0
[skip CI][wip] implement index2voxel function
Sep 24, 2022
b6d912b
[skip CI][wip] add implementation for SE of regression coefficient
Sep 24, 2022
01aab8b
[skip CI][wip] add a demonstration for CBMREstimator & CBMRInference
Nov 6, 2022
5f732ab
[skip CI][WIP] fix a bug in log-likelihood function of CNB model
Dec 21, 2022
f745b63
[skip CI][WIP] Update code according to comments
Jan 10, 2023
2f10a96
refactor the optimizer functions into the model class
Jan 15, 2023
59432d9
create a fit method for models
jdkent Jan 16, 2023
02c9c69
allow categorical variables in CBMR
Jan 19, 2023
116c8c2
restruct code in CBMRInference
Jan 24, 2023
1913f60
[skip CI][WIP] update example file based on reconstructed code
Feb 11, 2023
18bafd3
solve conflict
Feb 11, 2023
aa773d5
[skip CI][WIP] solve conflicts
Feb 12, 2023
8000f1c
solve conflicts
Feb 12, 2023
6390ce0
[skip CI][WIP] work on example file
Feb 17, 2023
b20dd74
[skip CI][WIP] complete example file for cbmr.
Feb 20, 2023
d82d485
[skip CI][WIP] implement an option to specify the reference subtype f…
Feb 25, 2023
c73bdbb
[skip CI][WIP] rewrite cbmr example in py file.
Feb 27, 2023
c0049e0
[skip CI][WIP] modify corrector class to be consistent with cbmr outputs
Mar 12, 2023
650cda4
[skip CI][WIP] add FDR/FWE correction methods to test
Mar 14, 2023
9904123
add testing cases with more coverage for CBMREstimator
Mar 19, 2023
f517b9f
[skip CI] [WIP] added new changes
Mar 20, 2023
e9f2cae
run black and isort
jdkent Mar 20, 2023
8efc82a
wip: working through refactor
jdkent Mar 24, 2023
15df47c
more refactor
jdkent Mar 24, 2023
2f68a02
merge with main
jdkent Mar 24, 2023
45004c7
remove debug info
jdkent Mar 24, 2023
88ecc31
fix errors
jdkent Mar 24, 2023
d90b73e
test firth penalty
jdkent Mar 26, 2023
5fd2402
black formating
jdkent Mar 26, 2023
addd0ba
more formatting
jdkent Mar 26, 2023
618a2ee
remove peaks2maps
jdkent Mar 26, 2023
d3d813f
remove redundant def
jdkent Mar 26, 2023
7d477d2
change documentation line
jdkent Mar 26, 2023
1fc008d
move patsy into function
jdkent Mar 26, 2023
448f376
add necessary installs
jdkent Mar 26, 2023
13b90f9
update example notebook with api
jdkent Mar 26, 2023
5ac3b0c
increase spacing and tolerance
jdkent Mar 26, 2023
2aa0906
fix estimator name
jdkent Mar 26, 2023
1645c40
sync utils with main
jdkent Mar 26, 2023
0b453f6
update to main on z_to_p test
jdkent Mar 26, 2023
f605cd1
remove conperm workflow
jdkent Mar 26, 2023
5446f44
remove whitespace
jdkent Mar 26, 2023
45f2ee6
fix some errors
jdkent Mar 26, 2023
30e34e2
make explicit where to document
jdkent Mar 26, 2023
f26282e
make StandardizeField a transformer
jdkent Mar 26, 2023
ba12a80
add functorch for python 3.6
jdkent Mar 27, 2023
38fb4e5
try to use older version of functorch
jdkent Mar 27, 2023
2307161
loosen restriction
jdkent Mar 27, 2023
d386573
fix bugs in cbmr example file
Apr 1, 2023
52f830b
[skip CI][WIP] fix bugs in testing function for cbmr_update
Apr 1, 2023
2b56139
add documentation for models.py
Apr 2, 2023
69f1b87
add documentation for cbmr.py
Apr 2, 2023
18ae03f
add documentation for utils.py
Apr 3, 2023
02db35c
add description for CBMREstimator
Apr 3, 2023
42e12cd
change lr to a smaller value
Apr 3, 2023
2643ecb
edit description function and add reference.
Apr 3, 2023
109897f
check if result.__description is a string.
Apr 3, 2023
1dd2299
resolve merge conflict
Apr 6, 2023
0f46781
set random seed
Apr 6, 2023
f4d4b49
simplify the log-likelihood function of NB model
Apr 7, 2023
383dc22
simplify the log-likelihood function of NB model
Apr 7, 2023
1171c30
implement wald test for CBMRInference
Apr 9, 2023
7529a6f
edit testing function for cbmr
Apr 9, 2023
0696e05
edit testing function for correctors
Apr 9, 2023
1f47e5f
fix linting error
Apr 10, 2023
5651c07
fix linting error
Apr 10, 2023
7be1632
fix linting error
Apr 10, 2023
395dae2
fixed linting error
Apr 10, 2023
c938ec3
fix linting error
Apr 10, 2023
931d2c1
fix linting error
Apr 10, 2023
73fe525
fix linting error
Apr 10, 2023
3745624
fix linting error
Apr 10, 2023
da7577b
fix linting error
Apr 10, 2023
6e79adc
fix linting error
Apr 10, 2023
2b8827a
remove unused test datasets
Apr 27, 2023
da2fbe2
fix linter error
Apr 27, 2023
c288695
add cbmr to docs/api.rst
Apr 27, 2023
cabdfce
edit example file for cbmr
Apr 27, 2023
e7bc4c1
remove the standardize_field function as it's replicated in the Stand…
Apr 29, 2023
ab751a5
use pass instead of return in the abstract methods
Apr 29, 2023
a95e116
added a test for StandardizeField class.
Apr 29, 2023
4705c47
edit example file of cbmr methods.
Apr 29, 2023
d48cd41
fix linter error.
Apr 29, 2023
677e6a5
fix a linter error.
Apr 29, 2023
d3487f5
fix a linter error
Apr 29, 2023
6a7b4c9
fix merge
jdkent May 3, 2023
93cff60
fix names of notebooks
jdkent May 3, 2023
4bbe51e
remove functorch (it was absorbed into torch)
jdkent May 3, 2023
8e34a5c
[skip ci] merge
jdkent May 3, 2023
b36ef7d
fix math mode and links in cbmr example.
May 18, 2023
5ab8a2b
fix math mode
May 18, 2023
f882778
include default.yml as part of nimare package
jdkent Jun 12, 2023
875e1a0
Merge branch 'main' of github.com:neurostuff/NiMARE into main
jdkent Jul 20, 2023
c442bda
add a test with none moderator variable for CBMRInference
yifan0330 Jul 20, 2023
7c3860c
merge yifan
jdkent Jul 20, 2023
20e8908
add a separate test for moderators=None
yifan0330 Jul 20, 2023
9be5278
Merge branch 'fix_cbmr' of github.com:yifan0330/NiMARE into fix/regul…
jdkent Jul 21, 2023
a3c7a9e
fix none moderators
jdkent Jul 21, 2023
1938f8b
add file back in from main
jdkent Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions nimare/meta/cbmr.py
Expand Up @@ -513,11 +513,14 @@ def create_regular_expressions(self):
operator = "(\\ ?(?P<operator>[+-]?)\\ ??)"
for attr in ["groups", "moderators"]:
groups = getattr(self, attr)
first_group, second_group = [
f"(?P<{order}>{'|'.join([re.escape(g) for g in groups])})"
for order in ["first", "second"]
]
reg_expr = re.compile(first_group + "(" + operator + second_group + "?)")
if groups:
first_group, second_group = [
f"(?P<{order}>{'|'.join([re.escape(g) for g in groups])})"
for order in ["first", "second"]
]
reg_expr = re.compile(first_group + "(" + operator + second_group + "?)")
else:
reg_expr = None

setattr(self, "{}_regular_expression".format(attr), reg_expr)

Expand Down
36 changes: 34 additions & 2 deletions nimare/tests/test_meta_cbmr.py
Expand Up @@ -39,7 +39,7 @@ def cbmr_result(testdata_cbmr_simulated, model):
cbmr = CBMREstimator(
group_categories=["diagnosis", "drug_status"],
moderators=["standardized_sample_sizes", "standardized_avg_age", "schizophrenia_subtype"],
spline_spacing=200,
spline_spacing=100,
model=model,
penalty=False,
lr=1e-2,
Expand All @@ -56,7 +56,7 @@ def cbmr_result(testdata_cbmr_simulated, model):
@pytest.fixture(scope="session")
def inference_results(testdata_cbmr_simulated, cbmr_result):
"""Test inference results for CBMR estimator."""
inference = CBMRInference(device="cuda")
inference = CBMRInference(device="cpu")
inference.fit(cbmr_result)
t_con_groups = inference.create_contrast(
[
Expand Down Expand Up @@ -121,7 +121,39 @@ def test_firth_penalty(testdata_cbmr_simulated):
)
res = cbmr.fit(dataset=dset)
assert isinstance(res, nimare.results.MetaResult)


def test_moderators_none(testdata_cbmr_simulated):
"""Unit test for Firth penalty."""
dset = StandardizeField(fields=["sample_sizes", "avg_age", "schizophrenia_subtype"]).transform(
testdata_cbmr_simulated
)
cbmr = CBMREstimator(
group_categories=["diagnosis", "drug_status"],
moderators=None,
spline_spacing=100,
model=models.PoissonEstimator,
penalty=False,
lr=1e-2,
tol=1e7,
device="cpu",
)
res = cbmr.fit(dataset=dset)
assert isinstance(res, nimare.results.MetaResult)
inference = CBMRInference(device="cpu")
inference.fit(res)

t_con_groups = inference.create_contrast(
[
"DepressionYes",
],
source="groups",
)
inference_results = inference.transform(
t_con_groups=t_con_groups
)

assert isinstance(inference_results, nimare.results.MetaResult)

def test_CBMREstimator_update(testdata_cbmr_simulated):
"""Unit test for CBMR estimator update function."""
Expand Down