You are not authenticated, login.
text: sort by
tags: modified
type: chronology
{395} is owned by tlh24.
[0] Kennedy PR, Mirra SS, Bakay RA, The cone electrode: ultrastructural studies following long-term recording in rat and monkey cortex.Neurosci Lett 142:1, 89-94 (1992 Aug 3)

hide / / print
ref: -0 tags: tennenbaum compositional learning character recognition one-shot learning date: 02-23-2021 18:56 gmt revision:2 [1] [0] [head]

One-shot learning by inverting a compositional causal process

  • Brenden Lake, Russ Salakhutdinov, Josh Tennenbaum
  • This is the paper that preceded the 2015 Science publication "Human level concept learning through probabalistic program induction"
  • Because it's a NIPS paper, and not a science paper, this one is a bit more accessible: the logic to the details and developments is apparent.
  • General idea: build up a fully probabilistic model of multi-language (omniglot corpus) characters / tokens. This model includes things like character type / alphabet, number of strokes, curvature of strokes (parameterized via bezier splines), where strokes attach to others (spatial relations), stroke scale, and character scale. The model (won't repeat the formal definition) is factorized to be both compositional and causal, though all the details of the conditional probs are left to the supplemental material.
  • They fit the complete model to the Omniglot data using gradient descent + image-space noising, e.g tweak the free parameters of the model to generate images that look like the human created characters. (This too is in the supplement).
  • Because the model is high-dimensional and hard to invert, they generate a perceptual model by winnowing down the image into a skeleton, then breaking this into a variable number of strokes.
    • The probabilistic model then assigns a log-likelihood to each of the parses.
    • They then use the model with Metropolis-Hastings MCMC to sample a region in parameter space around each parse -- and they extra sample ψ\psi (the character type) to get a greater weighted diversity of types.
      • Surprisingly, they don't estimate the image likelihood - which is expensive - they here just re-do the parsing based on aggregate info embedded in the statistical model. Clever.
  • ψ\psi is the character type (a, b, c..), ψ=κ,S,R\psi = { \kappa, S, R } where kappa are the number of strokes, S is a set of parameterized strokes, R are the relations between strokes.
  • θ\theta are the per-token stroke parameters.
  • II is the image, obvi.
  • Classification task: one image of a new character (c) vs 20 characters new characters from the same alphabet (test, (t)). In the 20 there is one character of the same type -- task is to find it.
  • With 'hierarchical bayesian program learning', they not only anneal the type to the parameters (with MCMC, above) for the test image, but they also fit the parameters using gradient descent to the image.
    • Subsequently parses the test image onto the class image (c)
    • Hence the best classification is the one where both are in the best agreement: argmaxcP(c|t)P(c)P(t|c)\underset{c}{argmax} \frac{P(c|t)}{P(c)} P(t|c) where P(c)P(c) is approximated as the parse weights.
      • Again, this is clever as it allows significant information leakage between (c) and (t) ...
      • The other models (Affine, Deep Boltzman Machines, Hierarchical Deep Model) have nothing like this -- they are feed-forward.
  • No wonder HBPL performs better. It's a better model of the data, that has a bidirectional fitting routine.

  • As i read the paper, had a few vague 'hedons':
    • Model building is essential. But unidirectional models are insufficient; if the models include the mechanism for their own inversion many fitting and inference problems are solved. (Such is my intuition)
      • As a corrolary of this, having both forward and backward tags (links) can be used to neatly solve the binding problem. This should be easy in a computer w/ pointers, though in the brain I'm not sure how it might work (?!) without some sort of combinatorial explosion?
    • The fitting process has to be multi-pass or at least re-entrant. Both this paper and the Vicarious CAPTCHA paper feature statistical message passing to infer or estimate hidden explanatory variables. Seems correct.
    • The model here includes relations that are conditional on stroke parameters that occurred / were parsed beforehand; this is very appealing in that the model/generator/AI needs to be flexibly re-entrant to support hierarchical planning ...

hide / / print
ref: -0 tags: lavis jf dyes fluorine zwitterion lactone date: 01-22-2020 20:06 gmt revision:0 [head]

Optimization and functionalization of red-shifted rhodamine dyes

  • Zwitterion form is fluorescent and colored; lactone form is not and colorless.
  • Lactone form is lipophyllic; some mix seems more bioavailable and also results in fluorogenic dyes.
  • Good many experiments with either putting fluorine on the azetidines or on the benzyl ring.
  • Fluorine on the azetidine pushes the K ZLK_{Z-L} toward lactone form; fluorine on the benzyl ring pushes it toward the zwitterion.
  • Si-rhodamine and P-rhodamine adopt the lactone form, and adding appropriate fluorines can make them fluorescent again. Which makes for good red-shifted dyes, ala JF669
  • N-CH3 can be substituted in the oxygen position too, resulting in blue-shifted dye which is a good stand-in for EGFP.

hide / / print
ref: -0 tags: Courtine e-dura PDMS silicone gold platinum composite stretch locomotion restoration rats date: 12-22-2017 01:59 gmt revision:0 [head]

PMID-25574019 Biomaterials. Electronic dura mater for long-term multimodal neural interfaces.

  • Fabrication:
    • 120um total PDMS thickness, made through soft lithography, covalent (O2 plasma) bonding between layers
    • 35nm of Au (thin!) deposited through a stencil mask.
    • 300um Pt-PDMS composite for electrode sites, deposited via screenprinting
  • 100 x 200um cross section drug delivery channel.
  • Compared vs. stiff 25um thick PI film electrode.
    • stiff implants showed motor impairments 1-2 weeks after implantation.
  • Showed remarkable recovery of supported locomotion with stimulation and drug infusion (to be followed by monkeys).

hide / / print
ref: -0 tags: bone marrow transplant chimera immune response to indwelling electrode implant capadona inflammation date: 02-02-2017 23:24 gmt revision:1 [0] [head]

PMID-24973296 The roles of blood-derived macrophages and resident microglia in the neuroinflammatory response to implanted intracortical microelectrodes.

  • Quite good introductory review on current understanding of immune / inflammatory / BBB breakdown response to indwelling neural implants.
  • Used chimera mice with marrow from CFP mice transplanted into irradiated hosts, so myeloid cells were labeled (including macrophages and monocytes).
    • Details of this process are properly fascinating ... there are clever ways of isolating and selecting the right marrow cells.
  • Implanted with a dummy Michigan style probe, 2mm x 123 um x 15um.
  • Histological processes and cell sorting / labeling also highly detailed.
  • 60% of the infiltrating cells (CFP+) are macrophages.
    • Within the total IBA1+ population (macrophages + microglia), we saw that only 20% of the total IBA1+ population was comprised of microglia at two weeks post implantation (Fig. 9G).
    • Additionally, at chronic time points (four, eight and sixteen weeks), we observed that less than 40% of the total IBA1+ population was comprised of microglia (Fig. 9G).
    • On the other hand, no significant differences were observed in microglia populations over time (Fig. 9G, Table 4). Together, our results suggest a predominant role of infiltrating macrophages surrounding implanted microelectrodes over time.
  • IBA1 = marker for ionized calcium binding adapter molecule, to label the total population of microglia/ macrophages (both resting and activated)
  • CD68 = activated microglia / macrophage.
    • Hard to discriminate microglia and infiltrating macrophages.
  • Interestingly, fluctuations in GFAP+ immunoreactivity correlated well with neuronal density and CFP+ immunoreactivty, suggesting a possible role of astrocytes in facilitating trafficking of blood-derived cells.
  • Contrary to what has been suggested by many intracortical microelectrode studies, a consistent connection was not found between activated microglia/macrophages and neuron density in our chimera models

hide / / print
ref: -0 tags: bone regrowth hyperelastic 3d print implant hydroxyapatite polycaptolactone date: 09-30-2016 18:27 gmt revision:0 [head]

Hyperelastic “bone”: A highly versatile, growth factor–free, osteoregenerative, scalable, and surgically friendly biomaterial

  • (From the abstract): hyperelastic “bone” is composed of 90 weight % (wt %) hydroxyapatite and 10 wt % polycaprolactone or poly(lactic-co-glycolic acid),
  • Can be rapidly three-dimensionally (3D) printed (up to 275 cm3/hour) from room temperature extruded liquid inks.
  • Mechanical properties: ~32 to 67% strain to failure, ~4 to 11 MPa elastic modulus & was highly absorbent (50% material porosity)
  • Supported cell viability and proliferation, and induced osteogenic differentiation of bone marrow–derived human mesenchymal stem cells cultured in vitro over 4 weeks without any osteo-inducing factors in the medium.
  • HB did not elicit a negative immune response, became vascularized, quickly integrated with surrounding tissues, and rapidly ossified and supported new bone growth without the need for added biological factors.

hide / / print
ref: -0 tags: physical principles of scalable neural recording marblestone date: 08-25-2014 20:21 gmt revision:0 [head]

PMID-24187539 Physical principles for scalable neural recording.

  • Marblestone AH1, Zamft BM, Maguire YG, Shapiro MG, Cybulski TR, Glaser JI, Amodei D, Stranges PB, Kalhor R, Dalrymple DA, Seo D, Alon E, Maharbiz MM, Carmena JM, Rabaey JM, Boyden ES, Church GM, Kording KP.

hide / / print
ref: Sanders-2000.1 tags: polymer fiber immune reaction biocompatibility rats polycaprolactone recording electrodes histology MEA date: 01-28-2013 00:01 gmt revision:11 [10] [9] [8] [7] [6] [5] [head]

PMID-10906696[0] Tissue response to single-polymer fibers of varying diameters: evaluation of fibrous encapsulation and macrophage density.

  • Fibers smaller than 6μm6 \mu m show reduced immune response.
    • Fibers implanted in the subcutaneous dorsum (below the skin in the back of rats).
    • Polypropylene. (like rope).
    • Wish the result extended to small beads & small electrodes. 7μm7 \mu m is tiny, but possible with insulated Au wires.
      • Beads: try PMID-1913150 -- shows that the 600um - 50um beads ('microspheres') are well tolerated.
      • Also {750}.
  • Macrophage density in tissue with fiber diameters 2.1-5.9um comparable to that of unoperated contralateral control.


fiber diametercapsule thickness


[0] Sanders JE, Stiles CE, Hayes CL, Tissue response to single-polymer fibers of varying diameters: evaluation of fibrous encapsulation and macrophage density.J Biomed Mater Res 52:1, 231-7 (2000 Oct)

hide / / print
ref: Menei-1994.09 tags: microspheres beads polycaprolactone biocompatible drug delivery histology date: 01-27-2013 20:54 gmt revision:3 [2] [1] [0] [head]

PMID-7814435 Fate and biocompatibility of three types of microspheres implanted into the brain.

  • microspheres ( 24μm 24 \mu m ) appear to be engulfed or surrounded by histocytic cells.
  • poly(e-caprolactone), which is supposed to be biodegradable, did not dissolve in the brain. The polymer is hydrophobic.
  • 20um spheres could be engulfed by macrophages; their microspheres were too large, and were encapsulated in a thin coallagen layer and astrocytic process.
  • no scale bars - annoying - but we can estimate the size of the coating to be about the same size as the beads themselves.

hide / / print
ref: Freire-2011.01 tags: Nicolelis BMI electrodes immune respones immunohistochemistry chronic arrays rats 2011 MEA histology date: 06-29-2012 01:20 gmt revision:5 [4] [3] [2] [1] [0] [head]

PMID-22096594[0] Comprehensive analysis of tissue preservation and recording quality from chronic multielectrode implants.

  • Says what might be expected: tungsten microelectrode arrays work, though the quality gradually declines over 6 months.
  • Histological markers correlated well with recording performance.
  • Shows persistent glial activation around electrode sites + cell body hypertropy.
    • Suggest that loss in recording quality may be due to glial encapsulation.
  • References
    • Szarowski et al 2003 {1028}
    • Ward et al 2009
  • Histology:
    • NADPH-d: nicotinamide adenine dinucleotide phosphate-diaphorase, via beta-NADP
    • CO: cytochrome oxidase, via diamnibenzidine DAB, cytochrome c and catalase.
      • both good for staining cortical layers; applied in a standard buffered solution and monitored to prevent overstaining.
  • Immunohistochemistry:
    • Activated microglia with ED-1 antibody.
    • Astrocytes labeled with glial fibrillary acid protein.
    • IEG with an antibody against EGR-1, 'a well-known marker of calcium dependent neuronal activity'
    • Neurofilament revealed using a monoclonal NF-M antibody.
    • Caspace-3 with the associated antibody
    • Details the steps for immunostaining -- wash, blocknig buffer, addition of the antibody in diluted blocking solution (skim milk) overnight, wash again, incubate in biotinylated secondary antibody, wash again, incubate in avidin-biotin-peroxidase solution.
    • Flourescent immunohistochemistry had biotynlation replaced with alexa Fluor 488-conjugated horse anti-mouse and Alexa Fluor 594-conjugated goat anti-rabbit overnight.


[0] Freire MA, Morya E, Faber J, Santos JR, Guimaraes JS, Lemos NA, Sameshima K, Pereira A, Ribeiro S, Nicolelis MA, Comprehensive analysis of tissue preservation and recording quality from chronic multielectrode implants.PLoS One 6:11, e27554 (2011)

hide / / print
ref: -0 tags: bees energy harvesting honey date: 04-11-2012 06:02 gmt revision:2 [1] [0] [head]

This morning hundreds of bees were swarming outside my front door -- a fact is not without reason, as my roommate makes honey, and her hive just today outgrew the apiary. Hence the hive split this morning, and one queen be left to wait on a branch outside while scouts searched for good places to build a new colony; meanwhile hundreds of non-scout workers were swarming around her.

Bees are amazing. Anyway, a friend sent a link to an article describing how to generate microwatts of energy off a flying insect, which led me to wonder how much energy those bees could have been producing instead of milling protectively about their queen.

  • number of bees : 1000
  • power, with direct connection to flight muscles: 400 uW
  • total possible power: 400mW
  • kCal in a tablespoon (21g) of honey: 64
    • in joules: 270kJ
  • Length of time it would take for 500 madly flapping bees (1) to generate the energy within a tablespoon of honey: 375 hours (15.6 days)
  • Yield of honey from a large, productive hive: 150 lbs / year (2)
    • in watts: 27.8 W
    • number of bees: 20000 (2)
    • factor better than energy harvesting: 3.5

Conclusion: let them make honey :-)

