SynapseGenerator

Previous topic

Specification of the input parameter structure “lpar”

This Page

Function list

These are the functions contained in the SynapseGenerator toolbox.

synGenPipeline.Shared.genSynX(lpar, synNeurMap, prei, posti, sortPerPre)

genSynX generates a matrix of the structure of X from the synapse neuron map synX = genSynX(lpar,synNeurMap,prei,posti,sortPerPre) synNeurMap is the second output of generateConnectivity prei is the index(array) of the presynaptic neurons for which to collect the synapses. Use an empty array ( [] ) for all neurons. posti does what you expect sortPerPre is an boolean which prescribes whether the output matrix is has as last index the presynaptic (true) or postsynaptic (false) neuron.

Example: To show all synapses between preNeuron 1 and postNeuron 2 use

>> X = showX(lpar,genSynX(lpar,synNeurMap,1,2,true))

To show all synapses between preNeuron 1 and all postsynaptic neurons:

>> X = showX(lpar,genSynX(lpar,synNeurMap,1,[],false))

See also showX, generateConnectivity

synGenPipeline.Shared.generateConnectivity(Xpre, Xpost)

generateConnectivity generates synapses between two synaptic element matrices.

[conMat] = generateConnectivity(Xpre,Xpost)

Connects synaptic elements of a Pre and Post neuron if they exist in the same voxel. If there is overlap (multiple synapses in the same voxel in e.g. the presynaptic matrix), the synapse is assigned to the neuron with the highest value in X in that voxel.

[conMat, synNeurMap] = generateConnectivity(Xpre,Xpost)

Does the same, but also a creates a cell matrix of the same size as the connectivity matrix, with in cell(i,j) a list of voxel numbers with synapses between presynaptic neuron i and postsynaptic neuron j. This is used in for example genSynX and branchOrderDistr

See also genSynX(), branchOrderDistr()

synGenPipeline.Shared.growTrees(lpar, X, Yinfo, doPre, jitterAmplitude, bf, thr)

growTrees Grows trees from generated synaptic elements using TREES toolbox’ MST_tree

trees = growTrees(lpar,X,YinfoCell) grows the trees of the population which belongs to the element from the Yinfo cell array (e.g. YinfoCell{2})

trees = growTrees(lpar,X,Yinfo,doPre) grows the trees for all presynaptic or postsynaptic neurons, depending on wether doPre is true. Note that the correct X-matrix should be supplied.

trees = growTrees(lpar,X,Yinfo,doPre,jitterAmplitude) perturbs the synaptic elements on each axis by a normally distributed random value with standard deviation jitterAmplitude. The perturbation is capped at half the voxelsize, ensuring the synaptic elements remain in the voxel.

trees = growTrees(lpar,X,Yinfo,doPre,jitterAmplitude,bf,thr) overwrites the balancing factor (bf) and threshold (thr) that has been sampled and stored in Yinfo with the given values.

[ trees,synBOmap ] = growTrees(...) Also returns a cell array with lists for each neuron. The lists contain pairs of branch order and voxel number for synaptic element.

Example :

To generate all trees from the second population (which is presynaptic):

trees2 = growTrees(lpar,Xpre,Yinfo{2},... )

See also MST_tree()

synGenPipeline.Shared.lpar1D(sigAx, sigDen, NnPre, NnPost, nVox, axSeed, denSeed)
synGenPipeline.Shared.lparPetri(sigAx, sigDen, delta, Nn, nVox, somaSeed, axSeed, denSeed, nSigRange)

Simple model of neurons in a petri dish axons are modeled as a single gaussian density with sigma sigAx at a distance delta from the soma, whilst dendrites have a radius sigDen and are centered around the soma. lpar = lparPetri() Loads the model with default settings lpar = lparPetri(sigAx,sigDen,delta,Nn,nVox,somaSeed,axSeed,denSeed,nSigRange) loads an lpar with given parameters. Nn is the number of neurons, nVox the number of voels per dimension, three seeds are required, as well as a Y generation accuracy (cut of range)

synGenPipeline.Shared.Analysis.XYcorr(X, Y, doPlot, nBins, minOccur)

XYcorr Experimental measure for the correspondence between X and Y

[Rsqe,slope,fit] = XYcorr( X,Y,doPlot[,nBins,minOccur])

Returns the root of sum of the squared errors of the probability of a synapse in voxel with Y-value y,which should be y, the slope of the best fit (which should be 1), and all the fit data. doPlot is a boolean which signals whether to output the histogram and data line to the current figure. nBins is the number of bins, and minOccur is the minimal number of occurrences if a value in the Y matrix to be included in this analysis.

