Forums › Forums › General Questions › Curve Toolbox – Curve lenght
This topic contains 2 replies, has 2 voices, and was last updated by Duzzo 7 months, 2 weeks ago.

AuthorPosts

October 9, 2018 at 3:24 am #1523
Hi, I’m using the curve toolbox on BrainSuite v13a4. I would like to compare the length of one specific sulcus between subjects. I’m wondering if it is possible to measure the lenght of the drawn curves or extract any other quantitative measure of the sulci.
Thanks for your kind help and support
Davide Fedeli 
October 9, 2018 at 9:54 am #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) % READDFC reads a BrainSuite curve file. % % Author : David Shattuck, UCLA Brain Mapping Center fid=fopen(filename,'rb'); if (fid<0) error(['unable to open file ' filename(:)']); end; hdr.magic=char(fread(fid,8,'char')'); hdr.version=fread(fid,4,'uchar'); hdr.headerSize=fread(fid,1,'uint32'); hdr.dataStart=fread(fid,1,'uint32'); hdr.metadataOffset=fread(fid,1,'int32'); hdr.subjectDataOffset=fread(fid,1,'int32'); hdr.nCurves=fread(fid,1,'int32'); fseek(fid,hdr.metadataOffset,'bof'); xml=char(fread(fid,hdr.dataStarthdr.metadataOffset,'char')'); curves=cell(hdr.nCurves,1); fseek(fid,hdr.dataStart,'bof'); for i=1:hdr.nCurves; nPoints=fread(fid,1,'uint32'); curves{i}=fread(fid,[3 nPoints],'float32')'; 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/BCIDNI_brain_atlas/BCIDNI_brain.right.dfc'); curvelength(curveset{1})
Let us know if that does what you need.
thanks,
David Shattuck 
October 9, 2018 at 2:24 pm #1525
Thank you David for your answer! That’s exactly what I was looking for!
Best
Davide 
AuthorPosts
You must be logged in to reply to this topic.