Archis's Blog

July 21, 2011

Philosophical rant against frameworks

Filed under: Uncategorized — archisgore @ 4:15 am

I began this rant in one of my older BCI-related posts, about why I’m not going to use “Frameworks”. This is a first-class post into why I hate most frameworks and platforms out there, and why people should really just take it up with their companies how they can improve the promotion-systems if writing small tools doesn’t seem “fancy enough” (seems to me like either an HR problem for workers, or a faulty evaluation system for academicians.)

So what’s wrong? Some frameworks are good. Some are great even. I wouldn’t think of doing matrix algebra without Matlab (and I appreciate the fact that they allow us to write plugins to add new features and extend it.) I love how I run most of my code above the .Net CLR and it is “managed” for me. No more processes gone awry. Very few memory leak opportunities. Great library to work with. Same can be said for the JVM, or Python.

If you notice, each of the above is a platform with very little (or none) missing pieces. However, every so often, I come across a platform or framework, that is composed entirely of missing pieces. Something very typical I commented on in that BCI post is as simple as file-copy. Back in college, if I needed a file-copy, you’d see someone building a five-line program to copy files from one place to another. A good program would have buffering, network FS mounting, etc. etc. What it would still not have, and this is something that would never even cross the mind of the developer, is to make it a “data copying platform, where file-copying is a subset of the functionality.”

So what’s wrong with building a platform beyond your core problem? Lots. First, if you don’t know a requirement, you can’t plan for it. I’m making that a very hard statement. When you read the above, you have no idea what that “data” is going to be. If it is just binary opaque data, then it maps to file-copying. If it isn’t binary opaque data, then you have no clue what the requirement will be. So you end up providing features for extending events such as “precopy”, “postcopy”, “copyprogress”, etc. Chances are (and I’d call it a near-certainty) that when that specialized data really needs to be copied, your provided hooks are at best completely useless (in which case, a decision not to use your platform is easy to justify), or they miss some last-mile option which requires a complex hack. I’d bet almost everyone reading this has used at least one fancy solve-it-all framework which lacked one key feature, which required elaborate mechanisms to fit within that framework. If the framework were a tool instead, you could write your mechanism around it, instead of within it.

Taking the file-copy example above, I could generalize that task to something even more abstract. “Operation.” Instead of a file-copy program, I write a program to “Do Operations”, one of them being “File Copy”. So I’d have a framework for operations and each OperationProvider must provide a well-defined entry point called “DoOperation”. That way, when I need to do any other operations such as “FileZip” in the future, I can just write a plugin and leverage my framework. Either you keep the parameters to this entry-point super strict (a list of files), or you keep them super-generic (a Variant, or Object.) Either way, there is one common theme that begins to emerge. What you’re writing is an operating system shell!

The shell provides a generic method for “Doing Operations”, which are represented by distinct plugins called “executable files”, which are loaded dynamically at runtime, whose parameters are generic but are strongly type-checked within, and each plugin provides an entry-point, and blah blah blah…..

What I’ve observed is, 9 out of 10 frameworks, over a few iterations, end up becoming shell replacements. There is only a percieved benefit of abstraction and you have none of the loose-binding power of the system shell. Whatever features the framework itself was intended to provide, remains a small part of the system, largely superseeded by a magnitude of plugins, which now can’t be used for other tasks because they depend on the whole framework loading mechanisms.

I’m not without my own skeletons in the closet. During college, and in my first three years at Microsoft, I’ve tried every single time, (and once almost got away with it), to build these generic monsters. It’s very tempting really. When you’re working on a problem, you start to see generalizations. To be fair, a lot of them are real, while a small number of them are percieved - or you can just make something up like “Do Operation” which is so generic, you can fit anything in there. There’s a certain elegance in the Unix-style design (and even today, I won’t use a machine unless I have trusty VI and GREP installed.) The fact that tools are just that – tools. They do stuff they’re supposed to do, while remaining agnostic to the environment they run in. They can be combined or reconfigured to build bigger tools. And they depend on a framework too – the system shell.

Any modern OS comes with a shell capable of powerfull script execution. The fact is, platforms only work when they specialize more than the shell. The specialization has to be fairly targetted. The .Net CLR collects garbage. It is a framework that provides garbage collection to programs. The garbage collection itself is not arguable. The Type system is not up for plugin-based changes. Matlab’s language is immutable. Its matrices are not what you can plugin and modify.