Description :

To analyse whether X is according to Y, we assume that every voxel for every neuron is an experiment independent of all the others. If we were to randomly draw synaptic elements for 1 neuron according to its target distribution Y, we should find that the probability of a synapse in a certain voxel is equal to the value of Y in that voxel. This is because Y is a normalized probability density. Now for the more complicated case with N neurons with multiple synapses per neuron. To keep things simple, we assume that each generated synaptic element is the result of an independent draw from the whole Y matrix. The Y-matrix as a whole is not normalized, because it contains multiple neurons which should sum to 1, unless some of their density is outside of the target area.

To increase the sample size, we group the independent experiments according to the value of Y in the voxels. Therefore we define 20 bins over the values of Y, and collect the number of synaptic elements for each bin. Those values are normalized by: the number of experiments in each bin (histogram over Y), times the number of draws (the total number of synaptic elements), divided by a the target probability normalizing constant (the sum over the whole Y matrix). TODO:

We are actually sampling without replacement

disp([‘FillFrac = ‘ num2str(nnz(X)/nnz(Y))])

synGenPipeline.Shared.Analysis.Xmeasures(lpar, X, skipFracSameNeighbours)

Xmeasures calculates measures on the X matrix

Xmsrs = Xmeasures(lpar, X) calculates X measures.

Measures that end with Arr are arrays over all neurons.

Xmsrs = Xmeasures(lpar, X,true) skips the calculations of the fraction of same neighbours, which is by far the most time consuming computation.

The measures are : - fracOv Fraction of occupied voxels which are occupied by more than 1 synaptic element - fracFull Fraction of total voxels which are occupied by a synaptic element - numVoxOv Number of voxels occupied by more than 1 element - numVoxOccTot number of voxels occupied by at least 1 element - nSynElArr Number of synaptic elements for each neuron - nSynElTot Total number of synaptic elements - nSynAvStd Average and Standard deviation over neurons, number of synaptic elements - L1Norm Total sum of values of synaptic elements - nDeadNeurons Number of neurons without synaptic elements - fracDeadNeurons Fraction of neurons without synaptic elements - fracSameNeighbours Array of length 3 with : Fraction of neighbouring synaptic elements which are from the same neuron

not these anymore
number of neighbour-pairs from the same neuron total number of occupied neighbours]
synGenPipeline.Shared.Analysis.Ymeasures(Ypre, Ypost, doPlot)

Ymeasures calculates measures on the Y matrix

Ymsrs = Ymeasures(Ypre[,Ypost])

Calculates Y measures. The measures below are prefixed with pre or post. Pre correspond to the first input matrix

Measures that end with Arr are arrays over all neurons.

Ymsrs = Xmeasures(Ypre,Ypost,true) shows graphs of the Fractional occupancy (FracOcc) and the part of the density within the corresponding area (SumArr) for all neurons.

The measures are : - SumArr Sum of all the values of a neuron - Dead number of neurons with total density 0 - FracOccArr Fraction of the total voxels occupied for each neuron - Occ Fraction of the total voxels occupied by at least 1 neuron - MultiOcc Fraction of the total voxels occupied by more than 1 neuron - VoxNoccHist Normalized histogram for all voxels, counting number of non-zero Y’s - overlap* Fraction of voxels containing a non-zero total density for both Y’s (requires both Ypre and Ypost)

synGenPipeline.Shared.Analysis.branchOrderDistr(synBO, synNeurMap, doPre)

branchOrderDistr collects branch orders of synapses

BOlist = branchOrderDistr(synBO,synNeurMap,doPre)

Generates lists of branch orders of synapses. If doPre is true the lists are generated for the presynaptic population, otherwise for the postsynaptic population. The output is a cell array of the length of the number of neurons in the selected population, with in each cell an array of branch orders for the respective neuron.

synBo and synNeurMap are the 2nd outputs of growTrees and generateConnectivity respectively.

See also growTrees(), generateConnectivity()

synGenPipeline.Shared.Analysis.conMatMeasures(conMat, nBins, doPlot)

conMatMeasures Calculates and bins degree, strength and multiplicity distrubutions

stats = conMatMeasures(conMat,nBins). Calculates the in and out degrees (number of connected neurosn), in and out strengths (total number of synapses), and the multiplicity (number of synapses between any two neurons), binned in at most nBins bins. The output is a struct with 5 sub structs, one for each measure. The sub structs contain the edges, data, mean and standard deviation.

stats = conMatMeasures(conMat,nBins,true) Also plots the histograms in the current figure.