(1) Half the bees visible were resting on leaves, not madly flapping.

(2) Rough wiki-google estimate.

hide / / print
ref: Kennedy-1998.06 tags: Kennedy cone electrode ALS BMI date: 01-08-2012 00:35 gmt revision:4 [3] [2] [1] [0] [head]

PMID-9665587[0] Restoration of neural output from a paralyzed patient by a direct brain connection.

  • (abstract) Patients with severe paralysis of limbs, face and vocal apparatus may be intelligent and aware and yet, tragically, unable to communicate. We describe a communication link for such a 'locked-in' patient with amyotrophic lateral sclerosis. We recorded action potentials in her brain over several months by means of an electrode that induces growth of myelinated fibers into its recording tip. She was able to control the neural signals in an on/off fashion. This result is an important step towards providing such patients with direct control of their environment by interfacing with a computer. Additionally, it indicates that restoration of paralyzed muscles may be possible by using the signals to control muscle stimulators.
  • Repairing the PNS is hard. I wonder if a more logical, Gates-ian topic of socially worthwhile work would be to target more people. For example: curing cancer. There is a bit of vanity and scifi chasing in BMI studies mixed up with all the curiosity (science) and worthy causes.
    • That said, plenty of people are doing shit with their lives (in terms of social worth). All that realyl matters is passion. Kenny seems to have passion for his particular recording / BMI idea, which is good!


