Assortment of Figures

Herein lies an assortment of the many figures I’ve made over the years.  The emphasis of these is typically on information and understandability: things a good scientist should emphasize. You’ll find images, 2d and 3d plots, and combinations to illustrate the point at hand. Beyond these, there has been countless time series plots, scatter plots, bar graphs, and the standard fare for data display.  Note: in the figs at the bottom, some labels must be covered until publication. Without further ado…

Three projections of a fluorescent neuron with recording sites overlayed.

Three projections of a fluorescent neuron with recording sites overlayed.

Sites and recorded traces on the main dendritic trunk.

Sites and recorded traces on the main dendritic trunk.

bar graphs

Some bar graphs, with paired data overlayed.  Apologies, names covered since it is not yet published.

scatterplot and examples

Scatterplot and example traces.  Names covered again until publication.

traces, cross-correlograms, and summary data

Traces showing various degrees of synchronization of signals (top-left), cross-correlograms also showing varying synchrony (top-right).  Labels covered until publication.

Posted in Uncategorized | Leave a comment

Passwords and Passphrases

There are 95 typeable characters to use in your passwords.  A nice long random string of those 95 characters is probably the most secure password.  Secure, but hard to remember.  Here’s a webpage I wrote to generate secure passwords and passphrases.  Passphrases are actual words, which are easier to remember, and a string of them can be as secure as hard-to-remember password with mixed cases and special characters and all.  Here’s an xkcd comic that illustrates the basic problem.

There are three tools on that page, one to generate a string of words to make a passphrase, one makes a crude attempt to make a valid sentence with random words, and one that just gives you a traditional strong password.

How did I make them?

  1. Get some words.  I downloaded some books off the internet and extracted all the unique words and compiled a long list.  I think there was about 13000 words.  Those utilitarian steps I coded up in C# since it’s nice and easy to work with, and Visual Studio is awesome.
  2. Pick some words at random.  I read the dictionary in at the webserver (that step in php) and picksome at random.  That’s all there is to it.
  3. What about the random sentence?  I found a list of nouns and verbs and adjectives and whatnot online.  The potentially readable passphrase is of the form:

the [adjective] [noun] [adverb] [past tense verb] the [adjective] [noun]

Q: What was the hardest part you ask?  A: The list of verbs I found was in the present-tense, but the sentence sounded better if the words were in the past-tense.  So I translated them all manually.  That was a pain.  By the end I got the brain fuzz really bad.  You might find some mistakes in there.  There might be something in there like taked, instead of took.

Here’s the link again:  Generate passwords and passphrases.

Sincerely, Warmest regards, Best of luck,


the merciful hydrant unimpressively stamped the quarrelsome war

Posted in Uncategorized | Leave a comment

CV / Resume in HTML / CSS3

Dear Internet,

I’ve translated my CV into HTML/CSS from it’s old LaTex form.  I use LaTeX a few times per year, which means every time I’m dreading the thought of it.  Maybe if I used it everyday, I’d get the kinks worked out, but that’s not likely to happen ever.

How the page looks on smaller screens How the page looks on a wide screenHere’s my updated version.  Keith Kelleher, Ph.D.  Feel free to adapt it to your needs, but I would like to hear if you have found it useful.  It uses some JavaScript / JQuery to expand / collapse sections.  The CSS even adapts to the media style, so if you print it, you won’t print the expander buttons.  Also, if your screen is too small, it adjusts a bit to fit better, removes the pic of me etc.  You’d need to download all the necessary files as well, the CSS, the .js files, the icons.  The icons came from the interweb, there are 15 different ones in the whole set.  I like them because they look like merit badges.

Best, Keith.

Posted in CSS, CV, HTML, Resume | 1 Comment

Microsoft Certified Professional


It’s official.  I have many talents.  This is step one for my MCSD certification which will undoubtedly bring me fortune and glory, kid.  Probably somebody should hire me while I’m affordable.

Best, Keith.

Posted in Uncategorized | Leave a comment

Curve Fitting in Excel

Dear Internet,

