Productive Extended Streamline Tractography


In the last article I introduced Extended Streamline Tractography (XST). In this article I will talk talk about the best practices and supporting softwares when applying XST to real MR data.

The Pipline

  1. Preprocess DWI images
  2. Generate seeding coordinates from ROI mask
  3. Running XST
  4. Embedd diffusivity metrics onto the tractography model


The following are required to run the supporting scripts:


git clone
python install


git clone

Then make sure to add the neuro-script repo dir to the path in .bashrc. If you are on OSX then add it to .bash_profile.

export path=$PATH:/my/neuro-script

Preprocess DWI images

Diffusion weighted image (DWI) preprocessing involves a number of steps, including motion and eddy-current corrections, possibly reverse-phase encoding corrections, resampling ...

more ...

Intro to Extended Streamline Tractography


Diffusion tensor imaging (DTI) has become a mainstay in today's neuroimaging research toolbox. It is essential for in vivo study of white matter pathways in structural neuroimaging. It is however hampered by its inability to resolve crossing fibers within key brain regions. This limitation is due to the DTI gaussian diffusion model, where regions of low anisotropy and cross-fiber regions are indistinguishable due to their gaussian diffusion profile.

A number of approaches has appeared over the years to better image crossing regions. Most of these approaches are based on diffusion acquistions of more than 50 directions, and therefore belongs to the category of high angular resolution diffusion imaging (HARDI). Newer approaches tend to fall into model-free or model-based methods. Where model-free methods attempts to estimate a number of direction maximums directly from the diffusion signal, while model-based methods attempts ...

more ...

SQLite Index is essential

Here's something that is so obvious that I can't believe no one is screaming about it.

Create and use indexes on tables are an absolutely essential part of SQLite utilization on android.

I came across this when I had to optimize the loading time for over 10,000 stops across 300+ directions on 177 routes, and god knows how many GPS points for drawing each route in NextTTC. Slow loading times was not obvious when the relationships are not complex and can be referenced by the primary key. However the NextBus data for TTC decided that each stop/direction/route should be uniquely identified by a string tag rather than an integer ID, making join queries a slow and dreary affair.

The problem is compounded by the fact that SQLite implementation on Android 2.1 (and presumably earlier ...

more ...

On Qing Ping Jian

Date Tags sword , jian


Qing Ping Jian (青萍剑) is a set of famous sword forms in Chinese martial arts. Unlike other sword forms that are named after intimidating imagery or Daoist principals, it’s name is simply translated as “Green lemnoideae” sword. Like its name suggests, the characteristics of the form is known to be light on its feet, and the techniques are focused mostly on the manipulation of the sword by the wrist. It’s known to share its origin with Kun Wu Jian (昆吾剑). As far as I understand it, the Qing Ping system seems to specialize in the usage of lighter swords that can be freely used in light jabs, and can be manipulated easily by only the wrist. There are a lot of jumping and body angle changes in the air, something that can’t be done easily with heavier ...

more ...

Pagination, deep sort, and HABTM

Here's a problem that had me scratching my head for hours.

Creating views with HABTM relationships should be a bread-and-butter task in any web application. So you'd think Cakephp has made the workflow as intuitive as possible, but what a headache.

The standard method of HABTM queries in the documentation seems intuitive enough at first glance. And this is the approach I've used for a while.

$this->Recipe->bindModel(array('hasOne' => array('RecipesTag')));
$this->Recipe->find('all', array(
'fields' => array('Recipe.*'),
'conditions'=>array('RecipesTag.tag_id'=>124) // id of Dessert

That is until I needed to be able to sort the resulting table by the deeper associations with pagination. In which case something like:


Where Disorder is a deep associated table two levels down, is going to return the error that the column ...

more ...

Fix Camera.setPreview() crash

I was playing around with the camera capabilities in one of my apps when I encountered repeated crashes with error on my HTC Magic:

java.lang.RuntimeException: startPreview
failed at android.hardware.Camera.startPreview(Native Method)

It seems that when the screen orientation changed, the reported preview dimension did not synchronize with the new rotated screen size. I tried many different approaches to ensure that the dimension was was properly set, to no avail.

There is a report of the issue here. It seems to be an issue with API version 7 (android 2.1 update) on HTC phones. The solution is to simply not call Camera.setPreview().

So a working ( albeit a bit hacky ) solution would be:

private void startCamera(int width, int height) {
    if ( _isPreview == true )

    Camera.Parameters params = camera.getParameters();
    // * Should set the preview size ...
more ...