I’m attempting to perform a meta-analysis with NiMARE (version 0.0.12
), where I’d like to find the voxels most often associated with the term “threat”, so p(voxel|threat)
. I have the following code to download the NeuroSynth dataset and subset it by the threat term:
if not os.path.isfile("{}/neurosynth_dataset_with_abstracts.pkl.gz".format(output_dir)):
print("Downloading Neurosynth dataset with abstracts included")
neurosynth_dset = nimare.extract.download_abstracts(neurosynth_dset, "myemail@edu")
neurosynth_dset.save(os.path.join(output_dir, "neurosynth_dataset_with_abstracts.pkl.gz"))
print("Splitting NeuroSynth dataset by appropriate term (threat)")
threat_ids = neurosynth_dset.get_studies_by_label("terms_abstract_tfidf__threat", label_threshold=0.001)
threat_neurosynth_dset = neurosynth_dset.slice(threat_ids)
I then attempted to build and fit my GCLDA model:
if not os.path.isfile("{}/gclda_threat_model.pkl.gz".format(output_dir)):
print("Building and training GCLDA model(s)")
print("")
counts_df = nimare.annotate.text.generate_counts(
threat_neurosynth_dset.texts,
text_column="abstract",
tfidf=False,
max_df=0.99,
min_df=0.01
)
# only select columns with "threat" in name
counts_df = counts_df[[x for x in counts_df.columns if "threat" in x]]
# treat all columns as "threat", single topic
counts_df = pd.DataFrame(counts_df.sum(axis=1))
counts_df.columns = ["threat"]
coordinates_df = threat_neurosynth_dset.coordinates
coordinates_df.index = coordinates_df["id"]
# model
threat_model = nimare.annotate.gclda.GCLDAModel(counts_df,
coordinates_df,
n_topics=1,
n_regions=2,
symmetric=True
)
# fit model
threat_model.fit(n_iters=1000, loglikely_freq=10)
This produces the error: TypeError: object of type 'numpy.float64' has no len()
. If however, I don’t sum the counts_df
dataframe across columns and specify n_topics
> 2, then the model runs to completion. My issue though, is that I’m essentially trying to use NiMARE to produce plots akin to NeuroSynth, like this. Is there a way for me to treat the “threat” term as a single topic and produce a map similiar to NeuroSynth?
Thanks for the assistance.