The deeper problem that once begins to face very fast is that of coupling. Imagine a complex workflow where you define a billion operations that depend on a million other operations. Sounds like a perfect problem for “Framework Man” (if I were any good at photoshop, you’d see a superhero here.) In fact, that’s what most frameworks do. That generic “DoOperation” wrote about above isn’t as apparently ridiculous to others as one would think. A lot of what I’m about to say depends on interpretation, so many of you may disagree.

For the layperson, think of the coupling as how under the hood of your car, your sparkplug depends on the cylinder size you have, and your cylinder size dictates the power you get, and also the fuel injection, and also the the cooling required, and the cooling system eats some of that power, so that takes away a little from what you can use to run. The actual situation is a lot more complicated. Now here’s the thing with cars or operating systems – people fight tooth and nail to reduce coupling as much as humanly possible, and then some. Unless absolutely justified without no way out, you want to reduce coupling. I’m not exaggerating how seriously this is done.

Problem with that file-copy example I gave above is, it seems almost intentional, or at worst a tongue-in-cheek joke at how many people may end up using it because it provides: 1. Filecopy and 2. Extensibility.

Problems with coupling are well-known. One thing depends on another, depends on another, depends on another…. It is a nightmare to deploy, understand, maintain and most importantly fix! You see, if I found a better tool for file-copy, the best I’d do in an OS script is modify parameters to that tool. For a framework, I either write a shell wrapper (if so, what was wrong with a shell script anyway?), or modify the code to be hosted in it, and if the code is in a different language than what it supports, use another framework to write marshalling code around it.

I think what I’m saying here is, management and tasks must never mix. If you need to manage and handle complex workflows for file-copies, that’s fine. Have a framework that manages tasks. Let each of those tasks be handled by the native OS. Even if you can write a fancy-powerful task, write it as an independent tool that can be plugged out and replaced or reused. Call it on the shell. That way, others can quickly reproduce any problems they face with that task in the future when they need to debug. Fixing the task if code isn’t available, is as easy as finding another tool and fitting it in. Undoing the action of that task are simpler. These scenarios aren’t as far-fetched as one would think. Imagine if my n’th task in a workflow were writing registry keys, that my n+1th task were reading. If my n+1th task fails, it’s quite a nightmare to reproduce that failure without creating another workflow that can feed the whole chain (or mocking the task prior to it and hosting the whole framework beast). Trying different parameters involves running the mock workflow over and over again, and depending on what kind of checks, initializations it does, it’s a massive waste of time (is it too hard for the tool to first check for updates, then check for updates to each component, then checking security keys, etc. etc.?)

Small distinct stateless tools, data piped by the OS, a lightweight scripting langage for glue, and console control FTW!

June 21, 2011

Fact

Filed under: philosophy, Science — Tags: , , — archisgore @ 1:14 pm

This one comes from long introspection. Over the course of my career, I’ve been involved in sufficient debates and arguments where a misinterpretation of semantics has lead to difficulty in communication. I try to be very precise in choice of language and generally demand that others do the same. Any student of mathematics ought to appreciate the value of accurate semantics, and interpretation of data. However, not everyone is a mathematician, and predicate logic isn’t for everyone.

Last weekend I had the opportunity to meet someone whose opinion I value highly, and someone I hold in high regard in terms of intellect. Those discussions helped me formulate this with precision.

Regular readers will know that I frequently do change my opinions and definitions, or the premises upon which I build arguments. Therefore, if this conflicts with any previous posts, I would be glad to have that pointed out to me, as a reminder that I am in fact, learning.

I’ve been in plenty of debates where I try to get my opponent to state their premises. In many cases, they find me rude for interrupting them, because when I find a premise inaccurate, flawed, or misstated, I feel the need to get that clarified (and I forsee the need to write a post on how a good premise build up could make arguments efficient.) In many cases, premises are assumed to be facts (or at least, in a good argument they should be.)

So what is fact? I’ve heard plenty of opinions. I’ve heard people say, “What is fact for you, may not be fact for others.”

I think it’s worth dedicating a paragraph to clarify that fact is not Truth. Truth is best left for philosophers, and perhaps even theologists. While it is common that mathematical truth is based on fact, we shall not open that can of worms here.

Going back to what fact is. I must heavily insist that I disagree with the comment, “What is fact for you, may not be fact for others.”