[0] Kennedy PR, Bakay RA, Restoration of neural output from a paralyzed patient by a direct brain connection.Neuroreport 9:8, 1707-11 (1998 Jun 1)

hide / / print
ref: Doty-1956 tags: Doty 1958 conditioned reflexes stimulation date: 01-03-2012 07:05 gmt revision:6 [5] [4] [3] [2] [1] [0] [head]

PMID-13367871[0] Conditioned reflexes established to electrical stimulation of cat cerebral cortex.

  • One sentence: used ICMS to act as a CS for a CR (shock-avoidance) in cats. Not really ICMS, as electrodes were placed on the surface.
  • They suggest ICMS is a means for probing the cortex without going through that trouble and complex transform of the sensory nerves and PNS.
    • If only. ICMS is complex enough.
  • Loucks [6,7,8] used a buried induction coil! Have things advanced all that much? (They bring this up in that magnetic stimulation of the induction coil induces vibration, which the animal can feel.)
  • Use 'vitalium' screws to fix their plexiglas encased platinum wire electrode to the scull.
    • Relatively large electrodes, not in the cortex but resting upon it -- this is why the current was relatively high.
  • Monophasic ICMS, 50Hz, 2ms, 2 sec train, 4-6V (not current controlled).
    • Fixed this by putting a 10k resistor in series and recording current across that. approx 700uA stimulation current -- high!
  • Most of the cortex worked as a CS: stimulation of points distributed throughout the marginal, postlateral, middle suprasylvian, and middle and posterior ectosylvian gyri (Fig. 2).
  • Observed a narrow threshold for conditioning responses, e.g. 0.35mA would give only 1/5 correct, 0.45 4/5 correct.
  • Dura excised in these surgeries, since any stimulation of the dura is painful.
    • To control for this, they severed the trigeminal nerve.
  • gave strength / duration curves. (remember, monopolar).
  • deinervated the animals as control -- could feel nothing but the current delivered to their head!
  • Other controls: Loucks (7) showed that CR persisted with stimulation to the motor cortex after the limb that moved upon superthreshold stimulation was paralyzed.
  • "The present experiments fully confirm the thesis that CRs to cortical stimulation are in no way dependent on detectable motor effects."
  • Animals can also discriminate one frequency from another (30Hz vs 100Hz). Verified by Romo, much later.


[0] DOTY RW, LARSEN RM, RUTHLEDGE LT Jr, Conditioned reflexes established to electrical stimulation of cat cerebral cortex.J Neurophysiol 19:5, 401-15 (1956 Sep)

hide / / print
ref: Doty-1969.01 tags: Doty microstimulation brain behavior macaque conditioned stimulus attention motivation 1969 date: 12-29-2011 23:28 gmt revision:8 [7] [6] [5] [4] [3] [2] [head]

PMID-4888623[0] Electrical stimulation of the brain in behavioral context.

  • Excellent review.
  • Focal stimulation of macaques can induce insect-grabbing responses, after which they will carefully examine their hands to see what was caught!
    • Same thing has been observed in humans -- the patient reported that he wanted to catch 'that butterfly'.
  • Such complicated action must be the effect of downstream / upstream targets of the stimulated site, as the actual stimulation carries no information other than it's spatial locality within the brain.
  • Stimulation of the rostral thalamus in the language hemisphere can elicit phrases: "Now one goes home", "Thank you", "I see something".
    • These are muttered involuntarily and without recollection of having been spoken.
  • Doty stimulated macaques at 20ua for 500us as a CS in postcentral gyrus (S1?) for a lever press CR, which should (he says)only activate a few dozen neurons.
  • Can elicit mating behaviors in oposums with electrical stimulation of the hypothalamus, but only if another opossum or furry object is present.
  • Stimulation of the caudate nucleus in humans causes an arrest reaction: they may speak, smile, or laught inappropriately, but appropriate voluntary responses are brought to a halt.
  • Stimulation of the basolateral amygdala can cause:
    • Hungry cats to immediately stop eating
    • Stop stalking prey
    • Non-hunting animals to stalk prey, and indeed will solve problems to gain access to rats which can be attacked.
  • Prolonged stimulation of almost every place in the brain of a cat at 3-8Hz can put it to sleep, though since lab cats normally sleep 17/24hours, this result may not be significant.
  • Stimulation at most sites in the limbic system has the still mysterious ability to organize motor activity in any fashion required to produce more of the activity or to avoid it, as the case may be.
  • Rats that are stimulated in the periaqueductal gray will self-administer stimulation, but will squeal and otherwise indicate pain and fright during the stimulation. Increasing the duration of stimulation from 0.5 to 1 second makes self-administration of this apparently fearful stimulation stop in both rats and cats.
  • Certain patterns of activity within systems responsible for fearful or aggressive behavior, rather than being aversive are perversely gratifying. This is clearly recognized in the sociology of man...
  • Rats will self-stimulate with the same stimulus trains that will cause them to eat and drink, and under some conditions the self-stimulation occurs only if food or water is available.
  • On the other hand, rats will choose self-stimulation of the lateral hypothalamus instead of food, even when they are starving.
    • Electrically induced hunger is its own reward.
  • The work of Loucks (124, 125) forms the major point of origin for the concept that motivation is essential to learning. with careful and thorough training, Loucks was unable to form CRs to an auditory CS using stimulation of the motor cortex as the US. With this paradigm, the limb movements elicited by the US never appeared to the CS alone; but movements were readily established when each CS-US combination was immediately followed by the presentation of food.
    • However: Kupalov independently proved that stimulation of the motor cortex could be used as the US, at the same time using stimulation at other loci as the CS.
    • Why the difference? Attention -- failures are commonly obtained with animals that consistenly fidget or fight restraint, as most of them do.
    • Cortical stimulation itself is not rewarding or aversive; animals neither seek nor avoid stimulation of most neocortical areas.
  • On classical conditioning: [Bures and colleagues (20, 65) bibtex:Bures-1968 bibtex:Gerbrandt-1968] found that if an anticedent stimulus, which might or might not effect a neuron, were consistently followed by effective intracellular electrical stimulation of that individual neuron, in roughly 10 percent of the cells of the neocortex, hippocampus, thalamus, or mesencephalic reticular formation a change in the response of that cell to the antecedent stimulus could be observed.
  • With an apparent exception of the cerebellum it is possible to electrical excitation any place in the brain as a CS in chickens, rats, rabbits ...
  • Stimulation of group 1 proprioceptive muscle-afferent fibers in cats is ineffective as a CS.
    • Muscle spindles lack clear access to the systems subserving conditioned reflexes. (These instead go to the cerebellum)
  • Macaques can also discriminate between two stimulation sites 1-3 mm apart apparently over the entirety of the cortex, at frequencies between 2 and 100Hz, and over a 4-10fold range of currents.
  • In human cases where electrical stimulation or the cortex elicits specific memories, extirpation of the stimulated area does not effect recall of this memory (156) {973}.


