Coordinate-based meta-analysis reported that module 'numpy' has no attribute 'bool'

Summary of what happened:

Command used (and if a helper script was used, a link to the helper script or the command generated):

I run the following code:

meta = nimare.meta.cbma.ALE(null_method="approximate")
meta_results = meta.fit(pain_dset)

Version:

Environment (Docker, Singularity, custom installation):

Data formatted according to a validatable standard? Please provide the output of the validator:

Relevant log outputs (up to 20 lines):

get the error message:

AttributeError: module 'numpy' has no attribute 'bool'
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.
  mask_data = mask.get_fdata().astype(np.bool)
ERROR:nimare.meta.kernel:transform failed, removing None
ERROR:nimare.meta.cbma.base:_fit failed, removing None

Screenshots / relevant information:

Hi @Nan_Wang, and welcome to neurostars!

As far as I can tell, np.bool has been deprecated for a bit over a year. Perhaps nimare is expecting an earlier version of numpy? You can try changing the code to be mask_data = mask.get_fdata().astype(bool) or mask_data = mask.get_fdata().astype(np.bool_) and see if that works.

It would be good if you can confirm that you are on the most recent version of nimare and that you have the proper dependencies installed.

Also tagging @tsalo in case there is a fix that needs to be implemented in nimare.

Best,
Steven

Hi @Steven, thanks very much for your help!

I changed the code but it still didn’t work.

Also, my nimare comes from 2021 ohbm nimare tutorial, following this link: ohbm2021-nimare-tutorial/tutorial.ipynb at main · NanWang0221/ohbm2021-nimare-tutorial · GitHub
and to ensure I have the latest version, I run “pip install nimare” at the very beginning of the notebook. I also checked the libraries were all loaded. But I still got the same error message.

This is the original error message and I present it here again so you can compare the two

Hi @Nan_Wang,

I believe @jdkent just released version 0.0.13 of NiMARE, which should resolve the issue with numpy.

The mask @Steven was referring to is an internal variable in the NiMARE code, so you would need to access the NiMARE codebase to make that change (which you could definitely do if you have NiMARE cloned locally and installed in editable mode). However, it’s probably easier to install 0.0.13, and ensure your dependencies, such as numpy, are compatible with that version. pip should warn you if there’s a problem, when you install the new version of NiMARE.

@Steven thanks for pinging me.