Fix Intan RHD auxiliary channel name parsing#90
Conversation
- Modified `ndr.reader.intan_rhd.intanname2mfdaqname` to correctly handle channel names without hyphens (e.g., 'AUX1'). - Added fallback logic to extract trailing numbers when no hyphen is present. - Implemented specific logic for 'aux' channels to be treated as 1-based (matching 'AUX1' -> 'ax1'), while maintaining 0-based + 1 logic for others (e.g. 'DIN-00' -> 'di1'). - Added `testChannelNameParsing` to `tools/tests/+ndr/+unittest/+reader/TestIntanRhd.m` covering various naming cases.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
| chan_intan = str2num(name(sep+1:end)); | ||
| chan = chan_intan + 1; % Intan numbers from 0 | ||
| channame = [ndr.reader.base.mfdaq_prefix(type) int2str(chan)]; | ||
| if ~isempty(sep), |
Check notice
Code scanning / Code Analyzer
Extra comma is unnecessary. Note
| chan = chan_intan + 1; % Intan numbers from 0 | ||
| channame = [ndr.reader.base.mfdaq_prefix(type) int2str(chan)]; | ||
| if ~isempty(sep), | ||
| chan_intan = str2num(name(sep(end)+1:end)); |
Check notice
Code scanning / Code Analyzer
If you are operating on scalar values, consider using 'str2double' for faster performance. Note
| if ~isempty(sep), | ||
| chan_intan = str2num(name(sep(end)+1:end)); | ||
| chan = chan_intan + 1; % Intan numbers from 0 | ||
| else, |
Check notice
Code scanning / Code Analyzer
Extra comma is unnecessary. Note
| else, | ||
| % try to find a number at the end | ||
| [s,e] = regexp(name,'\d+$'); | ||
| if ~isempty(s), |
Check notice
Code scanning / Code Analyzer
Extra comma is unnecessary. Note
| % try to find a number at the end | ||
| [s,e] = regexp(name,'\d+$'); | ||
| if ~isempty(s), | ||
| chan_intan = str2num(name(s:e)); |
Check notice
Code scanning / Code Analyzer
If you are operating on scalar values, consider using 'str2double' for faster performance. Note
| end; | ||
| else, | ||
| chan = []; | ||
| end; |
Check notice
Code scanning / Code Analyzer
Extra semicolon is unnecessary. Note
| else, | ||
| chan = []; | ||
| end; | ||
| end; |
Check notice
Code scanning / Code Analyzer
Extra semicolon is unnecessary. Note
| end; | ||
| end; | ||
|
|
||
| if isempty(chan), |
Check notice
Code scanning / Code Analyzer
Extra comma is unnecessary. Note
|
|
||
| if isempty(chan), | ||
| channame = [ndr.reader.base.mfdaq_prefix(type)]; % fallback | ||
| else, |
Check notice
Code scanning / Code Analyzer
Extra comma is unnecessary. Note
| channame = [ndr.reader.base.mfdaq_prefix(type)]; % fallback | ||
| else, | ||
| channame = [ndr.reader.base.mfdaq_prefix(type) int2str(chan)]; | ||
| end; |
Check notice
Code scanning / Code Analyzer
Extra semicolon is unnecessary. Note
Test Results44 tests 44 ✅ 2s ⏱️ Results for commit e1b50f3. ♻️ This comment has been updated with latest results. |
- Updated `ndr.reader.intan_rhd.intanname2mfdaqname` to accept a channel structure in addition to a string. - Modified `getchannelsepoch` to pass the entire channel structure to `intanname2mfdaqname`. - Added logic to `intanname2mfdaqname` to handle names without hyphens (e.g., 'AUX1'). - Added fallback logic to use `chip_channel` + 1 if the channel name cannot be parsed. - Added comprehensive unit tests in `tools/tests/+ndr/+unittest/+reader/TestIntanRhd.m` covering standard names, 'AUX' names, and struct/fallback scenarios.
| end; % ndr.reader.intan_rhd.intanchanneltype2mfdaqchanneltype() | ||
|
|
||
| function [channame] = intanname2mfdaqname(intan_rhd_obj, type, name) | ||
| function [channame] = intanname2mfdaqname(intan_rhd_obj, type, name_or_struct) |
Check warning
Code scanning / Code Analyzer
Input argument might be unused. Consider replacing the argument with ~ instead. Warning
| % NAME_OR_STRUCT can also be the Intan channel structure (with fields 'native_channel_name', 'chip_channel', etc). | ||
| % | ||
|
|
||
| if isstruct(name_or_struct), |
Check notice
Code scanning / Code Analyzer
Extra comma is unnecessary. Note
|
|
||
| if isstruct(name_or_struct), | ||
| name = name_or_struct.native_channel_name; | ||
| if isfield(name_or_struct, 'chip_channel'), |
Check notice
Code scanning / Code Analyzer
Extra comma is unnecessary. Note
| else | ||
| chip_channel = []; | ||
| end | ||
| else, |
Check notice
Code scanning / Code Analyzer
Extra comma is unnecessary. Note
| else, | ||
| name = name_or_struct; | ||
| chip_channel = []; | ||
| end; |
Check notice
Code scanning / Code Analyzer
Extra semicolon is unnecessary. Note
| else, | ||
| chan = chan_intan + 1; % assume 0-based | ||
| end; | ||
| else, |
Check notice
Code scanning / Code Analyzer
Extra comma is unnecessary. Note
| end; | ||
| else, | ||
| chan = []; | ||
| end; |
Check notice
Code scanning / Code Analyzer
Extra semicolon is unnecessary. Note
| else, | ||
| chan = []; | ||
| end; | ||
| end; |
Check notice
Code scanning / Code Analyzer
Extra semicolon is unnecessary. Note
| end; | ||
| end; | ||
|
|
||
| if isempty(chan), |
Check notice
Code scanning / Code Analyzer
Extra comma is unnecessary. Note
|
|
||
| if isempty(chan), | ||
| % if we couldn't parse the name, try to use the chip_channel if available | ||
| if ~isempty(chip_channel), |
Check notice
Code scanning / Code Analyzer
Extra comma is unnecessary. Note
- Updated `ndr.reader.intan_rhd.intanname2mfdaqname` to accept a channel structure in addition to a string. - Modified `getchannelsepoch` to pass the entire channel structure to `intanname2mfdaqname`. - Added logic to `intanname2mfdaqname` to handle names without hyphens (e.g., 'AUX1'). - Added fallback logic to use `chip_channel` + 1 if the channel name cannot be parsed. - Updated `ndr.reader.intan_rhd.mfdaqchanneltype2intanfreqheader` to include `auxiliary_in` for sample rate lookup. - Added comprehensive unit tests in `tools/tests/+ndr/+unittest/+reader/TestIntanRhd.m` covering standard names, 'AUX' names, struct/fallback scenarios, and auxiliary sample rate lookup.
Fixes an issue where Intan RHD auxiliary channels were named just 'ax' instead of 'ax1', 'ax2', etc. This was because the parser expected a hyphen in the native channel name (e.g. 'A-000') which 'AUX1' does not have. The fix adds robust parsing for non-hyphenated names and ensures correct 1-based indexing for AUX channels.
PR created automatically by Jules for task 182949754954685460 started by @stevevanhooser