For one, if that were true, there would never be progress in the debate, and there would be no point in holding a debate. As I understand it, a debate operates on information that is an order higher than fact. It operates on two things: Interpretation of fact, and Opinion. I won’t go into analyzing opinion here.

After various attempt at defining fact, I arrived at a definition that fits the need quite snugly – Fact is observation (as in a scientific experimental observation.) There is a reason fact may not be truth – and that’s because the observation process may contain a flaw.

First lets look at whether it satisfies the rigorous requirements of building a premise.

1. An observation is, to put it in terms of signal processing, an ‘impulse response’. An observation is the effect a process has on a quantity you can measure. An observation is, whether correct or incorrect, indisputable by parties in an argument. Let me explain. If we were debating why a certain number of jobs are reduced, we may disagree on the reason of decline, however, our observation cannot change.

2. If the observation does change based on who is making the observation, it is all the better. Now we reach the very depths of predicate logic. The reason some arguments seem to go around in “circles” is not because two parties have incompatible observations, but because different parties have incompatible processes to make those observations. The power of defining fact as an observation comes into forcing both parties to agree on the process used to make the observation. You may argue that such deep definitions are irrelevant for a debate. I disagree. I argue that almost all debates are very simple and can follow simple First-Order-Predicate-Logic if we agreed on our observations. The real debate is in the details – can we agree on observation? Here we reach an opinion (and my job ends.)

So why this clarification? I strongly believe, and have observed, that many of the truths we cling to depend on our personal convenience (misquoting Obi-Wan a bit.) We try to appear to debate on a higher-order plane because it is a convenient arena where interpretations and opinions can be inserted without premises.

You can’t really disagree with observation. You can disagree with the process used to make the observation. A classic example is clinical trials. Common arguments about drug-approval testing go, “While the FDA thinks the drug is unfit for use, they don’t know the whole story.”

The fact of the matter is, the FDA isn’t interested in the whole story. They know the story they care about. Their process is well-documented and available for peer review. It is open to criticism and suggestions for improvement. Whether or not that process is followed for a certain clinical trial is also a matter of opinion (and to a large extent quantifiable.) However, having raised no objections to the process of the trial, nor any concerns regarding its execution, there really isn’t a different observation you can arrive at, and therefore, the fact cannot change for you.

A final question I want to address is, “Is observation good enough?” Observation is the “effect” a process is having on a measurable quantity. That is what I meant by ‘impulse response’ in DSP terms. Observation is all we really have. Almost all of science depends on observation. Do not misinterpret observation as ‘seeing’ (as in, ‘to see’.) Observation is quite literally measurement of an effect. When we observe gravity, we observe the effect gravity has on an object (change of force, shape, etc.) Even if you strive for truth, you will end up at a dead-end – observation.

June 17, 2011

Civilization

Filed under: Uncategorized — Tags: , , , , , — archisgore @ 2:52 am

I reaffirm what we already know of western countries, or should I say, developed countries. I’m sure different people will have a different comparison point, but I’ll explain mine.

I come from a remote village in India – one of those places where there used to be one bus that ran a few times a day into the city, and we had 4 hour power cuts daily, and one full day of power cuts. A small island-like place in between 3 rivers which, when flooded, would cut off a square-mile region from all civilization for a couple of days. If we got rain, the transformers would frequently blow, and we’d get power back the next evening. That was just routine life – it takes as long as it takes.

Today morning (well at noon), Redmond lost power. Outside by window a block from my apartment, I see a thick black column of smoke. A fire of proportions that clearly indicated a week’s outage in my timescale, but adjusting it to “America”, I estimated the next day.

I went to work at one hoping to camp out there as long as I could, and when I found office had no power either, decided to drive back. This was barely an hour after I lost power. On the way back, the traffic lights were already working. When home, I found power back on. Where I come from, this would be considered a miracle. If I were to narrate this back to the same place, they’d laugh in disbelief – it would sound like a ridiculous hyperbole from some “americanized desi who thinks he’s better than us.”

Also, when it happened, I could see a response in minutes. I still recall those phone calls we’d make to the power company back in India, only to get a very rude lecture (if ever they picked up) on how ungrateful I was for the little power that I did get during that day. There were cops on the streets, the traffic maintained control despite traffic lights going out, and well, civilization kicked in.

Pretty amazing how we set our expectations huh? This probably means I have to go back to work though…

June 9, 2011

Brainwaves are beautiful!

Filed under: Brain-Computer Interface — archisgore @ 9:53 am

