Exemplo n.º 1
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with DeNSE. If not, see <http://www.gnu.org/licenses/>.

import matplotlib.pyplot as plt
import nngt

import dense as ds
from dense.units import *
from dense.elements import Population

pop = Population.from_swc(ds.NeuronsFromSimulation("2culture_swc"))

graph, intersections = ds.generate_network(pop)

for key in intersections:
    intersections[key] = list(set(intersections[key]))

### Plot the graph in 2 subplots:
fig, (ax1, ax2, ax3) = plt.subplots(3, 1)
nngt.plot.draw_network(graph, spatial=True, axis=ax3)
for neuron in pop:
    if neuron < 100:
        try:
            ax1.plot(neuron.axon.xy[:, 0], neuron.axon.xy[:, 1], c='b')
        except:
            pass
    else:
        try:
Exemplo n.º 2
0
# DeNSE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with DeNSE. If not, see <http://www.gnu.org/licenses/>.

import matplotlib.pyplot as plt

import dense as ds
from dense.elements import Population

pop = Population.from_swc(ds.NeuronsFromSimulation("2culture_swc"))

graph, intersections, synapses = ds.generate_network(pop)

### Plot the graph in 2 subplots:
fig, (ax1, ax2) = plt.subplots(2, 1)
# nngt.plot.draw_network(graph,spatial = True,
# nsize="out-degree",
# ncolor="betweenness",
# esize=0.01,
# decimate =2,
# axis = ax2,
# dpi = 400)
ax1.set_title("Soma position")
for neuron in pop:
    if neuron >= 100:
        ax1.scatter(neuron.position[0], neuron.position[1], c='b')
    else:
Exemplo n.º 3
0
import sys

import matplotlib.pyplot as plt

import dense as ds
from dense.elements import Population

try:
    culture_folder = sys.argv[1]
except:
    raise ("add culture folder as first argument")

pop = Population.from_swc(ds.NeuronsFromSimulation(culture_folder))

graph, intersections, synapses = ds.generate_network(
    pop, intersection_positions=True)

### Plot the graph in 2 subplots:
fig, (ax1, ax2) = plt.subplots(2, 1)
ax2.set_title("Connections as a directed graph")
# nngt.plot.draw_network(graph,spatial = True,
# nsize="out-degree",
# ncolor="betweenness",
# esize=0.01,
# decimate =2,
# axis = ax2,
# dpi = 400)

ax1.set_title("Positions of nurons' soma")
for neuron in pop:
    ax1.scatter(neuron.position[0], neuron.position[1], c='r')
Exemplo n.º 4
0
                             dendrites_params=dendrite_params,
                             axon_params=axon_params)
    fig, ax = plt.subplots()
    # ds.plot.plot_neurons(gid=range(100), culture=culture, soma_alpha=0.8,
                       # axon_color='g', gc_color="r", axis=ax, show=False)
    # ds.plot.plot_neurons(gid=range(100, 200), show_culture=False, axis=ax,
                       # soma_alpha=0.8, axon_color='darkorange', gc_color="r",
                       # show=True)
    # step(4000, 0, False)
    # ~ for loop_n in range(5):
    # ~ step(500, loop_n, True)
    duration = time.time() - start

    # prepare the plot
    ds.plot.plot_neurons(gid=range(200), culture=culture, soma_alpha=0.8,
                       axon_color='g', gc_color="r", axis=ax, show=False)
    ds.plot.plot_neurons(gid=range(200, 400), show_culture=False, axis=ax, ymax=500,
                       soma_alpha=0.8, axon_color='darkorange', gc_color="r",
                       show=True)
    ds.plot.plot_neurons(gid=range(200, 400), show_culture=False, axis=ax,
                       soma_alpha=0.8, axon_color='yellow', gc_color="r",
                       show=True)
    plt.show(block=True)
    print("SIMULATION ENDED")

    # save
    graph =ds.generate_network()
    save_path = CleanFolder(os.path.join(os.getcwd(),"diode_double_swc"))
    ds.save_json_info(filepath=save_path)
    ds.SaveSwc(filepath=save_path,swc_resolution = 10)
Exemplo n.º 5
0
                             num_neurites=3)
    start = time.time()
    for i in range(10):
        step(500, 0, True)

    duration = time.time() - start

    plt.show(block=True)
    print("SIMULATION ENDED")

    # save
    save_path = CleanFolder(os.path.join(os.getcwd(), "swc"))
    ds.save_json_info(filepath=save_path)
    ds.SaveSwc(filepath=save_path, swc_resolution=10)
    structure = ds.morphology.NeuronStructure()
    graph = ds.generate_network(structure=structure)

    # ds.reset_kernel()

    ### Import population for network analysis
    # ng_population = ds.SimulationsFromFolder(save_path)
    # import pdb; pdb.set_trace()  # XXX BREAKPOINT
    # population = ds.SwcEnsemble.from_population(ng_population)

    # intersection = ds.IntersectionsFromEnsemble(population)
    # num_connections = np.sum([len(a) for a in intersection.values()])
    # graph = ds.generate_network(population, intersection)
    # #graph info
    # nngt.plot.degree_distribution(graph, ['in', 'out', 'total'])
    # nngt.plot.draw_network(graph, esize=0.1, show=True)
Exemplo n.º 6
0
import matplotlib.pyplot as plt

import dense as ds
from dense.elements import Population


try:
    culture_folder = sys.argv[1]
except:
    raise("add culture folder as first argument")

pop = ds.structure.Population.from_swc_population\
        (ds.NeuronsFromSimulation(culture_folder))

graph, intersections, synapses = ds.generate_network(pop,\
                                                intersection_positions=True,
                                                do_graph=False)


### Plot the graph in 2 subplots:
fig, (ax1,ax2) = plt.subplots(2,1)
ax2.set_title("Connections as a directed graph")
# nngt.plot.draw_network(graph,spatial = True,
                       # nsize="out-degree",
                       # ncolor="betweenness",
                       # esize=0.01,
                       # decimate =2,
                       # axis = ax2,
                       # dpi = 400)

ax1.set_title("Positions of nurons' soma")