Skip to content

Incorrect detection of mismatch between screen distance unit and gaze data #889

@gjheij

Description

@gjheij

pspm_find_valid_fixations should flag scenarios where there is a mismatch between input unit for the screen distance and the passed gaze data.

It finds the units of all channels using (see this line):

channelunits_list = cellfun(@(x) data.header.units, alldata.data, 'uni', false);

However, data.header should be x.header, to iterate over all channels in alldata.data. Otherwise the first element is always appended to the channelunits_list (e.g., all 'diameter'):

channelunits_list =

  7×1 cell array

    {'diameter'}
    {'diameter'}
    {'diameter'}
    {'diameter'}
    {'diameter'}
    {'diameter'}
    {'diameter'}

whereas i clearly have pixel data:

  7×1 cell array

    {'events'  }
    {'diameter'}
    {'pixel'   }
    {'pixel'   }
    {'diameter'}
    {'pixel'   }
    {'pixel'   }

If data.header is set to x.header, 'pixel' is correctly picked up, filtered out, resulting in the desired error.

% channels with 'pixel' are filtered out
>> channels_correct_units = find(~contains(channelunits_list, 'degree') & ~contains(channelunits_list, 'pixel'));
>> channels_correct_units

channels_correct_units =

     1
     2
     5

% gaze data only contains 'marker' and 'pupil' data
gazedata = 

  struct with fields:

    infos: [1×1 struct]
     data: {3×1 cell}

% resulting in desired prompt
[sts_gaze, gaze_x, gaze_y, eye] = pspm_load_gaze(gazedata, data.header.chantype);

    if sts_gaze < 1
        warning('ID:invalid_input', ['Unable to perform gaze ', ...
            'validation. Cannot find gaze channels with distance ',...
            'unit values. Maybe you need to convert them with ', ...
            'pspm_convert_pixel2unit()']);
Warning: There are no channels of type 'gaze_x_r' in the data file 
> In pspm_select_channels (line 82)
In pspm_load_data (line 234)
In pspm_load_channel (line 77)
In pspm_load_gaze (line 39) 
Warning: There are no channels of type 'gaze_y_r' in the data file 
> In pspm_select_channels (line 82)
In pspm_load_data (line 234)
In pspm_load_channel (line 77)
In pspm_load_gaze (line 40) 
end
Warning: Unable to perform gaze validation. Cannot find gaze channels with distance unit values. Maybe you need to convert them with pspm_convert_pixel2unit() 
>> 

Sidenote: pspm_convert_pixel2unit should be pspm_convert_gaze in the prompt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions