gclda.dataset.import_neurosynth

gclda.dataset.import_neurosynth(neurosynth_dataset, dataset_label, out_dir='.', counts_file=None, abstracts_file=None, email=None, vocabulary=None)[source]

Transform Neurosynth’s data into gcLDA-compatible files.

This function produces four files (word_indices.txt, word_labels.txt, peak_indices.txt, and pmids.txt) in a specified folder (out_dir/dataset_label), using data from a Neurosynth dataset and associated abstracts. These four files are necessary for creating a Dataset instance and running gcLDA.

Parameters:
neurosynth_dataset : neurosynth.base.dataset.Dataset

A Neurosynth Dataset object containing data needed by gcLDA.

dataset_label : str

The name of the gcLDA dataset to be created. A folder will be created in out_dir named after the dataset and output files will be saved there.

out_dir : str, optional

Output directory. Parent folder of a new folder named after dataset_label where output files will be saved. By default, it uses the current directory.

counts_file : str, optional

A tab-delimited text file containing feature counts for the dataset. The first column is ‘pmid’, used for identifying articles. Other columns are features (e.g., unigrams and bigrams from Neurosynth), where each value is the number of times the feature is found in a given article. This file is different from the features.txt file provided by Neurosynth, as it should contain counts instead of tf-idf frequencies, but it should have the same format. Only one of counts_file, abstracts_file, and email needs to be specified.

abstracts_file : str, optional

A csv file containing abstracts of articles in the database. The first column is ‘pmid’, used for identifying articles. The second column is ‘abstract’ and contains the article’s abstract. The abstracts_file can be created using download_abstracts in the Neurosynth Python package. Only one of counts_file, abstracts_file, and email needs to be specified.

email : str, optional

A valid email address. If neither counts_file nor abstracts_file is provided, then import_neurosynth will attempt to download article abstracts using Neurosynth’s download_abstracts function. This calls PubMed to get PMIDs and abstracts, which requires an email address. Only one of counts_file, abstracts_file, and email needs to be specified.

vocabulary : list of str, optional

A list of terms to use as the vocabulary for a dataset. Only works if abstracts_file or email address is provided (but not if counts_file is used).