To calculate and show histograms with the connectivity matrix use:

[conMat] = generateConnectivity(Xpre,Xpost);
[CMmsrs] = conMatMeasures(conMat,nBins,false);

subplot(5,4,[1 19]);
imagesc(conMat)
title('connectivity matrix');
xlabel('postSynaptic neuron');
ylabel('preSynaptic neuron');
statnms = fieldnames(CMmsrs) ;
for i = 1 : length(statnms)
  subplot(5,4,4*i);
  bar(CMmsrs.(statnms{i}).edges,CMmsrs.(statnms{i}).data) ;
  title(statnms{i}) ;
end

See also generateConnectivity(), imagesc(), bar(), fieldnames()

synGenPipeline.Shared.Analysis.densityProjection(lpar, X, useYrule)

densityProjection calculates density projections proj = densityProjection(lpar,X) Calculates the density projections of the X matrix, interpreting every nonzero value as a synapse. The output is a struct with nDim fields, one matrix for each projection.

proj = densityProjection(lpar,X,true) interprets the input matrix as an Y matrix, and hence uses the value in stead of the being-zeroness for the projections.

See also showProjections
synGenPipeline.Shared.Analysis.recenterX(lpar, X, YinfoCell)

recenterX moves ad rotates all synapses such that their respective soma and distributions align

recentered = recenterX(lpar, X,YinfoCell) generates a cellArray with one cell for each neuron in X. Each cell contains an nDim * nSyn array with the coordinates of each synaptic element in the coordinates of the generator. YinfoCell is an element from Yinfo.

For instance:

If there is only one postSynaptic population,

recent = recenterX(lpar,genSynX(lpar,synNeurMap,[],[],false),Yinfo{lpar.postIndex})

calculates the relative synapse coordinates of that population. synNeurMap is the 2nd output of generateConnectivity

See also genSynX(), generateConnectivity()

synGenPipeline.Shared.Analysis.somaDens3D(lpar, Yinfo, binSize)

somaDens3D Calculates soma density projections

proj = somaDens3D(lpar,Yinfo,binSize) Calculates projections of soma densities, binned in bins of size binSize, in world coordinates, NOT the number of voxels (unless lpar.vox.voxelSize ==1)

synGenPipeline.Shared.General.args2cellA(varargin)

args2cellA returns a cell array with the fields given by the input arguments

synGenPipeline.Shared.General.checkFields(substruct, fieldnames, defaults)

checkFields Verifies whether fields are in a structure, possibly adds them substruct= checkFields( substruct, fieldnames) where substruct is a structure, and fieldnames is a string or a cell of strings. Throws an error if any of the names in fieldnames is not a field of substruct. substruct= checkFields( substruct, fieldnames,defaults ) creates the field with the value from defaults if it is not present. fieldnames and defaults should be [cell arrays] of the same length.

synGenPipeline.Shared.General.condenseX(X)

condenseX creates a matrix of size nVox * 1, removing all overlap.

cX = condenseX(X), the output array has for each voxel the number of the neuron with the strongest (highest value) synaptic element.

This is a lossy method! It erases information about the values in the X matrix and any overlapping synaptic elements
synGenPipeline.Shared.General.coords2mat(lpar, xyz, fillVal)

coords2mat Generates an X matrix based on a cell array of synapse coordinates

X = coords2mat( lpar,xyz[,fillVal]), where fillVal is the value which to give the synapses in the output array (default : 1). xyz is the output of mat2coords.

See also mat2coords()

synGenPipeline.Shared.General.mat2coords(lpar, X)

mat2coords generates a cell array with coordinates synaptic elements for all neurons. xyz = mat2coords(lpar,X) xyz is organized as a cell array, one cell for each voxel, with an array of size nDim * nSynEl with the coordinates of all synaptic elements of that neuron.

See also coords2mat
synGenPipeline.Shared.General.oooSnapshot(filename, delayTime)

OOOSNAPSHOT Creates gif movie by appending frames.

filename = oooSnapshot( filename,delayTime ) creates a gif file with the current axis as the first frame. The output filename has a timestamp appended so it should be given back when adding frames using the call:

oooSnapshot(filename), appends the current axis to the gif file

Example : To create a rotating gif:

surf(peaks); 
[az,el] = view ;
rotAng = 360 ;
nRot = 50 ;
azArr = linspace(0,rotAng,nRot) +az ;
[gfile] = oooSnapshot('rotatingPeaks',1) ;
for az = azArr
  view(az,el)
  oooSnapshot(gfile) ;