There’s something so mesmerizing about looking at a real-time FFT of your own brain-waves. I found a good plotter library and with a sliding window of 64 samples (approximately the last second of data at 50Hz sampling,) I am seeing not only my own brainwaves being plotted in real-time (well, 5 times a second at least due to the bad code I wrote,) but I see a direct correlation between limb movements and the spikes. I’m plotting it too fast to actually make any sense of the spikes and I presume a lot of the energy is useless as a discriminant of individual limbs. I also notice a rather large DC component which I intend to get rid of.

For now, I’m just excited. What was five years in the dream-list, an year into planning, and about three months in coding has finally worked! I’m going to continue staring at them tonight just for fun.

Some upcoming experiments will be performing the FFT over larger windows (and higher frequency resolution.) Just lots and lots of raw recordings which I could move inMatlab and perform analysis there to compute a baseline. Recording at different states – sleepy, tired, excited (which is now), hungry, thinking, not-thinking, depressed, etc. Finally, perhaps even recording all night to find validate pop-culture know-how about Alpha, Beta sleep patterns.

If you want recordings, ping me. I can’t say for sure what kind of experiments I’ll perform, so it may be a bit random, but it’s a lot of data per second, so I’m going to run out of space real fast.

For now… live long and prosper!

June 6, 2011

First sanity test of EEG data

Filed under: Brain-Computer Interface — Tags: — archisgore @ 12:25 am

It’s been long since I last posted on what the BCI stuff is leading to. The delay was partly due to my random travels which seemed to have peaked out (I missed a lot of flights on my latest trip, and that’s an indication for me to stick around for a while.)

A main reason was trying to find a good source for capturing raw data. The situation wasn’t as hopeless as I initially thought – it appeared that there’s very few drivers that can read PendantEEG data. However, digging a little deeper, I found plenty of open-source projects to pick from, all of them on Google Code (I’ve been out of this world so long, I still default to sourceforge for all my needs.) A combination of legal and practical issues required plenty of thought. My binding contract at Microsoft requires that any code I write, is owned by the company. The boundary between personal pet projects, and moonlighting, is somewhat complicated. Let’s not go into the details (but you can ask me if you’re curious), because I’m eager to get onto all the latest cool stuff I’ve been doing.

I really loved all the stuff out there – BioEra and Pyofeedback, but they were somewhat too deeply integrated and exposing them as COM objects, or re-writing them to work on my box with minimal libraries would have taken a lot of work, and even if I could do it, would have put the whole thing in a legal mess of ownership, copyrights, and my job-security. The tool I settled on is PendantEEGToolset, which reads data and exposes it over a TCP channel. A TCP boundary is as safe as you can get in terms of de-coupling, and any code I write, is now owned by MSFT but at least it isn’t contaminated with GPL code. That means it’ll take some time getting out, but I can go about doing it “right”.

I finally was able to plot (and .Net isn’t good for fast graphing out of the box) signals and get garbage. When developing the drivers, I first tried to capture data without plugging in any electrodes to test the protocol works. I was a bit apprehensive because without electrodes, instead of getting a stream of zeros as I had expected, I was getting large steps and large falls. The FFT showed large numbers which made no sense. I wrote a signal generator that allows me to generate a custom signal and fake the protocol so I could ensure by FFT was running correctly.

However, when plugged onto a human being (and my first test subject was a visiting couchsurfer – with his consent of course), the readings normalized and I was able to observe a change in pattern in the time domain (I still haven’t been able to plot my FFTs fast enough, so will have to read the numbers tonight.)

All in all, a very successful sanity test. The device works (so far), and I’m capturing data. More next weekend.

June 2, 2011

Astrologers…

Filed under: Entertainment, philosophy, Science — Tags: — archisgore @ 2:10 am

Did I spell that right? I’m supposed to write a document that’s going to take 2 hours, and I’ve pushed it too far. Good time to get all my thoughts out to the world one at a time. Today, let’s rip on Astrologers a bit.

To give you an idea of the motivation, I picked up a hillarious book at the airport during my last India visit called “Am I a Hindu.” That’s going to lead to a few posts, but you’ll have to wait until the next time I run out of things to do, and face the inevitable document-writing task. Today, I began reading this book to take my mind off some blocking issues. I had read a part of it during my flight, and I recalled an emotional rollercoaster between humor, apathy and perhaps anger (or annoyance). I’m giving you this context because this post is regarding one argument that book made (I’m willing to discuss other arguments.)

