My new go-to for cheap PCBs: Seeed studio

Full disclosure: Seeed studio emailed me and said I'd get a $30 coupon if I wrote a review of my experience ordering PCBs from them. Edit: May 3, 2017 - they have since delivered on this promise, so I've got $30 to spend on new boards! Sweet. Definitely my new source for pcb manufacturing.

First off, I usually order 2-layer boards, and I'm not pushing the fab limits at all (usually my minimum clearance and trace widths are both >12 mil). My bottom line is price, since I pay for the stuff myself, and I'm a postdoc (hence I'm not rich).

In the past, I've ordered PCBs from Sunstone and Advanced Circuits (4PCB). Mostly, I care about price. At advanced circuits, for $33 I can get a seemingly arbitrarily large 2-layer board (only available to students, otherwise the minimum order quantity is 4), but if I tile a small PCB so that I can get 10 small PCBs for the price of one, then they slap on a $50 array fee. And then there's shipping (which for some reason is always really expensive, like >$20) so the minimum cost is about $50 for a single PCB. Sunstone used to be significantly more expensive, but I recently ordered some boards there for around $50 each.  So, similarly priced.

Recently, a friend of mine told me about Seeed studio. They are fantastically priced - I bought ten 2.2-square-inch boards (2-layer) for $15 there (plus an $18 shipping fee).

I received the board 9 days after ordering - comparable to sunstone and advanced circuits. Quality-wise they're clearly a little bit below sunstone and advanced circuits, as there are minor misalignments in the silkscreen and the soldermask. But so far as I can tell with my first batch, totally functional. Definitely will order again (and update this post if I find any further issues!)

 

New goal

For every dollar I spend on alcohol, I'm going to donate that same amount to a charity.

Are bacterial mutation rates higher in space?

Apparently Nanobiosym, a biotech company in the area, has decided to send MRSA up to the ISS on a spacex rocket. This is headline-grabbing stuff. From the NASA page:

Proof-of-Concept for Gene-RADAR® Predictive Pathogen Mutation Study (Nanobiosym Genes) evaluates the feasibility of one day using this device from Nanobiosym® to identify bacterial mutations in space. The X Prize-winning device can accurately detect any disease that has a genetic fingerprint, in real time and at the point-of-care. Microgravity may accelerate the rate of bacterial mutations and this pilot investigation analyzes this process in two strains aboard the International Space Station, which may provide insight into how deadly bacteria become drug-resistant.

(Source: https://www.nasa.gov/mission_pages/station/research/experiments/2420.html)

Seriously, what????? $20 to anyone who can provide a reasonable and nontrivial explanation (e.g. not like, the cultures were less aerated in space because they weren't on a shaker) for why microgravity would accelerate the rate of bacterial mutations.

From a Salon.com article, Anita Goel (founder of Nanobiosym) is quoted as saying “[Low Earth Orbit] acts as an incubator to accelerate the mutations that happen with some  bacteria and viruses”.

That makes no sense at all to me. Can anyone explain?

Correlations in time series are sensitive to timescale

... and it's something that perhaps we don't look at quite often enough!

What am I talking about? Well, let's imagine that we're interested in the relationship between two signals, X_1(t), and X_2(t). One of the most basic analyses we might do is ask "are they correlated?" But perhaps the correlation depends on the timescale that we focus on. Could a signal be positively correlated at once timescale and negatively correlated at another scale?

acor_fig1

Since I've shown you an example, hopefully you believe that a signal could be positively correlated at one timescale and negatively correlated at another! Here, X_1 and X_2 are positively correlated on a long timescale but negatively correlated on a short timescale.

Can we characterize this sort of relationship? Yes, and I'll outline one way of characterizing this sort of time-scale dependent correlation below.

Continue reading "Correlations in time series are sensitive to timescale"

Paper #20 - Specific roles for DEG/ENaC and TRP channels in touch and thermosensation in C. elegans nociceptors

Title: Specific roles for DEG/ENaC and TRP channels in touch and thermosensation in C. elegans nociceptors

Year: 2010

Summary:

Here they were interested in discovering which proteins mediate nociception - the sensation of pain. Neurons that detect pain are referred to as nociceptors, and are thought to be multimodal - that is, they respond to many kinds of sensory inputs that generate pain, like heat, cold, harsh touch, extreme pH, or noxious chemicals. This paper seeks to answer the question of how nociceptors obtain their multimodality. Do they have single receptors that respond to all these inputs? Or do they have many receptors? At which point do these sensory inputs converge onto the same signal transduction path?

Continue reading "Paper #20 - Specific roles for DEG/ENaC and TRP channels in touch and thermosensation in C. elegans nociceptors"

My top 54 functions to know when using R

I was trying to figure out what I'd want to know if I were just learning R, and I think these might be my favorites. The list is not complete, and I welcome suggestions! I will also try to add some documentation to this so that it could be printed out and used for reference.

  1. ls
  2. rm
  3. library
  4. install.packages
  5. list.files
  6. getwd, setwd
  7.  apply
    • mapply
    • sapply
    • lapply
  8. str
  9. dim
  10. colnames
  11. rownames
  12. names
  13. summary
  14. %in%
  15. which
  16. c
  17.  plot
    • points
    • lines
  18. image
  19. matplot
  20. hist
  21. heatmap
  22. density
  23. par
  24. layout
  25. legend
  26. text (mtext?)
  27. t
  28. na.omit
  29. read.table
  30. write.table
  31. as. (as.character, as.numeric, as.matrix...)
  32. data.frame
  33. aggregate
  34. merge
  35. reshape
  36. order
  37. sort
  38. cbind/rbind
  39. lm
  40. nls
  41. optim
  42. unique
  43. sum
  44. cumsum
  45. diff
  46. setdiff
  47. intersect
  48. rnorm
  49. sample

Paper #19 - Natural light-gated anion channels: a family of microbial rhodopsins for advanced optogenetics

TitleNatural light-gated anion channels: a family of microbial rhodopsins for advanced optogenetics

Year: 2015

SummaryIn this paper, they're interested in finding new optical actuators for controlling the membrane polarization of the cell (and particularly neurons). they begin by investigated a class of class of rhodopsins from cryptophytes, as opposed to previous channelrhodopsins which have been obtained for chlorophytes (green algae). Cryptophytes are also algae, but in a different kingdom (chromalveolata) than green algae (archaeplastida), thus they're probably quite significantly diverged.

They focus very quickly and with little justification (probably not their fault, Science doesn't provide much space) on  Guillardia theta, a cryptophyte alga with a fully-sequenced genome. In this genome, there are 53 proteins sharing similiarity to microbial rhodopsins.

Continue reading "Paper #19 - Natural light-gated anion channels: a family of microbial rhodopsins for advanced optogenetics"

Paper #18 - A neuropeptide-mediate stretch response links muscle contraction to changes in neurotransmitter release

TitleA neuropeptide-mediate stretch response links muscle contraction to changes in neurotransmitter release

Year: 2011

SummaryC. elegans has a ton of neuropeptides (apparently 115 proneuropeptide genes for up to 250 mature peptides, many of which have been observed experimentally by mass spec). These neuropeptides are generally secreted extrasynaptically, and have been shown to modulate choline/acetylcholine release at neuromuscular junctions in C. elegans. In this paper, they want to know how neuropeptides can control synaptic plasticity.

Continue reading "Paper #18 - A neuropeptide-mediate stretch response links muscle contraction to changes in neurotransmitter release"

My rules for good figures

Abstractly:

  • Put the labels as close to the data as possible.
  • When possible, reuse as much of the plot format as possible

More concretely:

  • For scale bars on images, it doesn't hurt to put text right next to the bar, telling your readers what the scale bar actually means (so that they don't have to go to the legend to find out that bar is 100um).
  • Putting the sample size directly on your plots is helpful (rather than in legends).
  • Bar plots with numeric values on the x-axis are almost never the best way to show the information - numeric variables demand quantitative plotting!
  • Axis labels are essential, and they need to be be as clear as possible about two things: 1) what was measured, and b) what that measurement should be interpreted as.
    • labels like 'Fraction' or 'Count' are generally not very helpful.

As always, suggestions welcome! I will update this list as I think of more things (and read more papers!).

Paper #16 - Dissecting a central flip-flop circuit that integrates contradictory sensory cues in C. elegans feeding regulation

TitleDissecting a central flip-flop circuit that integrates contradictory sensory cues in C. elegans feeding regulation

Year: 2012

Summary:

In this paper, they sought to understand how C. elegans controls its pharyngeal pumping ('feeding') behavior in response to attractive and repulsive chemical stimuli. They use diacetyl as an attractive stimulus, and quinine or high concentrations of isoamyl alcohol as repulsive stimuli.

Continue reading "Paper #16 - Dissecting a central flip-flop circuit that integrates contradictory sensory cues in C. elegans feeding regulation"

Paper #14 - Tyramine functions independently of octopamine in the Caenorhabditis elegans nervous system

Title: Tyramine functions independently of octopamine in the Caenorhabditis elegans nervous system

Year: 2005

Summary: The year was 2005, and no one knew if tyramine was important in C. elegans. It was known that octopamine was found in C. elegans extracts, and that exogenous octopamine could manipulate C. elegans behavior, but no one had yet found a tyramine hydroxylase gene that could turn tyramine into octopamine in animals. And importantly, no one knew how octopamine and tyramine differed in their roles in worm behavior.

Until this paper was published.

Continue reading "Paper #14 - Tyramine functions independently of octopamine in the Caenorhabditis elegans nervous system"

stimMatrixRGB - 96-well plate optogenetic stimulation

There are lots of optogenetic actuators. And they respond to diverse wavelengths. What if you could systematically profile how an organism or population of cells responds to a precise temporal stimulation profile in 3 colors?

Well, now you can. Because I built a board to do it. Here's an example of random stimulation wellof each well in a 96-well plate with blue and/or green light.

If this sounds like it might be useful to you - awesome, let me know! I'll be putting up the board schematics, bill of materials, and source code shortly so you can build your own.

img_7922 img_7916 img_7914img_7912

Where do you get the files? Here! And if you get stuck on building it, hit me up and I'd be happy to help.

 

Paper #13 - System-wide rewiring underlies behavioral differences in predatory and bacterial-feeding nematodes

Paper #13 - System-wide rewiring underlies behavioral differences in predatory and bacterial-feeding nematodes

Year: 2013

Summary: In Pristionchus pastoris - a nematode related to C. elegans, but also capable of eating other worms instead of just bacteria - how does the the pharyngeal nervous system differ?

Continue reading "Paper #13 - System-wide rewiring underlies behavioral differences in predatory and bacterial-feeding nematodes"

Paper #12 - Food and metabolic signalling defects in a Caenorhabditis elegans serotonin-synthesis mutant

Title: Food and metabolic signalling defects in a Caenorhabditis elegans serotonin-synthesis mutant

Year: 2000

Summary: Here they set out to characterize the overall role of serotonin in C. elegans  by constructing a mutant that cannot synthesize serotonin.

Continue reading "Paper #12 - Food and metabolic signalling defects in a Caenorhabditis elegans serotonin-synthesis mutant"

Paper #11 - Engineering pairs of distinct photoswitches for otogenetic control of cellular proteins

Title: Engineering pairs of distinct photoswitches for otogenetic control of cellular proteins

Year: 2015

Summary: In this paper, they are aiming to make a fast, sensitive and specific optically-controllable protein interaction. At first, they note that there are a number of photoactive proteins that have been engineered for use as photoswitchable actuators, including the LOV2 domain of phototropin 1, Vivid (VVD) and a bunch of others (cryptochrome 2, FKF1, UVR8, EL222). Point blank, I know nothing of any of these so I really can't comment on how this fits in with the field (maybe I'll try to come back to this later).

In this work, they focus on Vivid (VVD), from Neurospora crassa. It's one of the smallest proteins, uses FAD as a chromophore (which is ubiquitous in eukaryotic cells), and homodimerizes when blue light is applied. However, it's got drawbacks.

  1. It homodimerizes. Imagine you want to make gene A active when you apply light. You split gene A in half (A* and A') and make and express two fusion proteins: VVD-A* and VVD-A'. When you shine blue light, you're as likely to match A* with A' (its correct partner) as with A* (not its correct partner).
  2. It's slow. After you stop the blue light, it takes 3-4 hours before the dimers separate back into monomers.

Continue reading "Paper #11 - Engineering pairs of distinct photoswitches for otogenetic control of cellular proteins"

Fitting models/equations

When fitting fails, it fails for basically two reasons

  • bad initial conditions
  • bad model (ill-conditioning/multicollinearity)
Initial conditions.

90% of the time it's the initial conditions. In fitting, finding good initial conditions is usually one of the hardest things to do. You expect the fitter to do all the work but its really not that good - it just refines solutions when you're already in the vicinity of the solution.

As a RULE, always plot these three things overlaid:

  • Plot the data you want to fit, AFTER any transforms you might apply (for example, if you're going to fit the log-transformed data, PLOT the log-transformed data).
  • Plot the predictions based on the initial guesses for the parameters.
  • Plot the predictions based on the fit parameters.

How do we obtain good initial guesses?

  • One option is to guess some parameters (guided by what they mean in your model), check to see if they yield predictions anywhere in the vicinity of the data they're supposed to fit. This often works okay if you're only fitting one dataset. But what if you've got to fit 100 datasets? Then it's unlikely that a single initial estimate will work for all of them, and we're going to need to come up with initial estimates for each one.
  • A better option is to use heuristics to get you to ballpark estimates, correct to perhaps an order of magnitude. Examples of heuristics:
    • If I were fitting a straight line, e.g. y = mx+b (note that this is just a toy example and you'd never use an iterative solver to fit this), i might get an initial guess for the slope parameter m by first sorting my data in order of ascending x, and then using (y_last-y_first)/(x_last - x_first).
    • If I were fitting a logistic function:  y= K / (1+P * exp(-r*x)), I might choose K = max(x), because in my model, K is the maximum value it ever attains. For an initial guess for P, since I know at x=0, then y=K/(1+P), i might see if i have a datapoint around x=0. If I do, call it (x*, y*), then a decent initial guess for P might be  P = (K/y* - 1), or max(x)/y*-1.
Fitting on a log or linear scale (and transforms more generally):

While I can fit models many ways, one of the most common issues I've had arise is whether to fit them on a log or linear scale. These do NOT provide the same result - e.g. fitting y=mx+b, or fitting log(y) = log(mx+b). Why? Because when we fit, we're implicitly trying to minimize the overall difference between the left-hand side and the right hand side of the equation. Strictly, most fitters default to minimizing the sum of squared errors between the left- and right-hand sides (observed data and predicted data, respectively). On a linear scale, the difference between 10 and 100 is a lot more than the difference between 1 and 20, whereas on a log-scale, the latter is a much larger discrepancy.

  • Practically speaking, the way to choose whether to fit your data on a linear or log scale is to ask - do i care about absolute deviations? or relative deviations? Suppose I have some data (y) that span say four orders of magnitude, from 0.01 to 100.
  • This comes down to - do I believe the errors in my data are additive or multiplicative? In the former, fit the data on a linear scale. If errors are multiplicative, fit in on a log scale.
  • Instead of using a function that fits formulas, it often helps clarify the problem to formulate it as an optimization (maximization or minimization problem), and forces you to think clearly about what fitting actually means. Typical fitting function (e.g. lm() or nls() in R) use the sum of squared errors between the data and the predictions.

Paper #10 - Glia promote local synaptogenesis through unc-6 (netrin) signaling in C. elegans

Title: Glia promote local synaptogenesis through unc-6 (netrin) signaling in C. elegans

Year: 2007

Summary: The underlying question in this paper relates to: How do neurons know where to form synapses? Clearly this is a question I'm into, since this is the third paper I've looked into on this question (the first post here, on a paper from the Kaplan lab, and the second one was in yesterday's post, on a paper from the Schafer lab).

Continue reading "Paper #10 - Glia promote local synaptogenesis through unc-6 (netrin) signaling in C. elegans"

Paper #9 - Rewiring neural circuits by the insertion of ectopic electrical synapses in transgenic C. elegans

Title: Rewiring neural circuits by the insertion of ectopic electrical synapses in transgenic C. elegans

Year: 2014

Summary: Okay, this one seems really straightforward (and nice and short). Their big question: can you engineer synapses between particular neuron pairs in C. elegans? 

As a starting point, they decide to try to create novel electrical synapses (gap junctions), which have been previously created in other systems by overexpressing a single innexin (invertebrates) or connexin (vertebrates). They reason that expressing connexins (again, from vertebrates) in the worm is a better strategy than innexins, as both families of proteins can form gap junctions with a mixture of within-family proteins (e.g. a gap junction may involve several different connexins, or several different innexins, but not a combination of both). Therefore ectopic expression of an innexin would likely lead to all kinds of undesired gap junctions forming due to all the natively expressed innexins already present in neighboring neurons.

Continue reading "Paper #9 - Rewiring neural circuits by the insertion of ectopic electrical synapses in transgenic C. elegans"

Paper #8 - Memory in Caenorhabditis elegans Is Mediated by NMDA-Type Ionotropic Glutamate Receptors

Title: Memory in Caenorhabditis elegans Is Mediated by NMDA-Type Ionotropic Glutamate Receptors

Year: 2008

Summary: Okay, this is my second paper from Villu Maricq's group, and incidentally, from the same year. Must have been a good year.

In this paper, their question was: are glutamate receptors required for memory in C. elegans? AMPA and NMDA receptors have been implicated in memory in many systems, but not C. elegans. Specifically, in many systems neural activity modulates AMPA and NMDA receptor cycling and thus affects synapse strength.

Continue reading "Paper #8 - Memory in Caenorhabditis elegans Is Mediated by NMDA-Type Ionotropic Glutamate Receptors"

Paper #7 - Hierarchical sparse coding in the sensory system of Caenorhabditis elegans

Title: Hierarchical sparse coding in the sensory system of Caenorhabditis elegans
Year: 2015
Summary: The big question in this paper is how do different neurons convey sensory information about various stimuli.

To start, they generated a library of 19 strains, in total expressing GCaMP3 in 28 different neurons or neuron groups. They then the calcium response from >5 animals from each strain in response to a panel of 13 stimuli. Those stimuli included isoamyl alcohol (on and off), diacetyl (on and off), salt (on and off), pH (low and high), osmotic stress (on and off), E. coli supernatant (on and off), and blue light (on only). I believe all of these have been previously tested on specific C. elegans neurons, but this sort of systematic all-vs-all study has never been undertaken. Clearly, this is direly needed information to parameterize models of pan-neuronal activity!

Continue reading "Paper #7 - Hierarchical sparse coding in the sensory system of Caenorhabditis elegans"

Paper 6: HBL-1 patterns synaptic remodeling in C. elegans

TitleHBL-1 patterns synaptic remodeling in C. elegans

Year: 2012

Summary: C. elegans have five classes of motor neurons in the ventral nerve cord - A, B, VC, D, and AS. Within A,B, and D, there are both ventral and dorsal subgroups (e.g. D can be divided into VD and DD). However, at birth, only the DA, DB and DD neurons are present.

In this paper, they investigate a striking phenomenon, in which DD neurons, which initially form synapses with the ventral muscles, eliminate those synapses and instead form synapses onto the dorsal muscles (in order to be consistent with their name!). They mostly focus on the formation of new neuromuscular junctions, but note that the initial ventral axon converts to a dendritic fate (and thus presumably forms many new synapses which were not investigated in this paper), and that this rewiring process does not involve extension/retraction of neurites.

Continue reading "Paper 6: HBL-1 patterns synaptic remodeling in C. elegans"

Paper #5 - A C elegans mutant that lives twice as long as wild type

Title: A C elegans mutant that lives twice as long as wild type

Year: 1993

Summary:  The authors investigated several genes that can lead to dauer formation (an alternative third larval stage induced by stress and whose entry is mediated by a pheromone during L1). They hypothesized that since dauers are so long-lived, perhaps some of the genes activated during dauer stage would confer longevity to the worm.

Continue reading "Paper #5 - A C elegans mutant that lives twice as long as wild type"

A common error: Comparing the effects of two variables or treatments by comparing p-values

This is something I've seen a few times in papers recently and I find it kind of striking, since it's not something that's hard to spot as incorrect.

Let's imagine I've got a left-right neuron pair, neurons A and B, that I think might drive some particular behavior in C. elegans, say, head motion. I find that if I ablate neuron A, head motion gets slower (specifically, head velocity decreases, with a p-value < 0.05), and if I ablate neuron B, head motion doesn't get slower (specifically, head velocity decreases, with a p-value > 0.05).  Can I conclude that neuron A affects head motion differently than neuron B?

The answer should be pretty obviously no! I need to do a different statistical test to see if A has a different effect than B! Simply knowing the p-values of the two tests is wholly insufficient to tell if they have different effects. Imagine for one neuron p=0.049 and p=0.051. Obviously you wouldn't want to conclude they had different effects!

What statistical test is appropriate? I'm not 100% sure. My default  approach would be to fit a simple regression model in which we estimate Y = B_0 + B_1(A+B) + B_2 and test whether B_2 is nonzero.  However, this approach might not be optimal. Any suggestions?

Paper #4 - A Circuit for Gradient Climbing in C elegans Chemotaxis

Title: A Circuit for Gradient Climbing in C elegans Chemotaxis

Year: 2015

Summary:

In this paper, their goal is to understand how C. elegans can perceive scents over at least four orders of magnitude concentration range. Worms can sense and respond to extremely small amounts (10 nM) of diacetyl (an 'intensely buttery-smelling' compound, and not surprisingly, naturally found in butter), all the way up to massive concentrations of diacetyl (100 uM). How do they avoid sensor saturation? If a sensor saturates, it's no longer able to detect a gradient, and if a worm can't detect a gradient, it cant do chemotaxis!

Continue reading "Paper #4 - A Circuit for Gradient Climbing in C elegans Chemotaxis"

Paper #3 - Dynamic Encoding of Perception, Memory and Movement in a C. elegans Chemotaxis Circuit

Title: Dynamic Encoding of Perception, Memory and Movement in a C. elegans chemotaxis  circuit

Year: 2014

Summary: This work builds on work the previous year from Kunitomo et al. in Yuichi Iino's lab, where they found that C. elegans not only chemotaxes towards salt (a fact published at least as early as 1973), but specifically learns to associate a particular salt concentration with food or the absence thereof.

In this paper, the fundamental phenomenon they seek to explain is one in which C. elegans, cultured at X mM salt, will chemotax back towards the X mM when moved to a different salt concentration within a plate containing a spatial gradient of salt concentrations. For example, a worm cultured at 50mM salt and then moved to 25mM will attempt to climb back up the gradient ('positive chemotaxis'), but if placed at 75mM, will attempt to move down the gradient ('negative chemotaxis')

Continue reading "Paper #3 - Dynamic Encoding of Perception, Memory and Movement in a C. elegans Chemotaxis Circuit"

Paper #2 - Action potentials contribute to neuronal signaling in C elegans

Title:  Action potentials contribute to neuronal signaling in C elegans

Year: 2008

Summary: In this paper, they undertook patch clamp measurements on C. elegans neurons, a rarely used (and presumably difficult) technique, to study the electrophysiological properties of C. elegans interneurons. They specifically looked at AVA (the 'backwards command' neuron) and RMD interneurons. AVA has an apparently very linear IV-curve in current clamp mode, consistent with previous measurements.  In contrast RMD appears bistable, with a stable depolarized state at ~ -10mV! This is often referred to as a plateau potential, in which a brief current pulse can switch the neuron's state from low to high or vice versa. Without any stimulation, RMD also appeared to natively switch between a high and a low state, whereas AVA flatlined.

Continue reading "Paper #2 - Action potentials contribute to neuronal signaling in C elegans"

Paper #1 - Graded synaptic transmission at the Caenorhabditis elegans neuromuscular junction

One paper a day for a month. My plan is to post a summary of each paper, as well as any context I can provide, and any things I was confused about in the paper. Most importantly, I am going to list all the questions I thought of while reading the paper that WEREN'T addressed.

Title: Graded synaptic transmission at the Caenorhabditis elegans neuromuscular junction

Year: 2009

Summary: C. elegans neurons are mostly thought to lack action potentials due to a lack of voltage gated sodium channels, but some studies have found evidence of all-or-nothing signaling via calcium plateau potentials. Most previous electrophysiological papers have reported on a single neuron, including sensory neurons or interneurons, but none have studies motor neurons.  Do C. elegans motor neurons communicate with muscles in digital or analog? 

Continue reading "Paper #1 - Graded synaptic transmission at the Caenorhabditis elegans neuromuscular junction"

A function that I use all the time for peak detection

Maybe it's already out there in the R, but I haven't seen it before.

is.localmax = function(i,context, k, FUN=max, ...){
context = c(rep(NA,k), context, rep(NA,k)) # pad with NAs
i = i + k # account for the NA padding
contextMatrix = sapply(i, function(x) {context[(x-k):(x+k)]})
context[i] == apply(contextMatrix, 2, FUN, ...)
}

getPeaks = function(x,threshold,k) {
i = which(x>threshold)
if (length(i)>0)
i[is.localmax(i,context=x, k=k,FUN=max)]
else
NA
}

Basically, it finds all the indices above some threshold (quickly), and then only checks those to see if they are local maxima for some local window of length 2*k+1.

NOTE: this function fails if local maxima aren't unique. If you're likely to get two local maxima (e.g. from a low-resolution ADC)  in a single peak (e.g. the vector [0 0 1 2 3 3 2 1 0 ], it will return both indices 5 and 6), which may be undesirable. To work around this, add a very very small amount of noise to the signal (x) to force the code to select one of the indices at random.

 

 

What became of British Sea Power?

I ran across this video earlier today (and this one too is also damn good). I had forgotten about this band - I don't know if they're still around but I will look around. I remember having a copy of 'Decline of British Sea Power' which was apparently released in 03 (which makes sense because I remember listening to the album in high school). Definitely an album worth checking out.

Particle size selection by settling

Suppose you had a 10cm tube full of particles of various sizes, but you only wanted those bigger than 100um. Also, you have no filters. How might you get what you want?

Well, you could shake the tube up, wait a little bit for things to settle, remove the top half and toss it, refill the tube, and repeat! How well would this work? Well, maybe sort of okay. Here's some code in R to simulate it.

tubeHeight = 0.07             # m (0.07 = 7cm)
collectionHeight = 0.02            # m (0.02 = 2cm)
collectionTime   = 2*60            # seconds


radii = 10^seq(-6,-3, by=.02) # m
particleDensity = 1100        # kg/m^3
fluidDensity = 1000        # kg/m^3
mu = 1.88e-3            # viscosity of water



# in m/s
speed = function(rad)  (2/9)*(particleDensity-fluidDensity)*9.8*rad^2/mu


settlingVelocities = speed(radii)
settlingDistance = settlingVelocities * collectionTime
# fractionRetained is fraction below collectionHeight after time is up. 
fractionRetained = pmin((collectionHeight+settlingDistance)/tubeHeight, 1)

for (i in 5:1){
    if (i==5) plot(2*radii*1e6, fractionRetained^i,log='x', type='l',
                xlab='Diameter (um)', ylab='Fraction retained')
    if (i!=5) lines(2*radii*1e6, fractionRetained^i, col=i)
}
abline(v=radii[min(which(fractionRetained==1,arr.ind=T))]*2e6, lty=2)

the meaning of thank you

I just read this article, 'Thank you in Hindi and English mean very different things.' Similarly to most Americans (I imagine?), I was taught that it was important to remind people that you value them, and I guess I just don't know how I'd do this without saying thank you.
"In the Hindi language, in everyday gestures and culture, there is an unspoken understanding of gratitude."I would love to know how this conveyed. Maybe I'm just not feeling very positive about my daily interactions, but my impression is that the default is understood to be no gratitude unless it's made explicit.

things I would like to remember if/when I run a lab

I should offer my students the option to be corresponding authors on their papers. Similarly, I should seriously consider what my role was in the project and therefore whether I should be on the paper in the first place. I should strive to feel like I always deserve that spot and was doing more than contributing money and lab space.

If I have favorites, I should not treat them any differently than anyone else in the lab. I should celebrate all accomplishments as much as reasonably possible.

I should meet regularly with students and try to understand their goals and aspirations beyond their time in the lab.

I should give students an opportunity to provide honest feedback on how I am doing. This is not easy, but some PIs have had success with 6-month reviews.

I should encourage all my students to think about how to work on projects with the maximal possible impact, subject to the time constraints they have.

I should remind students that publications are not the only currency of value, and indeed are a very volatile and unreliable currency. However, unreported results are of no value to no one.

(inspired in part by many discussions with M. Datta)

Measuring productivity as 'Science, Nature, and Cell (SNC) publications'

From: Staffing labs for optimal productivity

How can this possibly be a metric that people think is acceptable? Even simply number of publications? When will we accept that any reasonable metric of productivity will have to be (a) multidimensional, (b) based on article-level metrics  and not journal-level metrics and (c) those underlying article-level metrics must be based on critical study of the work, not just easily-obtainable but ultimately uninformative features of the work like citation counts.

Finally, we should remember that any such 'productivity metric' will be ultimately be a very rough, error-prone one, as it's often difficult to judge the value of a work until many years after its publication.

 

8tracks mixes i dig

tycho live at KEXP - eh, this is youtube, not 8tracks, but i'll put it here anyhow. it's awesome.

good times hip hop - not sure how you couldn't like this. title is accurate.

those nights - bunch of electronic stuff i'd never heard before

keepsake - reaaaaaallly diggin the beats here on a friday afternoon.

classy revsion

from 2012

party mixology

beat cave vol 2 - totally into this one, and it's pretty diverse, from schlomo to flosstradamus

flowing loops

i made this when i was high

east coast kids - rockin

im feeling glitchy - uhhh.. glitchy?

get to work (extended) - first mix i fell in love with on 8tracks.

alt country, beautiful warbling and rock'n'roll

blunted beats - dilla and everything in the vicinity

Sunday morning - cant lie, only listened to the first track when i added this to the list, but i'm sure i'm not going to regret putting it here.

orion - slow and relaxing

until the devil knows you're dead