• Stars
    star
    275
  • Rank 149,796 (Top 3 %)
  • Language
    Python
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Data and code for Shen, Horikawa, Majima, and Kamitani (2019) Deep image reconstruction from human brain activity. PLoS Comput. Biol. http://dx.doi.org/10.1371/journal.pcbi.1006633.

Deep Image Reconstruction

Note: This demo code works with Python 2 and Caffe. Example code for the reconstruction with Python 3 + PyTorch is available at brain-decoding-cookbook-public.

Data and demo code for Shen, Horikawa, Majima, and Kamitani (2019) Deep image reconstruction from human brain activity. PLOS Computational Biology. The preprint is availabe at bioRxiv (Shen et al., 2017, Deep image reconstruction from human brain activity).

Dataset

Code

Requirements

Usage

Preparation

  1. Download data files from figshare (see data/README.md).
  2. Download Caffe networks (see net/README.md).

DNN feature decoding from brain activity

You can skip the feature decoding from brain activity since we provide the decoded DNN features used in the original paper (see data/README.md).

We used the same methodology in our previous study for the DNN feature decoding (Horikawa & Kamitani, 2017, Generic decoding of seen and imagined objects using hierarchical visual features, Nat Commun.). The latest Python code for the DNN feature decoding is available at GitHub:KamitaniLab/brain-decoding-cookbook-public.

Image reconstruction from decoded CNN features

We provide seven scripts that reproduce main figures in the original paper.

  • 1_reconstruct_natural_image.py
    • Reconstructing natural images from the CNN features decoded from the brain with deep generator network (DGN); reproducing results in Figure 2.
  • 2_reconstruct_natural_image_without_DGN.py
    • Reconstructing natural images from CNN features decoded from the brain without deep generator network (DGN); reproducing results in Figure 3A.
  • 3_reconstruct_natural_image_different_combinations_of_CNN_layers.py
    • Reconstructing natural images from CNN features decoded from the brain with different combinations of CNN layers; reproducing results in Figure 4.
  • 4_reconstruct_shape_image.py
    • Reconstructing colored artificial shapes from CNN features decoded from the brain; reproducing results in Figure 6A.
  • 5_reconstruct_shape_image_different_ROI.py
    • Reconstructing colored artificial shapes from CNN features decoded from multiple visual areas in the brain; reproducing results in Figure 7A.
  • 6_reconstruct_alphabet_image.py
    • Reconstructing alphabetical letters shapes from CNN features decoded from the brain; reproducing results in Figure 6B.
  • 7_reconstruct_imagined_image.py
    • Reconstructing imagined image from CNN features decoded from the brain; reproducing results in Figure 8.

PyTorch implementation of the reconstruction is available at GitHub:KamitaniLab/brain-decoding-cookbook-public.

Notes

Enable back-propagation in the DNNs

In the demo code, we use pre-trained VGG19 and pre-trained deep generator network (DGN) (Dosovitskiy & Brox, 2016, Generating Images with Perceptual Similarity Metrics based on Deep Networks. arXiv.). To enable make back-propagation, the following line should be added to the prototxt files (the file describes the configuration of the DNN):

force_backward: true

Get DNN features before ReLU

In our study, we defined DNN features of conv layers or fc layers as the output immediately after the convolutional or fully-connected computation (i.e., before applying the Rectified-Linear-Unit (ReLU)). However, as default setting of the pre-trained DNNs, ReLU operation is an in-place computation, which will override the DNN features we need. To In order to use the DNN features before the ReLU operation, you need to modify the prototxt file as below (taking the VGG19 prototxt file as an example).

Original:

layers {
  bottom: "conv1_1"
  top: "conv1_1"
  name: "relu1_1"
  type: RELU
}

Modified:

layers {
  bottom: "conv1_1"
  top: "relu1_1"
  name: "relu1_1"
  type: RELU
}

More Repositories

1

GenericObjectDecoding

