colored-CARL-Logo

 


CARLsim Documentation:
Matlab scripts

In order to easily analyze the simulation results, we provide a number of Matlab scripts, which can be found in the "scripts" directory within the CARLsim software pacakage.
However, please note that Matlab is not necessary to run the simulator. In general,any program can be used to analyze the simulation results. The Matlab scripts are provided for demonstration purposes and can easily be translated to the user's preferred analysis tool.
For a list C++ classes see Documentation.

^common
CARLsim ≥ 2.1

This folder contains a set of common Matlab scripts that can be used with any CARLsim setup or network.

^common:readFramesFromRgbFile.m
CARLsim ≥ 2.1

I = readFramesFromRgbFile( filename,dim,frames,plotIt,movieIt )

Reads stimulus frames from an RGB file that was created with common:writeFramesToRgbFile.m. The file data should be organized as img1R1 img1G1 img1B1 img1R2 img1G2 img1B2... img2R1 img2G1 img2B1 etc. in uchar format e[0,255].
Input arguments:

filename: filepath to RGB images, organized as R1 G1 B1 R2 G2 B2..., frame after frame.
dim: [nrRows nrCols]
frames: vector of all frames to read, or set to "-1" to read out all existing frames. Default: -1.
plotIt: set to true to plot each frame. Default: false.
movieIt: set to true to output frames to "./movie.avi". Default: false.
Output arguments:
I: All frames with values e[0,1] (required by imagesc() and the like)

^common:readNetwork.m
CARLsim ≥ 2.0

function [groups, preIDs, postIDs, weights, delays, plastic, maxWeights]
    = readNetwork(filename)

Reads the network state from file.
Input arguments:

filename: A network state file, created with CpuSNN::writeNetwork
Output arguments:
groups: array of size # groups, each element describing a group
preIDs: array of size # synapses, each element specifying the pre-synaptic group ID of this connection
postIDs: array of size # synapses, each element specifying the post-synaptic group ID of this connection
weights: array of size # synapses, each element specifying the weight of this connection
delays: array of size # synapses, each element specifying the delay of this connection
plastic: array of size # synapses, each element specifying whether this connection is plastic (value 1) or not (value 0)
maxWeights: array of size # synapses, each element specifying the maximum weight of this connection (for plastic connections, weights(i) is not necessarily the same as maxWeights(i))

^common:readSpikes.m
CARLsim ≥ 2.1

function spk = readSpikes( file, frameDur )

Reads CARLsim spike files, which are binary files in AER format (spike times (ms) followed by neuron ID, both uint32).
Input arguments:

file: A spike file, created with CpuSNN::setSpikeMonitor
frameDur: frame duration (ms). Output spk will contain the number of spikes a neuron emitted per frameDur. If frameDur is set to -1, spk will be returned in AER format [times;nIDs]. Default: 1000.
Output arguments:
spk: spike matrix [times,nIDs], 1-indexed.

^common:readSpikesAERtoFull.m
CARLsim ≥ 2.1

function spk = readSpikesAERtoFull( time,nIDs,frameDur,dim )

Converts a sparse AER representation of a spike file into full (expanded) matrix representation. time and nIDs can be created with common:readSpikes.m and frameDur set to -1.
Input arguments:

time: column vector of spike times
nIDs: column vector of corresponding neuron IDs
frameDur: frame duration (ms). Default: 1000
dim: [max limit of time,max limit of nIDs]. If omitted, these values are extracted from input parameters.
Output arguments:
spk: spike matrix [times,nIDs], 1-indexed.

^common:writeFramesToRgbFile.m
CARLsim ≥ 2.1

writeFramesToRgbFile( createFile,frames,appendIt )

Writes stimulus frames to an RGB file that can be read by the CARLsim example networks as well as common:readFramesFromRgbFile.m.

createFile: where to write the data. The data will be a string of uchar in order R1 G1 B1 R2 G2 B2 ... e[0,255]
frames: all image frames in standard RGB-format [dim1xdim2x3] as a cell-array
appendIt: if true, new data will be appended to createFile. Default: false.

^colorblind
CARLsim ≥ 2.0

The folder scripts/colorblind contains scripts to analyze the outputs of the colorblind experiment, as was part of the CARLsim 2.0 release.

^colorblind:colorblind.m
CARLsim ≥ 2.0

Script to analyze the results of the colorblind experiment. First, build and run the colorblind experiment (using, for example under Linux, make colorblind). This will store output files in Results/colorblind/, which are then read and visualized by this script.

^colorcycle
CARLsim ≥ 2.0

The folder scripts/colorcycle contains scripts to analyze the outputs of the RDK experiment, as was part of the CARLsim 2.0 release.

^colorcycle:colorcycle.m
CARLsim ≥ 2.0

Script to analyze the results of the colorcycle experiment. First, build and run the colorcycle experiment (using, for example under Linux, make colorcycle). This will store output files in Results/colorcycle/, which are then read and visualized by this script.

^orientation
CARLsim ≥ 2.0

The folder scripts/orientation contains scripts to analyze the outputs of the RDK experiment, as was part of the CARLsim 2.0 release.

^orientation:orientation.m
CARLsim ≥ 2.0

Script to analyze the results of the orientation experiment. First, build and run the orientation experiment (using, for example under Linux, make orientation). This will store output files in Results/orientation/, which are then read and visualized by this script.

^rdk
CARLsim ≥ 2.0

The folder scripts/rdk contains scripts to analyze the outputs of the RDK experiment, as was part of the CARLsim 2.0 release.

^rdk:rdk.m
CARLsim ≥ 2.0

Script to analyze the results of the RDK experiment. First, build and run the RDK experiment (using, for example under Linux, make rdk). This will store output files in Results/rdk/, which are then read and visualized by this script.

^v1MTLIP
CARLsim ≥ 2.1

The folder scripts/v1MTLIP/ contains scripts to analyze the cortical model of pattern motion selectiviy (consisting of simulated areas V1, MT, and LIP), which can be found in /examples/v1MTLIP in the CARLsim software package.

^v1MTLIP:makeBarSpeed.m
CARLsim ≥ 2.1

function [stim,whichStage] = makeBarSpeed(stimContrast, writeFile)

Creates the bar stimulus used in the speed tuning experiment. Results can be plotted using v1MTLIP:plotSpeed.m.
Input arguments:

stimContrast: stimulus contrast, e(0,1]. Default: 0.2.
writeFile: true|false, will write stim to file if set to true (using the function common:writeFramesToRgbFile.m). Default: false.
Output arguments:
stim: A cell array, each element is a number of frames, of dimension <nrX x nrY x nrT>, where nrT varies for each stage (a configuration given by bar direction, bar speed, and bar width).
whichStage: For each frame (for each element in stim), this vector stores a stage ID number. Find all frames that belong to stage ID 2? Simply do whichStage==2.

^v1MTLIP:makeGratingContrast.m
CARLsim ≥ 2.1

stim = makeGratingContrast(nrX, nrY, nrF, nPnts, direction, gratingSf,
          gratingTf)

Creates a sinusoidal grating stimulus with varying contrast. The stimulus is both returned and written to file, such that it can be plugged into CARLsim example model v1MTLIP. Use default parameter values to reproduce the stimulus used in CARLsim example v1MTLIP. The contrast sensitivity function can be plotted using v1MTLIP:plotGratingContrast.m.
Input arguments:

nrX: number of neurons in direction X
nrY: number of neurons in direction Y
nrF: number of frames per stimulus drift direction
nPnts: number of data points (samples 360deg drift direction)
direction: drift direction (radians)
gratingSf: spatial frequency component of the grating
gratingTf: temporal frequency component of the grating

Output argument:

stim: cell array of frames, each frame has dim nrX x nrY

^v1MTLIP:makeRDK.m
CARLsim ≥ 2.1

stim = makeRDK(nrX, nrY, nrF, nrTr, speed, density, delayPeriod)

Creates a random dot kinematogram (RDK) stimulus. The stimulus is both returned and written to file, such that it can be plugged into CARLsim example model v1MTLIP. Dots are drifting in random directions, with a given percentage of dots drifting coherently into the same direction ("coherence level"). Dots move at a given speed. A trial consists of a particular combination of coherence level and coherent drift direction (shown for nrF frames).Repeat trials nrTr times.
Use default parameter values to reproduce the stimulus used in CARLsim example v1MTLIP. The results can be plotted using v1MTLIP:plotRDKdecision.m.
Input arguments:

nrX: number of neurons in direction X
nrY: number of neurons in direction Y
nrF: number of frames per stimulus drift direction
nrTr: number of trials
speed: (coherent) drift velocity of the dots
density: dot density (number of dots per total number of pixels)
delayPeriod: adds silent frames between each trial (set to 0 to deactivate; else number of frames to activate)

Output argument:

stim: cell array of frames, each frame has dim nrX x nrY

^v1MTLIP:makeTuningGrating.m
CARLsim ≥ 2.1

stim = makeTuningGrating(nrX, nrY, nrF, nPnts, gratingContrast, 
                  gratingSf, gratingTf)

Creates a sinusoidal grating stimulus. The stimulus is both returned and written to file, such that it can be plugged into CARLsim example model v1MTLIP. Use default parameter values to reproduce the stimulus used in CARLsim example v1MTLIP.
Input arguments:

