BrainSuite Curve Format

BrainSuite uses a special format for storing curve data, such as for representing sulcal landmarks on the cortical surface. This format, which uses the extension .dfc, can store multiple curves in a single file, as well as metadata that represents names and colors for each curve. It can also store an entire delineation protocol, which will be displayed in the sulcal delineation tool. The layout of the file is as follows

File Layout

Field Description
DFC Header A file description that provides number of curves, as well as pointers to other data in the file
metadata embedded XML
subject data embedded XML (not used)
curve data number of points in curve, followed by float triples

The header portion, detailed below, includes information about the number of curves stored in the file, as well as pointers to the start of the data fields. The metadata field is used to indicate curve colors, and can also include an XML description of a delineation protocol.

DFC Header

Position Field Datatype Description
0 magic char[8] An 8 character string designating the filetype (‘DFC_LE\0\0’ or ‘DFC_BE\0\0’*).
8 version uint8[4] 4 unsigned characters, representing the version number (e.g.,
12 header size int32 size of the stored header
16 data start int32 offset from beginning of file to where the curves are stored
20 metadata offset int32 offset from beginning of file to where the metadata are stored
24 subject data offset int32 offset from beginning of file to where the subject data are stored (not currently used)
28 # of contours int32 number of curves stored in file

*DFC_LE or DFC_BE can specify the endianess of the data.
The curve data section of the file begins at position datastart, and is stored sequentially as

Cuve0 Curve1 CurveNC-1

where NC is the number of curves stored in the file.

Each curve is represented as:

N x0 y0 z0 x1 y1 z1 xN-1 yN-1 zN-1

where N is a 32-bit integer representing the number of points in the curve, and (xn,yn,zn) is the n-th point, represented by 3 32-bit floating point numbers. Thus, a curve with N curves will be stored in 4 + 3*4*N bytes. The curves are stored contiguously.

MATLAB Curve File Reader

The following is a simple implementation of a function to read DFC files in MATLAB.

function [curves,hdr,xml]=readdfc(filename)
% READDFC reads a BrainSuite curve file.
% Author : David Shattuck, UCLA Brain Mapping Center
if (fid<0) error(['unable to open file ' filename(:)']); end; hdr.magic=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,'uint32'); hdr.subjectDataOffset=fread(fid,1,'uint32'); hdr.nCurves=fread(fid,1,'int32'); xml=char(fread(fid,hdr.dataStart-hdr.metadataOffset,'char')'); curves=cell(hdr.nCurves,1); for i=1:hdr.nCurves; nPoints=fread(fid,1,'uint32'); curves{i}=fread(fid,[3 nPoints],'float32')'; end; fclose(fid);