Hi Christian,
Sorry for the long delay in getting back to you. I needed some time to go through the code carefully.
In DSI Studio, the along-tract direction is determined as follows. At the end of fiber tracking, for each trajectory, the head and tail positions are used to compute a head-to-tail vector ((v_x, v_y, v_z)). DSI Studio then takes the absolute values ((|v_x|, |v_y|, |v_z|)) to identify the dominant dimension—that is, the dimension with the largest absolute value. If the head-to-tail vector component along this dominant dimension is negative, the trajectory is reversed.
Hope this clarifies things.
Best regards,
Frank