Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 34eda6e
  • /
  • neural_tuning
  • /
  • Tutorial_PoissonGLM.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:7216c108513d012681c2159d4e50b797bf80ab6d
directory badge
swh:1:dir:bd9d3a4b73b0f4285b3baf8a908c0ac87f420c72

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tutorial_PoissonGLM.py
# -*- coding: utf-8 -*-
# @Author: gviejo
# @Date:   2022-08-24 15:16:57
# @Last Modified by:   gviejo
# @Last Modified time: 2022-08-24 17:03:58


import numpy as np
from matplotlib.pyplot import *
from scipy.io import loadmat
import pynapple as nap
from numba import jit

# LOAD THE DATA
stim = np.squeeze(loadmat('data_RGCs/Stim.mat')['Stim']) # contains stimulus value at each frame
stim_times = np.squeeze(loadmat('data_RGCs/stimtimes.mat')['stimtimes']) # contains time in seconds at each frame (120 Hz)
all_spike_times = [np.squeeze(x) for x in np.squeeze(loadmat('data_RGCs/SpTimes.mat')['SpTimes'])] # time of spikes for 4 neurons (in units of stim frames)


# Putting the data into pynapple
dt = stim_times[1] - stim_times[0]

main_ep = nap.IntervalSet(start=0, end=(stim.size)*dt)
stimulus = nap.Tsd(t = stim_times, d = stim, time_support = main_ep)
spikes = nap.TsGroup(
    {i:nap.Ts(t = all_spike_times[i]) for i in range(len(all_spike_times))},
    time_support = main_ep,
    num_spikes = np.array([len(spk) for spk in all_spike_times])
    )


regressors, offset, p = nap.compute_1d_poisson_glm(spikes, stimulus, dt, 0.2, ep = main_ep)


count = spikes.count(dt)


figure()
plot(count[2])
plot(p[2])

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API