Lets get this out of the way - lack of disproof, is not a proof. I’d love to talk to anyone who believes that isn’t true (that was sarcastic; if you think lack of disproof is proof itself, I probably don’t ever want to speak to you in my life). The Indian Government proclaims it’s a science, and I claim I’m king of the world. Neither of the clauses is relevant for this discussion. A common argument we hear from pro-Astrology people is, “Why is it so difficult to believe stars could affect the physical processes within you?”

It’s not difficult to believe at all. I never claimed a remote planet doesn’t have gravitational influence on me. I’m claiming you’re full of crap. When I rip on Astrologers and Prophesizers, I’m making fun of them. I’m claiming they’re full of bullshit. It’s about them! That’s as direct as I can say it (offense intended). I have no problem believing that we might be able to model those interactions, and what the result of that influence would be. I’m not saying it can’t be done. I’m saying you’re not the ones doing it.

“If people can predict weather, why can’t people predict fortunes?”

We could extend this argument infinitely – If people can predict weather, and people can predict fortunes, why can’t people predict when we’ll get a man on Mars? If people can predict weather, the stock market, the next Tsunami, and some Earthquakes, sure, it may be possible to predict fortunes too. Doesn’t change the fact that you’re not the one to do it.

I think the modern Astrology debate has gotten too impersonal. Perhaps we’re trying to be too politically correct, or the Astrologers are just better at reframing the problem than we are at noticing that it got reframed right under our noses. I believe in open-heart surgery, however, if you’re any one of the people reading this blog, I can safely say I’m not letting you come anywhere near my heart. If you tried to convince me, I’d find it midly humorous and highly annoying. It’s the same with Astrologers – science doesn’t deny modelling. Modelling is a fundamental tenet of Science. What we’re saying is, you’re no good at it, and that you have no idea what you’re talking about.

It’s true that all models are merely approximations. That’s why in addition to predicting weather, weather-predictors are also constantly ‘learning’ from the outliers. They’re on the search for new variables, and better sampling methods. I’ve not seen major publications that have indiciated the discovery of any new variables or processes, or models that provide a better fit than what historic Astrology demonstrates. Even if that’s accomplished, a theory that does not demonstrate a prediction record significantly higher than a random process, is not considered a theory at all. Are astrologers willing to submit themselves to a controlled experiment where they can demonstrate their predictors are any better than a random predictor?

Hence the title of this post – ‘Astrologers’. Don’t make this about the “Science of Astrology”. I don’t claim it won’t work. This is about you – I claim you don’t work.

April 30, 2011

PendantEEG drivers

Progress on the Brain Computer Interface project. To recap: I picked the Pendant EEG as my device-of-choice. I did not however, purchase the BioEra or BioExplorer packages. Partially because I hate frameworks (more on that later), and mainly because I didn’t want to spend the money. Part of this is just pain ego. I just wanted a raw library from where I could read two-channel data and then pump it into any pipeline I wanted, without an expensive software to do the same thing. (Don’t get me wrong – BioEra is an awesome architecture and especially for home-training sessions, it’s very powerful).

I spend the last three weeks going over options, and couldn’t find the spec (sort of) for capturing raw EEG data. I noticed that, until about 2009, BioEra had an open-source fork called BioEra Light on SourceForge. Turns out this tool claims to read the PendantEEG data. A quick look at their sources and you’ll find the code (best spec), to read this data. It’s a pity this isn’t part of a native library, but now I intend to make it one.

This weekend will be spend in this coding effort. I’m going to try and stick to C as language of choice, since the lib can then be consumed from Java or .Net or whatever (doing the reverse is possible, but breaks my philosophical rant below.) Since such a raw library is asked for many times, it would make sense for me to publish it, but that’s probably going to take a while before I figure out all the agreements and legalities. If it helps, I’ve pointed you to where you can read the code, at a  glance it seems extremely simple, elegant and well-written. If others have followed a better approach, I’m always willing to improve.

EDIT:

I did some more hunting around. Turns out, I was wrong in my assumption. Someone else published some BSD-licenced C++ code on Google Code here: http://code.google.com/p/pyofeedback

For completeness, here’s the link to BioEra: http://sourceforge.net/projects/bioera/

Both projects were last updated in 2009, and I’ve made contact with their owners to get any help I can. I don’t want another fork going around the web for the next person to find. I’m considering contributing to/using one of the above.

Philosophical rant about frameworks: 

