AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
February 23, 2006 09:26AM
Hello,

In our lab, we have been developing and using a new plugin for doing volumetrics of manually traced areas in the brain, using "slice-by-slice" volumetric calculations. We will be publishing soon.

I wonder if that script could be useful to other people doing similar work? If you think that's the case, we would be pleased to make it available to the program AFNI. Below is the text that explains what the program can do.

Denise Bernier
Dalhousie University



#!/usr/bin/perl

###############################################################################
# ROIseg #
# #
# This Perl Script segments a region of interest (ROI) and classifies the #
# included voxels by tissue type. An option has been added to do a 3D #
# slice-by-slice segmentation along the 3 axes (X,Y,Z) and optionally, to #
# classify each voxel by slice number and tissue type. #
# #
# Perl Script originally written by Remi Groleau #
###############################################################################





###############################################################################
# Help menu section #
###############################################################################

$ver = "4.0";
$author = "Remi Groleau and Denise Bernier";
$revision = "Thursday January 12th, 2006";
$version_txt = <<END_VER;

VERSION:

Version: $ver
Revision: $revision
Written, developed and tested by $author

END_VER

$RangeLow = 2; # Default Range low limit (inclusive).
$RangeHigh = 200; # Default Range high limit (inclusive).

$help = <<HELP_TEXT;

GENERAL DESCRIPTION:

The goal of this Perl Script is to do a volumetric evaluation of a
brain area. Optionally, each voxel within the ROI may be classified in one
of three classes of tissue: White Matter (WM), Grey Matter (GM) or Cerebro
Spinal Fluid (CSF). The intensity range associated with each tissue class
has to be defined on the command line.

Summary of the process:

From the 3D master brain underlay, each voxel corresponding to the
ROI is converted into a text format and copied into a text file. The
intensity range of each tissue class is defined on the command line. Then
each voxel from the ROI text file is compared with those limits and copied
in different text files according to their tissue type classification.
Along the way, the count of voxels of each class is kept. The resulting
files are converted back into mask files (overlays) in order to be
visualized over the master.

If the user sets the -A segmentation switch on the command line, the
ROI is segmented into one-voxel-thick slices along each axis (X,Y,Z). One
table of results is created for each axis of segmentation. These tables
have six columns each. The first column represents the slice number. The
second, third, fourth and fifth columns represent respectively the count
of CSF, GM, WM, and Other voxels in the slice. The sixth column
represents the total count of voxels in the slice. Each voxel in the ROI
text file is evaluated sequentially and classified by slice number and
tissue type. Each voxel having three coordinates (X,Y,Z), it belongs to a
slice in each axis of segmentation. Thus, each voxel will be accounted for
once in each table's total column and once in each table's tissue type
section. Once the segmentation and tissue classification are done, each
table is copied in a different text file labeled according to its axis of
segmentation.

If the user sets the -3D segmentation switch, the ROI is segmented
into one-voxel-thick slices along each axis (X,Y,Z) the same way the -A
switch does but without the classification of tissue types. This outputs
three tables having four columns each. The first column represents the
slice number; the second column, all the voxels included within the range;
the third column, all the Other voxels; and the fourth column, the total
number of voxels. Two masks are created, one for the "in-range" voxels and
one for the "Other" voxels.

In the case where both the -A and -3D switches are enabled, both kinds
of tables will be created, in addition to the masks for the three tissue
types (CSF, GM and WM), and to the "in-range" mask and the "Other" mask.
Note that the "Other" mask is the same for -A and -3D because it represents
the out-of-range voxels, this range being common to both switches.


FILE NAME CONSTRUCTION:

Make sure that the input files are named according to these standards when
using ROIseg. Look to set the -s and -b switches appropriately.
The followings are the input files required by ROIseg in order to create
the appropriate text file from the mask if the text file does not already
exist or if the -c switch was set.

master = subjectID + "_master+orig"
ROI_mask = subjectID + brain_area + "_mask+orig"

The following is the text file required by ROIseg in order to perform the
segmentation itself. If it does not exist, ROIseg will create it using
3dmaskdump and the files listed above.

ROI_txt = subjectID + brain_area + "_txt"

The followings are the output files produced by ROIseg when doing the
segmentation. If they already exist they will be replaced. The seg_output
file is a text file where the results are written. This file is also
printed to STDOUT (usually the terminal window) before ROIseg exits.