end
synGenPipeline.Shared.General.randSample(distr, num, par1, par2)

randSample Draws random samples according to distributions given by string samples = randSample(distr, num,par1,par2), returns num samples from the distribution distr with parameters par1 and par2.

distr is any of the following strings:

  • unifRand uniform random random numbers between par1 and par2
  • delta Dirac delta “distrubtion”, all samples are par1
  • normal normally distributed with mean par1 and std par2
  • unif Uniformly spaced, monotonic change between par1 and par2
  • randi random integer between par1 and par2
  • alli All integers between par1 and par2, repeated to until
synGenPipeline.Shared.General.rotation_matrixCell(degx, degy, degz)

rotation_matrixCell is an adaptation of rotation_matrix from the TREES toolbox that accepts arrays as input, and gives a cell array as output

Copyright (C) 2009 Hermann Cuntz: treats the different rotations in order x then y then z. In other words it’s the rotation_matrix R = Rz*Ry*Rx. Degrees of rotation are given in radians.

  • degx, degy, degz ::values: degrees of rotation (in radian)
  • hand::string ‘right|left’: for right/left-handed system {DEFAULT: ‘right’}

Output - M::matrix 3x3: rotation matrix

synGenPipeline.Shared.General.squareMe(lpar, X)

squareMe reshape the X matrix to a square

X = squareMe(X) returns the matrix of X reshaped to a square of size nVox * Nn

X = squareMe(lpar,X) does the same thing, but has the same input as unsquareMe

See also unsquareMe()

synGenPipeline.Shared.General.structToCellOfArgs(inStruct)
structToCellOfArgs coverts a structure to a cell array with {‘fieldname’,value} pairs.
argCell = structToCellOfArgs(instruct)... Useful when dealing with input to functions that accepts options. see below.

Example: surfset.FaceColor = ‘interp’; surfset.FaceAlpha = 0.5 ; surfopt = structToCellOfArgs(surfset) ; surf(peaks,surfopt{:}) ;

synGenPipeline.Shared.General.uncondenseX(cX, Nn)

uncondenseX reverses the condenseX precedure. Creates a full X matrix from a condensed one.

X = uncondenseX(cX,Nn) returns the uncondensed matrix X from the condensed matrix cX. Nn is the number of neurons. If Nn is omitted, the highest value in cX is used, which works if the highest index neuron has at least 1 synaptic element.

See also condenseX()

synGenPipeline.Shared.General.unsquareMe(lpar, X)

unsquareMe reshapes the X matrix to have nDim+1 dimension

[X,xsz ] = unsquareMe(lpar, X) where X is the reshaped input matrix, and xsz is the size of the input matrix (such that xsz(end) == Nn)

See also squareMe()

synGenPipeline.Shared.notMine.approxeq(a, b, tol, rel)

Are a and b approximately equal (to within a specified tolerance)? p = approxeq(a, b, thresh) ‘tol’ defaults to 1e-3. p(i) = 1 iff abs(a(i) - b(i)) < thresh

p = approxeq(a, b, thresh, 1) p(i) = 1 iff abs(a(i)-b(i))/abs(a(i)) < thresh This file is from matlabtools.googlecode.com

synGenPipeline.Shared.notMine.distinguishable_colors(n_colors, bg, func)

DISTINGUISHABLE_COLORS: pick colors that are maximally perceptually distinct

When plotting a set of lines, you may want to distinguish them by color. By default, Matlab chooses a small set of colors and cycles among them, and so if you have more than a few lines there will be confusion about which line is which. To fix this problem, one would want to be able to pick a much larger set of distinct colors, where the number of colors equals or exceeds the number of lines you want to plot. Because our ability to distinguish among colors has limits, one should choose these colors to be “maximally perceptually distinguishable.”

This function generates a set of colors which are distinguishable by reference to the “Lab” color space, which more closely matches human color perception than RGB. Given an initial large list of possible colors, it iteratively chooses the entry in the list that is farthest (in Lab space) from all previously-chosen entries. While this “greedy” algorithm does not yield a global maximum, it is simple and efficient. Moreover, the sequence of colors is consistent no matter how many you request, which facilitates the users’ ability to learn the color order and avoids major changes in the appearance of plots when adding or removing lines.

Syntax:
colors = distinguishable_colors(n_colors)

Specify the number of colors you want as a scalar, n_colors. This will generate an n_colors-by-3 matrix, each row representing an RGB color triple. If you don’t precisely know how many you will need in advance, there is no harm (other than execution time) in specifying slightly more than you think you will need.

colors = distinguishable_colors(n_colors,bg)

