gclda.dataset.Dataset

class gclda.dataset.Dataset(dataset_label, data_directory, mask_file=None)[source]

Class object for a gcLDA dataset.

A Dataset contains data needed to run gcLDA models. It can also be used to view dataset information and can be saved to a pickled file.

Parameters:
dataset_label : str

The name of the gcLDA dataset. Also the name of a subfolder in data_directory containing four files (word_indices.txt, word_labels.txt, peak_indices.txt, and pmids.txt) with the data needed to create the dataset.

data_directory : str

The path to the folder containing the data. Should contain a subdirectory named after dataset_label with files needed to generate a Dataset.

mask_file : str, optional

A brain mask file used to define the voxels included in the dataset. If not provided, the mask file used by Neurosynth will be used by default.

Attributes:
dataset_label : str

The name of the dataset.

mask_img : nibabel.Nifti1Image

A nifti object of the mask file.

word_labels : list of str

List of word-strings (wtoken_word_idx values are indices into this list).

pmids : list of int

List of PubMed IDs (i.e., studies) in dataset.

wtoken_doc_idx : list of int

List of document-indices for word-tokens.

wtoken_word_idx : list of int

List of word-indices for word-tokens.

ptoken_doc_idx : list of int

List of document-indices for peak-tokens x.

peak_vals : numpy.ndarray of int

A focus-x-3 array of X, Y, and Z coordinates of foci in dataset in stereotactic (generally MNI152) space.

Methods

display_dataset_summary() View dataset summary.
load(filename) Load a pickled Dataset instance from file.
save(filename) Pickle the Dataset instance to the provided file.
view_doc_labels([n_pmids]) View first n_pmids PMIDs in dataset.
view_peak_indices([n_peak_indices]) View first n_peak_indices peak indices.
view_word_indices([n_word_indices]) View first n_word_indices word indices.
view_word_labels([n_word_labels]) View first n_word_labels words in dataset.
next  
__init__(dataset_label, data_directory, mask_file=None)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

display_dataset_summary()[source]

View dataset summary.

classmethod load(filename)[source]

Load a pickled Dataset instance from file. If the filename ends with ‘z’, it will be assumed that the file is compressed, and gzip will be used to load it. Otherwise, it will be assumed that the file is not compressed.

Parameters:
filename : str

File with saved Dataset instance.

Returns:
dataset : gclda.dataset.Dataset

Loaded Dataset instance.

save(filename)[source]

Pickle the Dataset instance to the provided file. If the filename ends with ‘z’, gzip will be used to write out a compressed file. Otherwise, an uncompressed file will be created.

Parameters:
filename : str

Where to save Dataset instance.

view_doc_labels(n_pmids=1000)[source]

View first n_pmids PMIDs in dataset.

view_peak_indices(n_peak_indices=100)[source]

View first n_peak_indices peak indices.

view_word_indices(n_word_indices=100)[source]

View first n_word_indices word indices.

view_word_labels(n_word_labels=1000)[source]

View first n_word_labels words in dataset.