Back to the main page.

Bug 1405 - ft_senstype does not work with volume data

Reported 2012-04-02 21:08:00 +0200
Modified 2012-04-11 16:48:37 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P3 normal
Assigned to: Robert Oostenveld
Depends on:
See also:

Gio Piantoni - 2012-04-02 21:08:14 +0200

load /path/to/fieldtrip/template/headmodel/standard_mri.mat mri = ft_checkdata(mri, 'hasunits', 'yes'); % this last line is adapted from ft_sourceinterpolate % ERROR: Reference to non-existent field 'nChans'. Error in ft_senstype (line 188) elseif isheader && input.nChans==1 && ~isempty(regexp(input.label{1}, '^csc')) Error in ft_convert_units (line 56) if ft_senstype(obj, 'meg') Error in ft_checkdata (line 402) data = ft_convert_units(data); It looks like ft_senstype.m is not very robust in recognizing datatype (see FIXME at line 122). A quick workaround is of course isfield(input, 'nChans') in ft_senstype but maybe there is a more elegant way. Thanks!

Robert Oostenveld - 2012-04-03 16:11:43 +0200

hmm, why does an anatomical MRI end up in ft_senstype...? Regardless of that, I suggest that for all ft_XXXtype we use an approach like try % do the detection here catch type = 'unknown' end to make them more robust without having to make the detection too complex.

Johanna - 2012-04-04 11:04:48 +0200

Note: Marlieke has reported on the mailing list a similar error with different code, but getting the error on line 188 of ft_senstype. Madelon has also just reported this error to me directly (but I assumed it had to do with her new data EEG cap type), but it also crashed with line 188 of ft_senstype.

Robert Oostenveld - 2012-04-04 12:31:53 +0200

the output of ft_read_mri may contain a header (of all the dicom files), which causes "isheader" to be true, whereas it was not the expected header. I fixed it (as suggested by Giovanni) and added a test script manzana> svn commit forward/ft_senstype.m test/test_bug1405.m Sending forward/ft_senstype.m Adding test/test_bug1405.m Transmitting file data .. Committed revision 5587.

Robert Oostenveld - 2012-04-04 12:48:55 +0200

The question remained: why is senstype being called on an MRI? I tracked that down, it is due to the hasunits option, which causes it to go through ft_convert_units which tries ft_convert_units. Looking at ft_convert_units, I see if ft_senstype(obj, 'meg') siz = norm(idrange(obj.chanpos)); unit = ft_estimate_units(siz); elseif ft_senstype(obj, 'eeg') siz = norm(idrange(obj.chanpos)); unit = ft_estimate_units(siz); which in both cases can in principle fail, because eeg or meg data might not have chanpos. This error can indeed be triggered by >> hdr = ft_read_header('Subject01.ds'); >> ft_checkdata(hdr, 'hasunits', 'yes') ??? Reference to non-existent field 'chanpos'. Error in ==> ft_convert_units at 57 siz = norm(idrange(obj.chanpos)); Error in ==> ft_checkdata at 402 data = ft_convert_units(data); where the header is a MEG header, but itself does not contain chanpos. Also a raw data structure (output of ft_preprocessing) would suffer the same fate. I changed this, it now returns the appropriate error >> ft_checkdata(hdr, 'hasunits', 'yes') ??? Error using ==> ft_convert_units at 98 cannot determine geometrical units Error in ==> ft_checkdata at 402 data = ft_convert_units(data);

Robert Oostenveld - 2012-04-04 12:51:14 +0200

(In reply to comment #4) manzana> svn commit Sending forward/ft_convert_units.m Sending forward/ft_voltype.m Transmitting file data .. Committed revision 5589. The change in ft_voltype.m was only to align the whitespace

Robert Oostenveld - 2012-04-11 16:48:37 +0200

I cleaned up my bugzilla list by changing the status from resolved (either fixed or wontfix) into closed. If you don't agree, please reopen the bug. Robert