Browse Source

switched data format to HDF5 and updated readme

Tim Gollisch 2 years ago
parent
commit
e32f7afec6
6 changed files with 84 additions and 63 deletions
  1. 0 1
      DATA.mat
  2. 0 53
      Fig1_example.m
  3. 0 1
      ImageData.mat
  4. 27 8
      README.md
  5. 1 0
      responses2naturalimages.h5
  6. 56 0
      sample_code_for_Fig1.m

+ 0 - 1
DATA.mat

@@ -1 +0,0 @@
-/annex/objects/MD5-s12998820--751496f88d8abd67ecf9f726c705b0bc

+ 0 - 53
Fig1_example.m

@@ -1,53 +0,0 @@
-
-
-% load stimulus images
-% Natural images 1-300
-% Black image 301
-% Gray  image 302
-% While image 303
-load('ImageData.mat');
-imSize = 256; % 256x256 pixels
-
-% load Raster spikes and Receptive fields
-load('DATA.mat');
-
-% example cell and image in Fig.1
-CellID = 44;
-ImageID = 228;
-
-figure;
-set(gcf,'Position', [120 100 120+1000 100+850 ]);
-
-subplot(2,2,1)
-% Generate stimulus image
-buf = ImageData(:,ImageID);
-buf = reshape(buf,imSize,imSize);
-imagesc(buf);
-hold on;
-set(gca,'YDir','normal');
-colormap gray;
-caxis([-0.5 0.5])
-
-% Generate RF outline with 3 standard deviation
-RF = RF_parameter(CellID);
-i = zeros(2,1e3);
-for j=1:size(i,2)
-    alpha = 2*pi*(j-1)/(size(i,2)-1);
-    i(:,j) = 3*sqrtm(RF.sigma)*[cos(alpha);sin(alpha)]+RF.mu;
-end
-plot(i(1,:),i(2,:),'b','LineWidth',2);
-
-% Get Raster
-data = squeeze(Raster_data(CellID,:,:,:));
-Raster = squeeze(data(ImageID,:,:));
-
-% Get all the trials for this cell
-NTrial = nnz(sum(Raster,1));
-Raster = Raster(:,1:NTrial)';
-
-subplot(2,2,[2 4])
-imagesc(Raster)
-set(gca,'YDir','normal');
-xlabel('Time')
-ylabel('Trial')
-

+ 0 - 1
ImageData.mat

@@ -1 +0,0 @@
-/annex/objects/MD5-s27551004--8755bfa4bdcc12297aa45de5958aca47

+ 27 - 8
README.md

@@ -5,20 +5,39 @@ Contact: Tim Gollisch, Email: tim.gollisch@med.uni-goettingen.de, Website: https
 
 This repository contains the main data that was analyzed in the paper
 
-Liu JK, Gollisch T (2021) Simple Model for Encoding Natural Images by Retinal Ganglion Cells with Nonlinear Spatial Integration..
+Liu JK, Gollisch T (2021) Simple Model for Encoding Natural Images by Retinal Ganglion Cells with Nonlinear Spatial Integration.
 
-The data set contains multielectrode-array recordings of retinal ganglion cell spiking activity, measured in the isolated salamander retina. The stimulus was a sequnce of 300 natural images, plus 1 black image, 1 gray images and 1 white image. For details, please refer to the Methods section of the original paper.
+The data set contains multielectrode-array recordings of retinal ganglion cell spiking activity, measured in the isolated salamander retina. The stimulus was a sequnce of 300 natural images, plus 1 black screen (-100% contrast), 1 gray screen (0% contrast), and 1 white screen (+100% contrast). For details, please refer to the Methods section of the original paper.
 
-If you plan to use this data for a publication, please inform us about it and don't forget to cite the original paper as well as the source of the data (DOI XXX).
+If you plan to use this data for a publication, please inform us about it, and don't forget to cite the original paper as well as the source of the data (including the DOI).
 
 
 ### Structure of the data:
 
-ImageData.mat: 303 stimulus images with natural images [1:300], black image [301], gray image [302] and white image [303]
+The data are contained in a single HDF5 file (responses2naturalimages.h5). The file contains 4 HDF5 datasets:
 
-DATA.mat: there are two Matlab structured data with 156 cells. 
-1) Raster_data [N_cell, N_image, N_time, N_trial] is the binary raster spike variable for each cell [N_cell=156] and image [N_image=303] within a time window [N_time=300 ms] in each trial [N_trial=13]. 
-2) RF_parameter has the parameters of the receptive field (RF) for each cell fitted by a 2D Gaussian function.
+spikes: Spike data from 156 cells to the 303 images (300 natural, plus presentation of black, gray, and white) for 13 trials each of 300 ms (from image onset to 100 ms after image offset) at 1 ms resolution. The dataset contains a 156x303x13x300 4-dimensional binary matrix of zeros and ones, corresponding to "spike" ("1") or "no spike" ("0"). The dimensions of the matrix correspond to 156 cells times 303 images times 13 trials times 300 time bins. 
 
