Select Page

# Reply To: Curve Toolbox – Curve lenght

Forums Forums General Questions Curve Toolbox – Curve lenght Reply To: Curve Toolbox – Curve lenght

#1524

hi Davide –

We don’t have tools for that as part of the package, but if you are familiar with Matlab or C++ you can calculate these lengths pretty easily. If you save out the curves as a .dfc file, you can then read them with one of our file readers.

You can find a Matlab function for reading the dfc file at the bottom of this page: http://brainsuite.org/formats/dfc/. (I think it is out

``````function [curves,hdr,xml]=readdfc(filename)
%
% Author : David Shattuck, UCLA Brain Mapping Center
fid=fopen(filename,'rb');
if (fid<0)
error(['unable to open file ' filename(:)']);
end;
curves=cell(hdr.nCurves,1);
fseek(fid,hdr.dataStart,'bof');
for i=1:hdr.nCurves;
end;
fclose(fid);``````

The curves are represented as a series of points in mm coordinates, so you can compute the path lengths very easily:

``````function curvelength=curvelength(curve)
curvelength=sum(sqrt(sum((curve(2:size(curve,1),:)-curve(1:size(curve,1)-1,:)).^2,2)));``````

If you then read in a dfc, you can easily compute the length of any of the curves:

``````curveset=readdfc('/Applications/BrainSuite18a/svreg/BCI-DNI_brain_atlas/BCI-DNI_brain.right.dfc');
curvelength(curveset{1})
``````

Let us know if that does what you need.

thanks,
David Shattuck