This syntax allows you to specify the background color, to make sure that your colors are also distinguishable from the background. Default value is white. bg may be specified as an RGB triple or as one of the standard “ColorSpec” strings. You can even specify multiple colors:

bg = {‘w’,’k’}

or

bg = [1 1 1; 0 0 0]

will only produce colors that are distinguishable from both white and black.

colors = distinguishable_colors(n_colors,bg,rgb2labfunc)

By default, distinguishable_colors uses the image processing toolbox’s color conversion functions makecform and applycform. Alternatively, you can supply your own color conversion function.

Example:
c = distinguishable_colors(25); figure image(reshape(c,[1 size(c)]))
Example using the file exchange’s ‘colorspace’:
func = @(x) colorspace(‘RGB->Lab’,x); c = distinguishable_colors(25,’w’,func);

Copyright 2010-2011 by Timothy E. Holy Parse the inputs

synGenPipeline.Shared.notMine.fn_structdisp(Xname)

Recursively display the content of a structure and its sub-structures

Input:

  • Xname/X one can give as argument either the structure to display or

    or a string (the name in the current workspace of the structure to display)

A few parameters can be adjusted inside the m file to determine when arrays and cell should be displayed completely or not Thomas Deneux Copyright 2005-2012

synGenPipeline.Shared.Visual.getColors(inp)

Default colormap for the plotting functions

See also showX, showY, showSoma, showTrees

synGenPipeline.Shared.Visual.pipelinePlot(lpar, Y, X, trees, whichNeuron, mode, f0)

PipelinePlot generates figures which can be used to explain the pipeline usage : pipelinePlot(lpar,Y,X,trees,whichNeuron,mode,f0)

synGenPipeline.Shared.Visual.plot3Ddensity(Pin, nSurf, isoRange, alphaRange)

plot3Ddensity visualizes a 3d density from a 3d matrix using transparent iso-surfaces

plot3Ddensity(Pin [,nSurf,isoRange,alphaRange]) shows the probability density of the 3-dimentional matrix P with nSurf (default:5) iso-surfaces with increasing opaqueness (alpha value).

isoRange and alphaValues are arrays of length 2, with the minimum and maximum values. For alpha the defaults are 0.05 and 0.25, for isoRange its 0.35 and 0.9 times the maximum value in Pin

Special thanks to Jesper from: http://www.mathworks.com/matlabcentral/newsreader/view_thread/268693

synGenPipeline.Shared.Visual.recenterPlot(lpar, X, YinfoCell)

recenterplot shows a Scatter plot of all ssynaptic elements of a population relative to their soma at (0,0) with the axes of the generators aligned

recenterPlot(lpar,X,YinfoCell) shows a the recentered synaptic elements of the of the neurons in the neuron population corresponding to the index of YinfoCell in Yinfo. NOTE: do not give Xpre when YinfoCell is a postSynaptic population

recentered = recenterPlot(...) returns a cell array with synapse coordinate, same as recenterX(lpar,X,YinfoCell) would.

Example:

Show the recenterPlot for the first population which is postsynaptic:

recenterPlot(lpar,Xpost,Yinfo{1});

See also recenterX()

synGenPipeline.Shared.Visual.recenteredXhist(lpar, X, YinfoCell)

recenteredXhist plots histograms of the synaptic elements of all neurons in X, relative to the soma projected to the X Y and Z directions in the density generator (aka blob)

recenteredXhist( lpar, X,YinfoCell) shows the histograms of the synaptic elements from X of the neurons in the neuron population corresponding to the index of YinfoCell in Yinfo. NOTE: do not give Xpre when YinfoCell is a postSynaptic population

Example:

Show histograms for the first population which is postsynaptic:

recenteredXhist(lpar,Xpost,Yinfo{1});
synGenPipeline.Shared.Visual.setLimToWorld(lpar)

setLimToWorld sets the limit of the current axis to the world size.

setLimToWorld(lpar) sets the axes of the current axis to the world size in lpar.vox.worldSize (calculated in prepareForYgen)

See also prepareForYgen()

More of the improvement

synGenPipeline.Shared.Visual.showConMat(conMat, conMatMsrs)

showConMat shows the connectivity matrix and histograms of measures showConMat(conMat) shows the connectivity matrix together with the histograms of the measures from conMatMeasures.

showConMat(conMat,conMatMeasures) can be used when the connectivity matrix measures are already calculated, or when they should be calculated using non-default settings.

synGenPipeline.Shared.Visual.showProjections(lpar, varargin)