Recently, I’ve acquire an absolute and complete hatred of frameworks. Two Three things in particular I want to avoid follow in my weekend projects at least.

1. Code must compile exclusively out of the same directory. If it’s outside of that directory, especially one-level up, it’s got to be a transparent binary that I care nothing about. I come across way too much code which has “frameworks” to help write executables. Command-line parsing logic, some kind of usage-printing-helper, etc. They’re not exactly classes you can reference in a library, but the code files aren’t in the folder you’re reading your logic from. Massive waste of time if you just want to add another param and move on.

2 .Must conform to the platform. NO syntax overloads. I love language-features and libraries. All code I read, I want to give you a spec: .Net 2.0 or .Net 3.5 or whatever, and if you read a code-line, it must correspond to something directly interpretable by and semantically accurate to an anthropomorphic being named .Net 3.5. If a sentence begins with “See this looks just like an event in Java, but internally…” it’s booted ruthlessly.

3. Unix-philosophy of specific tools for a focussed purpose. Like the Terminator, if the purpose vanishes, the tool must question its own reason to exist. I don’t want an ls command that has a data-driven manifest, that tells it to load listing-provider-factories, that instantiate listing-providers, which have their own configurations providing the parameters for their initialization, thereby allowing you to list, not only files and directories, but all the galaxies and stars, and streets in NY or the known prime numbers, using just one command. I’ll put in the effort to learn, as ridiculous as it may sound, a brand new command for the oft-necessary purpose of listing all galaxies when I’m browsing a folder tree.

April 12, 2011

BCI 2

Filed under: Brain-Computer Interface — Tags: , , , — archisgore @ 9:20 am

A continuation to the original BCI post with very minor updates. The first time, they didn’t ship my electrodes, and in the meantime, I’m in India till 4/20, so have no way of performing any tests until I get back. However, I did get a chance to think of the experimental setup and what my initial sanity tests will be. I won’t be starting a dual-feedback loop for another few months due to the potential dangers involved.

The very first thing when I plug it into a human will be to simply look for correlation of motor activity with the spectrum. In order to prevent the subject from performing repeated actions, I’ll record the data along with markers for various motor activity. In order to synchronize the marker with the activity, I intend to have my program provide a visual cue of what the subject is intended to do now, and provide a 10-second window in which they must do it. Appropriate 3-second windows will be added regularly for eye-blinks (yes, they can’t blink an eye unless I tell them to.) The eye-blinks is tricky because I’m not sure right now what kind of artifacts I am going to find in the signal. Separate out 20% marker data as my “test” data.

The next step is to go over these recordings at high-frequency or high-time resolutions (sort of like wavelets but not quite – still multiple FFTs and Sin/Cos being my constituent functions.) Maybe train a classifier to test for identification of markers and use the test-data to protect against memorization. I love linear classifiers unless the data justifies it.

The purpose here is to:

1. Test my software and know that data pipeline is functional and properly written and I have enough disk space for the recordings.

2. Test the device itself and experimentally verify its claimed accuracy/sensitivity.

3. Warm up to all those things I might have forgotten in 3 years.

To reiterate before concluding – for the near future, my interest is in labelling Motor Activity, not Motor Imagery.

April 1, 2011

Making a Brain-Computer Interface

After five years of consistently blogging, and consistently failing to do something about it, the BCI-building has begun. The academician in me needed an outlet and I’ve been craving for something hardcore technical for a while now. So begins the first formal attempt at building a cheap home-made BCI. I’m going to label all entries so that it will be easy to follow progress on this.

Unlike my regular posts which are composed with at least some thought, this series of entries will be more like a journal. I’ll post entries with what I do, what methods I follow, everything I try. With any luck, there should be enough detail that anyone could replicate what I am doing with full fidelity. The attempt at any original research is not even a long-term goal. The goal here is to, and I say this as directly as possible, with no misconceptions whatsoever, and no subtext, “to have fun.”

If you have any interesting theories, experiments, I would love to hear your thoughts. If you’d like to participate, you’re welcome to join. Most followups will be brain-dumps of my thoughts – unedited, raw, and naive. A side-effect of this blog is to also demonstrate any points of failure, or stuff that doesn’t work. At this point, I have nothing working. I don’t want to claim that I knew everything, in case I succeed.  I won’t use the excuse that I never wanted to succeed in case I fail. I want to make this work, and even if it doesn’t, it won’t change the fact that I still wanted it to work. If I make a mistake it’s going to be published, since I will try and publish what I intend to do before I do it as a validation.

At the moment, I picked the PocketEEG from PocketNeurobics (apparently an Australian company) to get started. I’ve been out of this world for a while (four years), and it takes a long time to catch up on the IEEE Journal of Biomedical Engineering where most BCI work is (used to be?) published. The WaveRider system is a clinical device but it costs too much for me at the moment, but if this device fails, I’ll save up for the WaveRider and go with it. It’s a two-channel device.

I haven’t got the electrodes yet, so haven’t taken any readings, but plenty of work has to happen before the electrodes become relevant. The recommended software to be used with it is BioExplorer which I think costs too much. I instead tried to connect the open-source BioEra software. The UI takes me back to the good old colleges days before the polished world of  iPhones and iPads. It has a way to define the processing pipeline but I rather hate doing it graphically. The dongle does provide a fake serial port on your PC that you can read from, but I didn’t want to go through that much trouble. I intend to use BioEra to capture the signal and send it across a local TCP channel into a server I’ll write that does what I want it to. BioEra seems to support plugins, but I love the flexibility of having my own executable as opposed to being “hosted in” another exe.

This pipeline investigation should take until the weekend, and hopefully I’ll have it coded over the weekend. If I’m lucky, and the electrodes to arrive, I’ll be sure to post some recordings of motor activity of right and left hands, captured from the C3 and C4 points at the beta band.

The reason I don’t want to use the provided FFT block is because I much rather enjoy playing with parameters initially. Do I want it sliding window at every point or will I perform it on intervals? If I intend to do something like auto-regression, I’d much rather use my own buffers and optimize the pipeline to operate on. I’ll post what happens.

December 26, 2010

Mythbusters’ method of derivation by first-principles

Filed under: Entertainment, Personal, Preaching, Science — Tags: , , , — archisgore @ 1:20 pm

I’m the type of person who loves deriving from first-principles and one who admires people who like to do the same. This post goes in honour (British English, people – I come from an ex-colony) of the Mythbusters.

To figure things out, to derive things when no knowledge exists is a concept that seems rare today, and yet I’m sure it was rare as far as humanity existed. It is simply observation bias that made me believe the Renaissance period was any better than today. I didn’t read about all the billion people over the world who didn’t do anything while Da Vinci was doing something. Science and Technology ‘exist’ just as a lot of other things.

Most people know things – they don’t find out things, or learn things; they just know things. I came back from a road trip an hour ago on a route that everyone knew had no places to stay or eat, and yet I stayed in warm lodgings, clean beds, and ate some of the best American food in 20 years. We know toast is made by heating bread. We know we’re supposed to go ‘ahhh’ when we eat French or Italian food, and we know bread can’t be made any other way because – well wouldn’t we know about it already? Red wine is better than White wine. Gas pumps have gas, because… they just do, don’t they? Two drinks are never dangerous for driving because I always have control.

Unfortunately, a lot of science education programs also follow this pattern. There exists the earth. It is round. We live on it. It revolves around the sun. I literally don’t know a single person (including myself) around me who can devise a simple experiment right now on the spot to test whether or not the earth is round. I went through five years of college being told Knowledge (no, not a grammatical error there, I was literally told Knowledge – as in a proper noun).

The one thing that really defines the Renaissance was the spirit of individuality and discovery. Leonardo didn’t make ‘great’ paintings, as if God had said, “Let there be a definition of great paintings that humans can aim for. There was hence a definition for what maketh paintings great.” Leonardo made paintings – they were appreciated. Others couldn’t make much better than his, and his paintings obtained value. The renaissance evolved and nurtured the process of independent thought and opinionated thinking (two things I value most.)

I wrote once before about how a process (also called a model) is what defines everything about science, and perhaps what defines science itself versus… well, lack-of-science. I can’t be more precise than that because process is all-encompassing. String theories don’t define one outcome, but define a process by which outcomes for all situations can be predicted. ‘Solutions of equations of the n’th degree’ in mathematics are really the processes used to solve any system of any number of equations with any number of variables of the n’th degree. As a child I had the opportunity to read some interesting books by 20th century scientists, and one difference I noted from modern populist writing is their emphasis on their line of reasoning, their attempts at scientific enquiry, the setbacks, the necessity for designing creative experiments to test hypothesis.