-Fig1_example.m: the example Matlab script to demonstrate the plot of the RF and raster under a stimulus image. By default, running this script gives the plot in Fig.B.
+In Python, the dataset can be read into a numpy array with:
+import numpy as np
+import h5py
+f = h5py.File('responses2naturalimages.h5', 'r')
+spikedata = np.array(f['spikes'])
 
+In Matlab, the dataset can be read into a matrix with:
+spikedata = h5read('responses2naturalimages.h5','/spikes');
+Note, though, that this will yield a 300x13x303x156 matrix with permuted dimensions because of how Matlab handles HDF5 datasets.
+
+The other datasets, described below, can be read in with equivalent statements.
+
+images: Pixel-wise contrast values of the applied 303 images. The dataset contains a 303x256x256 3-dimensional matrix (256x256x303 matrix when read in Matlab), specifying the contrast (with values between -1 and 1) at the 256x256 pixels for each of the 303 images. The matrix indices correspond to image number times x-coordinate (left to right) times y-corrdinate (bottom to top), with the first entries corresponding to the lower-left corner of the image.
+
+In Python, for example, after having read in the dataset, you can use the following to plot an image (here image number 228):
+import matplotlib.pyplot as plt
+plt.imshow( np.transpose(imagedata[227,:,:]), cmap='gray', vmin=-1, vmax=1, origin='lower' )
+
+mu: Center coordinates of 2D Gaussian fit to receptive fields. The dataset contains a 156x2 matrix (2x156 when read in Matlab), specifying the x and y coordinate of the receptive field center point in units of pixels on the images (with (0,0) corresponding to the lower-left point of the image).
+
+sigma: Covariance matrix of 2D Gaussian fit the receptive fields. The dataset contains a 156x2x2 matrix (2x2x156 when read in Matlab), specifiying the 2x2 covariance matrix of the receptive field for each cell. Units are the same as for mu.
+
+In "sample_code_for_Fig1.m", we provide a sample Matlab script, which shows how to read the data in Matlab, extract spike times of multiple trials for a given image, and plot the image together with the receptive field outline. This reproduces part of Figure 1 of the accompanying paper.

+ 1 - 0
responses2naturalimages.h5

@@ -0,0 +1 @@
+/annex/objects/MD5-s31234717--ab2556d7552286e41ac1831a7c0f91d4

+ 56 - 0
sample_code_for_Fig1.m

@@ -0,0 +1,56 @@
+% Load images (n=303)
+% Natural images: 1-300
+% Black: image 301
+% Gray:  image 302
+% White: image 303
+imagedata = h5read('responses2naturalimages.h5','/images');
+
+% Load spike rasters and receptive field information
+spikedata = h5read('responses2naturalimages.h5','/spikes');
+mudata = h5read('responses2naturalimages.h5','/mu'); % Center coordinates
+sigmadata = h5read('responses2naturalimages.h5','/sigma'); % Sigma matrices (convariance matrices)
+
+% Prepare figure
+figure;
+set(gcf,'Position', [100 100 100+880 100+300]);
+
+% IDs for sample cell and image of Fig. 1 in manuscript
+CellID = 44;
+ImageID = 228;
+
+% Plot sample image
+subplot(1,2,1)
+thisimage = squeeze(imagedata(:,:,ImageID));
+imagesc(thisimage);
+hold on;
+set(gca,'YDir','normal');
+axis([0, 256, 0, 256] );
+axis equal;
+xlabel('Pixels')
+ylabel('Pixels')
+colormap gray;
+caxis([-1 1])
+
+% Plot RF outline at 3 sigma
+mu = mudata(:,CellID);
+sigma = sigmadata(:,:,CellID);
+i = zeros(2,1e3);
+for j=1:size(i,2)
+    alpha = 2*pi*(j-1)/(size(i,2)-1);
+    i(:,j) = 3*sqrtm(sigma)*[cos(alpha);sin(alpha)]+mu;
+end
+plot(i(1,:),i(2,:),'b','LineWidth',2);
+
+% Get spike rasters for sample cell and sample image
+data = squeeze(spikedata(:,:,:,CellID));
+Raster = squeeze(data(:,:,ImageID));
+
+% Get all the trials for this cell and image
+NTrial = nnz(sum(Raster,1));
+Raster = Raster(:,1:NTrial)';
+
+subplot(1,2,2)
+imagesc(Raster)
+set(gca,'YDir','normal');
+xlabel('Time [ms]')
+ylabel('Trial')