Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] View of /branches/lamont/test/tracto.diderot
 [diderot] / branches / lamont / test / tracto.diderot

# View of /branches/lamont/test/tracto.diderot

Mon Apr 26 00:57:58 2010 UTC (9 years, 10 months ago) by glk
Original Path: trunk/test/tracto.diderot
File size: 1705 byte(s)
`simple diffusion tensor tractography example`
```// tracto.diderot
//
// simple tractography; this only traces half the path, depending on
// seedSign; caller will half to piece these together into single path
// uses midpoint method (RK2) for integration
//

input string dataFile;          // name of dataset
input real stepSz;              // size of steps
input real CLmin;               // minimum value of CL anisotropy measure
input int stepNumMax;           // max number of steps allowed, or zero if no limit

field#1(3)[3,3] F = convolve (bspln3, img);

actor Tracto (vec3 seedPoint, int seedSign)  // seedSign == +1 or -1
{
int         stepNum = 0;
vec3        pos = seedPoint;
vec3        guide = seedSign * principleEvec(F@seedPoint);
real        aniso = 0.0;

update
{
if (inside (pos,F)) {
tensor[3,3] ten = F@pos;
aniso = CL(ten);  // "CL" is a linear anisotropy measure
if (aniso < clmin) {
// terminate because anisotropy went too low
stabilize;
}
// else
vec3 evec = principleEvec(ten);
if (dot(evec, guide) < 0) { evec = -evec; } // fix eigenvector sign
evec = principleEvec(F @ (pos + 0.5*stepSz*evec));
if (dot(evec, guide) < 0) { evec = -evec; } // fix eigenvector sign
guide = evec;
pos = pos + stepSz*evec;
stepNum = 1 + stepNum;
if (stepNumMax > 0 && stepNum > stepNumMax) {
// terminate because we took too many steps
stabilize;
}
} else {
// terminate because we went out of bounds
stabilize;
}
}

}
```