{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Welcome to PSYC.161-WI19\n",
"# Introduction to Programming for Psychologists & Neuroscientists\n",
"by Yaroslav O. Halchenko \n",
"\n",
"**email:** class-psyc161@onerussian.com\n",
"\n",
"**Where:** here in Moore 453, later might move to 303\n",
"\n",
"**When:** T/Th either 10:30am-12:00pm (need to find some 3h slots - TODO).\n",
"\n",
"**Details:** https://github.com/dartmouth-pbs/psyc161\n",
"\n",
"**Canvas:** Maybe"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# Why me?"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# Why you?"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Why not just a \"Programming 101\"?\n",
"\n",
"**Best Practices for Scientific Computing**\n",
"by Greg Wilson et al., PLOS Biology 2014\n",
"\n",
"http://dx.doi.org/10.1371/journal.pbio.1001745\n",
"\n",
"Box 1. Summary of Best Practices\n",
"1. **Write programs for people, not computers**\n",
"2. **Let the computer do the work**\n",
"3. **Make incremental changes**\n",
"4. **Don't repeat yourself (or others)**\n",
"5. **Plan for mistakes**\n",
"6. Optimize software only after it works correctly\n",
"7. Document design and purpose, not mechanics\n",
"8. **Collaborate**\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# Why \"Programming?\""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## Automation\n",
"\n",
"\n",
"xkcd.com/1205"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Automation\n",
"\n",
"xkcd.com/1319"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# Why \"Programming?\"\n",
"## Automation\n",
"\n",
" by Bruno Oliveira\n",
"\n",
"- **Reusable** (fix-rerun, or might even benefit others)\n",
"- **Flexible** (could be generalized/extended -- apply accross studies)\n",
"- **Scalable** (worked for >1 subjects, will work for any #)\n",
"\n",
"- **Exact description** of performed actions (was any \"Methods\" section was sufficient?) "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Why \"Programming?\"\n",
"## Programming == Problem solving\n",
"\n",
"Given a problem\n",
"\n",
"1. **Understand** what the problem is\n",
"2. **Conceptualize** approach to solve it\n",
"3. **Implement** the approach\n",
"4. **Verify** that the problem is solved, if not goto 1\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Why \"Programming?\"\n",
"## Programming =(historically)= Computer Science\n",
"\n",
"I hoped we will touch upon topics from\n",
"\n",
"- Data structures and algorithms ([CS 31](http://www.cs.dartmouth.edu/~cs31/))\n",
"- Computability and complexity ([CS 39](https://ssl.cs.dartmouth.edu/~ac/Teach/CS39-Winter15), CS49)\n",
"- Software engineering\n",
"- Problem solving (CS 10)\n",
"- Numerical and computational tools (CS 70/170)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# How will we do it?\n",
"\n",
"- Classes once/twice a week for a total of 3h/week\n",
" - (In-Class participation counts!)\n",
"\n",
"- Hands-on sessions through out the classes\n",
" - Codescope within [FOPP-PBS-WI2019](https://runestone.academy/runestone/static/fopp-pbs-wi2019/index.html) online text book. Note that online built-in Python is not a complete Python\n",
" - Python IDE (Pycharm)/editors\n",
" - Git and GitHub (Travis CI and friends)\n",
" - IPython notebooks\n",
" - tests (pytest)\n",
"\n",
"- Homework excercises due every week (but the last 4 weeks)\n",
" - Peer-review (?)\n",
"\n",
"- Final project\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# Final project\n",
"\n",
"- It must be a new development (i.e. not something you did before this\n",
" course), although you can choose to improve upon your prior code\n",
"\n",
"- Ideally should be something **you** or someone would end up re-using\n",
" later on\n",
"\n",
"- Contributions to existing scientific projects will be strongly\n",
" encouraged (benefit from established QA, feedback, distribution\n",
" channels, etc)\n",
"\n",
"- Possible projects will be suggested and discussed in the class on\n",
" 4-5th week and possible domains are\n",
"\n",
" - Data structures/algorithms implementation\n",
" - Stimuli/experiment\n",
" - Data Analysis\n",
" - Establishing/improving quality assurance (tests, etc) of an\n",
" existing scientific FOSS project\n",
" \n",
"- Team work is encouraged (but contribution ratio will be assessed)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# My goals\n",
"\n",
"## 1. Teach you programming\n",
"\n",
"- be able to use programming concepts (conditionals, iterations, functions, modules)\n",
"- solve problems alogirithmically so you have a generic and scalable solution not a list of copy-pasted and tuned lines\n",
"- get a healthy amount of paranoia - all code has bugs. Learn how to avoid/detect via in-line assertions and (unit-)tests\n",
"\n",
"## 2. Teach you to efficiently use tools\n",
"\n",
"- to become at least a few times more efficient in the tools you had touched (shell, git, github, ipython/jupyter)\n",
"- to know and know how to use existing offerings\n",
"- to be able to collaborate\n",
"- to be sure you have done *it* correctly: validate and (unit-)test\n",
"\n",
"## 3. Teach you to become part of the scientific Python ecosystem\n",
"\n",
"- contribute back"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Lecture #1: Python for sciences, fun and profit\n",
"(AKA Introduction)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# Why Python?"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"# Why not?"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"- Free, Open, Cross-platform - **scale and share without limits**\n",
"- Generic programming language - **avoid learning a new software for each new problem**\n",
" - Stimuli delivery\n",
" - Numerical (Data) analysis\n",
" - Simulations\n",
" - Web platforms\n",
" - Web scraping/Data mining\n",
" - Systems automation\n",
" - ...\n",
"- \"Friendly\" to other ecosystems - **it is ok to use other software on an occasion**\n",
" - Interface data/functionality from other languages (R, Matlab) and libraries\n",
"- “Python is executable pseudo-code.” (Python lore (often attributed to Bruce Eckel)) - **code of others is readable**\n",
"- \"Batteries included\" includes testings framework(s) - **testing is now integral part of nearly any Python project**\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# No, why \"Python\" name?"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## Has nothing to do with the snake\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# (Monty) Python\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# (Scientific) Python ecosystem is\n",
"\n",
"- [Python](http://python.org) (programming language/interpreter): ~~2.7.15,~~ 3.7.2\n",
" - [The Python standard library](https://docs.python.org/3/library/) (AKA \"batteries\"): io, sys, re, copy, math, random, glob, csv, httplib, argparse, unittest, ...\n",
"- [IPython](http://ipython.org) improved Shell and Notebook\n",
"- Python IDEs - Integrated Development Environment\n",
" - [Pycharm](https://www.jetbrains.com/pycharm/), [Spyder](https://pythonhosted.org/spyder), ...\n",
"- [NumPy](http://numpy.org) - core datastructure object for efficient numeric arrays manipulations\n",
"- \"Numeric batteries\": \n",
" - [SciPy](http://scipy.org) - high-level data processing routines. Optimization, regression, interpolation, statistics, etc...\n",
" - [Matplotlib](http://matplotlib.sourceforge.net), [seaborn](http://stanford.edu/~mwaskom/software/seaborn/), ... - plotting, visualization\n",
" - [Pandas](http://pandas.pydata.org) - efficient manipulation/analysis of tabular data\n",
" - [statsmodels](http://statsmodels.sourceforge.net) - statistical models\n",
"- \"Brainy ones\":\n",
" - [PyMVPA](http://pymvpa.org), [NiLearn](http://nilearn.github.io), ... - statistical learning analysis of neural data\n",
" - [PsychoPy](http://www.psychopy.org), [OpenSesame](http://osdoc.cogsci.nl), ... - stimuli delivery\n",
" - [dipy](http://nipy.org/dipy/), [nipype](http://nipy.org/nipype), [nitime](http://nipy.org/nitime/), ...\n",
"- Data management/distribution\n",
" - [DataLad](http://datalad.org)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# How to install Python\n",
"- Linux distributions: package managers\n",
" - Debian/Ubuntu: recommend enabling [NeuroDebian](http://neuro.debian.net) for recent versions of many useful Python modules (psychopy, pandas, seaborn, sklearn, pymvpa, dipy, nipype, nitime, ...)\n",
"- OSX/Windows:\n",
" - OS X is coming with some Python\n",
" - NeuroDebian VM\n",
" - \"Free\" (but not fully open) [Anaconda](https://store.continuum.io/cshop/anaconda/)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.15+"
}
},
"nbformat": 4,
"nbformat_minor": 1
}