nrX: number of neurons in direction X
nrY: number of neurons in direction Y
nrF: number of frames per stimulus drift direction
nPnts: number of data points (samples 360deg drift direction)
gratingContrast: contrast of the plaid (between 0 and 1)
gratingSf: spatial frequency component of the grating
gratingTf: temporal frequency component of the grating

Output argument:

stim: cell array of frames, each frame has dim nrX x nrY

^v1MTLIP:makeTuningPlaid.m
CARLsim ≥ 2.1

stim = makeTuningPlaid(nrX, nrY, nrF, nPnts, plaidContrast, plaidAngle,
                  gratingSf, gratingTf)

creates a plaid stimulus consisting of two superimposed sinusoidal gratings. The stimulus is both returned and written to file, such that it can be plugged into CARLsim example model v1MTLIP. Use default parameter values to reproduce the stimulus used in CARLsim example v1MTLIP.
Input arguments:

nrX: number of neurons in direction X
nrY: number of neurons in direction Y
nrF: number of frames per stimulus drift direction
nPnts: number of data points (samples 360deg drift direction)
plaidContrast: contrast of the plaid (between 0 and 1)
plaidAngle: separating angle of the two gratings
gratingSf: spatial frequency component of the gratings
gratingTf: temporal frequency component of the gratings

Output argument:

stim: cell array of frames, each frame has dim nrX x nrY

^v1MTLIP:plotGratingContrast.m
CARLsim ≥ 2.1

[] = plotGratingContrast()

Produces the contrast sensitivity function of model V1 simple cells (blue), plotted against electrophysiological data from (Movshon & Newsome, 1996) (red). Each data point is a V1 mean response to a drifting grating, averaged over both one second of stimulus presentation and all neurons in the subpopulation. Vertical bars are the standard deviation on the population average.
A suitable stimulus can be created using makeGratingContrast.m.

^v1MTLIP:plotGratingPlaid.m
CARLsim ≥ 2.1

[] = plotGratingPlaid()

Generates polar plots of MT direction tuning for a sinusoidal grating and a plaid stimulus drifting upwards, where the angle in the polar plot denotes motion direction and the radius is the firing rate in spikes per second. A suitable stimulus can be created by using v1MTLIP:makeTuningGrating.m and v1MTLIP:makeTuningPlaid.m.

^v1MTLIP:plotGratingPlaidCorrelation.m
CARLsim ≥ 2.1

[] = plotGratingPlaidCorrelation()

Computes the pattern index for all MT CDS cells (blue open circles) and all MT PDS cells (red crosses), and plots them as a Fisher Z-score. The blue solid lines are the classification region boundaries, with a criterion of 1.28. A suitable stimulus can be created using v1MTLIP:makeTuningGrating.m and v1MTLIP:makeTuningPlaid.m.

^v1MTLIP:plotRDKdecision.m
CARLsim ≥ 2.1

[] = plotRDKdecision()

Plots the results of the random dot kinematogram (RDK) two-alternative forced-choice (2AFC) experiment. This script generates both the psychometric and the chronometric function. Simulation data are compared to psychophysical data from (Roitman & Shadlen, 2002).
The RDK stimulus was constructed out of approximately 150 dots (15 % dot density, maximum stimulus contrast) on a 32x32 input movie.
A suitable stimulus can be created using v1MTLIP:makeRDK.m.

^v1MTLIP:plotSpeed.m
CARLsim ≥ 2.1

[] = plotSpeed()

Plots MT CDS speed tuning curves. In this experiment, a single bar is drifting over the entire visual field either to the right (preferred direction) and left (anti-preferred) direction at different speeds. MT CDS cells are either "band-pass", "low-pass" or "high-pass" (Rodman & Albright, 1987). A suitable stimulus can be created using v1MTLIP:makeBarSpeed.m, which can then be plugged into the CARLsim example model v1MTLIP.

^v1MTLIP:projectV1toMT.m
CARLsim ≥ 2.1

[] = projectV1toMT()
Generates projection weights from V1 to MT, such that neurons in MT are selective to a particular speed. Prints all projection weights to console, which can be cut and pasted to the C++ network description file main_v1MTLIP.cpp.

^References

  • Movshon, J. A., and W. T. Newsome. 1996. "Visual response properties of striate cortical neurons projecting to area MT in macaque monkeys." Journal of Neuroscience no. 16 (23):7733-7741.
  • Rodman, H. R., and T. D. Albright. 1987. "Coding of Visual Stimulus Velocity in Area Mt of the Macaque." Vision Research no. 27 (12):2035-2048. doi: Doi 10.1016/0042-6989(87)90118-0.
  • Roitman, J. D., and M. N. Shadlen. 2002. "Response of neurons in the lateral intraparietal area during a combined visual discrimination reaction time task." Journal of Neuroscience no. 22 (21):9475-9489.
 
 
 

 

CARLsim

Carl