[0] Doty RW, Electrical stimulation of the brain in behavioral context.Annu Rev Psychol 20no Issue 289-320 (1969)

hide / / print
ref: Kennedy-1992.08 tags: BMI Kennedy cone electrode electrophysiology recording neurotrophic date: 12-17-2011 01:00 gmt revision:1 [0] [head]

PMID-1407726[] The cone electrode: ultrastructural studies following long-term recording in rat and monkey cortex

  • they placed sciatic nerve inside the glass cone electrode to encourage regrowth.
    • alternatively, they filled the cone electrode with 'matrigel' whatever that 'neurotrophic substance' is.
  • good recordings at 6 months post impantation.
  • virtually no neurons were found in the tissue in any cone
    • however, they saw plenty of mylenated axons. (the mylenation assuredly is good for the quality of recordings hah)
    • in no case was the tissue absent from the glass.


hide / / print
ref: notes-0 tags: perl one-liner svn strip lines count resize date: 03-22-2011 16:37 gmt revision:13 [12] [11] [10] [9] [8] [7] [head]

to remove lines beginning with a question mark (e.g. from subversion)

svn status | perl -nle 'print if !/^?/' 

here's another example, for cleaning up the output of ldd:

ldd kicadocaml.opt | perl -nle '$_ =~ /^(.*?)=>/; print $1 ;' 

and one for counting the lines of non-blank source code:

cat *.ml | perl -e '$n = 0; while ($k = <STDIN>) {if($k =~ /\w+/){$n++;}} print $n . "\n";'

By that metric, kicadocaml (check it out!), which I wrote in the course of learning Ocaml, has about 7500 lines of code.

Here is one for resizing a number of .jpg files in a directory into a thumb/ subdirectory:

ls -lah | perl -nle 'if( $_ =~ /(\w+)\.jpg/){ `convert $1.jpg -resize 25% thumb/$1.jpg`;}'
or, even simpler:
ls *.JPG | perl -nle '`convert $_ -resize 25% thumb/$_`;'

Note that -e command line flag tells perl to evaluate the expression, -n causes the expression to be evaluated once per input line from standard input, and -l puts a line break after every print statement. reference

For replacing charaters in a file, do something like:

cat something |  perl -nle '$_ =~ s/,/\t/g; print $_'

hide / / print
ref: notes-0 tags: ice hydrophones glissando recording sound date: 01-19-2010 16:41 gmt revision:0 [head]

http://silentlistening.wordpress.com/2008/05/09/dispersion-of-sound-waves-in-ice-sheets/ -- amazing!

hide / / print
ref: -0 tags: ocaml budget money date: 12-11-2009 20:02 gmt revision:1 [0] [head]

This morning i checked my bank account, and was throughly offended with what was in there. To figure out where I was spending my money, I exported a csv from the bank's website, and read it into open office to label each expense. Since I couldn't easily figure out how to sum along each label, I wrote an ocaml program to do this --

let gitline ic = (
	try input_line ic, false 
	with _ -> "", true
	) ;;
