Skip to content

Instantly share code, notes, and snippets.

@fzenke
Created August 22, 2017 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fzenke/470797d0479190a5d7fff553e24f2050 to your computer and use it in GitHub Desktop.
Save fzenke/470797d0479190a5d7fff553e24f2050 to your computer and use it in GitHub Desktop.
Network with cell assembly in TikZ
\documentclass{standalone}
\usepackage{tikz,graphicx}
\usepackage{sfmath}
\usepackage{xifthen}
\renewcommand\familydefault\sfdefault
\usetikzlibrary{calc,fadings,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[thick]
\pgfmathsetmacro{\n}{10} % sets number of units -1
\pgfmathsetmacro{\r}{1.5} % sets radius
\pgfmathsetmacro{\e}{0.5} % sets sparseness
\pgfmathsetmacro{\s}{12346} % sets random seed
\definecolor{patterncolor}{RGB}{0,0,0} % assembly color
\coordinate (center) at (0,0);
\foreach \i in {0,1,...,\n}{% This one doesn't matter
% with the front lipids visible
% top layer
\pgfmathsetmacro{\dx}{rand*0.1}% A random variance in the x coordinate
\pgfmathsetmacro{\dy}{rand*0.1}% A random variance in the y coordinate,
\ifthenelse{ \isodd{\i} }{
\node[circle,draw,patterncolor,fill] (neuron\i) at ($({\r*sin(\i*360/(\n+1))},{\r*cos(\i*360/(\n+1))})+(center)$) {} ;
}{
\node[circle,draw,lightgray,fill] (neuron\i) at ($({\r*sin(\i*360/(\n+1))},{\r*cos(\i*360/(\n+1))})+(center)$) {} ;
}
}
\pgfmathsetseed{\s} % set random seed
\foreach \source in {0,...,\n}
\foreach \dest in {0,...,\n} {
\pgfmathparse{rnd}
\pgfmathsetmacro{\foobar}{\pgfmathresult}
\ifthenelse{\lengthtest{\foobar pt<\e pt}}{
\ifthenelse{\equal{\source}{\dest}}{
}{
%\ifthenelse{\isin{\source}{13578} \AND \isin{\dest}{13578}}{
\ifthenelse{ \isodd{\source} \AND \isodd{\dest} }{
%\ifthenelse{\source<5 \AND \dest<5}{
\draw[->,patterncolor,thick] (neuron\source) to (neuron\dest);
}{
\draw[->,lightgray] (neuron\source) to (neuron\dest);
}
}
}{}
}
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment