Learn Python with Talk Python's 270 hours of courses

Python in Neuroscience and Academic Labs

Episode #461, published Thu, May 9, 2024, recorded Thu, Mar 14, 2024

Do you use Python in an academic setting? Maybe you run a research lab or teach courses using Python. Maybe you're even a student using Python. Whichever it is, you'll find a ton of great advice in this episode. I talk with Keiland Cooper about how he is using Python at his neuroscience lab at the University of California, Irvine.

And Keiland wanted me to let you know that if any developers (who are not themselves scientists) are interested in learning more about scientific research and ways you may be able to contribute, please don't hesitate to reach out to him.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guest Background

In this episode, our guest is Dr. Keelan Cooper, a neuroscientist at the University of California, Irvine. He originally hails from Indiana, where he started tinkering with computers and code in his teens—eventually teaching himself Python to automate data collection for a high school project. Today, Keelan uses Python extensively in his neuroscience research, from recording electrical activity of neurons with custom hardware to analyzing large-scale data and running deep learning models.

1. Python in Neuroscience

  • Automating Lab Work: Keelan described how Python scripts can automate tasks that previously required manual data entry, saving time and reducing errors.
  • Data Collection and Analysis: His lab collects high-volume time-series data (e.g., electrical signals from neurons) and video data from animal behavior experiments. Python and libraries like NumPy (numpy.org) and Matplotlib (matplotlib.org) handle tasks ranging from signal processing to plotting.
  • OpenCV for Video: Keelan spoke about using OpenCV (opencv.org) to stream and record video data, which can then be used for automated behavior analysis in animal studies.

2. Hardware and Infrastructure

  • Recording Equipment: The lab uses silicon probes to record from hundreds of neurons simultaneously. Keelan has also built custom camera servers and microcontroller-based systems (in C++ or MicroPython) for streaming data.
  • Local vs. Cluster Compute: Most preprocessing and smaller analyses happen on local machines or lab servers, while larger deep learning jobs run on GPUs in shared campus clusters or specialized lab hardware.

3. Python Tools and Workflows

  • Core Libraries: Keelan mentioned NumPy, Matplotlib, SciPy, pandas (pandas.pydata.org), scikit-learn (scikit-learn.org), and deep learning frameworks like PyTorch (pytorch.org).
  • Notebooks & Scripts: Jupyter notebooks (jupyter.org) are used for exploratory data analysis and presentation; final workflows often get refactored into Python packages or .py modules.
  • Django for Web Services: Keelan briefly noted using Django (djangoproject.com) to set up web interfaces and data streaming services.

4. Deep Learning & Continual AI

  • Catastrophic Forgetting: Keelan talked about the concept of catastrophic forgetting in neural networks—if a model learns a new task, it may lose performance on previous tasks.
  • Continual AI: He helps run a nonprofit called Continual AI (continualai.org), which develops solutions and fosters community around “continual learning”—where AI can learn tasks sequentially without forgetting. Their deep learning library Avalanche can be found at avalanche.continualai.org.

5. Broader Reflections on AI

  • Historical Perspective: The conversation touched on the evolution from early Word2Vec models to today’s large language models.
  • Potential & Caution: Keelan expressed optimism about AI’s ability to accelerate science (e.g., AlphaFold for protein folding) while urging sensible policy and awareness of challenges such as disinformation or workforce changes.

Overall Takeaway

Python’s versatility powers a wide range of tasks in modern neuroscience—from building custom hardware setups, to processing massive neural time-series data, to training cutting-edge deep learning models. By combining open-source tools (NumPy, Matplotlib, PyTorch, OpenCV, and more) with creative hardware solutions and careful scientific practice, researchers like Keelan are breaking new ground in understanding the brain and pushing AI capabilities forward in tandem.

Links from the show

Keiland's website: kwcooper.xyz
Keiland on Twitter: @kw_cooper
Keiland on Mastodon: @kwcooper@fediscience.org

Journal of Open Source Software: joss.readthedocs.io
Avalanche project: avalanche.continualai.org
ContinualAI: continualai.org
Executable Books Project: executablebooks.org
eLife Journal: elifesciences.org
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy

Talk Python's Mastodon Michael Kennedy's Mastodon