Camera Calibration Theory

Single Camera Model

We assume the camera adheres to the “pin-hole” model. With this model, there are certain quantities we need to find to characterize the “intrinsics” of the system:

  1. position of image center
  2. focal length
  3. scaling factors to convert height and width of pixels to physical units
  4. lens distortion

Note that 2) and 3) are typically combined as, mathematically, it’s not necessary to know the focal point explicitly. This is talked about in the next section.

The diagram below describes the model:

Continue reading “Camera Calibration Theory”

Acquiring Stereo Images with Spinnaker API + Hardware Trigger

In the previous article, I set up a stereo vision rig. Now, its time to take pictures with it. The most important thing to do is to set things up so that the synchronized capture works correctly.

The cameras I used are Blackfly S cameras which use the Spinnaker API. I’ve opted to use the python version of the API because python is great for tinkering. The first thing to do is to go onto Flir‘s website, search for Spinnaker, and then download and install the SDK and Spinnaker for python. I’ve opted to use Ubuntu 16.04 with Spinnaker version 1.10.0.31.

After you install the SDK and python extension, take a look at the documentation for synchronized capture. If you scroll down to configuring Blackfly S cameras, you must:

  • For the primary camera: 1) enable the 3.3V output for line 2
  • For the secondary camera: 1) set the trigger source to line 3, 2) set the trigger overlap to “read out”, and 3) then set trigger mode to “on”.

Continue reading “Acquiring Stereo Images with Spinnaker API + Hardware Trigger”

Stereo Camera Setup with Blackfly S Mono USB3 Vision Cameras

The Cameras

#Part
2Blackfly S Mono 3.2 MP USB3 Vision Camera
16 pins, 1m GPIO Cable, Hirose HR10 Circular Connector
2USB 3, 1m, Type-A to Micro-B Cable

The most important component of the setup is the cameras, so I picked the cameras I wanted first, then built up the rest of the rig around them. I decided to go with two Flir Blackfly S Mono USB3 vision cameras; I went with these cameras because they offer a good overall balance between image quality, resolution, price, and they use Flir’s Spinnaker SDK. They were also the newest cameras released by Flir at the time and it always feels good to be on the cutting edge.

These cameras use a primary/secondary setup for synchronized capture. One camera (in my case, the left camera) is set as the “primary”. This camera will acquire the image and uses a “trigger” to send a signal to the other camera to acquire an image at the same time.

Continue reading “Stereo Camera Setup with Blackfly S Mono USB3 Vision Cameras”

bedpostx with Docker and Singularity!

In the previous article, I discussed the preprocessing of diffusion data. In this article, I’ll demonstrate how to use bedpostx with Docker and Singularity!

Tools and files used in this article:

The version of FSL used in the docker is 5.0.10 and it has the cuda 8 version of bedpostx_gpu from here. PREPROCESSED.zip is preprocessed diffusion data using my dtiQA Singularity/Docker image.

Continue reading “bedpostx with Docker and Singularity!”

DWMRI Preprocessing (and Quality Assurance) with Docker and Singularity!

In the previous article, I discussed the general processing flow for DWMRI data. In this article, I’ll go into more detail on the preprocessing (and Quality Assurance) of diffusion data, and we’ll do it with Docker and Singularity!

Tools and files used in this article:

Some things: I’ve decided that the documentation is now good enough on topup and eddy that anyone can invest the time and get them both working. Instead, I’ve opted to simply dockerize/singularize the entire process into a pipeline so that you can get it up and running quickly. The pipeline is called “dtiQA” and uses topup/eddy to preprocess the data and then runs a QA using DTI-related statistics. The version of FSL used in the container is 5.0.10 and has the 5.0.11 eddy patch.

scans.zip contains four DWMRI scans acquired in this order:

  1. 1000 b-value x 32 gradient directions (1000_32_1)
  2. 1000 b-value x 6 gradient directions (1000_6_rev)
  3. 2000 b-value x 60 gradient directions (2000_60)
  4. 1000 b-value x 32 gradient directions (1000_32_2)

Continue reading “DWMRI Preprocessing (and Quality Assurance) with Docker and Singularity!”

A brief introduction to diffusion weighted MRI (DWMRI) processing

This article serves as a brief introduction to DWMRI processing.

Tools and files used in this article:

dwmri.dcm is a 32 direction, 1000 b-value DWMRI dicom file, dcm2niix is a commonly used DICOM to NIFTI converter, nifti_utils is a library to work with NIFTIs in MATLAB, dwmri_visualizer is a visualization tool for diffusion images in MATLAB, and FSL is a powerful and commonly used medical image processing library.

A very common pipeline for dwmri processing is:

1.\ ACQUISITION
\downarrow
2.\ DICOM
\downarrow
3.\ NIFTI,\ BVEC,\ BVAL
\downarrow
4.\ PREPROCESSING
\downarrow
5.\ PROCESSING

Continue reading “A brief introduction to diffusion weighted MRI (DWMRI) processing”

Working with NIFTI(-1) files in MATLAB

This article will discuss the NIFTI-1 format and how to work with these files in MATLAB. The purpose of this article is to give a high-level introduction to “get you going”.

Tools and files used in this article:

What is a NIFTI file?

It’s essentially: a file containing a 3D array with an associated orientation. Technically, it’s a file containing a 348 byte header followed by image data. There’s more information here, here, and here about the specifics of what’s contained in the header. In this article, I’ll simply discuss how the orientation is stored in the header and how to use it, as well as a couple other fields which are important to properly using and manipulating the data. There are some other fields specific to certain modalities (i.e. fMRI), but they are not discussed here.
Continue reading “Working with NIFTI(-1) files in MATLAB”