Tuesday, June 19, 2018
Wednesday, March 22, 2017
Thoughtflow.io - connecting people by sentence sentiment clustering
To present the idea and implementation of Thoughtflow, I start off by asking the following. What is common between an Overwatch server outage rage forum, a terrorist nest, a Bruce Lee quote enthusiasts gathering place, a puppy death cry-over, a chat group full of people who just farted, an ad hoc hiking trip or swingers party organizing interface and whatever you can imagine where resonating thoughts meet and empathy flourishes? Let me cut the BS and get to the answer.
Thoughtflow is designed to extract sentiment (meaning) out of sentences and group them according to similarity. Think of a search bar, you type in your thought as a sentence and you get grouped up with others who typed in analogous sentences.
One level deeper: Thoughtflow uses machine intelligence to turn human readable text to a numerical vector, which is then used to address a high dimensional space. In this metric space, distances between vectors can be defined and used to tie close ones together, hence to establish groups of related sentences - that is, cluster them.
Outline of Thoughtflow: web UI accepts sentences, forwards it to Skip-Thought, which then spits out the encoded sentence as a numerical vector. The sentence vector is consumed by DBSCAN and is grouped up by semantic similarity with other live sentences/thoughts in the system. In groups, users may post on the wall, comment, or vote - at the moment.
So, how could you turn a sentence into a vector, while holding onto the meaning? Or a (simpler) alternative, how could you turn a word into a vector in the same manner? That's what word2vec models are for! Here's how they work.
Sunday, March 13, 2016
EEG feature of fear downregulation
How do you identify fear immediately? How do you classify fear from EEG? How would you quantify fear? These questions bothered me in the beginning when I started researching the intersection of emotions, affective physiological responses and EEG signal processing. I imagined a biofeedback computer game / therapy program that helps people conquer their fears by rewarding them in the process. As time went on, my empirical knowledge and experimental data were extended, which, though changed the questions, not the vision. Here I'd like to outline how it all happened, what are the results and prospects of the research.
Experiment
While reading papers on EEG response upon fear stimulation, I was quite annoyed that the stimuli used in previous experiments were mostly IAPS images or video clips from horror movies (yeah, The Shining) completely taken out of context. To this day I believe that such stimuli are not sufficient to evoke strong enough emotional responses in a time period higher than a couple of seconds, and thus unable to provide insight into the big picture of fear regulation.
The experimental design hasn't changed much since my previous measurements, but gameplay and webcam videos were also recorded this time, in addition to EEG, heart rate (HR), and galvanic skin response (GSR) vital signals. First open-, then closed-eye measurements were taken for Individual Alpha Frequency estimation. Participants then played the "daylight" version of a computer FPS game as the baseline measurement. Only the "night" version contained fear inducing stimuli.
Wednesday, January 27, 2016
Bit of insight into payment habits - a Bitcoin blockchain investigation
As a project work, I looked at the dynamics of transactions in the Bitcoin cryptocurrency system. Delay times between consecutive payments were analysed to investigate their distribution - a distribution that could predict the next time an individual intends to spend money. This study is inspired by (Barabási 2005), a paper showing that human dynamics follow a fat-tailed power-law distribution in terms of certain tasks, like e-mail communication. It is yet to be examined if payment habits exhibit the same behavior or not. [Note: a fat-, or heavy-tailed distribution in this case is characterized by long waiting times, and burst like activities - e.g. we usually send e-mails in batches, time to time, and not in every hour a mail.]
Transactions, or payments, of 59490 accounts were fetched from the Bitcoin blockchain by calling the API of blockchain.info. Accounts were then filtered by the amount of payments initiated – minimum number of 60 transactions was required – in order to leave out bitcoin addresses used once (“Protect Your Privacy - Bitcoin” 2016) or just a few times. Account information of 6729 Bitcoin addresses made to the analysis phase in the end.
Inter-payment delay times of two accounts. Tall spikes suggests a heavy-tailed distribution - long waiting times (delay time in seconds).
Thursday, October 29, 2015
Brainstorming about brainstorming techniques
I'm about to attend a hackathon in Helsinki where I study right now. The team has already brought together, but finding an idea to hack the hell out of is not that simple. That's why I started thinking how to make brainstorming easier, how can I help my brain in the process. Here I share two approaches that I came up with - I'm not saying I was the first to figure these out, though; I have no clue.
Montage brainstorming
For the hackathon, the team had to choose, which gadget(s) to use - if more, than which combination - to build a creative, promising product. There was 20 of them so this decision alone was far from trivial. We agreed to try out a neuro headband, but still, there are a again a million ways to hack further brain signals with the other devices. There, it came to my mind, what if I constitute a montage, images of all devices cut and pasted side by side in a single image to view. It's so much easier to make associations between devices - or more abstractly, between choices of a parameter of an idea - than keeping your mind updating over and over again of the choices available. You just look at the montage and let your brain connect the dots for you. This technique, of course, is only convenient when you have all the possible choices available and their number doesn't exceed, let's say, 30. For most parameters of a hackathon / startup idea, montage brainstorming is not applicable. Don't worry, the other brainstorming method I'm going to show is just for those difficult cases.
The actual montage of devices that I assembled. Lots of tools to hack!
Wednesday, April 29, 2015
Analogy recovery from the Wikipedia corpus - a natural language processing task
Natural language processing is a field of science aiming at teaching machines the hectic human language, whether it is spoken or written. On the lowest level of abstraction computers talk to each other in sequence of bits, which in chunks forms instructions. The instruction set is limited, as well as well-defined - not any like human language. We can express rather complex concepts by a single word, while a computer would struggle spending a great amount of its words (1 word usually consists of a few bytes) to tell the same stuff. Also, families of human languages are results of thousands years of evolution, thus often neglect logic as much as are built upon traditions. All in all, getting machines understand our most innate communication form is not an easy sport. In fact, it's difficult as hell. So complex that so far we could only rely on heuristics; not even close to a full blown neural net, which would imitate our language processing brain parts, functions.
Saturday, April 4, 2015
Existence of an ideal time capsule
Let's say, you want to hide, or make inaccessible some data (e.g. video of yourself, a secret) till a given time - or in other words, send a message to the future. The problem is how would you prevent yourself, or in that matter, anybody else, to read that peace of data before the given time? How do you make absolutely sure that there's no way to open the time capsule prematurely?
You'd say let's put that secret inside a platinum chest, inside a platinum chest, inside a platinum chest ... with a self-destruction function, so if someone peeked into those boxes before intended, then the data would be wiped out of existence. Oh and do not forget to bury that matryoshka platinum chest deep down the crust of earth where platinum is at the limits of melting.
A modern time capsule feeding on solar energy.
Monday, January 19, 2015
Acquiring fear intensity from EEG
My bachelor's thesis project is about the measurement of fear using EEG signals, similarly to my previous lab work. In this case though I made the participants to play a horror game instead just inducing fear by the means of audio stimuli. Also, I attempted to obtain the intensity of the emotion not just whether it is present or not - in addition to EEG signals, self-assessment, heart rate (HR) and skin conductance (GSR) data were gathered to verify the intensity. If you are interested in the whole thing in detail you can read it here (or at the end of this post). Team of the Synetiq neuromarketing research company supervised my thesis. They helped me a lot in putting together the measurement layout, the preprocessing of HR, EEG, and GSR signals and in the analysis of results.
Course of measurement
The experiment consisted of six main parts: 1) first, baseline self-assessment, 2) open-, and closed-eye baseline measurements, 3) baseline gameplay, 4) second self-assessment, 5) fear inducing gameplay, and 6) the last self-assessment. In total, the experiment took about 30 to 40 minutes with the time spent on the placement of the measurement tools excluded.
Parts of the 30-minute measurement as of time – width of the boxes are proportional to the length of the corresponding events.
Thursday, November 27, 2014
Tóth's food serving game
Recently I've dived into game theory by attending a course. I've always been haunted by a dilemma while serving food to my guests at my apartment and now I'd like to introduce this problem in the formal terms of game theory - just for fun :D
Let's have a grill party G(N, f), where N is the set of hungry participants (|N| is the number of them), and f is the amount of food available that is divided among p1, p2, ... p|N| plates. Let h ∈ N be the host of the party, g1, g2, ..., g|N|-1 ∈ N the guests. h serves the food for all the participants including h, as well as divides the f amount among the plates while, being a kind host, lets the guests to choose which plate they want to take. In the end h takes the last one left. Actions of the players' are as follows (a1, a2, ..., an ∈ Ax denotes the set of actions player x is able to take):
Thursday, August 14, 2014
Parameter fitting tool for MOOSE
During my last week in India, I contributed to the MOOSE project by providing an interface to a parameter fitting tool. Now parameters of MOOSE models can be searched by doing some tiny Python scripting.
When you have experimental data on a phenomenon, and you intend to create a computational model of it, usually you need to apply parameter fitting/searching techniques. These methods help you determine those parameters of your model that you have no reference on. Parameter fitting using MOOSE models are accomplished through utilizing Optimizer [1], a parameter fitting tool developed for neural simulations, which I came across by pure chance.
Results 'layer' from the Optimizer tutorial. Optimizer has a simple GUI to guide the user to a successive parameter fitting.
Friday, August 8, 2014
Profiling Python C extensions
During my collaboration with Upinder S. Bhalla's lab, I made possible to profile MOOSE C++ code through Python scripting, which means one can profile the native functions of MOOSE without writing any C++ code.
For profiling I used gperftools: I wrapped three of its functions, particularly ProfilerStart, ProfilerStop and ProfilerFlush in python functions using Cython. The recompilation of MOOSE is also needed with the -lprofiler flag. After that, one can just call the wrapper functions for ProfilerStart and ProfilerStop before and after the python code that calls the C extensions one is interested in to profile. Then pprof can be used to investigate the results of profiling.
Howto
To profile Python C extensions, first Cython, gperftools and libc6-prof packages need to be installed. If you'd like a visual representation of the results of your profiling, better install kcachegrind as well.
The simplest way to get the wrapper done is to write a cython script wrapping the gperftools functions and a python script that compiles the wrapped functions and link them to the gperftools library.
Let's call the Cython script gperftools_wrapped.pyx:
1: cdef extern from "gperftools/profiler.h":
2: int ProfilerStart(char* fname)
3: void ProfilerStop()
4: void ProfilerFlush()
5:
6: def ProfStart(fname):
7: return ProfilerStart(fname)
8:
9: def ProfStop():
10: ProfilerStop()
11:
12: def ProfFlush():
13: ProfilerFlush()
14:
Here we define a python function for each function of gperftools that we wrap. More functions can be wrapped for more custom profiling (see ProfilerStartWithOptions()).
Model of the basal amygdala - computational Pavlovian fear conditioning
After the first week of the CAMP course we had to decide which project we intended to do next week. I was always interested in how fear and anxiety evolve in the brain so at the end I decided taking a joint project with my course fellow Cristiano Köhler about modeling the basal amygdala - a part of amygdala which is involved in the formation of fear and extinction memories. The main task was to reproduce a model of the basal amygdala and investigate its behavior. Our helpful supervisor was Arvind Kumar, one of the authors of the paper [1] that describes the model in the first place.
Objectives
At first, we reproduced the model of Vlachos et al., 2011 of the basolateral amygdala. The task of the model is to be able to remember a conditional stimulus (CS, e.g. flute tone) paired to an unconditional stimulus (US, e.g. electric shock) - so basically after applying Pavlovian fear conditioning on the model, it takes the same conditional stimulus (without the shock) as a cue of fear. However, further presentations of CS alone results in a decline of this conditioned response - that process is called fear extinction. Another phenomenon is called fear renewal, which shows the context-dependency of fear conditioning and extinction: after the fear conditioning and extinction period in context A (CTXA) and context B (CTXB) respectively, a repeated CS presentation in context A immediately brings back the fear memories despite the effect of the extinction period.
Model
The model intends to reproduce the functions of the basal amygdala. It's a large-scale spiking neuron network implemented in Python, utilizing the Brian library. The model consists of 4000 leaky integrate-and-fire neurons - 3600 so called excitatory and 400 inhibitory neurons. Three kind of inputs are given to the system as Poisson spike trains: (1) CS-US pairs, (2) context information to a subset of neurons and (3) background noise to all the neurons. Plasticity is established in the connections between the inputs (CS-US, context information) and the excitatory neurons. Further plasticity is introduced in the synapses from inhibitory to excitatory neurons to investigate the effects it may bring about.
Distribution of inputs in the spiking neural network model. CS-US are provided to all neurons while CTX input is fed only to a subpopulations of excitatory neurons - from [1].
Thursday, July 24, 2014
Computational Approaches to Memory and Plasticity - a great insight into neuroscience
I had the opportunity mostly thanks to Dr. Upinder S.Bhalla and Subhasis Ray to attend a 2-week-long course on neuroscience, more particularly on how memory is formed and what are the methods to computationally model this process. I'm staying in India at NCBS, where the conference took place, for more 3 weeks; at the moment I'm working in Upi's lab to optimize MOOSE by implementing some GPGPU code.
Photo taken at campus of NCBS - such greenery.
Monday, July 21, 2014
EEG data analysis of audio induced fear
My previous post ended with some statistics now I proceed to the analysis of the retrieved signals. The results and the measurement itself is rather instructive than useful and practical, so if you are interested in a working solution I have to disappoint you. I'm planning a measurement concept that is going to be much simpler and going to look at the problem from a different perspective. Also as I dived more into the literature, I found that there was no need for the 3-minute calm part, there was rather need for the measurements immediately before and after the effects played.
Hypothesis to test - frontal alpha asymmetry
Pattern of asymmetrical frontal EEG activity is found to distinguish positive (happiness, joy) from negative (fear, anger) emotions by Hell and Nitschke [James A. Coan, 2004]. Although, this hypothesis turned out to be false (at least other more supported hypothesis came), and instead some showed that it would be the indicator of valence - greater right frontal activity (which means greater left alpha power) compared to the left frontal activity indicates approach or engage stimulus and greater left frontal activity infer tendency to withdrawal stimulus. This is called Davidson's approach/withdrawal model [Davidson, 1993]. Here I should point out that activity is inversely related to alpha power, which means lower power reflects more activity and vice versa.
Alpha power means the values of the signal converted to frequency domain at 7 to 12 Hz. Here is the alpha power spatial representation of a fearful (withdrawal stimulus) person playing a horror game - not part of the main measurements. Here the alpha asymmetry model actually worked.
Saturday, May 10, 2014
Measured audio induced fear of 24 subjects using EEG signals
For my current thesis I had measurements of EEG activity from 24 mostly student subjects. The intention was to capture moments of fear or anxiousness which are induced only using audio effects. What turned out early that it's pretty hard to do. How can you arouse anxiousness to people that have different concepts of what's frightening and what's not? How can you point out the exact moment, when that feeling occurred? Are just audio inputs enough for someone to experience real danger?
Wednesday, April 16, 2014
From PDEs to Hines' solver
To understand and model electrical activity in neurons and neural networks, it is necessary to solve equations on current flows. When we take a single neuron into account, we should distribute that current flow over time and space which takes us to solve a PDE (Partial differential equation) instead of a more simple ODE. Such a cable equation allowing spatial variation looks like this:
Wednesday, April 2, 2014
NNGPU architectural design finished
NNGPU is a GPU (CUDA) powered trainable artificial neural network simulator. It's designed to be able to manage not just multilayer perceptron (MLP) networks, but practically any kind of trainable networks. Supervised learning is to be used with backpropagation training algorithm. Ability of generalization of a network can be measured, both train and test sets can be provided. It's not a complete, fully optimized framework for making artificial neural networks; it's rather a GPGPU demonstration of speed relative to a single-threaded CPU implementation. I plan to make a comparison between (single-threaded) CPU and GPGPU run to evaluate effectiveness.
First I've made a use-case diagram on the functionality of NNGPU; here it is.
Sunday, March 30, 2014
Numerical methods for solving ODEs in MOOSE
This post is about methods for solving ODEs (Ordinary Differential Equations) and about such methods used particularly in GENESIS, the ancestor of MOOSE (Multiscale Object-Oriented Simulation Environment), for neuronal modeling.
Before we discuss the methods themselves, there's a need for mentioning stiffness. We consider an ODE stiff if it has abrupt transitions in it, like an action potential. Basically stiffness measures the difficulty of solving an ODE numerically.
Stiff systems