let fos = float_of_string
let ios = int_of_string
let soi = string_of_int
let sof = string_of_float
let foi = float_of_int
let iof = int_of_float
let fabs = abs_float

let read fname = 
	let eof = ref false in
	let out = ref [] in
	let ic = open_in fname in
	let tab = Str.regexp "," in
	while not !eof do (
			let line, eoff = gitline ic in
			let ar = Array.of_list (Str.split tab line) in
			if Array.length ar = 7 then ( 
				let debit = fos ar.(3) in
				let credit = fos ar.(4) in
				let wha = ar.(6) in
				out := (debit,credit,wha) :: !out ; 
			eof := eoff; 
	) done; 
	close_in_noerr ic ; 

let _ = 
	let sumht = Hashtbl.create 50 in
	List.iter (fun a -> 
		let debit,credit,wha = a in
		let m = try Hashtbl.find sumht wha with _ -> 0.0 in
		let m2 = m -. credit +. debit in
		Hashtbl.replace sumht wha m2
	) ( read "/home/tlh24/Desktop/Suntrust_History.csv"); 
	Hashtbl.iter (fun wha valu -> 
		print_endline( wha^","^(sof valu)); 
	) sumht ; 
The first half of this file is 'stock' - just helper functions for reading in the CSV file (you can copy-paste to use on your own files). After that, it's just assigning fields to variables and summing along the labels with a hash table - easy as it should be. Certainly it could be accomplished in far fewer lines with perl, but perl is not at the tip of my tongue as ocaml is now :-)

For the curious, here is the result (bar charts >> pie charts):

I spend a lot of money on food and 'parts'. Food is pretty self-explanatory; 'parts' includes electronic parts, bike parts (a fender, bike clips, new lights), a new cell phone, stuff from home depot. Tools was mostly for a cylinder of welding gas - you have to buy the cylinder; the gas is relatively cheap. The labels are sort-of amorphous, since all are directed toward the goal of fixing my (*&^%) car, which has a rusted-out crack in the frame from where the (*&^%) previous owner attached an aftermarket brace. Finally, the gas was from a 1300 mile road trip over Thanksgiving (in my other POS car, whose drivers side front wheel bearing is loose on the strut mount, oh my). Normally I don't spend that much on gas.

hide / / print
ref: -0 tags: perl one-liner search files cat grep date: 02-16-2009 21:58 gmt revision:2 [1] [0] [head]

In the process of installing compiz - which I decided I didn't like - I removed Xfce4's window manager, xfwm4, and was stuck with metacity. Metacity probably allows focus-follows-mouse, but this cannot be configured with Xfce's control panel, hence I had to figure out how to change it back. For this, I wrote a command to look for all files, opening each, and seeing if there are any lines that match "metacity". It's a brute force approach, but one that does not require much thinking or googling.

find . -print | grep -v mnt | \
perl -e 'while($k = <STDIN>){open(FH,"< $k");while($j=<FH>){if($j=~/metacity/){print "found $k";}}close FH;}' 
This led me to discover ~/.cache/sessions/xfce4-session-loco:0 (the name of the computer is loco). I changed all references of 'metacity' to 'xfwm4', and got the proper window manager back.

hide / / print
ref: -0 tags: computational geometry triangulation ocaml kicadocaml zone fill edge date: 01-26-2009 01:47 gmt revision:3 [2] [1] [0] [head]

I have been working hard to add zone support to kicadocaml since the implementation in kicad's PCBnew is somewhat borken (at least for my boards). It is not a very easy task!

Roughly, the task is this: given a zone of copper pour, perhaps attached to the ground net, and a series of tracks, vias, and pads also on that layer of the PCB but not on the same net, form cutouts in the zone so that there is an even spacing between the tracks/vias and zone.

Currently I'm attacking the problem using triangles (not polygons like the other PCB softwares). I chose triangles since I'm using OpenGL to display the PCB, and triangles are a very native mode of drawing in OpenGL. Points are added to the triangle mesh with an incremental algorithm, where the triangles are stored as a linked-mesh : each triangle has a pointer (index#) to the triangle off edge ab,bc,ca. This allows finding the containing triangle when inserting a point a matter of jumping between triangles; since many of the points to be inserted are close to eachother, this is a relatively efficient algorithm. Once the triangle containing a point to be inserted is found, the triangle is split into three, the pointers are updated appropriately, and each triangle is tested to see if flipping with it's pair would result in a net larger smallest interior angle between the two. (This is not the same as Delaunay's criteria, but it is simpler, and it produces equally beautiful pictures.)

The problem is when two triangles are allowed to overlap or a gap is allowed - this makes the search algorithm die or get into a loop, and is a major major problem of the approach. In Guibas and Stolfi's paper, "Primitives for the manipulation of general subdivisions and the computation of Voronoi diagrams", they use an edge data structure, rather than a triangle data structure, which I suppose avoids this problem. I was lazy when starting this project, and chose the more obvious triangle-centric way of storing the data.

The insertion of points is actually not so hard; the big problem is making sure the edges in the original list of polygons are represented in the list of edges in the triangle mesh. Otherwise, triangles will span edges, which will result in DRC violations (e.g.g copper too close to vias). My inefficient way of doing this is to calculate, for all triangles, their intersections with the polygon segments, then adding this to the mesh until all segments are represented in the list. This process, too, is prone to numerical instability.

Perhaps the solution is to move back to an edge-centric data representation, so that certain edges can be 'pinned' or frozen, and hence they are guaranteed to be in the triangle mesh's edge list. I don't know; need to think about this more.

Update: I got most of it working; at least the triangulation & making sure the edges are in the triangle mesh are working. Mostly there were issues with numerical precision with narrow / small triangles; I rewrote the inside triangle function to use the cross product, which helped (this seems like the simplest way, and it avoids divisions!):

let insidetri a b c d = 
	cross (sub b a) (sub d a) > 0.0 &&
	cross (sub c b) (sub d b) > 0.0 &&
	cross (sub a c) (sub d c) > 0.0 

as well as the segment-segment intersection algorithm:

let intersect a b c d = 
	(* see if two line segments intersect *)
	(* return the point of intersection too *)
	let ab = sub b a in
	(* a prime is the origin *)
	let bp = length ab in
	let xx = norm ab in
	let yy = (-1.) *. (snd xx) , (fst xx) in
	let project e = 
		(dot (sub e a) xx) , (dot (sub e a) yy)
	let cp = project c in
	let dp = project d in
	let cd = sub dp cp in
	let m = (fst cd) /. (snd cd) in
	let o = (fst cp) -. m *. (snd cp) in
	let e = add (scl ab (o /. bp)) a in
	(* cp and dp must span the x-axis *)
	if ((snd cp) <= 0. && (snd dp) >= 0.) || ((snd cp) >= 0. && (snd dp) <= 0.) then (
		if o >= 0. && o <= bp then ( true, e )
		else ( false, e )
	) else ( false, e )

Everything was very sensitive to ">" vs. ">=" -- all must be correct. All triangles must be CCW, too, for the inside algorithm to work - this requires that points to be inserted close to a triangle edge must be snapped to that edge to avoid any possible CW triangles. (Determining if a triangle is CW or CCW is as simple as measuring the sign of the smallest cross product between two segments). I tried, for a day or so, to include a specialized function to insert points along a triangle's edge, but that turned out not to matter; the normal flipping routine works fine. I also tried inserting auxiliary points to try to break up very small triangles, but that really didn't affect the stability of the algorithm much. It is either correct, or it is not, and my large board was a good test suite. I have, however, seeded the triangularization with a grid of (up to) 20x20 points (this depends on the aspect ratio of the region to be filled - the points are equally spaced in x and y). This adds (max) 800 triangles, but it makes the algorithm more stable - fewer very narrow triangles - and we are working with sets of 10,000 triangles anyway for the large zones of copper.

Some corrections remain to be done regarding removing triangles based on DRC violation and using the linked-mesh of triangles when calculating edge-triangle edge intersection, but that should be relatively minor. Now I have to figure out how to store it in Kicad's ".brd" file format. Kicad uses "Kbool" library for intersection polygons - much faster than my triangle methods (well, it's in C not ocaml) - and generates concave polygons not triangles. Would prefer to do this so that I don't have to re-implement gerber export. (Of course, look at how much I have re-implemented! This was originally a project just to learn ocaml - Well, gotta have some fun :-)

hide / / print
ref: notes-0 tags: CO2 global warming carbon dioxide indonesia brazil date: 03-14-2008 21:34 gmt revision:0 [head]

From the New Yorker, Feb 25:

  • "Just two countries - Indonesia and Brazil - account for ten percent of the greenhouse gasses released into the atmosphere. "
  • "During the next twenty-four hours the effect of losing forests in Brazil and Indonesia will be the same as if eight million people boarded airplanes at Heathrow airport and flew en mass to New York. "

hide / / print
ref: notes-0 tags: flock OSS opensource Mozilla LGPL money corporations browser comment embedded mobile opera date: 12-20-2007 16:23 gmt revision:0 [head]

I'm posting my comments about http://flock.com/ here just in case they are removed from the actual site

This is all very interesting. I just downloaded it, and flock seems to work well. I'm probably not going to use it unless there is some demonstrable technical superiority (e.g. leaks less memory than firefox), as the social sites just distract me from getting work done.

Anyway, I have a question: how are you going to make money? How are you paying the developers? If you are not and it is all OSS, where is the source? It seems like the VC's are just throwing money away for the (hypothetical) good of the social-network crowd. Or, rather, you are indirectly funding the popularity of sites that flock makes it easy to get at. Are these sites (e.g. facebook) paying you? Wait -- flock allows you to look at content and not the ads. They are not paying you.

Perhaps you are moving along the lines of Opera, and intending to get people addicted to flock to a degree that they demand it on their mobile devices. Mobile devices are closed (for now .. check google), hence you can make money licensing software to phone manufacturers. I imagine that you'll have to rewrite the Mozilla core to do this (unless phones become significantly more powerful - not likely, they are battery devices. ) Mozilla is (L)GPL - you'll have to release the source. To the best of my knowledge, with non-physical goods money can only be made from gradients in knowledge (pun.. intended), therefore you will have to keep the source closed. If this is the case, you'll be able to make money (on this, i don't know what else you have planned) for a while, and when you can no longer, I hope you open the source like netscape.