showProjections shows heatmaps of density projections showProjections(lpar,Y,X,synNeurMap) Calculates and shows the density projections of the target density, the synaptic elements and the synapses. The arguments X and synNeurMap are optional. showProjections(lpar,Yproj,Xproj,synProj) shows the density projections generated using densityProjection. Again Xproj and synProj are optional

See also densityProjection

synGenPipeline.Shared.Visual.showSoma(lpar, Yinfo, showPre, markerSize, cc, markerType)

Plots the soma to the current axis.

showSoma(lpar,Yinfo,showPre,markerSize,cc,markerType) shows the soma with the given markerSize, colorcode and markerType.

showPre indicates what population to plot the soma for, either pre (true) post(false) or all in Yinfo (empty : [])

cc has one or more colors

markerSize and markerType can be scalars or arrays with the same number of elements as the number of soma to plot, or empty to indicate default behaviour.

cc is a colorcode as return by for example lines. Each row has three values, making a rgb triplet. The colormap can be of any length and will be repeated if it is not long enough

Examples:

To show the soma of the second population in Yinfo using default settings:

showSoma(lpar,Yinfo(2)); % use non-curly brackets

See also lines()

synGenPipeline.Shared.Visual.showSynapses(lpar, synNeurMap, prei, posti, colorPerPre, cc)

showSynapses plots the synapses between given presynaptic and postsynaptic neurons

showSynapses(lpar,synNeurMap,prei,posti,colorPerPre,cc) plots all synapses between the presynaptic neurons prei and postsynaptic neurons posti. Both can be scalar for 1 neuron, arrays for multiple, or empty for all. colorPerPre is a boolean which signifies wether the shown synapses have the same color based on presynaptic (true) or postsynaptic (false) partner. cc is a color map (default: getColors) and can be a single rgb triplet (e.g. [1 0 0 ] for red) to color all synapses the same, or a matrix of at least size Nn by 3.

See also getColors()

synGenPipeline.Shared.Visual.showTrees(trees, cc, options)

showTrees adds the trees to the current axis showTrees( trees,cc,options ) adds all trees in the trees cell array of TREES-toolbox trees to the current axis. cc is the color code, either a single rgb triplet, or an matrix with triplets. options is a string with options for the TREES toobox plotting function plot_tree

Example:
To add the three TREES-toolbox trees from the cell array called trees with indices 3,33 and 333 in to the current axis, with the color the same as their synaptic elements use: showX(lpar,X) ; cc = getColors(333) ; cc = cc([3,33,333],:) ; showTrees(trees([3,33,333]),cc); %using array index to cell array

See also : plot_tree

synGenPipeline.Shared.Visual.showX(lpar, X, cc, useStem)

showX plots the generated synaptic elements for all neurons in X

showX(lpar,X[,cc]) plots the generated synaptic elements for every neuron in X. cc is the colormap used. By default it is the one in getColors.

Examples:

To show only the synaptic elements of the second neuron use

X = squareMe(X);
showY(lpar,X(:,2));

To show all generated synapses, colored by postsynaptic neuron use:

synX = genSynX(lpar,synNeurMap,[],[],false);
showX(lpar,synX);

To show the synapses of postsynaptic neuron 1 to any postsynaptic neuron with an even number, colored by presynaptic use:

synX = genSynX(lpar,synNeurMap,2:2:end,1,true);
showX(lpar,synX);

See also getColors(), genSynX(), squareMe()

synGenPipeline.Shared.Visual.showY(lpar, Y, cc, area, varargin)

showY adds all target densities in Y in the current figure for anyD:

showY(lpar,Y) plots the densities of all neurons

showY(lpar,Y,cc) Using the color specified in cc. Each row has an RGB triplet. If the matrix is not long enough, it will be repeated. If cc is not given, or it is empty, getColors will be used.

showY(lpar,partY,cc,area) plots the densities of all neurons generated using generatePartialY in the same area.

for 2D:

showY(lpar,Y,cc,[],surfOptStruct) where surfOptStruct is a structure with the fieldnames being properties of surf.

showY( lpar,partY,cc,area,surfOptStruct) where surfOptStruct is a structure with the fieldnames being properties of surf and partY is generated using generatePartialY with the same area.

for 3D:
showY(lpar,Y,cc,[,[],nSurf,alphaRange,Prange]). nSurf is the number of isosurfaces shown for each neuron (default: 5). Prange gives the range of iso-values of the surfaces as a product of the maximum value in Y. (default: [0.02,0.9]). alphaRange give the range for the alpha values(opaqueness) of the surfaces (default: [0.08 0.25]).
Example:
To show only the density of the second neuron use Y = squareMe(Y) ; showY(lpar,Y(:,2));