My name is Keith and I have a hammer. It is called “curve fitting.” The world is full of nails that could be, and in my opinion, absolutely should be hit with this hammer.

I know, I know, there are critics of curve fitting. I know that no analysis procedure can increase the amount of information in your data. I know all that. But your data came from some real-world signal, and if you have noise added on top of it, then a procedure that removes the noise, and pushes your data back towards the original signal, is good. The processed data can be closer to the real signal than the noisy data, that’s good, so no more apologies.

I’m going to post some shtuff on this blog to demonstrate curve fitting using a variety of methods. The first of these installments is for Excel. I know! Excel can do arbitrary functional fitting! You can download the worksheet to follow along here: curve fitting in Excel

Let’s get going: As a simple example, let’s fit a straight line to some data. That’s something of the form y = ax + b, where we’ll have data for x and y, and we’ll figure out the slope parameter, a, and the offset parameter, b, for a straight line fit. Later we’ll do something more complicated.

  1. Step zero: generate some synthetic data
  2. Generate an estimate based on an initial guess of a and b.
  3. Overlay the fit on top of the data
  4. Optimize the fit
  5. Go on about your day

Okay, getting things started, let’s generate some data to test our setup. In the figure below, I made some synthetic data which is described by a straight line, and is corrupted by some noise. NOte the three variables in the first column, “actual slope”, “actual_offset”, and “noise”. These are named variables, meaning that I highlighted the cell and typed a name for the variable in the little box on the top left (where in the figure it says “actual_slope”. That way I can use the name of the variable in my equations and I don’t have to worry about having the correct cell reference (i.e. I can type “actual_slope” rather than $A$2 – you could use $A$2 in this case with the dollar signs so that the reference stays constant for all cells.)

synthetic data to fit

make yours like mine

So the equations for the data are as follows:
X is random : “rand()”
true Y is calculated from the X : “=C2*actual_slope+actual_offset”
estimated Y is a noisy version of true Y : “=D2+NORM.INV(RAND(),0,noise)”, where the NORM.INV stuff is a way to get normally distrubed noise, as is more common in the world.

Select your data, Copy, then right click - paste special - values, so that they don't get randomized over and over again.

Select your data, Copy, then right click – paste special – values, so that they don’t get randomized over and over again.

Important note, before you start the fitting, if you generate your data this way, with the rand() functions, you have to stabilize those values before you start the fitting. Rand() will regenerate random numbers each time there is a calculation, so your data will be jumping around and around while you’re algorithm is trying to fit it. So, highlight your data, right click and copy it, then right click and paste special – values over the data. Then your data are numbers, not rand() functions.

Next, we’ll guess at what the slope and offset of the best fit line are, and plot that. We don’t have to guess well, that’s the whole point, we can make a rough guess and let Excel optimize it. Below, you’ll see the updated spreadsheet. I have made new parameters, “estimated_slope” in cell A12, and “estimated_offset” in cell A15. I selected 1 and 5 for the starting point, and as you can see by the plot of the estimated line, it is not that good of a guess. Column G is the estimated Y value for the X values in column C, using those guessed parameters. Column H is the error (i.e. Estimated Y – Measured Y). Note that the error is calculated always from the measured Y, not true Y, because you’re not supposed to know that, if you did you’d be finished already.

Make a guess at the starting point for the line parameters, then minimize the error

Make a guess at the starting point for the line parameters, then minimize the error

Look at cell A18, which holds a value I named “SSE” which stands for sum of squared error. This is the sum of all the squared values in Column H, and this is our estimate of how good this line fits our data. 0.405 is the sum of the squared errors of our fit – our measured Y values, and this is what gets minimized in our optimization.

Now we go to the critical step. Optimizing our parameters so that our fit is as good as possible. In the Data menu, in the Analysis group, select “Solver”.

If the Solver command or the Analysis group is not available, you need to load the Solver Add-in program.

How to load the Solver Add-in program

1.Click the File tab, click Options, and then click the Add-Ins category.
2.In the Manage box, click Excel Add-ins, and then click Go.
3.In the Add-ins available box, select the Solver Add-in check box, and then click OK.

Select your objective function, your variables, and "Go!"

Select your objective function, your variables, and “Go!”

Set your Objective, which means to ‘maximize’ or ‘minimize’ a certain value, in our case we are ‘minimizing’ the SSE for our fit, so put the address for the SSE, and make sure you select “Minimize”. The other imporant factor is to determine which cells hold your variables, in our case, the named variables “estimated_slope” and “estimated_offset”.

the fitted data

the fitted data

And here is the result, notice how the red fit line is a much better estimate of our true hidden values. Also, our cells which held our estimated variables are now different, and are relatively good approximations to the true values. The more data you have, or the less noise you have, the better that approximation will be.

Now, let’s do something harder. (something that couldn’t be done with ‘add trendline’). Below you’ll see a more complicated dataset, which is roughly the shape of the current induced by a synaptic impulse in your brain.

a more complicated fit, let's see if this one works

a more complicated fit, let’s see if this one works

Here I’ve generated a data trace, which is what we in the neuroscience biz call an excitatory post-synaptic conductance (EPSC). It is an impulse, with a fast onset, and a slower offset, and is pretty closely approximated by an exponential rise and decay. Here we’re going to try to figure out via fitting, how fast the EPSC rises, and decays, and at exactly what time it comes on, and the size and all that stuff.

I’ve set it up the exact same way, made some initial guesses as to the variables, and I’ve made a cell which holds the objective measure of the goodness-of-fit, and away we go, running Solver. And okay, it didn’t work the first time, with those initial starting conditions, let me try again with a closer guess. Oh, and I forgot to select Minimize, but wait it still isn’t working. Okay, well, I guess it’s too hard, it’s not working. Maybe I’m doing something wrong, oh wait! I forgot to copy, and paste-special-values my data. Probably that’s it, my data is changing every iteration and that’s making it hard. Let’s see if that works now. Yeah, that’s better.

end result of 5 parameter fitting in Excel

end result of 5 parameter fitting in Excel

Note the estimated parameters are pretty close to the “true parameters” and the fit looks pretty good. I hope this helps in your data analysis. Here’s the worksheet for these two problems. curve fitting in Excel


Posted in Uncategorized | 1 Comment

Multilayer Perceptron in MATLAB / Octave

At some point in my life, as perhaps in yours, I had to write a multilayer perceptron code from scratch. It is a useful exercise, and the result posted here is a nice, barebones implementation that I use on occasion to get a peek under the hood of how my networks are working. If you use the code, please cite this page, and please let me know if you found it useful or not. This is the archive (5.8kB) containing 5 M source code files. Description of each is below, and the files are heavily commented.

The code files are as follows:

    • run_mlp.m

Script for generating synthetic data, calling the ANN, plotting and testing the output. This one can be run and it will call all the others.

    • train_mlp.m

This function intializes the model, presents the training patterns a given number of times, and returns the trained model. Arguments given are the training dataset, the target model output, the numbers of hidden layer neurons, the number of iterations to present the whole dataset, and the learning rate. Outputs are the trained model, the output of the model to the training set, and the correlation of output to target output.

    • update_mlp.m

This function is called a number of times (number of iterations * number of training examples) from train_mlp.m. This function does most of the complicated calculations for the ANN. It first calculates the activations of each layer of neurons, then calculates the error and propagates the error back through the network, and then updates the weights and biases accordingly. This is done in MATLAB so the calculations are done as matrices, which is nice at the end, but took some head scratching to figure out the first time.

    • test_mlp.m

A simple function for calculating the output of a trained model on a test dataset. Arguments to the function are the model, the input, and the target output. Returned variables are the output, and the correlation of output to target output.

    • clouds_on_unit_circle.m

This is just a helper function for generating some synthetic data that I use in run_mlp.m. It makes a 2D dataset which consists of populations scattered on the plane. There are some colorcoded plots which make it obvious what is going on.

Posted in Uncategorized | 9 Comments

Create and print a sundial

Dear Internet,

Here’s a little project I put together out of curiosity. Given latitude, longitude, date and time, where is the sun relative to you? Answer: it’s a whole mess of sines and cosines and stuff. Once you calculate it though, you’re just a few more sines and cosines away from being able to draw out a cool sun dial. I wrote this bit of code in php, which creates an svg sundial for your location that you can print out. Free fun for kids and cool dudes and fly ladies.

Here it is.  Create and print your own printable sundial.
Sundial Wizerd

And here’s a site that done helped me to gets the sines and cosines figured.

Let me know if you like it or hate it.
Best, Keith.

Posted in Uncategorized | Leave a comment


Hello, planet Earth!

Welcome to our Brain Annex, that repository for all the things that tend to fall out of our brains, so we write them down here, where you can access them as well.  We are Keith and Claudia, two post-doctoral neurobiologists working in sunny La Jolla, California.  We’ll post various things here, from protocols, to tips and tricks we’ve used to get our experiments working.  We’re both experts in in vitro electrophysiology, whole cell patch clamp, field recordings, fluorescence imaging, etc.  As for our non-overlapping skills, Claudia has experience with in vivo physiology, and has tons of molecular biology experience.  I, on the other hand, I did run a protein gel once (twice actually, since I messed up the first one).  My own experience extends to neuronal modeling and advanced data analysis methods and data mining.

Best of luck,
Keith & Claudia

Posted in Uncategorized | Leave a comment

Hi America, Did I mention…

Hi America, How are you?

It’s been a long time since I’ve blooged. Did I mention that I graduated with my Ph.D.? I’m not sure if I blooged it. It is called blooging isn’t it? I can’t even remember that.

Did I also tell you that we moved to California? I’m sure I blooged that one. I may be lazy, but even I wouldn’t forget to bloog that.

Here’s a nice picture of the sunset from the cliffs here in sunny San Diego.

I’m sure I already told you that I got a post-doc at the Salk Institute. Did I tell you? Maybe not. Maybe I’m terrible. Anyway, here I am at the Salk. On the equini the sun lines up with the river that runs through our central courtyard, so that’s pretty cool.

Here I am being silly.

Here’s a seal that lives down the street from us.

Here I am when I first wake up. Seriously though, you know it’s cool to have wild seals and sea lions nearby, but what people don’t tell you about that, is that seals and sea lions are actually quite smelly.

Here we are when we went hiking at Mission Trails Park.

Perhaps the most exciting thing was when Claudia made empanadas and one of them contained a greetings of love from a UFO alien.

And another contained a fossilized dinosaur bird.

Oh did I mention that we are training for the half marathon in the Avenue of the Giants? And we’re also registered for the AFC Half Marathon here in sunny San Diego. Also we’re registered for the Marine Corps Marathon. It will be Claudia’s first marathon, and my first in a while. So, I’ve got that going for me, which is good.

Anywho, that’s about all that’s going on here. I miss my friends back in Houston. You guys are very cool. You should come visit. You can sleep on the futon.

Best, Keith.

Posted in Uncategorized | 11 Comments

working / teaching

Hey America,

How have you been? You look good. Well, you don’t look bad anyway.

I am here, writing my dissertation, which may be the reason why I find it urgent to update my blog. Yeah, I was brainstorming what is the best way to formulate the model by which I analyze my data, and it occurred to me that I have not blogged anything in a really long time. I haven’t read any blogs either, so I really don’t know what my old friends are up to.

Mostly I have been only working these past months, and not much time for anything else. I am also teaching two lab classes in Introductory Biology, which is a class full of young Science majors, ready to take the world by its ear and shake it up. In truth, most of them are not very enthusiastic about Science, which is a little sad, at least from my point of view. This is the business of many awesome people, and awesome questions. The biggest questions there are. The human brain, and life, and big bangs, and nanobots, and cancer, and climate change, and evolution, and self-organization, etc. I think I’ll try to get them to focus on that big picture in the few remaining classes.

Anywho, I should get back to my writing.
Best, Keith.

Posted in Uncategorized | 3 Comments