Demo code for Horikawa and Kamitani (2017) Generic decoding of seen and imagined objects using hierarchical visual features. Nat Commun https://www.nature.com/articles/ncomms15037.
MATLAB
150
star
2

HumanDreamDecoding

Codes used in "Neural decoding of visual imagery during sleep" by Horikawa et al (Science, 2013, http://science.sciencemag.org/content/340/6132/639.long)
C
38
star
3

bdpy

Python package for brain decoding analysis (BrainDecoderToolbox2 data format, machine learning analysis, functional MRI)
Python
35
star
4

icnn

iCNN: image reconstruction from CNN features
Python
34
star
5

VBCCA

Variational Bayesian Canonical Correlation Analysis
MATLAB
30
star
6

brain-decoding-cookbook-public

Jupyter Notebook
23
star
7

BrainDecoderToolbox2

Matlab library for brain decoding analysis (BrainDecoderToolbox2 data format, machine learning analysis, functional MRI)
MATLAB
22
star
8

slir

Python package for Sparse Linear Regression (SLiR)
Python
21
star
9

smlr

Python package for Sparse Multinomial Logistic Regression (SMLR)
Python
20
star
10

End2EndDeepImageReconstruction

Python
20
star
11

EmotionVideoNeuralRepresentation

Data and code for reproducing results of Horikawa, Cowen, Keltner, and Kamitani (2020) The neural representation of visually evoked emotion is high-dimensional, categorical, and distributed across transmodal brain regions. iScience (https://www.cell.com/iscience/fulltext/S2589-0042(20)30245-5).
MATLAB
19
star
12

InterIndividualDeepImageReconstruction

Python
17
star
13

BHscore

Jupyter Notebook
12
star
14

brain-decoding-datasets

Python API for datasets published from Kamitani Lab, Kyoto Univ and ATR.
Jupyter Notebook
10
star
15

SOLR

Matlab and Python code for sparse ordinal logistic regression (SOLR).
MATLAB
10
star
16

IllusionReconstruction

A reconstruction framework for materializing subjective experiences from brain signals
Python
8
star
17

PyFastL2LiR

Fast L2-normalized linear regression
Python
8
star
18

ist-group-seminar-kamitani

Jupyter Notebook
8
star
19

OpenData

Portal to open data from Kamitani Lab, Kyoto Univ. and ATR. https://kamitanilab.github.io/OpenData/
7
star
20

SoundReconstruction

Jupyter Notebook
5
star
21

JavaNeuroshareLib

Java Neuroshare Library
Java
4
star
22

dnn-feature-decoding

4
star
23

cnnpref

Python
3
star
24

BrainLinerDataConverter

Open source conversion libraries for the BrainLiner HDF5 data format.
Python
3
star
25

GOD_stimuli_annotations

To share captions of stimuli dataset
Jupyter Notebook
3
star
26

imageGeneration_MATLAB

Matlab functions to generate pattern images (sine grating, concentric sine, Gabor patch, and random dots) and draw basic figures (filled/frame oval/rectangle, line, and polygon)
MATLAB
3
star
27

BlurImageSharpening

MATLAB
2
star
28

spurious_reconstruction

Python
1
star
29

docker-images

Shell
1
star
30

BrainLinerDataFormat

Documentation and examples about the BrainLiner HDF5 data format.
1
star
31

PositionDecoding

Demo codes for our paper, "Position information encoded by population activity in hierarchical visual areas", http://eneuro.org/content/early/2017/03/23/ENEURO.0268-16.2017
MATLAB
1
star
32

NeuralCodeConverter

Neural code converter (original paper: Yamada K, Miyawaki Y, Kamitani Y (2015) "Inter-subject neural code converter for visual image representation". NeuroImage 113, 289-297. http://www.sciencedirect.com/science/article/pii/S1053811915002554)
MATLAB
1
star
33

InterSiteNeuralCodeConversion

Python
1
star