ft_appendsens: use chantype when present for checking consistency #2228
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ft_appendsens checks the consistency of the sensor sets prior to merging, one of the criteria being their 'type'. It uses ft_senstype for this purpose (around line 65). However, this does not always work reliably when the sensor set has labels that trip ft_senstype up in believing the sensor type is, for instance, ext1020 instead of eeg, such as may happen with the idiosyncratic labels typically used for iEEG electrodes/channels. I noticed it does this even when a chantype field is already present, ignoring the information contained by that field. I think a proper fix for this would involve some major consideration of what information ft_senstype (and ft_datatype_sens, for that matter) should prioritize for different modalities (also as a function of ft version, as seems to be another variable). In the meantime, the present PR makes ft_appendsens exploit information from the chantype field during the consistency check, diverting to ft_senstype when necessary.