Datasets:
File size: 5,360 Bytes
da29ee5 5e54a5b da29ee5 955f139 da29ee5 6185f75 da29ee5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | ---
pretty_name: SpatialBrain
language:
- en
license: other
task_categories:
- image-to-text
- feature-extraction
tags:
- fmri
- neuroscience
- brain-decoding
- spatial-reasoning
- coco
- multimodal
size_categories:
- 10K<n<100K
---
# SpatialBrain
SpatialBrain links 73,000 COCO natural images with spatial-semantic annotations and processed visual-cortex fMRI responses from eight Natural Scenes Dataset participants. It is intended for visual brain decoding, brain-image representation alignment, and spatial-relation modeling.
## Dataset Contents
- `coco_images_73k_224_float16.hdf5`: 73,000 images resized to 224 x 224 and stored as float16.
- `annotations.json`: COCO IDs, instances, bounding boxes, attributes, captions, absolute positions, and pairwise relations.
- `subject_to_COCO73k_ID.hdf5`: subject-specific stimulus-to-image mappings.
- `shared_COCO73k_ID.npy`: image IDs shared across participants.
- `subjXX/func1pt8mm/*_nsdgeneral_betas.hdf5`: trial-by-voxel beta matrices for the NSD general ROI.
- `subjXX/func1pt8mm/*_prf-visualrois_betas.hdf5`: trial-by-voxel beta matrices for pRF visual ROIs.
- `subjXX/func1pt8mm/*_brainmask_betas.hdf5`: trial-by-voxel beta matrices for whole-brain ROIs.
The processed beta matrices are stored as float16 HDF5 datasets. Each row represents a stimulus trial and each column represents a selected voxel. The HDF5 files also contain trial, session, COCO image ID, mask, and voxel-index metadata. Convert beta arrays to float32 at load time when required by a model; this does not restore precision lost during float16 storage.
## Text Annotation Usage
`annotations.json` is a JSON array with one record per image. Use `COCO73kID` to join an annotation with the image array and with `coco73k_ids` in a subject's fMRI HDF5 file. `COCO2017ID` identifies the corresponding source image in COCO 2017.
Each record contains:
- `instances`: object category, `[x, y, width, height]` bounding box, and a short attribute phrase.
- `captions`: natural-language descriptions of the full image.
- `absolute_position`: the coarse image location and occupied grid cells for each instance.
- `relative_position`: directed relations between two instances, identified by `subject_id` and `object_id`.
Instance IDs are zero-based indices into the record's `instances` list. Absolute `position` may be empty when no single coarse label is assigned. Relative relations include spatial terms such as `to the left of` as well as contextual terms such as `with`, `on`, `hold`, and `carry`.
```python
import json
import h5py
with open("annotations.json", encoding="utf-8") as f:
annotations = json.load(f)
# COCO73kID is the image-array index and the cross-modal join key.
by_id = {record["COCO73kID"]: record for record in annotations}
record = by_id[0]
print(record["captions"])
for item in record["absolute_position"]:
instance = record["instances"][item["instance_id"]]
print(instance["category"], item["position"], item["grids"])
for relation in record["relative_position"]:
subject = record["instances"][relation["subject_id"]]["category"]
obj = record["instances"][relation["object_id"]]["category"]
print(subject, relation["relation"], obj)
# Join one subject's fMRI trials to text annotations.
with h5py.File("subj01/func1pt8mm/subj01_nsdgeneral_betas.hdf5", "r") as f:
trial_coco_ids = f["coco73k_ids"][:]
first_trial_annotation = by_id[int(trial_coco_ids[0])]
```
Loading the full JSON file requires memory for all records. For memory-constrained workflows, use a streaming JSON parser or preprocess the file into an indexed format once.
## Minimal Loading Example
```python
import h5py
path = "subj01/func1pt8mm/subj01_nsdgeneral_betas.hdf5"
with h5py.File(path, "r") as f:
betas = f["betas"][:] # trial x voxel, float16
betas_fp32 = betas.astype("float32")
coco73k_ids = f["coco73k_ids"][:]
sessions = f["sessions"][:]
trials = f["trials"][:]
```
## Access and Use
The fMRI data originate from the Natural Scenes Dataset. Users must review and comply with the [NSD Terms and Conditions](https://cvnlab.slite.page/p/IB6BSeW_7o/Terms-and-Conditions) and complete the [NSD Data Access form](https://forms.gle/xue2bCdM9LaFNMeb7). COCO-derived images and annotations remain subject to the applicable COCO terms and source-image licenses. No additional license is granted by this repository.
The dataset contains human neuroimaging data. Use it only for research consistent with the original consent, ethics approvals, and applicable institutional requirements. Do not attempt participant re-identification.
## Citation
Please cite the Natural Scenes Dataset:
```bibtex
@article{allen2022massive,
title = {A massive 7T fMRI dataset to bridge cognitive neuroscience and artificial intelligence},
author = {Allen, Emily J. and St-Yves, Ghislain and Wu, Yihan and Breedlove, Jesse L. and Prince, Jacob S. and Dowdle, Logan T. and Nau, Matthias and Caron, Brad and Pestilli, Franco and Charest, Ian and Hutchinson, J. Benjamin and Naselaris, Thomas and Kay, Kendrick},
journal = {Nature Neuroscience},
volume = {25},
pages = {116--126},
year = {2022},
doi = {10.1038/s41593-021-00962-x}
}
```
When using COCO images or annotations, cite the relevant COCO publications as required by the original dataset.
|