Skip to content

Tutorial 1 Generating training data with IMOD

Chris Churas edited this page Aug 12, 2018 · 15 revisions

This page provides instructions on how to generate training data using IMOD that can be used to train CDeep3M

Goals

  1. Use IMOD program to get information about SBEM image stack
  2. Generate a training dataset from training data using IMOD to train CDeep3M

Requirements

Step 1 Download and unzip the dataset

A. Download the ZIP file entitled datasetone.zip from:

https://github.com/CRBS/cdeep3m/wiki/data/datasetone.zip

B. Unzip the contents to an easily accessible location:

  • For Windows 7/8/10: Unzip the file into a new folder in your home directory. If you used the IMOD cygwin install, the home directory will be C:\Users\<username> (for windows 10 it may be C:\cygwin\home\<username>)

From the cygwin terminal this can be done with this command ($HOMEPATH is an environment variable in Windows set to the user's home directory):

cd ~
unzip $HOMEPATH/Downloads/datasetone.zip
  • For Mac: Unzip the file into a new folder (e.g. /Users/<username>/datasetone).

  • For Linux: Unzip the file into a new folder (e.g. /home/<username>/datasetone).

C. Open your terminal program

D. Navigate to the directory to which you unzipped the dataset, using the cd command in the terminal:

cd ~/datasetone

E. List the directory's contents using the ls command. you should see two files, sbem_train.mrc and sbem_model.mod

Terminal showing unzip of datasetone.zip file

Step 2 Determine the properties of the dataset

A. At the command line type:

header sbem_train.mrc

and output like the following will be displayed:

Detailed view showing output of header sbem_train.mrc

Terminal showing output of header sbem_train.mrc

Step 3 Update IMOD model file for training labels

To save time a model file sbem_model.mod has been included in datasetone.zip and already has all mitochondria traced except for tile/slice 2

A. Open the training data stack in 3dmod by running the following command:

3dmod sbem_train.mrc

Window showing 3dmod after it opens sbem_train.mrc

B. To save time open the existing model file sbem_model.mod by clicking File -> Open Model in 3dmod as seen in here:

Shows file open in 3dmod

Shows file open dialog in 3dmod

Loaded model (mitochondria are outlined in green)

Shows loaded model in 3dmod

C. In this tutorial, we will be generating training data for mitochondria. Manually segment all instances of mitochondria in tile number 2 of your training data stack.

For more information on segmentation and model files click here.

A useful video illustrating the use of IMOD's Drawing tools can be found here

D. Be sure to save the model when done using the same name sbem_model.mod

Step 4. Generate a Training label stack

Goal: generate a new MRC stack with same dimensions as the training images (we previously segmented)

All pixels inside of the traced contours value = 1,

All pixels outside of the traced contours value = 0.

Binary label stack will be created that will serve to tell the CDeep3M training algorithm where mitochondria are.

We will use the IMOD program imodmop to generate this stack.

A. Create the binary label stack using the following command:

imodmop -mask 1 sbem_model.mod sbem_train.mrc sbem_train_labels.mrc

(To understance the meaning of these arguments and the imodmop syntax, view the imodmop man page in the terminal by typing man imodmop -- to exit the man page type q

B. Visuallize the label stack using 3dmod:

3dmod sbem_train_labels.mrc

Shows loaded binary mrc stack in 3dmod

Step 5 Generate training image and label PNGs

The CDeep3M training algorithm can take PNGs (or TIFs). Since PNG files are smaller we will convert from MRC to PNG.

A. First we need to make sub-directories under the train folder for images and labels (The '-p' argument for mkdir will automatically create any missing parent directories):

mkdir -p train/images
mkdir train/labels

B. Next, convert the MRC stack of raw training images to individually numbered PNGs using the IMOD program mrc2tif. The '-p' forces conversion to PNG, rather then TIF and the 'x' at end is needed by mrc2tif as a filename prefix:

mrc2tif -p sbem_train.mrc train/images/x

C. Convert the MRC stack of training labels to individually numbered PNGs using the IMOD program mrc2tif:

mrc2tif -p sbem_train_labels.mrc train/labels/x

Terminal showing commands to generate training data

Next

Congratulations on completing Tutorial 1.

Click here to continue with Tutorial: 2 Launch and train CDeep3M

Clone this wiki locally