Skip to content

Instantly share code, notes, and snippets.

View laurentperrinet's full-sized avatar
👁️‍🗨️
Busy coding...

Laurent Perrinet laurentperrinet

👁️‍🗨️
Busy coding...
View GitHub Profile
@laurentperrinet
laurentperrinet / nb_remove_output.py
Last active March 26, 2017 07:27 — forked from decabyte/nb_remove_output.py
Remove output from Jupyter notebook from the command line
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Remove output from existing Jupyter Notebooks.
Modified from remove_output by Minrk, damianavila, gabraganca.
References:
[0]: https://github.com/jupyter/nbformat
[1]: http://nbformat.readthedocs.org/en/latest/index.html
[2]: http://blog.jupyter.org/2015/04/15/the-big-split/
@laurentperrinet
laurentperrinet / bibtex.py
Created April 15, 2016 11:28
MoinMoin_BibTexParser
#FORMAT python
# -*- coding: UTF-8 -*-
"""
A parser to display bibtex code with a nice formatting within MoinMoin wiki pages.
The parsing is done in pure pytho, so that you will not need external programs. This
parser script should work for MoinMoin 1.9.3.
Copyright: 2012 by Laurent Perrinet -- see https://github.com/meduz/MoinMoin_BibTexParser
@laurentperrinet
laurentperrinet / 2018-05-22_minimal_working_example_lmfit.ipynb
Created May 22, 2018 13:47
2018-05-22_minimal_working_example_lmfit
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@laurentperrinet
laurentperrinet / run_notebooks.py
Created November 22, 2018 09:19 — forked from tpogden/run_notebooks.py
Run a Set of Jupyter Notebooks from the Command Line
# ! python
# coding: utf-8
import os
import argparse
import glob
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
from nbconvert.preprocessors.execute import CellExecutionError
@laurentperrinet
laurentperrinet / list_workspaces.py
Last active March 8, 2021 16:33
How can I list all existing workspaces in JupyterLab?
#!/usr/bin/env python3
"""
How can I list all existing workspaces in JupyterLab?
as answered @
https://stackoverflow.com/questions/52656747/how-can-i-list-all-existing-workspaces-in-jupyterlab/53011827#53011827
"""
import argparse
# construct the argument parse and parse the arguments
@laurentperrinet
laurentperrinet / flaskplotlib.py
Last active December 23, 2019 15:27 — forked from liuyxpp/flaskplotlib.py
Example of rendering a matplotlib image directly to Flask view
from flask import Flask, make_response, render_template
app = Flask(__name__)
@app.route("/")
def index():
render_template("index.html")
@app.route("/simple.png")
def simple():
import datetime
@laurentperrinet
laurentperrinet / rename_files.py
Created August 4, 2020 08:33
A short python script to rename a bunch of files
#!/usr/bin/env python3
"""
rename a bunch of files given a glob pattern and change A into B
rename_files.py -g "**/*.pdf" -a "\\" -b "_" --dry-run
rename_files.py -g "**/*" -a "\\" -b "_"
"""
import argparse
@laurentperrinet
laurentperrinet / paper_import.py
Last active December 23, 2020 09:03
Import your iOS paper © 53 artwork to a folder of png files
"""
Import your iOS paper © 53 artwork to a folder of png files
Paper is an iOS application to create doodles, created by 53 and now owned by
weTransfer :
https://paper.bywetransfer.com/
This gist lives at:

Dear Editor,

Thank you for inviting me to review this manuscript.

Unfortunately, I cannot review for Nature journals as long as the new and enormous open-access APC fee is in place. The $11,528 now being charged is significantly above the average APC of the biggest for-profit publishers, estimated as around $2,660 (https://undark.org/2021/01/14/big-science-publisher-is-going-open-access/).

‘$11,528’ is not just a large number. It is one semester of a graduate student’s stipend, a neuroimaging study, funds for 4-6 graduate students to attend a scientific meeting. These charges take away money, often from government grants, that would otherwise be spent in important ways - for trainees and for science more broadly.

The ‘Editorial Assessment Charge’ piloted in some Nature journals is also a worrying development. Charging more than $2,000 upon submission is not only excessive, but adds barriers where none should exist.

@laurentperrinet
laurentperrinet / fit_vonmises.py
Last active June 23, 2022 07:32
Quick function to fit a Von Mises distribution
import numpy as np
# https://en.wikipedia.org/wiki/Von_Mises_distribution
def tuning_function(theta, theta0, kappa, fmax, bsl, theta_bound):
# Von Mises, with kappa the concentration, theta0 the location
# fmax the firing rate at pref ori, bsl the min firing rate (not the baseline, which was substracted)
tf = bsl + np.exp(kappa*(np.cos(2*np.pi/theta_bound*(theta-theta0))-1)) * (fmax-bsl)
return tf
# we will use the tutorial from https://lmfit.github.io/lmfit-py/model.html :