neuro-conda

A Python Distribution for Neuroscience

Stefan Fürtinger

Ernst Strüngmann Institute
Frankfurt

Joscha Tapani Schmiedt

Brain Research Institute
Universität Bremen

November 9, 2023

Outline

Why

What

How

Why

Outline

Why

What

How

Python is Great!

Data Analysis!

[1]: import numpy as np
     import seaborn as sns
     sns.set_theme(style="ticks")

     rs = np.random.RandomState(11)
     x = rs.gamma(2, size=1000)
     y = -.5 * x + rs.normal(size=1000)

     sns.jointplot(x=x, y=y, kind="hex", color="#4CB391")

Statistics!

[1]: import statsmodels.api as sm
     x = np.linspace(0, 10, 100); X = np.column_stack((x, x ** 2))
     beta = np.array([1, 0.1, 10]); e = np.random.normal(size=100)
     X = sm.add_constant(X); y = np.dot(X, beta) + e
     model = sm.OLS(y, X); results = model.fit()
     print(results.summary())

                                 OLS Regression Results
     ==============================================================================
     Dep. Variable:                      y   R-squared:                       1.000
     Model:                            OLS   Adj. R-squared:                  1.000
     Method:                 Least Squares   F-statistic:                 4.020e+06
     Date:                Wed, 25 Oct 2023   Prob (F-statistic):          2.83e-239
     Time:                        11:13:17   Log-Likelihood:                -146.51
     No. Observations:                 100   AIC:                             299.0
     Df Residuals:                      97   BIC:                             306.8
     Df Model:                           2
     Covariance Type:            nonrobust
     ==============================================================================
                      coef    std err          t      P>|t|      [0.025      0.975]
     ------------------------------------------------------------------------------
     const          1.3423      0.313      4.292      0.000       0.722       1.963
     x1            -0.0402      0.145     -0.278      0.781      -0.327       0.247
     x2            10.0103      0.014    715.745      0.000       9.982      10.038
     ==============================================================================
     Omnibus:                        2.042   Durbin-Watson:                   2.274
     Prob(Omnibus):                  0.360   Jarque-Bera (JB):                1.875
     Skew:                           0.234   Prob(JB):                        0.392
     Kurtosis:                       2.519   Cond. No.                         144.
     ==============================================================================

Machine Learning!

[1]:
from sklearn.cluster import MeanShift, estimate_bandwidth
from sklearn.datasets import make_blobs

centers = [[1, 1], [-1, -1], [1, -1]]
X, _ = make_blobs(n_samples=10000, centers=centers, cluster_std=0.6)
bandwidth = estimate_bandwidth(X, quantile=0.2, n_samples=500)
ms = MeanShift(bandwidth=bandwidth, bin_seeding=True)
ms.fit(X)

Just Install It!

“Just” Install It!

Taken from xkcd

Just Use Conda!

What

Outline

Why

What

How

neuro-conda 🧠🐍

A Python Distribution for Neuroscience

  • use conda without having to use conda
  • simplifies learning and using Python in neuroscience
  • bundles commonly used neuroscience packages into curated conda environments
  • supports Windows, macOS and Linux

What’s Inside?

Electrophsysiology (Spikes + LFP)

Electrophysiology (LFP + M/EEG) + Neuroimaging

Machine Learning + Parallelization

Data, Formats, Coding

How

Outline

Why

What

How

Just Install It!

Just Install It! (No, Really)

Windows 10/11 (PowerShell)

Invoke-WebRequest `
https://raw.githubusercontent.com/neuro-conda/neuro-conda/main/libexec/install.ps1 `
-OutFile $Env:temp\install_neuroconda.ps1; `
Invoke-Expression $Env:temp\install_neuroconda.ps1;

macOS + Linux

/bin/bash -c "$(curl -fsSL \
https://raw.githubusercontent.com/neuro-conda/neuro-conda/main/libexec/install.sh)"

Windows 10/11 (PowerShell)

Set-ExecutionPolicy -ExecutionPolicy ByPass -Scope Process

macOS + Linux

Usage

Open a PowerShell window

(neuro-conda-2023b) PS C:\Users\myusername > _

Usage

Open a PowerShell window

(neuro-conda-2023b) PS C:\Users\myusername > _
(neuro-conda-2023b) PS C:\Users\myusername > ipython

Usage

Open a PowerShell window

(neuro-conda-2023b) PS C:\Users\myusername > _
(neuro-conda-2023b) PS C:\Users\myusername > ipython
Python 3.10.12 (main, Jul  5 2023, 18:54:27) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help

In [1]: _

Usage

Open a PowerShell window

(neuro-conda-2023b) PS C:\Users\myusername > _
(neuro-conda-2023b) PS C:\Users\myusername > ipython
Python 3.10.12 (main, Jul  5 2023, 18:54:27) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help

In [1]: _

+ Open a terminal window

(neuro-conda-2023b) myusername@mycomputer ~ % _

Usage

Open a PowerShell window

(neuro-conda-2023b) PS C:\Users\myusername > _
(neuro-conda-2023b) PS C:\Users\myusername > ipython
Python 3.10.12 (main, Jul  5 2023, 18:54:27) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help

In [1]: _

+ Open a terminal window

(neuro-conda-2023b) myusername@mycomputer ~ % _
(neuro-conda-2023b) myusername@mycomputer ~ % ipython

Usage

Open a PowerShell window

(neuro-conda-2023b) PS C:\Users\myusername > _
(neuro-conda-2023b) PS C:\Users\myusername > ipython
Python 3.10.12 (main, Jul  5 2023, 18:54:27) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help

In [1]: _

+ Open a terminal window

(neuro-conda-2023b) myusername@mycomputer ~ % _
(neuro-conda-2023b) myusername@mycomputer ~ % ipython
Python 3.10.11 (main, Jul 5 2023, 13:41:39) [Clang 14.0.6 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: _

Happy Pythoning!

neuro-conda 🧠🐍

Thank You For Your Attention!

Stefan @pantaray stefan.fuertinger@esi-frankfurt.de

Joscha @joschaschmiedt schmiedt@brain.uni-bremen.de