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

WARNING:nimare.utils:Argument <class 'nimare.meta.kernel.MKDAKernel'> has already been initialized, so arguments will be ignored: r, memory, memory_level #906

Closed
JohannesWiesner opened this issue Nov 14, 2024 · 3 comments · Fixed by #907
Assignees
Labels
bug Issues noting problems and PRs fixing those problems.

Comments

@JohannesWiesner
Copy link

Summary

I am getting this warning when initializing an instance of nimare.meta.kernel.MKDAKernel:

WARNING:nimare.utils:Argument <class 'nimare.meta.kernel.MKDAKernel'> has already been initialized, so arguments will be ignored: r, memory, memory_level

Additional details

  • NiMARE version: 0.4.0

What were you trying to do?

Follow the tutorial up to this point (I also provided a memory instance):

# emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
# ex: set sts=4 ts=4 sw=4 et:
"""

.. _metas5:

========================================================
 Run a meta-analytic coactivation modeling analysis
========================================================
Meta-analytic coactivation modeling (MACM) is a common coordinate-based
analysis in which task-independent "connectivity" is assessed by selecting
studies within a larger database based on locations of report coordinates.
"""
import os

import numpy as np
import nibabel as nib
from nilearn.image import load_img
from nilearn import plotting, image, datasets

import nimare
from nimare.tests.utils import get_test_data_path

###############################################################################
# Load Dataset
# --------------------------------------------------
# We will assume that the Neurosynth database has already been downloaded and
# converted to a NiMARE dataset.
dset_file = '/zi/home/johannes.wiesner/work/project_mase/data/neurosynth_dataset_with_abstracts.pkl.gz'
dset = nimare.dataset.Dataset.load(dset_file)

###############################################################################
# Define a region of interest
# --------------------------------------------------
# We'll use the right amygdala from the Harvard-Oxford atlas
atlas = datasets.fetch_atlas_harvard_oxford('sub-maxprob-thr50-2mm')

# FIXED THIS BECAUSE NIB GAVE AN ERROR
img = load_img(atlas['maps']) 

roi_idx = atlas['labels'].index('Right Amygdala')
img_vals = np.unique(img.get_fdata())
roi_val = img_vals[roi_idx]
roi_img = image.math_img('img1 == {}'.format(roi_val), img1=img)

###############################################################################
# Select studies with a reported coordinate in the ROI
# ----------------------------------------------------
roi_ids = dset.get_studies_by_mask(roi_img)
dset_sel = dset.slice(roi_ids)
print('{}/{} studies report at least one coordinate in the '
      'ROI'.format(len(roi_ids), len(dset.ids)))

###############################################################################
# Select studies with *no* reported coordinates in the ROI
# --------------------------------------------------------
no_roi_ids = list(set(dset.ids).difference(roi_ids))
dset_unsel = dset.slice(no_roi_ids)
print('{}/{} studies report zero coordinates in the '
      'ROI'.format(len(no_roi_ids), len(dset.ids)))


###############################################################################
# MKDA Chi2 with FWE correction
# --------------------------------------------------
mkda = nimare.meta.cbma.mkda.MKDAChi2(kernel__r=10)
mkda.fit(dset_sel, dset_unsel)
@JohannesWiesner JohannesWiesner added the bug Issues noting problems and PRs fixing those problems. label Nov 14, 2024
@JohannesWiesner
Copy link
Author

Can solve this by creating an instance of kernel = MKDAKernel() and passing this to MKDAChi2(kernel_transformer=kernel). But the docs of MKDAChi2 say:

Keyword arguments. Arguments for the kernel_transformer can be assigned here, with the prefix 'kernel__' in the variable name.

so this should actually not be necessary?

@jdkent
Copy link
Member

jdkent commented Nov 15, 2024

thank you for the report @JohannesWiesner!

I found the issue and have created a pull request in #907.

@jdkent
Copy link
Member

jdkent commented Nov 19, 2024

this is fixed and released in 0.4.1, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues noting problems and PRs fixing those problems.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants