Back to the main page.

Bug 1819 - ft_read_headshape should return the label for tetgen files

Status CLOSED FIXED
Reported 2012-11-07 15:55:00 +0100
Modified 2013-06-30 15:17:14 +0200
Product: FieldTrip
Component: forward
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 enhancement
Assigned to: Jakob Ludewig
URL:
Tags:
Depends on:
Blocks: 18221840
See also:

Robert Oostenveld - 2012-11-07 15:55:42 +0100

right now there is the following case 'tetgen' % reads in the tetgen format and rearranges according to FT conventions % tetgen files also return a 'faces' field (not used here) shape = rmfield(shape,'fid'); IMPORT = importdata([filename '.1.ele'],' ',1); shape.tet = IMPORT.data(:,2:5); IMPORT = importdata([filename '.1.node'],' ',1); shape.pnt = IMPORT.data(:,2:4); In some cases there is also a label. This should be returned in the output, in a format consistent with vista and with FT_DATATYPE_PARCELLATION.


Robert Oostenveld - 2012-11-08 12:11:08 +0100

to work on this we need test files


Johannes Vorwerk - 2012-11-09 12:02:07 +0100

This should be solved by adding two lines: case 'tetgen' % reads in the tetgen format and rearranges according to FT conventions % tetgen files also return a 'faces' field (not used here) shape = rmfield(shape,'fid'); IMPORT = importdata([filename '.1.ele'],' ',1); shape.tet = IMPORT.data(:,2:5); if size(IMPORT.data,2)==6 shape.index = IMPORT.data(:,6); end IMPORT = importdata([filename '.1.node'],' ',1); shape.pnt = IMPORT.data(:,2:4); The name of the field where the index data are stored has to be aligned with bug 1818 of course!


Lilla Magyari - 2012-11-13 17:35:32 +0100

hi Jakob, please see bug1818 (also assigned for you) for my comments. Lilla


Robert Oostenveld - 2012-11-20 11:40:49 +0100

I have added file format detection for all tetgen formats, please check ft_filetype for what it returns (tetgen_xxx). mac001> svn commit ft_filetype.m private/filetype_check_extension.m Sending ft_filetype.m Sending private/filetype_check_extension.m Transmitting file data .. Committed revision 6961.


Robert Oostenveld - 2012-11-20 11:45:10 +0100

(In reply to comment #4) I have updated ft_read_headshape accordingly, it now allows the filename of either file to be specified. mac001> svn commit ft_read_headshape.m Sending ft_read_headshape.m Transmitting file data . Committed revision 6962. for example >> mesh = ft_read_headshape('tet_4layer_127_127_127.1.node') mesh = pnt: [801633x3 double] tet: [4985234x4 double] unit: 'mm'


Johannes Vorwerk - 2012-11-20 15:28:41 +0100

(In reply to comment #5) If you change it to case 'tetgen_ele' % reads in the tetgen format and rearranges according to FT conventions % tetgen files also return a 'faces' field (not used here) [p, f, x] = fileparts(filename); shape = rmfield(shape,'fid'); [p, f, x] = fileparts(filename); filename = fullfile(p, f); % without the extension IMPORT = importdata([filename '.ele'],' ',1); shape.tet = IMPORT.data(:,2:5); if size(IMPORT.data,2)==6 labels = IMPORT.data(:,6); % representation of data is compatible with ft_datatype_parcellation shape.tissue = zeros(size(labels)); numlabels = size(unique(labels),1); shape.tissuelabel = {}; for i = 1:numlabels ulabel = unique(labels); shape.tissue(labels == ulabel(i)) = i; shape.tissuelabel{i} = num2str(ulabel(i)); end end IMPORT = importdata([filename '.node'],' ',1); shape.pnt = IMPORT.data(:,2:4); we should have the labels according to bug1818.


Robert Oostenveld - 2012-11-20 23:06:05 +0100

(In reply to comment #6) I have just included the suggestion from Johannes mbp> svn commit ft_read_headshape.m Sending ft_read_headshape.m Transmitting file data . Committed revision 6967.


Lilla Magyari - 2012-11-21 17:05:51 +0100

(In reply to comment #7) hi, test/test_bug1818 runs without error which means that this bug has been fixed too, so I am closing it. Lilla