Technically, though, excellent job! your website is also very pretty!

hide / / print
ref: bookmark-0 tags: open source cellphone public network date: 11-13-2007 21:28 gmt revision:2 [1] [0] [head]


  • kinda high-level, rather amorphous, but generally in the right direction. The drive is there, the time is coming, but we are not quite there yet..
  • have some designs for wireless repeaters, based on 802.11g mini-pci cards in a SBC, 3 repeaters. total cost about $1000
  • also interesting: http://www.opencellphone.org/index.php?title=Main_Page

hide / / print
ref: notes-0 tags: perl one liner hex convert date: 08-15-2007 23:55 gmt revision:0 [head]

I wanted to take lines like this:

272 :1007A500EB9FF5F0EA9E42F0E99D42F0E89C45F0AA
and convert them into proper hex files. hence, perl:

perl -e 'open(FH, "awfirm.hex"); @j = <FH>; foreach $H (@j){ $H =~ s/^s+d+s//; $H =~ s/\//; print $H; }'

hide / / print
ref: bookmark-0 tags: federal reserve video printing money economics date: 06-01-2007 20:32 gmt revision:0 [head]


need to learn more about this infamous federal reserve!

hide / / print
ref: physics notes-0 tags: plasma mercury vapor lamp electron ozone date: 04-03-2007 15:23 gmt revision:3 [2] [1] [0] [head]

