Back to the main page.

Bug 2806 - ft_read_cifti: ask permission to build in support for passing LabelTable info to output for dense-label files

Status CLOSED FIXED
Reported 2015-01-12 10:14:00 +0100
Modified 2015-07-15 13:31:22 +0200
Product: FieldTrip
Component: fileio
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Jan-Mathijs Schoffelen
URL:
Tags:
Depends on:
Blocks:
See also:

Jan-Mathijs Schoffelen - 2015-01-12 10:14:13 +0100

In order to be able to use a dense-label cifti file needs to pass the LabelTable information to the output (creating a XXXlabel field that belongs to the corresponding XXX field, the latter of which is correctly passed to the output (although 0-based -> FT convention requires it to be 1-based)). I request permission to do this :-). I would suggest to build this in around line 900 in ft_read_cifti: if ~isempty(NamedMap) % do some stuff here end agreed?


Robert Oostenveld - 2015-01-12 12:12:50 +0100

permission granted ;-) Please inform me (through here) of the update to the code, so that I can also update the cifti-matlab release on github.


Jan-Mathijs Schoffelen - 2015-01-13 11:37:59 +0100

[jansch@mentat002 fileio]$ svn diff ft_read_cifti.m Index: ft_read_cifti.m =================================================================== --- ft_read_cifti.m (revision 10096) +++ ft_read_cifti.m (working copy) @@ -510,7 +510,8 @@ brainstructureIndex{i} = 1:BrainModel(i).SurfaceNumberOfNodes; case {'2', '2.0'} greynodeIndex{i} = BrainModel(i).VertexIndices; - brainstructureIndex{i} = 1:BrainModel(i).SurfaceNumberOfVertices; + %brainstructureIndex{i} = 1:BrainModel(i).SurfaceNumberOfVertices; + brainstructureIndex{i} = 1:numel(BrainModel(i).VertexIndices); otherwise error('unsupported cifti version'); end % switch @@ -902,11 +903,31 @@ source.label = {Parcel(:).Name}; end +if ~isempty(NamedMap) + % the following assumes a single NamedMap + if isfield(NamedMap, 'LabelTable') + % use the key-label combination in the label table + haslabeltable = true; + key = NamedMap.LabelTable.Key; + end + source.datalabel = NamedMap.LabelTable.Label(:); +end + if readdata if isfield(source, 'data') % rename the data field source.(fixname(dataname)) = source.data; + + % adopt FT convention for parcel-to-label mapping + if haslabeltable + tempdata = nan+zeros(size(source.data)); + for k = 1:numel(key) + tempdata(source.data==key(k)) = k; + end + source.data = tempdata; + end source = rmfield(source, 'data'); + end % rename the datalabel field @@ -914,4 +935,5 @@ source.(fixname([dataname 'label'])) = source.datalabel; source = rmfield(source, 'datalabel'); end + end


Jan-Mathijs Schoffelen - 2015-01-13 11:38:48 +0100

[jansch@mentat002 fileio]$ svn commit -m "enhancement - also output the XXXlabel field when reading a dlabel cifti" ft_read_cifti.m Sending ft_read_cifti.m Transmitting file data . Committed revision 10097.


Jan-Mathijs Schoffelen - 2015-01-13 13:49:43 +0100

[jansch@mentat002 fileio]$ svn diff ft_read_cifti.m Index: ft_read_cifti.m =================================================================== --- ft_read_cifti.m (revision 10097) +++ ft_read_cifti.m (working copy) @@ -903,6 +903,7 @@ source.label = {Parcel(:).Name}; end +haslabeltable = false; if ~isempty(NamedMap) % the following assumes a single NamedMap if isfield(NamedMap, 'LabelTable') [jansch@mentat002 fileio]$ svn commit -m "bugfix - added default haslabeltable, causing crash after latest commit, thanks Andre for reporting" ft_read_cifti.m Sending ft_read_cifti.m Transmitting file data . Committed revision 10098.


Jan-Mathijs Schoffelen - 2015-02-08 19:43:55 +0100

My initial attempt caused some troubles but all seems fine now (with regards to reading in, and dealing with the LabelTable, either present or not).