Problems and Solutions » AFNI Draw Dataset: Counseling and Hacking Tips

Use AFNI's Draw Dataset plugin to perfect your brainstripping.

The Draw Dataset plugin lets one outline regions in an image using the mouse, then fill in those regions with the desired value. By using a value of 0, one can effectively erase unwanted tissue in each slice.

1. Begin with an image which has already been through a first stripping in BET or XBSE. Start up AFNI in the directory which houses that image. Note that the latest version of AFNI can handle analyze format, so a conversion to AFNI format is unnecessary. However, if you use a .img file, it will appear with anterior regions pointing to the bottom of the screen. To change the orientation, select "Disp" in the axial (or coronal, or saggittal) view, then select "Rot 180". (See screenshot.)

2. In the main AFNI dialogue, click on Define Datamode, then on the plugins menu.

3. Select Draw Dataset. (See screenshot.)

4. Make a copy of the structural image which you want to modify, so that the original image is not ruined when your caffeine jitters lead you to carve odd hieroglyphics in some poor subject's brain. The copy can be made in the dialogue:

a. Select "Copy Dataset."
b. Set the three adjacent drop-down menus to read "Data", "Anat", and "As Is", respectively.
c. From the "Choose Dataset..." menu, select the image which you wish to copy.
d. When you click "Set" in the "Choose Dataset..." menu, a copy will be saved, and that copy will now be the active image.
e. Be sure to remove the check from the "Copy Dataset" option; otherwise, a new copy of the image will be made each time you click "Save", each time appending an extra "C" to the filename (e.g., "CCCOPY_vwfa_03.hdr+orig").
Note that if the original dataset was in analyze format, the copy will be saved in AFNI format. (See screenshot.)
5. Set up your drawing tool:

a. Set the fill value to 0.
b. Choose the color which tickles you (not necessarily pink).
c. The default tool should be "Filled Curve"--use it.

With this tool, one uses the middle mouse button to draw a closed region. When you release the mouse button, the region is filled with the fill value. Note that if you release the button before you have closed the loop, Draw Dataset will try to close the curve for you and fill in the resulting region. This auto-complete feature works pretty well.

6. Take advantage of the "Undo" and "Redo" buttons in the bottom row. Note that these features work not only for the last-made change: you can undo and redo any changes which you have made to an image during this session of Draw Dataset. In truth, Undo and Redo make it unnecessary, though still advisable, to work on a copy of the original dataset.

7. Save your work whenever the thought occurs to you. Note that after each save, the name of the active image will disappear from the top row of the dialogue box. You can retrieve it by re-selecting the image from the "Choose Dataset..." menu, but this re-selection seems unnecessary: when you make your next change, the dataset name should reappear at the top.

8. Using the Filled Curve tool, you will have to proceed slice by slice through the brain. Note that the border between gray matter and fatty tissue can be unclear in the top three or four brain slices (at least, it appears so with T2-weighted images from the BIRC). I have tried to draw reasonable, if somewhat arbitrary, borders in these slices by squinting a lot and comparing the current image with the brain-fat demarcation in lower slices.

9. Rest your eyes--this is going to take a while. Still, the effort seems worthwhile: one or two days of detail work will assure you of quality brainstripping for an entire research study.

10. When you have finished, use Format Convert to return your structural image to analyze format.

Look at some before-and-after pictures. Remember that AFNI and AFNI Draw Dataset are lower in carbs than a cardboard box.