Python API to easily download stimuli and fMRI betas from Natural Scenes Dataset.
Project description
🧠🏞️ nsdget
nsdget: easily download and use the single trial betas 1.8mm and coco images from the Natural Scenes Dataset
Note: I'm not affiliated with Natural Scenes Dataset. I just wanted an easier and quicker way to download the data I needed from them (hence this package).
Shoutout to https://github.com/clane9/NSD-Flat/ since I reused some of the functions from there. Thank you!
Usage
To use the data, please fill out the NSD Data Access Agreement first. Then download the nsdget python package:
Install
uv add nsdget
or
pip install nsdget
Then, to download the betas for all 8 subjects and 73k coco images do
from nsdget import nsd_betas_images_trials, nsd_coco_image, nsd_single_trial_betas
df = nsd_betas_images_trials(save_to="./nsdata/") # 213k trials in a Pandas DataFrame
betas = nsd_single_trial_betas(df.iloc[0]) # first betas trial as Nifty Image
image = nsd_coco_image(df.iloc[0]) # first trial stimulus as COCO PIL Image
Example above ran in example.ipynb.
Note that download happens only once. After the first slow run, subsequent runs will be very fast.
If you want the betas in numpy, just convert from nibabel image to numpy like
nd_betas = betas.get_fdata()
If you want the COCO image in numpy just convert the PIL Image to numpy like
nd_image = np.asarray(image)
Development
Dev run
uv sync
make run
Deployment PyPi
uv sync
TOKEN=... make publish # insert your PyPi token where ...
References
- https://naturalscenesdataset.org/ (Allen, St-Yves, Wu, Breedlove, Prince, Dowdle, Nau, Caron, Pestilli, Charest, Hutchinson, Naselaris*, & Kay*. A massive 7T fMRI dataset to bridge cognitive neuroscience and artificial intelligence. Nature Neuroscience (2021).)
- https://cocodataset.org/#home
- https://github.com/clane9/NSD-Flat/blob/b6851300ea3778eae7e4dbb88a85d71ce18cb9a5/generate_dataset.py#L157
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nsdget-0.0.4.tar.gz.
File metadata
- Download URL: nsdget-0.0.4.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e24fb504cc3962eee7af7cf73959222f733f6c51ca4be73484c4eb37f7d91b61
|
|
| MD5 |
01a21f40577076b0956d32f641a670e3
|
|
| BLAKE2b-256 |
a471a1e45a87cad8176bb3c2e40cbe9796e333d90d5fa62a7185dfcec2029804
|
File details
Details for the file nsdget-0.0.4-py3-none-any.whl.
File metadata
- Download URL: nsdget-0.0.4-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d2c6d45bdced813cdde1e3dcc79d6807428deaffcd94afa2733631ea883b08f
|
|
| MD5 |
41ee4f26aec4e5b87164cefe9b2dd179
|
|
| BLAKE2b-256 |
717f453a0c7aff3e0675f3a24a9d6941cf4778243872692336d300ca08a870e8
|