Use teensy microcontrollers instead of arduinos

This post is mostly just an advertisement for the teensy family of microcontrollers (MCUs).

People like to use ‘arduino’ as shorthand for easy to use MCU (and wherever you go you see arduinos with ratsnets of loose wires stuck in the headers) but in almost all cases you should use a teensy instead. Arduinos have given many people the wrong  impression that cheap and easy to use MCUs are not powerful enough to do some pretty heavy lifting.

Teensy is the project of Paul Stoffregen (twitter, github, buy teensys at https://www.pjrc.com/teensy/) – I use these so much in quick experiments and main rigs its hard to count how many I bought.

There are two versions you should consider – the teensy 3.2 which you’ll use for most stuff, and the teensy 3.6 which is even faster, has more pins, but can not handle 5V signals. There is also a cheaper LC version, use that if you need _many_ for some fun project. If you are currently using arduinos, just get a teensy 3.2.

Upsides:

  • Good price: Its its $11 for the LC version, 25 for the 3.2 workhorse and $30 for the 3.6 monster.
  • Insane speeds: the teensy 3.6 runs a 32 bit 180 MHz ARM Cortex-M4 processor with an FPU. That’s enough to run a wall-size LED screen.
  • Fast serial connection to PC. You can stream over 0.6 MB/s (megabytes per second) from a PC with these (source).
  • Many bus types are supported: Connect multiple i2c buses/peripherals to one teensy. I used this for all kinds of sensors/actuators.
  • Breadboard compatible. Its set up in a nice .1″ grid so it snaps into breadboards, not some fully insane proprietary half-offset pattern. This means you can use a breadboard and not have your rig fail in the middle of an experiment like an arduino with loose wires will.
  • So many fun built-in functions. Timers, interrupts, capacitive sensors, ADCs/DACs.
  • Great real analog i/o. This deserves its own point. These things can read two analog signals with 13bit usable resolution (more info). (Use the i2c bus to add more ADCs though if you need em). There’s also pretty nice DACs on there (more info).
  • Great community. If you google arduino problems you will likely eventually find the true solutions to basic problems. The teensy forums are full of usable solutions, even to tricky problems.

Downsides:

  • If you want the fastest one (the 3.6 at the time of writing) you can only use 3.3V signals, so use a 3.2 if you need 5V inputs/outputs.
  • On some linux systems, the teensy needs a physical reset after re-programming. Make sure you don’t block that button in your project 🙂

Some examples
of stuff that we’ve done that would be impossible with an arduino but were easy with a teensy:

  • Makeshift 100kHz signal generator and digitizer to measure the frequency response of a tunable lens.
  • Read a very precise quadrature encoder  by counting pulses at kiloherz speeds using the built-in hardware counters and some libraries.
  • Smooth control over stepper motors with microstepping libraries.
  • Capacitive touch buttons.
  • Running a pretty complex control loop with a bunch of floating point math and multiple i2c interfaces talking to a few sensors and a serial uplink to a PC at 500Hz.

To the average user, teensys look and behave just like arduinos, you use the same software to program them, all regular arduino code just works on them, but they go so much faster and further.

How to:

  • Buy one (or 4 or so, you’ll want more) from PJRC.
  • Install the arduino software (check that your version is supported, as of writing the latest supported one is 1.8.8).
  • Install Teensyduino.
  • Install the blink example, enjoy the blinking LED.
  • Go solve real problems.
Posted in Uncategorized | Comments Off on Use teensy microcontrollers instead of arduinos

Visualizing recording pipettes with quantum dots

Here’s a quick description/’review’ of the method for making pipettes fluorescent by quantum dot coating described in Andrásfalvy et al 2014. We used the protocol for some in-vivo 2p guided sharps recordings a while ago and really liked how cheap, simple and versatile the method was.

We previously used a flourescent dye (alexa) in our pipette solution, and while giving great contrast, this resulted in fluorescent dye accumulation after repeated recordings. Qdots just leave a visible but not overly bright ring where the pipette enters the tissue, which turns out to be pretty helpful in guiding subsequent recordings.

Another potential upside of qdots might be being able to use different channels for a fluophore on the inside of the pipette and for the qdots.

Finally, we found that qdots work better than alexa for thin pipettes, where the tiny inside diameter makes it very challenging to locate the tip of the pipette with a 2p.

We used the protocol from:
Andrásfalvy et al.: Quantum dot–based multiphoton fluorescent pipettes for targeted neuronal electrophysiology, Nature Methods 11, 1237–1241 (2014)

qdot coating

from Andrásfalvy et al. 2014

Pipette bubble number
This method makes use of the ‘bubble number’ test, which is a quick and easy way for measuring the tip opening diameter of micropipettes, and for making sure that pipettes dont get clogged with the qdots:

Bowman & Ruknudin: Quantifying the geometry of micropipets, 1999 Cell Biochemistry and Biophysics

The method estimates the tip opening by measuring the pressure required to expel bubbles from the pipette in methanol. It’s possible to precisely measure tip diameters with this, but here we just used it as a ballpark estimate and to very quickly check for clogging.

Attach the pipette to a syringe that allows you to apply pressure, dip the pipette in methanol while holding light pressure, and steadily increase the pressure until small bubbles rise from the tip. Fine adjustments of the pressure should now reveal a precise point at which bubbles either appear, or not. With some calibration, this point should allow a good prediction of the tip resistance. I usually get down to ~5ml compressed air volume from 10ml, for ~15MOhm pipettes, but this value depends on a few factors, and should be calibrated.

Preparing the quantum dots
In order to ‘paint’ the glass pipettes with the qdots, they need to be suspended in hexane.
The qdots usually come in tuolene, we’ve tested this protocol with red (630nm) ones from Sigma.

To get the qdots out of the tuolane and into hexane, we need:
A small 2000g bench top centrifuge, a pipette, some centrifuge compatible tubes, acetone, methanol, and hexane.

  1. Wash the qdots in a 50/50 mixture of acetone and methanol. We’ve used up to 2 parts of the aceton&methanol mix to 1 part of the qdots (1 mg/mL in toluene).
  2. Spin down until either a pellet forms, or sometimes the qdots just adhere to the wall of the tube – as long as the solvent can be removed cleanly with a pipette, and replaced with new clean solvent, it’s alright. This step can be repeated to further wash the qdots. We haven’t noticed any differences after the 1st wash, so we stuck with just doing 2.
  3. Once the qdots are suspended in clean acetone/methanol, remove the acetone/methanol and add as much hexane to the qdots as desired. A less diluted solution will require fewer (possibly only one) dip of the pipette to coat. We found that dilution to the original volume (of the acentone methanol toluene qdot mix) worked well and gave us good control over the pipette coating.

Coating the recording pipettes
Now, just dip the tips of the pipettes in the qdot hexane solution, and dry off. It is very important to keep enough pressure on the pipette to keep the dots from clogging the tip – you always want enough pressure to keep bubbling the tip. A quick bubble test in methanol after the qdot dipping is an easy way to check if the tip was clogged. If needed, multiple dips can be used to accumulate more qdots. The coating can be checked by eye with a UV light, just from a little LED flashlight.

Keeping the qdot solution around for more than a few days might require adding new hexane every now and then, most small plastic containers that we tried failed to stop evaporation. Once the solution dries out completely it can be pretty tricky to get the qdots back into a nice solution.

Posted in Electrophysiology | Leave a comment

Low cost laser cut syringe pump

Here’s a yet another design for a cheap-ish open source syringe pump. There are many designs for these out there already, including 3d printed ones, and ones made from lego.

This one is designed to be fast to build, robust, mechanically stiff, and precise. I’ve used 16 of these for over a year now to deliver water rewards and had no issues. I use them to give small water rewards of around 0.003ml, but the precision of these is mostly determined by the mechanics of the syringe, not the pump.

The total cost per pump is under $100 when making over 10. See the bill of materials (BOM) here (This should have everything you need to order and build these), and the github repo with the design files here.

An array of the pumps in action.

I’ve used both gravity fed solenoid and syringe pump systems and I’ve come to vastly prefer the latter. The main benefits of using syringe pumps over solenoid valves for reward delivery are:

  • Independence of flow speed. With a gravity fed system, the reward size is controlled by timing the valve opening. For small reward sizes and low (gravity fed) pressures, changing the length of tubing can affect the reward size as much as changing the mounting position etc.  You can also use very long tubing with pumps and still reliably deliver small rewards.
  • Liquid compatibility. Valves are notoriously hard to implement reliably with sticky liquids. Syringe pumps can deliver almost anything.
  • Easy filling/cleaning. Pulling the plunger back all the way on a syringe pump creates a small opening in the back of the syringe, which makes it possible to flush the tubing and syringe, and/or conveniently fill the system from the other end. Simply pushing the plunger forwards a bit closes the system, so that water can be filled easily without air bubbles.

The main downside is size, and possibly the slightly lower delivery speed, though depending on the motor and threading on the driving screw this could be made almost equivalent to a solenoid.

Rendering of the design – the M8 threaded rod is not shown here.

 

This design is built around a few simple ubiquitous components that can all be ordered online and assembled with very few tools:

  • A pair of extruded aluminum profiles to form a stable base.
  • A standard stepper motor, with some coupling and a standard M8 threaded rod and M8 nuts for creating precise linear motion (these are pretty terrible for running smoothness, but we’re not making a 3d printer here, so it doesn’t matter). An acme thread and nuts could be substituted for faster travel, but the M8 seems perfect for getting enough speed and very high precision, and the threaded rods are cheap.  By using two M8 nuts that are pre-loaded against each other, backlash is eliminated, and the pair simultaneously holds the sled assembly together (you should still apply some hot glue).
  • A pair of round precision rods and 4 standard linear bearings to ensure clean linear motion of the sled. I used 10mm rods here, but 8 or even 6mm should work just as well, this would just require changing the hole sizes for accommodating the bearing OD.
  • A set of laser cut acrylic parts that hold everything together and form the clamps for holding the syringe. Apart from some screws, no other custom parts are required. The laser cut parts that are screwed together, and the linear bearings can be fixed with a hot glue gun. If you want to modify the design you can do most edits just with illustrator.
  • Pro tip: Ask your laser cutting place to peel the backing paper before cutting the parts. No one is going to judge you for some burn marks on the pumps, but peeling the paper off all the parts is easily the most annoying part of the assembly process.
  • Pro tip 2: If you’re getting your M8 threaded rods and precision linear rails in longer sizes, which is likely, you will want to borrow someones angle grinder, or buy one, to cut them to length. This is not a job for a dremel.

The control software is very simple, I just use a teensy with the accelstepper library and a standard stepper driver. Once the volume/step is calibrated, delivering reward boils down ot just issuing forward backward commands, for example via a serial interface from a python program , or matlab etc.

As an extra flourish, it is nice to turn off the motor current when the motor is not moving – this keeps it from heating up. Also, when running multiple pumps on the same rig this might be required to keep the power supply fuse from tripping, as each stepper motor can consume ~1A when energized regardless of whether it is moving or under load. The stepper driver I used here, as do almost all of them, has an EN pin that can be used to de-energize the motor. One important caveat for this is to not simply de-energize the motor immediately after it was moved, but to wait ~100-500ms or so. This is because if an accelerated motor is de-energized, it can continue to spin for a few steps. Keeping the field on for a while serves to brake the motor, so it can then be safely de-energized without accidentally delivering more liquid than intended.

 

Posted in Uncategorized | Comments Off on Low cost laser cut syringe pump

Preprint: Free head rotation while 2-photon imaging

We just posted the preprint for a method that allows 2-photon imaging while mice  freely rotate horizontally and  run around a real (or virtual) 2-D environment. The system allows attaching other instruments (ephys, opto, etc.) to the headpost. We think that this approach is useful not only for studies of 2-D navigation, but more generally will allow studies of natural and computationally complex behaviors.

The mice run around on an air-floated maze (similar to Kislin et al. 2014 and Nashaat et al. 2016). Horizontal rotation has been demonstrated to work well for behaviour in VR in rats using a harness (Aronov and Tank 2014) and more recently with a head-fixation system in mice (Chen et al. 2018), and seems to not only make the animals more comfortable, but also seems to preserve head-direction encoding and grid-cell activity.

Our system is well tolerated by mice with minimal habituation, and we get stable 2-photon imaging even during fast head rotations and locomotion (see video).

Jakob Voigts, Mark Harnett: An animal-actuated rotational head-fixation system for 2-photon imaging during 2-d navigation

The main feature of our approach is that the rotation is active – we measure the torque applied by the mouse and move the headpost with a motor which has enough torque to quickly accelerate/decelerate the heavy rotating headpost, making it appear to have low friction and inertia. This means that the weight of the headpost doesn’t matter much, so we could make the system mechanically stable (and you can attach whatever instruments to the headpost – neuropixel probes anyone?).

Also, we modified the usual flat air maze approach (Kislin et al. 2014 and Nashaat et al. 2016) to be rotationally restricted: The maze can translate but not rotate, which is important in order for the torque applied by the animals to go completely to the headpost, where it is measured and actively compensated instead of spinning the maze.

The system right now depends on a fair bit of strategically applied epoxy, but we’re in the process of turning it into a (somewhat) easily replicated add-on to existing systems.

 

Posted in Calcium imaging, Science | Comments Off on Preprint: Free head rotation while 2-photon imaging

GCaMP imaging in cortical layer 6

For my PhD work I made extensive use of 2-photon imaging of layer 6 cell bodies at depths of up to ~850μm using GCaMP. This is somewhat deeper than we (and others) have been able to image comfortably using other mouse lines. While we didn’t empirically test all the edge cases of our protocol to validate which parameters were actually needed to achieve this imaging depth, here is a very rough overview of the likely reasons we were able to acquire reasonable images in L6. In brief: there’s no very interesting tricks involved, other than somewhat sparse expression and clean window surgeries.

This is all work that was done in collaboration with Chris Deister in Chris Moore’s lab.

L6 cell bodies, montage from multiple frames where each cell was active. Individual frames usually only show very few active cells.

Sparse expression
We used the NTSR1 line to restrict GCaMP6s expression to L6 CT cells. We used AAV2/1-hSyn-Flex-GCaMP6s (HHMI/Janelia Farm, GENIE Project; produced by the U. Penn Vector Core), with a titer of ~2*10^12/ml  with an injection of ~0.3μl, through a burr hole, >2 weeks prior to window implant surgery. This gives us a relatively localized expression in L6 (approximate diameter of region with cell bodies ~300 μm), and results in relatively little fluophore above the imaged cells.

Compounding this effect, the L6 CT processes above L4/L5a are relatively sparse. Together, this means that we were able to image at large depths without risking significant excitation of fluophores above the focal point. See also Durr et al. 2011 for a nice quantification of superficial/out of focus fluorescence.

 

“The maximum imaging depth was limited by out-of-focus background fluorescence and not by the available laser power. For specimens with sparser staining patterns or staining limited to deeper layers, larger imaging depths seem entirely possible.”  from: Theer, P., Hasan, M.T., and Denk, W. (2003). Two-photon imaging to a depth of 1000 mu m in living brains by use of a Ti:  l2O3 regenerative amplifier. Opt. Lett. 28, 1022–1024.

On top of the local expression pattern achieved through the AAV injection, the highly sparse spiking activity in L6 CT cells are very friendly to GCaMP imaging. Because neighboring cells rarely were co-active, the identification of cells and segmentation of fluorescence traces was relatively easy, even with the significantly degraded z-resolution. Edge case: We imaged a few animals where GCaMP expression was much more spread out, likely due to variation in the AAV spread, and some reporter line crosses that expressed YFP in all L6 CT cells, in addition to AAV-mediated GCaMP. Imaging at depths past L4/5 was harder in these animals with laser powers that would safely avoid any tissue heating or bleaching, suggesting that local expression/sparsity of superficial fluorescence was a requirement for imaging. Part of this was that increased background fluorescence from the dense L4/5 innervation by the L6 CT made it harder to distinguish cell bodies, but it seems likely that the overall increased out-of-focus fluorescence starts being an issue in some cases.

Window diameter
At depths below L2/3, the window diameter can start to affect imaging quality. With large NA objectives (we almost exclusively used a 16x 0.8NA here), deeper imaging planes, and imaging locations away from the center of the window, progressively more excitation light can get cut off by the edge of the window, resulting in power and effective NA loss.

Here is a plot of the available 2-photon excitation power for a completely uniformly filled 0.8NA objective through a 1mm window, ignoring tissue scattering. Realistic beam profiles that deliver more power at lower angles will be affected less in terms of power, but will still lead to effective NA loss, so this plot only works as an upper bound on how bad things could get. The plot shows the squared fraction of photons that make it to the focal spot, for imaging in the center of the (1mm) window (red), or 200μm of center (black).
1mm_window_light_cutoff

While a 2mm window should be big enough from this point of view when imaging in the window center, we used a 3mm imaging windows, giving us plenty of room to search for sensory driven barrels to image in without risking any light cut off. Also, the edges of windows are rarely as clear as the center, so the extra safety margin is good to have. This can mean not having to wait for an extra week for the window to clear sufficiently, which is a big help. Past 3mm, window size seems to offer little further advantages, at least for S1 imaging, and bigger windows are much harder to position flat on the cortex.

Large windows could also make it somewhat easier to collect the emitted (scattered) visible light. The rule of thumb for the surface area from which scattered photons are emitted is ~1.5*imaging depth (Beaurepaire&Mertz 2002), so a window that doesn’t cut off excitation light should be near optimal for collection as well.

‘Stacked’/’Plug’ Imaging window
We used the window design described in Andermann et al. 2011 and Goldey et al. 2014, made from 3 and 5mm cover slips (Warner CS-3R and CS-5R, ~100-120μm thickness), directly on the dura without any agar (or any topical pharmaceuticals). This, together with somewhat thinning the skull under the 5mm portion of the glass (especially rostral&caudal of the window for S1 implants, these are the ‘high spots’ that would make the window rock in the medial/latral direction otherwise) to ensure flat position of the glass on the brain, positions the bottom of the window at, or slightly below the level of the inner surface of the skull, which pushes back any swelling that will have occurred during the craniotomy, and compensates the distance between the glass and the brain surface cause by the curvature of the skull.

imaging window 'plug' design.

imaging window ‘plug’ design.

When setting the window into place, it is important to carefully inspect blood flow and to avoid applying too much pressure on the brain and chronically affecting blood flow, especially at the borders of the window. If flow is reduced immediately after window insertion but recovers within a few minutes we usually had no issues.

The main effect of the window design is that the edge formed by the 3mm cover slips seems to keep dura/bone regrowth out of the imaging area – we’re usually able to image for as long as we want to (>2-3months) – usually AAV over-expression rather than window clarity limits the imaging schedule.

Edge case:
Flat 5mm windows without the stacked 3mm cover slips seem to give approximately the same initial imaging quality, but quickly degrade due to tissue regrowth, suggesting that the flat positioning of the window is not always a limiting factor for good optical access.

Surgery quality
We made sure to minimize any damage to the dura during the craniotomy and window implant. If bleeding occurred post-operatively, or if there was any amount of subdural blood, L6 imaging was impossible. Due to the window design, superficial blood usually cleared up within 1-2 weeks. In some cases, window clarity still improved after ~4 weeks. The main reason we saw bleeding was when we had performed viral injections ~2 weeks before the window implant, and the burr hole left a small spot of dura adhesion that ripped out when removing the bone – it seems possible that performing injections at the time of window implant could be preferable in some cases.

Occasionally windows deteriorated after >2 months – the first sign of this is the appearance of freely moving csf(?) under the window, and/or increased dura autofluorescence elicited by blue light. In any of these cases, L6 imaging became almost impossible immediately, even though axons/dendrites down to L4 could still be imaged without problems.

Edge case: We had 2 cases of animals with very mild cases of  superficial blood in the tissue in which L6 imaging was possible with laser powers of ~70mW total that were barely ok to use in other cases (that is we didn’t observe beaching or any evidence of tissue damage), but that caused superficial tissue damage in the mice with mild residual blood. We don’t know whether this is due to a higher IR absorption and subsequent damage by superficial layers/dura in these mice, or whether the blood increased the likelihood of a immune reaction, or whether the problem was purely coincidental. The take away is that it’s better to wait a few days for windows to clear up rather than pushing to potentially dangerous laser powers.

Microscope optics
We’re using a microscope with a 2″ collection path and a Nikon 16x/.8NA objective. This objective seems to represent a nice sweet spot of good enough NA and great collection efficiency (see also Labrigger). We’re slightly under-filling the back aperture, which sacrifices z-resolution but somewhat increases the proportion of photons that make it to the focal spot because lights coming in at vertical angles has to traverse less tissue (check the Labrigger post on this). We haven’t systematically tested the difference of over vs. underfilling, but it looks like the effect on achieving imaging depth  is pretty negligible in our hands, partially because the sparsity of L6 firing makes z-resolution less important than it would be otherwise. Only in cases where L4/5 neurite fluorescence was an issue, overfilling significantly improved matters. We also switched to overfilling for occasional high-magnification scans of individual cells to verify that the cells appeared healthy – typical imaging resolution and PSF degradation in L6 means that the cell nucleus was almost never clearly visible.

Excitation wavelength & Pre-chirping
We’re using a Spectra-Physics Mai Tai DeepSee laser, usually at a wavelength of 980nm, which is a good choice for exciting Gcamp6, and gives us more ballistic photons than shorter wavelengths. Generally, longer wavelengths result in less scattering – this increase in mean free path length at longer wavelengths is a significant factor in deep imaging because only non-scattered photons contribute to the 2p excitation at the focal volume (see Helmchen&Denk 2005 for a review, Durr et al. 2011 also has some nice quantification of this in non-brain tissue). We observe massively increased tissue autofluorescence at the dura for wavelenghts of >1000nm, so we settled on 980nm for most deep imaging.

Here’s a plot of the available power (Lamber-Beer law, squared to account for 2p excitation power) for a few wavelengths, mean free path length estimates are taken from Jaques, 2013. Take this with a grain of salt – the estimates depend heavily on estimates of the scattering coefficients of alive neural tissue which vary substantially, but the general trend should apply in any case.

Lambert-Beer exponential decay of non-scattered photons by depth for a few wavelengths (P_0 * exp(-depth/l_s))^2

Lambert-Beer exponential decay of non-scattered photons by depth for a few wavelengths (P_0 * exp(-depth/l_s))^2. All mean free path length estimates are approximations, the literature is not fully consistent on the numbers, so the values will not match specific setups.

For deep imaging past 700μm we typically set our laser power at 980nm to ~160-180mW total with the galvos centered, which corresponds to a maximum of 70-80mW total going into tissue when scanning at ~8-10Hz with an approximate pixel dwell time of 1-2μs. We haven’t systematically tested how much further we could push the power levels. In our experience total delivered powers above 140-150mW damage the tissue, though there is evidence that higher levels could be possible without causing damage (Podgorski et al.) – the details of the surgery, duty cycle of the imaging, area over which the beam is scanned, wavelength, pulse frequency vs energy per pulse etc. seem to start to matter substantially in this regime.

We also use a pre-chirper to maximize 2p excitation. The effect of tuning the pre-chirper is much more pronounced in deep imaging than at L2/3, but it looks like most animals with good image quality should work, albeit with lower yield and requiring marginally more power without tuned pre-chirping. For tuning, we use software that displays a trace of the mean brightness of some large region of the image where we see fluorescence, and we manually select a setting that maximizes brightness.

GCaMP6s & virus expression time scale
We’re using GCaMP6s to maximize SNR – the slower kinetics of 6s are a good fit for the very low firing rates of L6 CT cells. We haven’t tested 6f yet in this preparation, but with good surgeries it seems like it should work as well, if maybe at a slightly lower yield.

It is also noteworthy that we almost always observe a sudden shift from expression levels that were too low for imaging but gave us a few barely visible cells to great expression – often from one day to the next. We’re not sure whether this is due to a nonlinearity in apparent cell brightness on top of a linear increase in indicator level, or if there’s an uptick in indicator expression somewhere ~2-3 weeks post infection.

We used AAV2/1-hSyn-Flex-GCaMP6s, and usually had to wait ~3 weeks for good expression, but in some animals the data quality still improved slightly after week 6. This is fairly typical of AAV2/1 and matches the time scale of the increase in chr2 photocurrent when using aav mediated chr2.

Refrences

  • Deep tissue two-photon microscopy. 2005, Nat. Methods, Helmchen Fritjof, Denk Winfried (link)
  • Influence of optical properties on two-photon fluorescence imaging in turbid samples. 2000, Applied Optics, Andrew K. Dunn, Vincent P. Wallace, Mariah Coleno, Michael W. Berns, and Bruce J. Tromberg (link)
  • Epifluorescence collection in two-photon microscopy. 2002, Applied Optics, Emmanuel Beaurepaire and Jerome Mertz (link)
  • Effects of objective numerical apertures on achievable imaging depths in multiphoton microscopy. 2004, Microsc Res Tech., Tung CK1, Sun Y, Lo W, Lin SJ, Jee SH, Dong CY. (link)
  • Maximum imaging depth of two-photon autofluorescence microscopy in epithelial tissues
    Nicholas J. Durr, Christian T. Weisspfennig, Benjamin A. Holfeld, and Adela Ben-Yakar
    (link)
Posted in Calcium imaging, Science | Leave a comment

Mirror alignment target for 2-photon microscopes

When aligning the laser path of a system in which mirrors are translated, like for instance for the x/y/z adjustments on a 2-photon microscope, the laser path needs to be kept in parallel with each of the translation axes. Also, for almost any system, it is important to keep the beam well centered in the axis of optical elements. It is therefore common practice (in systems where the mirror mounts are placed precisely in line) to align beam paths by centering the beam on each mirror in the system, by using an alignment target that is put in the mirror mount in place of the mirror.

Because the final alignment on a 2p scope can often not be done in a visible wavelength (either none is available, or the laser angle varies too much for the visible tuning range to be useful for alignment), IR viewer cards are needed to check if the beam hits the target in the center. This is cumbersome, requiring at least 2 hands, and error prone.

By making a mirror mounted IR viewing card that sits at the same plane and x/y position in the mount as the mirror surface, this process can be made much faster. There are a few existing options that look promising (Thorlabs, 3d printed cap with target for laser cutter), but none of these seem to provide the same precision and repeatability as a machined mirror target that is well seated in the mirror mount.

Here’s an easy recipe for adding an IR viewer card to a mirror alignment target, requiring only a target (Mirror mounted holder + aperture plate), a good IR viewer card, or a 1/2″ IR viewer disk (I’m not 100% about the quality of these though) and some very common tools:

Ingredients & tools for the alignment tool

Ingredients & tools for making the alignment tool

Cut part of an IR viewer card to the same size as the aperture in the mirror mount adapter (1/2″ in this case)

Adapter with viewer card inserted

Insert viewer card into the adapter and and make a small mark in the center. Then hold the card in place with the 1/2″ aperture plate and secure it with the set screw. Make sure that the adapter you’re using ends up placing the IR card at the same plane as the mirror surface, or there will be a small position offset.

Alignment tool in action

Posted in Calcium imaging | Comments Off on Mirror alignment target for 2-photon microscopes

Cheap dental drill

Common dental drills are useful/required to have in any systems lab. In addition to the usual applications, these can be used to cut holes in cover slides (diamond abrasive burrs), to cut small openings in drive implant bodies, smooth out dental cement, or even metal parts, etc. However, dental drills are quite expensive when purchased from vendors of dental supplies. Luckily, the only key part of the system that seems to be hard to find cheaply, the air regulator and foot pedal, can be made with parts available from amazon etc. just by screwing together some air hose fittings.

In total, this bill of materials combines to a fully functional, brand new dental drill for a total of <$100 excluding the bits/burrs. This list can entirely be ordered from amazon, and can likely be had a bit cheaper on aliexpress or similar.

Hand piece, the actual ‘drill’ part:
Any 2-hole handpiece will do, here’s a nice option for ~$30 that has a built-in LED that is powered by the turbine. These are available in low-speed/high torque as well, and/or at various angles.

Air regulator:
We can make the foot pedal/regulator from a simple foot pedal ($15 at amazon, 12mm threaded connectors) and a regulator ($9 with 1/4″ NPT thread). Now we just need some push-to-connect fittings for 6mm hard plastic tubing that work with the 12mm and 1/4″ NPT threads, so for instance these for $8 (they’ll need some teflon tape or epoxy to not leak on the 12mm threads), and some 6mm pneumatic tubing, like this for $10. To attach this to your air outlet, some other 6mm push-to-connect fitting with an appropriate threading might be needed.

Instead of the 6mm hard plastic tubing, just about any air hose could be used, but I like this option because the push to connect fittings are easy to use and the hose is easy to cut to length and is fairly thin and doesn’t get in the way. For the low pressure section of this, a more flexible tube like some thick wall tygon tube variant with barb connectors could likely work as well.

Now we just need a standard 2-hole style handpiece connector, (~$10 here or anywhere really) – conveniently, the common tube OD on these is ~4mm which fits snugly into the 6mm pneumatic tubing, and this part of the system is pretty low pressure, so a bit of glue and/r heat shrink tube is enough to connect the handpiece to the pedal/regulator combo. I also removed the water delivery tube from the handpiece connector, and cut off the thick protective tube that surrounded the air and water tubes, so only the air tube is left. This makes the drill a bit less robust, but removes almost any tugging from the hose and makes handling the drill easier. If the air hose is ever damaged it could be easily replaced by any type of tube that fits over the barb in the 2-hole connector.

back of foot pedal

back of foot pedal

Now these parts fit together in the obvious order: air outlet > regulator (watch the direction – there’s one input and one output) > foot pedal (also has one input and one output, plus a ‘bleed’ output on the side, ignore that one) > handpiece. The regulator could also go right next to the air outlet. Here, I screwed it to the foot pedal to make a neat little unit. I just drilled out a hole in the top of the pedal housing and used a M6 screw and nut for this.

Top view of the foot pedal

Top view of the foot pedal

For the burrs, we typically use Round, #1/4 carbide burrs for craniotomies and burr holes, and sometimes a #2-4 for thinning and/or to remove large amounts of cement. This is the only part of the system that can’t be ordered on amazon, but is quite cheap anyways.

 

Posted in Calcium imaging, Electrophysiology | Comments Off on Cheap dental drill

Open Ephys @ SfN2016

just_logo_big

There’s a lot of Open Ephys and open-source science related stuff going on at SfN this year:

We will be hanging out at our poster on Wed., Nov16, afternoon, MMM62 and talk about, the next generation system and interface standard that we’ve been working on. We’ll also have a prototype system to play with that was developed and built by Jon Newman, Aarón Cuevas López, and myself.

The quick summary is that we’re proposing a standard for PCIe based acquisition systems that can deliver very high data rates, submillisecond latencies, make it easy (and cheap) to add new data sources, and will be able to grow with new technology generations. All that is accomplished by using existing industry standards and interfaces. The project overlaps with Open Ephys but our hope is that it will serve as a pretty generic interface standard for many applications.

We’ll also have a Open Ephys meeting on Monday, 6:30 pm, Marriott Ballroom A. We’ll bring the poster and live demo, and have a quick overview of what Open Ephys is up to, and have time to chat with current and potential users and developers.

In addition, here are some posters that highlight open-source tools for electrophysiology and imaging:

Saturday afternoon, FFF9 “Validation and biological relevance of a real-time ripple detection module for Open Ephys”

Saturday afternoon, KKK58 “Smartscope 2: automated imaging for morphological reconstruction of fluorescently-labeled neurons”

Sunday afternoon, LLL49 “LabStreamingLayer: a general multi-modal data capture framework”

Sunday afternoon, LLL47 “RTXI: a hard real-time closed-loop data acquisition system with sub-millisecond latencies”

Monday afternoon, U5 “Wirelessly programmable module for custom deep brain stimulation”

Tuesday afternoon, JJJ18 “Low latency, multichannel sharp-wave ripple detection in a low cost, open source platform”

Wednesday afternoon, MMM56 “A multi-target 3D printed microdrive for simultaneous single-unit recordings in freely behaving rats”

Posted in Open Ephys | Comments Off on Open Ephys @ SfN2016

Backlight for high-speed video whisker tracking

Here’s a simple recipe for a very bright uniform background for high-speed videography. This approach will work well for any applications where the outline of a small objects needs to be measured at high frame rates. For vibrissa tracking, or calibrating piezo stimulators I currently only use a single such backlight and no other light sources – this avoids any reflections on the tracked object and usually gives the cleanest, most interpretable data.

Obligatory warning:  Do not look at LEDs with unprotected eyes – these things get extremely bright and you might damage your retina. 

backlight on

The basic design has three components, bottom to top:

  1. A customizable array of LEDs, attached to a heat-sink, with a power supply and current regulator.
  2. A spacer/reflector made from mirrored acrylic.
  3. A glass diffuser.

LED arraybacklight LED array

For whisker tracking I use either deep red, or NIR leds, in the common hexagonal packaging , in a grid pattern of one led every ~2cm or so, with a sufficiently powerful driver. The density of the LEDs could easily be increased to yield an even more powerful backlight.

I just superglue the leds to a aluminium sheet with a thin layer of insulator in between (here I just used lab tape – not ideal but good enough). The aluminum sheet is then just clamped to the optical breadboard so the whole table works as heatsink. If this is not an option, big CPU coolers are fairly cheap and can remove a lot of heat. As a current regulator I use a BuckPuck from ledsupply.com driven from a sufficiently powerful DC supply (old laptop power supplies work well, or even ATX supplies if 12V are sufficient for your LEDs). Alternatively, a current limited bench supply would also work.

Spacer/Reflector

To get a uniform backlight, I use a square box (just 4 sides) out of _mirrored_ acrylic (from mcmaster). It just sits on the led array in a couple of guides so its always in the same place. Ideally, this reflector should be measured so that the resulting apparent/virtual pattern of LEDs seen by the diffuser is totally uniform, but in practice I found that this does not matter a whole lot.

Diffuserbacklight_LED_diffuserOn top of the spacer, I use a home made diffuser, made from two sheets of cheap frosted glass, glued together (here I just use kapton tape), held at ~5mm from each other with spacers. I just cut the glass myself with one of these. This double diffuser works better than much more high quality single-sheet ones, and is ~10x cheaper. make sure that the construction of the diffuser allows for easy cleaning, so avoid tape or glue that can’t tolerate ethanol.

The trick is to play with the spacing of the mirrored box, and the LEDs until the light is very uniform. This calibration only really works when using a camera, because eyes are surprisingly bad at detecting brightness gradients – also, the brightness of this light can reach unsafe levels so avoid staring directly at the light even with the diffuser.

Posted in Uncategorized | Comments Off on Backlight for high-speed video whisker tracking

Simultaneous 2p imaging and visible-light optogenetics

We recently needed to verify how a large population of neurons reacts to weak optogenetic stimulation. We found that with a relatively straightforward setup, visible light optogenetic stimulation can be integrated into existing 2p rigs without resulting in problematic imaging artifacts. Here, we  slightly de/hyperpolarized cells with a ~1mm beam of light aimed at the imaging window while imaging and delivering sensory stimuli, but the same approach should work for all kinds of experiments with implanted optical fibers, scanned focused light, or even patterned light stimulation.

Setup overview (shown here is full-field diffuse illumination from a bare fiber - other configurations should work exactly the same).

Setup overview (shown here is full-field diffuse illumination from a bare fiber – other configurations should work exactly the same).

WARNING: Don’t direct light into photomultipliers unless you’ve taken adequate precautions to ensure that they won’t be damaged. None of the methods described here have been tested other than in our specific microscope. Specifically, this method is probably not safe for GaAsP PMTs.

Fast light pulsing outside the frame acquisition times
Our 2p setup using galvos only scans in the X direction, giving us at least 200μs of flyback time during which no data is acquired. By only stimulating during this period,  visible light artifacts can be  massively reduced. On systems with bidirectional scanning, there should still be some dead-time at the frame edges where the galvos stop/reverse.

Schematic of the stimulation scheme - light pulses are delivered at the onset of the galvo flyback when no data is acquired.

Schematic of the stimulation scheme – light pulses are delivered at the onset of the galvo flyback when no data is acquired.

Short light pulses (ch 2) inserted after each 8th x-line scan (ch 1)

Short light pulses (ch 2) inserted after x-line scans (ch 1) – here, only every 8th line is used.

We pipe the line trigger outputs from the galvo controller into an arduino and generate a 50μs long trigger for the LED on every Nth line, just after the previous line has finished scanning. Depending on the details, the resulting pulse rate should be at >200Hz, which for ChR2 stimulation should be close to functionally equivalent to constant light (Lin et al. 2009). Power can be adjusted by varying either the duty cycle or LED brightness.

Here’s some simple arduino code for the triggering.

The cyclops LED driver

The cyclops LED driver

The method requires a light source that can switch on and back off with no residual light within ~50-100μs. We tried a few commercial LED drivers, and the ubiquitous CNI made dpss lasers and nothing was even remotely up to the task. We had success with a fast diode laser (Power Technology), but the best solution by far was simple LEDs with a very fast and stable driver circuit, the cyclops LED driver that Jon Newman, now at the Wilson lab at MIT has developed.  The high linearity and <2μs rise/fall time of the driver means that no extra light bleeds into the frame even for fast scanning, and power can easily be adjusted by modulating either the duty cycle or the drive current.

One of the 75μs LED light pulses (triggered ~50-100μs after line end via an arduino), measured with a Si Photodiode on a Thorlabs PM100D meter. The rise time/decay are due to the meter's time constant, the actual rise/fall times are <2μs.

One of the 75μs LED light pulses (triggered ~50-100μs after line end via an arduino), measured with a Si Photodiode on a Thorlabs PM100D meter. The rise time/decay are due to the meter’s time constant, the actual rise/fall times are <2μs.

Sign up for our newsletter and we’ll ping you once the cyclops is back in stock.

Avoiding PMT damage
Even though the light pulsing means that the images should be relatively  free of the stimulation light, the PMTs would still see the full blast of light, which can either cause damage (definitely don’t try this with GaAsPs unless you’re sure that they wont see the stimulation light by accident!) or at least desensitize them. We tested this on our multi-akali PMT with around 0.1mW total integrated power at 450nm (which isn’t filtered out from the PMTs very well in our scope) out of a bare 200um fiber shining light uniformly over the imaging window which results in moderate back scatter into the imaging optics. We didn’t measure the exact power at the objective back aperture, but after only 50 trials of 1 sec each, the sensitivity of the PMT was sufficiently reduced to make imaging in deep layers of cortex almost impossible.

To resolve this issue, we attempted to filter out as much of the LED light out of the detection path as possible. We have a NIR block filter (OD 6 NIR blocking filter, Semrock) with notches at ~560nm (halo/arch) and ~470nm (chr2) that keeps most of the power of the LED away from the PMTs, plus another step of decent filtering from the primary dichroic blocking yellow light. This arrangement means that with yellow light (up to 1mW integrated power, >20mW peak, diffuse illumination directed at imaging window) we can’t see any clear imaging artifact in the line following the stimulation, and the blue LED (similar power) just leaves a very faint streak of brighter pixels across the imaging x-line after each LED pulse. In both cases, care still needs to be taken to account for residual slight brightening of the images when the LEDs are on. We haven’t been able to detect any significant PMT desensitization over the course of an imaging session using these filters.

Removing residual image artifacts
Even when filtering the LED light out of the PMT path to a degree that avoided sensitivity losses, we still observed a visible increase in image brightness over the course of ~half a image line, and weaker, but still detectable brightening over other image lines. This artifact is likely caused by a combination of the PMT  bandwidth (we are, after all still saturating the signal while the LED is on), and some slower timescale tissue fluorescence elicited by the visible light.

The simple brute force solution that we found to work well was to just pulse the LED every 4th or 8th line, and simply interpolate over these to get rid of the artifacts. With ~10Hz frame rates, and selecting this pattern so that a different set of image lines is degraded & interpolated out every frame, the resulting error in the data is minimal. If using a local pixel correlation method to detect ROIs, it is advisable to either keep track of which lines were interpolated, or detect them later, and exclude these pixels from the local cross-correlation computation to avoid skewed results. Finally, even though the interpolation does a good job at removing most of the artifact, in some cases there was still a very small predictable increase in image brightness due to the stimulation which can be accounted for fairly easily by measuring it using neuropil/background ROIs over the entire imaging session and then subtracting it out for it. Additionally, when using a method like this, or any other, that could induce slight brightness changes, it is a good idea to use analysis methods that are not affected by slight changes in overall brightness.

Posted in Calcium imaging, Open Ephys | Comments Off on Simultaneous 2p imaging and visible-light optogenetics