Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement caching for nimare.io.convert_neurosynth_to_dataset #826

Open
JohannesWiesner opened this issue Aug 21, 2023 · 2 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@JohannesWiesner
Copy link

Summary

It seems that nimare.io.convert_neurosnyth_to_dataset can take a while to finish. This makes it a little bit tedious when writing an analysis script because the user always has to wait for this function to finish until other analysis steps can be tried out. Maybe offering caching here (e.g. nimare.io.convert_neurosnyth_to_dataset(cache_dir='../path/to/cache/dir') would help?

@JohannesWiesner JohannesWiesner added the enhancement New feature or request label Aug 21, 2023
@JohannesWiesner
Copy link
Author

JohannesWiesner commented Aug 21, 2023

Right now, I simply wrap the whole function inside a cached wrapper function like such, which of course also works fine:

@memory.cache
def get_nimare_dataset(databases):
    
    ds = nimare.io.convert_neurosynth_to_dataset(
        coordinates_file=databases['coordinates'],
        metadata_file=databases['metadata'],
        annotations_files=databases['features']
        )

    return ds

Thought it would be a nice addon if this would be available out-of-the-box :)

@JulioAPeraza
Copy link
Collaborator

Thanks! That is a good suggestion.

I think we currently have a workaround to this. Most NiMARE's classes support save/load methods, which save the object as a pickle file, and load a pickle file as a NiMARE class.

Generally, the Neurosynth dataset is downloaded and converted into a NiMARE dataset object only once. The class could be saved with dset.save(dset_fn), keep it somewhere accessible, and load it with dset = nimare.dataset.Dataset.load(dset_fn) if it needs to be reused.

This is not as elegant as caching the function, but at least it reduces the overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants