## LaTeX – how to programmatically change the path of your figures

Last updated on August 17th, 2013

Scenario: You want to programmatically define where your figures are in your latex document without going through and manually editing all your paths. You have a folder called `"figs"` that contains all your figures, but this folder might move.

# Here’s how to programmatically change the path of where your images are located

Or more specifically programmatically change where the `"figs"` folder is located

The basic idea: You can define a variable in latex that stores the path to your images and then include this variable when you set your image path.
Continue reading “LaTeX – how to programmatically change the path of your figures”

## Mean absolute error tutorial MATLAB

Last updated on August 17th, 2013

# Here’s how to calculate the mean-absolute-error by hand in MATLAB

Basic idea: You have a set of numbers,

`Actual = [1 2 3 4];`

Then you have some method that tries to predict these numbers and returns some predicted values,

`Predicted = [1 3 1 4];`

You might now ask, “How do I evaluate how close the Predicted values are to the Actual values?”

Well one way is to take the mean absolute error (MAE) and report that.
Continue reading “Mean absolute error tutorial MATLAB”

## Root Mean Square Error tutorial – MATLAB

Last updated on February 4th, 2014

# Here’s how to calculate the root mean square error.

Assume you have one set of numbers that represent the Actual values you want to predict.

`Actual = [1 2 3 4];`

Then assume you have another set of numbers that Predicted the actual values.

`Predicted = [1 3 1 4];`

How do you evaluate how close Predicted values are to the Actual values?

Well you could use the root mean square error (RMSE) to give a sense of the Predicted values error.

Here’s some MATLAB code that does exactly that.
Continue reading “Root Mean Square Error tutorial – MATLAB”

## X3D – how to rotate an object

Last updated on August 17th, 2013

## LaTeX – how to add a new reference to the BibTeX

Last updated on August 17th, 2013

## How to add a BibTeX entry to LaTeX

This assumes,

2. you are using Texmaker (if you’re not, you probably should be)

It seems to me you must go through a series of arcane steps to be able to add a reference to your BibTeX bibliography and get it to work in your $\LaTeX$ file.

Here’s the steps and their order that have worked for me. I have included my a few comments that hopefully help to give you a sense what is going on.

## MATLAB – how to calculate the Jaccard similarity coefficient/index and distance between images

Last updated on February 9th, 2014

Here’s how to calculate the Jaccard similarity coefficient and Jaccard distance between two or more images.

But first, some quick definitions

The Jaccard index is the same thing as the Jaccard similarity coefficient. We call it a similarity coefficient since we want to measure how similar two things are.

The Jaccard distance is a measure of how dis-similar two things are. We can calculate the Jaccard distance as 1 – the Jaccard index.

For this to make sense, let’s first set up our scenario.

We have Alice, RobotBob and Carol. Alice draws a white line. RobotBob and Carol try to copy Alice. We want to measure how similar RobotBob’s and Carol’s lines are to Alice’s line.
Continue reading “MATLAB – how to calculate the Jaccard similarity coefficient/index and distance between images”

## Cluster commands

Last updated on August 17th, 2013

Often I find myself running jobs on the cluster and I can never remember the basic commands. So here’s some useful commands that you can use to run jobs on the cluster.

*** note that I’m running jobs on Simon Fraser University’s (SFU) cluster and I have no idea if these will work on your specific configuration ***

Assume you have a cluster script called test.pbs

## Unity3D – example online game

Last updated on August 17th, 2013

A few months ago, I romanticized about developing video games and spent an evening trying out Unity3D.

I have to say I’m pretty impressed. With zero prior experience using it and barely going through any sort of tutorials, in a couple of hours I managed to put together a little world to run around in!

## Spinal Cord Segmentation using an A* search

Our paper was accepted in ISBI 2013! ðŸ™‚

The paper is called:

## Globally Optimal Spinal Cord Segmentation Using a Minimal Path in High Dimensions

I think the title really summarizes the work pretty nicely so I’ll break down each part of the title to give you a brief overview of the paper.

“Spinal Cord Segmentation” = this is the goal of the work. Given a 3D MRI, we want a method that can mark those voxels that belong to the spinal cord. Segmentation means to label the voxels as spinal cord or background.

“High Dimensions” = we represented the segmented spinal cord by a list of 6 numbers. I’ll explain this a bit more since this a bit tricky to understand. We used principle component analysis (PCA) to represent the “shape” of a 2D slice of the spinal cord. PCA allows us to represent each shape by its center point (x,y,z) and three principle components (giving us a total of 6 numbers per 2D slice). We can represent our spinal cord as a stack of these 2D shapes, or equivalently, a list of 6 numbers.

Now the question is, how to find this list of 6 numbers? Well we can search for them. This is similar to finding the shortest path in between 2 points, but instead of searching over 2 or 3 (spatial) dimensions, we search over the 6 dimensions (3 spatial and 3 shape).

“Minimal Path” = a minimal path finds the shortest path in between two points. In our methods, a user enters the start and end point of the spinal cord, and we find the minimal path in 6D between these two points. We use a slightly modified version of the A* search to find this minimal path. A path is defined to be “short” if the shapes “fits” well (e.g. the borders match) with what is in the MRI.

“Globally Optimal” = means that we can find the best segmentation that exists based on how we defined how well the shape “fits”. Our method will always find the global minimum and will not get stuck in any local minima.

You can take a look at the paper here.

Here’s the poster we did for the ISBI conference.

The nice PDF can be viewed here.