Hi there,
I’m trying to replicate the image decoder feature from the Neurosynth web interface (which I understand is now outdated/deprecated?) using NiMARE (0.0.10rc2), to obtain correlations of my image of interest with terms in the Neurosynth database.
I’ve followed the instructions in the NiMARE docs for downloading the Neurosynth database, and attempted to use nimare.decode.continuous.CorrelationDecoder as follows:
import os
import nimare
out_dir = os.path.abspath("nimare_ns_data/")
files = nimare.extract.fetch_neurosynth(path=out_dir, version="7", overwrite=False, source="abstract", vocab="terms",)
neurosynth_db = files[0]
neurosynth_dset = nimare.io.convert_neurosynth_to_dataset(coordinates_file=neurosynth_db["coordinates"], metadata_file=neurosynth_db["metadata"], annotations_files=neurosynth_db["features"])
neurosynth_dset.save(os.path.join(out_dir, "neurosynth_dataset.pkl.gz"))
neurosynth_dset = nimare.extract.download_abstracts(neurosynth_dset, "alyssa.dai@mail.mcgill.ca")
neurosynth_dset.save(os.path.join(out_dir, "neurosynth_daaset_with_abstracts.pkl.gz"))
from nimare.decode import continuous
decoder = continuous.CorrelationDecoder(feature_group=None, features=None)
decoder.fit(neurosynth_dset)
decoder.transform("myimage.nii.gz")
However, at the decoder.fit line, I’m getting the following error:
Dataset created in /home/daialy/.nimare/temporary_files
ERROR:nimare.meta.kernel:transform failed, removing /home/daialy/.nimare/temporary_files/MKDAKernelds0tb3nh20210923T125916
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/daialy/anaconda3/lib/python3.8/site-packages/nimare/base.py", line 548, in fit
self._fit(dataset)
File "/home/daialy/anaconda3/lib/python3.8/site-packages/nimare/decode/continuous.py", line 185, in _fit
dataset = kernel_transformer.transform(dataset, return_type="dataset")
File "/home/daialy/anaconda3/lib/python3.8/site-packages/nimare/utils.py", line 473, in memmap_context
return function(self, *args, **kwargs)
File "/home/daialy/anaconda3/lib/python3.8/site-packages/nimare/meta/kernel.py", line 160, in transform
coordinates[["i", "j", "k"]] = mm2vox(coordinates[["x", "y", "z"]], mask.affine)
File "/home/daialy/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py", line 2935, in __setitem__
self._setitem_array(key, value)
File "/home/daialy/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py", line 2965, in _setitem_array
indexer = self.loc._get_listlike_indexer(
File "/home/daialy/anaconda3/lib/python3.8/site-packages/pandas/core/indexing.py", line 1552, in _get_listlike_indexer
self._validate_read_indexer(
File "/home/daialy/anaconda3/lib/python3.8/site-packages/pandas/core/indexing.py", line 1640, in _validate_read_indexer
raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Index(['i', 'j', 'k'], dtype='object')] are in the [columns]"
I’m having trouble finding info on this error in the context of NiMARE, so any advice on how to troubleshoot this would be much appreciated! I’m also not 100% certain if this is the right way to use the CorrelationDecoder with the Neurosynth data, so kindly let me know if there are any steps I missed.
Thanks!