See also surf(), squareMe(), getColors()

synGenPipeline.Shared.Xgeneration.genRand1(Y, nSynMean, nSynStd, removeOverlap)

genRand1 generates synaptic elements using a sort of rejection sampling

[X] = genRand1(Y,nSynMean,nSynStd,removeOverlap)

Generates synaptic elements according to the distribution in Y. nSynMean is the expected number of synaptic elements. It can also be an array with one entry for each neuron. The minimal standard deviation of the number of synaptic elements for one neuron is the square root of the mean.A higher value can be supplied in the (array) nSynStd. removeOverlap can be set to true to prune any synaptic elements that are in a voxel which is already occupied. This invalidates nSynMean and nSynStd though.

The method multiplies each normalized density with the expected number of synaptic elements. Each (neuron,voxel) combination then is assigned a synaptic element with a probability equal to the result of that multiplication.

To rm overlap, assume “binomial process” with p from Y, http://en.wikipedia.org/wiki/Product_distribution

synGenPipeline.Shared.Xgeneration.Lasso.CalculateXw(tpar, w)

Core function of LASSO, multiplies the weights with their gaussian kernels by means of an insertian and convolution

synGenPipeline.Shared.Xgeneration.Lasso.Lam1Max(lpar)

Returns the maximum stable value of Lambda_1. Higher is very unstable, lower is likelt stable Based on the rationale that the constrained and the L1 norm has to be so low that the object function’s value decreases for at least 1 weight

synGenPipeline.Shared.Xgeneration.Lasso.SqEWC(tpar, w, y)

Squared error with competition, objective function, also calculate first derivative (g)

CHANGELOG:

  • XGLOB is now lpar.derp.X
  • used preC.XpX and preC.Xpy
  • vectorized adding SQE
synGenPipeline.Shared.Xgeneration.Lasso.SqEWCp(lpar, w, y, alpha)

Square error with competition and L2 regularization (given by alpha), for improved stability but also more overlap

w(feature,1) X(instance,feature) – GLOBAL y(instance,1) – GLOBAL

CHANGELOG:

  • XGLOB is now lpar.derp.X
  • used preC.XpX and preC.Xpy
  • vectorized adding SQE

TODO:

  • ADJUST FOR MULTIPLE TARGETS!
  • VERIFY [~,p] = size(lpar.derp.X);
synGenPipeline.Shared.Xgeneration.Lasso.doAllLasso(lpar, lassoSettings, doPre)

Generates synaptic elements using a LASSO. This method requires extensive tuning

[X] = doAllLasso( lpar,lassoSettings) does the LASSO for both the presynaptic and the postsynaptic population. This method requires the Y matrix with a higher resolution and generates this itself.

lassoSettings is a struct with the following fields

Parameters:
  • nFac – factor if Y’s increase in detail
  • kSig – Size of the convolution Gaussian
  • templNsig – convolution Gaussian cut-off number of sigma
  • scaleFac – Multiplier on Y
  • lambeg – begin value of lambda1, as a factor of lam1_max (so should be (0-1) )
  • a – HAL-LASSO’s a
  • b – HAL-LASSO’s b
  • lam2 – lambda 2
  • Nit – Maximum number of iterations
synGenPipeline.Shared.Xgeneration.Lasso.doLasso(tpar, funObj, y)

Internal function, used by doAllLasso()

synGenPipeline.Shared.Xgeneration.Lasso.genDerp(tpar)

generate Derived Parameters (core function of doAllLasso)

synGenPipeline.Shared.Xgeneration.Lasso.genPreC(tpar, y)

GeneratePrecalculates,core function of doALlLasso Direct decendent of genPreC3 (v2). TODO: add mode from genPrec4 is it’s to big

[X1,Y1]=ndgrid(xx,yy); NptT= prod(cell2mat(tpar.vox.voxPerDim)) ;
synGenPipeline.Shared.Xgeneration.Lasso.myL1General2_PSSgb(funObj, w, lambda, options)

Adaptation of L1General2_PSSgb. Added specific stopping condition on explosion and printing to a figure of verbose is true Process Options

synGenPipeline.Shared.Xgeneration.Lasso.myisLegal(v)

improvement of isLegal from L1General when non-complex values are guaranteed

synGenPipeline.Shared.Xgeneration.TIsingFolder.TIsing(varargin)

TIsing, Tailored Ising, generates synaptic elements using an ising grid TIsing(Y,voxPerDim,J,H|beta,cSeed) Initializes the TIsing model. J(1) is the nearest neighbor coupling, and J(2) is the coupling within a voxel TIsing(nItt,beta) Runs the metropolis algorithm TIsing(nItt,beta,tol,conf) experimental runs the metropolis algorithm with stopping condition TIsing(J,H|beta,seed) changes the variables stored in the c file. Any can be empty. getInfo : nargin == 0 reset state nargin == 1; p, P(size of Y), or -beta (to use 1/(exp(-beta*h)+1)

synGenPipeline.Shared.Ygeneration.generatePartialY(lpar, Yinfo, area)

generatePartialY generates a part of the target density based on the generated covariance matrices in Yinfo

[ YprePart,YpostPart,neuronIndex ] = generatePartialY(lpar,Yinfo,area)

Generates a part of the target densities specified by the area. area is an nDim by 2 matrix specifying the bounds of the world to generate in world coordinates. Because not necessarily all neurons have a nonzero density in this area some are not generated. Therefore an array with indices in Yinfo of the generated neurons in Ypart is also returned as neuronIndex.

synGenPipeline.Shared.Ygeneration.generateY(lpar, Yinfo)

GenerateY generates the whole target density based on the generated covariance matrices in Yinfo.

[Ypre,Ypost] = generateY(lpar,Yinfo) is how we do it.

synGenPipeline.Shared.Ygeneration.prepareForYgen(lpar)

prepareForYgen First thing to do after lpar definitition. Always. processes and fixes lpar, samples stuff [lpar,Yinfo ] = prepareForYgen(lpar) does what it has to do.

See also generateY,
synGenPipeline.Shared.Ygeneration.preparePartialY(lpar, Yinfo)

preparePartialY is required to run before using generatePartialY [lpar,Yinfo] = preparePartialY(lpar,Yinfo) Is how we do it

See also generatePartialY

synGenPipeline.Shared.Ygeneration.Blobs.SpinyStellate3D(nArm, typeSpec)

Discontinued model of a spyny stellate neuron consisting of nArm gaussians randomly distrubuted around the soma SigL and SigP give the longitudonal and perpendicular components of the gaussians distR gives the distance of the centres of the gaussians to the soma

synGenPipeline.Shared.Ygeneration.Blobs.genAx1(typeSpec)

genAx1 is a 1st order model of long range axonal projection. In this model the projection area of a long range axon consists of 3 gaussian spheres (or circles), with sigma sig and a distance sig * rr from a common centre

synGenPipeline.Shared.Ygeneration.Blobs.genGauss(typeSpec)

A spherical gaussian with sigma sig

synGenPipeline.Shared.Ygeneration.Blobs.genGauss2(typeSpec)

Generates a gaussian with zero crosscorrelation The diagonal components of the covariance matrix are given by sigx, sigy and sigz

synGenPipeline.Shared.Ygeneration.Blobs.genPyr0(typeSpec)

genPyr0 is a zeroth order model of a pyramidal cellfun

The model consists of two gaussians, one for the basal dendrites, and one for the apical dendrites.

The sigma in the z-direction (orthogonal to the pial surface) of the apical dendrite is given by tsz (top sigma z).

The apical dendrites x and y sigma is given by tsz * tsr (top sigma ratio).

The size of the gaussian in the xy plane of the basal dendrites is given by bsxyr (bottom sigma xy arrrr (because pirates are cool))

The size of the gaussian in the z direction of the basal dendrites is given by bsr * bsxyr

The distance between the two gaussians is given by the distance ration (dr) times the sum of the two sigmas in the Z diretion

f is the distance of the soma to the basal gaussian, as ratio of the distance between the two (so it should be between 0 and 1)

synGenPipeline.Shared.Ygeneration.Blobs.gmmBlob(matFileName, typeSpec)

Generator function(blob) using a matfile with generated gaussian mixture models. Don’t use this yourself! This is used in loadTypeSpecFromMatFile

synGenPipeline.Shared.Ygeneration.Blobs.loadTypeSpecFromMatFile(matFileName)

loadTypeSpecFromMatFile set the typespec to generate neurons acccording to the GM-models in the matfile The matfile can be created with GMfit.m by fitting gaussians to neuron reconstructions

synGenPipeline.Shared.Ygeneration.Blobs.petriAx(typeSpec)

0th order model af an axon in a petri dish The axon is described as a circular gaussian with sigma sig at a distance delta from the soma

synGenPipeline.Shared.Ygeneration.Blobs.petriDen(typeSpec)

0th order model of a dendrite in a petri dish The dendrite is modeled as a single gaussian around the soma with sigma sig