from IPython.display import SVG, Image
class SVGImage():
def __init__(self, fname, width=None):
self.fname = fname
self.width = width
def _repr_html_(self):
if self.width:
return "<image src='{}' width='{}'/>".format(self.fname, self.width)
else:
return "<image src='{}'/>".format(self.fname)
image_width = '80%'
SVGImage('images/spike_train.svg', width=image_width)
Image('images/nrn1001-704a-i2.png', width=600)
Data from Simmons et al. Transformation of Stimulus Correlations by the Retina. PLOS Computational Biology, 2013 10.1371/journal.pcbi.1003344
Exploratory data analysis can never be the whole story, but nothing else can serve as the foundation stone — as the first step.
— John W. Tukey in Exploratory Data Analysis
SVGImage('images/logos.svg', width='90%')
specialises on operations with files and executing external tools (incl. Python scripts)
allows to pass parameters to programs (command-line arguments)
Unix philosophy emphasizes building short, simple, clear, modular, and extensible code that can be easily maintained and repurposed by developers other than its creators
— Wikipedia
General purpose:
Specialised:
import parse_data
import calculate_correlations
import plot_histogram
def main(data_path):
data = parse_data.main(data_path)
correlations = calculate_correlations.main(data)
plot_histogram.main(correlations,
saveto='correlation_histogram.svg')
if __name__ == '__main__':
data_path = '/location/of/datafile'
main(data_path)
!tree .. -C -L 2 --dirsfirst --noreport -d
.. ├── data ├── docs │ └── images ├── figures ├── libs │ └── pyNeuro ├── results ├── scripts └── workflows
import single_analysis
files = ['../data/file1.txt',
'../data/file2.txt']
for fname in files:
single_analysis.main(fname)
Software engineers:
Scientists:
You specify rules and recipes, build tool determines which ones to execute and in what order of execution.
Rule 1:
input.txt --> intermediate.txt | script1.py
Rule 2:
intermediate.txt,params.json --> results.txt | script2.py
SVGImage('images/dependency_graph.svg', width='90%')
Anthony Scopatz & Kathryn Huff, Effective Computation in Physics, O'Reilly