For the last three years, I’d been trying to figure out just what makes me such a mad fan of the Mythbusters, and the answer is that they are more old-school scientists than many I have met in my life in a university. Of course one does chance upon those rare inquisitive individuals who want to know, but they are few and far apart. I must say that the Mythbusters remind me of some of the influential people from my past who made me who I am today – people who genuinely wanted to find out. I will put this out there – Adam and Jamie are two of the very best science teachers that exist on earth today, and the reason is precisely because they are not scientists (while that’s clearly not true, we’ll go by their claim for now.)

They love to discover. They love to figure out. Sure, you’d say, why figure out what’s already known? If you really just said that, then you don’t know squat! :-) To design an experiment to test a hypothesis is a complex task, heck there’s a whole specialization one can study in design of experimentation. Designing an experiment for a theory that cannot be easily tested rarely happens through dreams, no matter how much we want to believe that that’s how we’ll get rich some day. It comes through practice. Let’s be honest, half the things Adam and Jamie test are not known – sure we can make an educated guess at them, but we don’t know them do we? Chickens are not spheres with point mass.

The Mythbusters teach true, pure science, while selflessly claiming they’re not scientists. They derive from first-principles. Instead of assuming chickens are spheres of point-mass, they start with chickens as chickens, and spherical-masses as spherical-masses. If the two being shot out of a cannon demonstrate the same result, Adam goes, “Hmm… Jamie, what if we replaced our chickens with small spherical balls?” (such a thing has not really happened on the show, I made that up.) This casual remark teaches tons more science than all of high-school physics put together. It demonstrates how generalizations come to be in the first place. What the phrase, ‘without loss of generality’ means. What substitutions are allowed. How experiments must be broken down. How do you discover theory in the first place?

Deriving from basics is one of the key overlooked abilities of this decade. Yes, we know the earth is round. We know we can go in space and figure it out. We also know that some ancients figured it out long ago. Most readers of this blog, I’m sure, are at least self-styled techies who are ‘in the know’ about all things technology. I doubt there’s anyone who can come up with an experiment to test the veracity of that hypothesis right now without leaving this page. That’s the kind of stuff the Mythbusters do daily. Some of the tests they are asked to conduct are impossible to imagine being tested. It is like a classic Sherlock Holmes mystery – when you know the answer, it’s obvious, it couldn’t have been anyone else! I’ve been racking my own brains for the last hour trying to figure out how, given that I don’t even know what “The earth” is, I would attempt to figure out its shape. I’ve had formal education in high-school physics.

They also follow a pre-declared results-based experimentation process. A lot of experiments in my high-school physics were dead-on in conclusions, but they never defined what a set of outcomes would have implied before the results were described. The Mythbusters approach is truly scientific. They would first ask: Why do you decide that you want to put an Apple in liquid nitrogen? Then they would define what each outcome would imply: Suppose it were to come out soft, what would that tell us? Suppose it were to come out hard, what would that tell us?

Objectivity is very hard to learn – and is a constant struggle. We all hope our very first outcome is favourable, and it rarely is. Data is manipulated, conclusions are creatively worded, because the results don’t quite imply what we expect them do. The Mythbusters are not afraid to fail, but heck, they love to fail! Almost every other episode they are proven wrong. They love it! It doesn’t get any purer science than that!

If today’s kids are going to break new barriers, then they must have the ability to derive from first-principles – from the very basic axioms. This however, must be done without compromising clear and hard science. Plenty of out-of-the-box thinkers who promote unlearning what universities teach, get too carried away in philosophy, spirituality or just plain stupidity. Deriving from first-principles never causes you to unlearn what you have learnt, but rather causes you to conform what you have learnt. If you were to put an apple in liquid nitrogen, no matter how out-of-the-box you are, it must have the same results as anyone else doing it. If not, you’ve hit upon something and must find out why.

I’m glad the President Obama recognized such brilliant men who love to discover and figure out. It is heartening to see them teaching principles of science (and I know secretly that they too know they are following the scientific method) without making it ‘science’. Under the casual tone of ‘obvious necessary steps’, they are secretly teaching some very fundamental methods of scientific enquiry that took me years to learn.

EDIT: Some people just asked me, why this is important. We come across people treating simple problems as if they were obstacles created by God, or treating solutions as if they just came into existence of their own accord, without appreciating that there was some human being who developed that solution. If one cannot appreciate that, then one can never look at current problems as solvable, since they inevitably ‘exist’. Brings to me frightful visions of the Eloi.

« Newer PostsOlder Posts »

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.