ok, so i just (19 Feb 2007) did some simple experiments with the small (100W) mercury vapor lamp that i have + a hard-drive magnet + a solenoid.

  1. magnet splits the plasma into two paths, depending on the direction of the AC plasma current. The split is strongest when at the transition between north and south poles on the HD rare-earth magnet, as here the field lines are going in short loops with the vertical part approximately intersecting the plasma, and hence exerting the lorentz force towards or away from the magnet.
    1. it is possible to extinguish the bulb by moving the plasma too close! I think that this forces the electrons to collide with the quartz tube, cooling them too much.
  2. I also built a solenoid out of a small spool of 14 gauge magnet wire attached to my buzz box arc welder. The current was set at ~50 amps, (not sure how accurate that setting was) - enough to get the small coil pretty hot rather quickly. When placed inside the AC-energized coil, the plasma arc was forced to spiral around the walls of the quartz tube.
    1. This is most likely because the mean velocity of the electrons is pretty low, hence the lamour radius is high in the relatively-weak magnetic field. I notice that at the beginning of igniting the mercury-vapor lamp, far more ozone is produced (as gauged by smell) than is produced when it is hot and the plasma current is high. This accompanies a shift from a very blue emission spectra to a whiter emission, I think this is because the pressure becomes higher inside the tube, hence the mean free path of the electrons is lower, hence they have less energy to excite the hard-UV bands of mercury ions once the lamp is hot. http://en.wikipedia.org/wiki/Planck's_constant --> E=hv, where v is the frequency --> 250nm approximately equals 5 eV. lamour radius: mv/qB. 5ev ~= 1.33e6 m/s. @ B= 0.1T, lamour radius = 7.5e-5m = 0.07mm (what?) ok, more reasonable: B = 0.005T, r = 1mm - still smaller than observed! Need to check this magnetic field. B=mu n I. I = 50A, n = 3 * 2/0.064) = 93 turns, mu (air) = 4*pi*10^-7 --> B ~= 0.005T. (as a first approximation). If the electron velocity is lower, then the radius will be smaller; it is the opposite for the magnetic field strength.
    2. of course, we are disregarding thermal interactions, as well as drift - will have to look at the textbook for this.
  3. Feb 23 2007 - I made a larger-diameter solenoid out of the 14 gauge copper wire & turned the buzz-box welder current up to 100A (or so it says, don't know how much in practice) - enough to get the coil very hot very quickly. I put this current loop around the broken 400W metal-halide lamp - the one originally from the blacklight cannon. As it is still being driven from the same low-wattage power supply, it remains cool, the bulb voltage is low (21V) and much UV (and ozone) is produced - generally indicating that the pressure in the bulb is low and the electron velocity/mean free path is higher.
    1. well, actually: when the blub pressure is low, much energy below 240nm is produced. Apparently this is what is required for ozone production:
    2. HBO lamps do not generate ozone, because owing to the self-absorption in the cooler outer arc regions, all radiation below 240nm is trapped within the discharge. However during run-up before pressure increases, some ozone is produced.
    3. When I turned the solenoid on around the ignited bulb, the concentration of plasma in the center noticably increased, and the luminous intensity increased also. I'm not sure if this was due to AC pumping of plasma current; I doubt it, as most of the magnetic flux should have went around the plasma.
    4. The bulb voltage went to 23 - 24V; I do not know the current, I will have to measure it (perhaps with an oscilloscope?)
    5. The plasma became less uniform, too, perhaps because the solenoid was not aligned to the E-field with any accuracy.

hide / / print
ref: notes-0 tags: perl one-liner match grep date: 02-17-2007 17:45 gmt revision:2 [1] [0] [head]

to search for files that match a perl regular expression: (here all plexon files recorded in 2007)

locate PLEX | perl -e 'while ($k = <STDIN>){ if( $k =~ /PLEXdddd07/){ print $k; }}'