CSFseg_txt = subjectID + "CSFseg_txt"
CSFseg_mask = subjectID + "CSFseg_mask+orig"
GMseg_txt = subjectID + "GMseg_txt"
GMseg_mask = subjectID + "GMseg_mask+orig"
WMseg_txt = subjectID + "WMseg_txt"
WMseg_mask = subjectID + "WMseg_mask+orig"

X_seg = subjectID + brain_area + "_X_seg"
Y_seg = subjectID + brain_area + "_Y_seg"
Z_seg = subjectID + brain_area + "_Z_seg"

3Dseg_txt = subjectID + "3Dseg_txt"
3Dseg_mask = subjectID + "3Dseg_mask+orig"

X_3Dseg = subjectID + brain_area + "_X_3Dseg"
Y_3Dseg = subjectID + brain_area + "_Y_3Dseg"
Z_3Dseg = subjectID + brain_area + "_Z_3Dseg"

OTHERseg_txt = subjectID + "OTHERseg_txt"
OTHERseg_mask = subjectID + "OTHERseg_mask+orig"

seg_output = subjectID + brain_area + "_seg_output"

USE AND OPTIONS:

use: ROIseg [OPTION]

options:

-help Displays this text

-s [subjectID] Sets the prefix of each file that ROIseg uses in order
to identify them all. This prefix must match the prefix
used to label each AFNI file in the current working
directory.
(Default subjectID = "")

-b [brain_area] Sets the ROI tag that will label the segmented brain
area. See how file names are constructed in the
FILE NAME CONSTRUCTION section above.
(Default brain_area = "")

-gm [low high] Specifies the grey matter range inclusively. Any
value lower than the gm low limit is considered CSF, and
any value higher than the gm high limit is considered
WM. This switch also enables the creation of the masks
associated with each tissue type (-T). It must be set in
order to use -T or -A.

-r [low high] Specifies the total intensity range to be
considered during segmentation. Voxels with values
outside this range will be classified Other. These
values are inclusive.
(Default range = $RangeLow - $RangeHigh)

-c Will force conversion of the masks into text files
if they already exist.

-NU If this switch is set ROIseg will use the master file
corrected for non uniformity of intensity. This master
file name must be constructed as follows:

corrected master = subjectID + "_NU" + "_master+orig"

NOTE: All the output file names will automatically be
affected the same way.

-T Enables the creation of the tissue type masks. This is
the default switch if neither of -A or -3D is set.

-A Enables the creation of the tissue type masks (-T) along
with the slice-by-slice segmentation in the 3 axes.
Result will be written in 3 files labeled according to
each axis. In each of these files there are six columns:
| slice # | CSF | GM | WM | OTHER | Total |
The correspondence of each file for the segmentation
along the 3 axes is given by the followings, for MRIs
aquired coronally:
X_seg = X axis = Right to Left = Sagittal
Y_seg = Y axis = Superior to Inferior = Axial
Z_seg = Z axis = Posterior to Anterior = Coronal

-3D Enables the slice-by-slice segmentation in the 3 axes
without the tissue type classification. Results will
be written in 3 files according to each axis. In each of
these files there are four columns:
| slice # | in-range | OTHER | Total |
The correspondence of each file for the segmentation
along the 3 axes is given by the followings, for MRIs
aquired coronally:
X_3Dseg = X axis = Right to Left = Sagittal
Y_3Dseg = Y axis = Superior to Inferior = Axial
Z_3Dseg = Z axis = Posterior to Anterior = Coronal
Subject Author Posted

plugin for AFNI

Denise Bernier February 23, 2006 09:26AM

Re: plugin for AFNI

Kristina Simonyan February 23, 2006 01:03PM

Re: plugin for AFNI

Denise Bernier February 24, 2006 01:21PM

Re: plugin for AFNI

Kristina Simonyan February 24, 2006 01:43PM

Re: plugin for AFNI

rick reynolds February 25, 2006 10:24PM

Re: plugin for AFNI

Denise Bernier February 27, 2006 06:37PM

Re: plugin for AFNI

rick reynolds February 28, 2006 08:47AM

Re: plugin for AFNI

John November 07, 2008 11:58AM

Re: plugin for AFNI

rick reynolds November 07, 2008 01:32PM

Re: plugin for AFNI

John November 07, 2008 01:38PM

Re: plugin for AFNI

Denise Bernier February 27, 2006 06:48PM

Re: plugin for AFNI

ziad November 07, 2008 01:28PM