Curve Toolbox – Curve lenght

Viewing 2 reply threads
  • Author
    Posts
    • #1523
      Duzzo
      Participant

      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

    • #1524
      David Shattuck
      Keymaster

      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.dataStart-hdr.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/BCI-DNI_brain_atlas/BCI-DNI_brain.right.dfc');
      curvelength(curveset{1})
      

      Let us know if that does what you need.

      thanks,
      David Shattuck

    • #1525
      Duzzo
      Participant

      Thank you David for your answer! That’s exactly what I was looking for!
      Best
      Davide

Viewing 2 reply threads
  • You must be logged in to reply to this topic.