Skip to content

Fix Intan RHD auxiliary channel name parsing#90

Merged
stevevanhooser merged 8 commits intomainfrom
fix-intan-aux-names-182949754954685460
Dec 12, 2025
Merged

Fix Intan RHD auxiliary channel name parsing#90
stevevanhooser merged 8 commits intomainfrom
fix-intan-aux-names-182949754954685460

Conversation

@google-labs-jules
Copy link
Contributor

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

- 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.
@google-labs-jules
Copy link
Contributor Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


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

Extra comma is unnecessary.
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 you are operating on scalar values, consider using 'str2double' for faster performance.
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

Extra comma is unnecessary.
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

Extra comma is unnecessary.
% 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

If you are operating on scalar values, consider using 'str2double' for faster performance.
end;
else,
chan = [];
end;

Check notice

Code scanning / Code Analyzer

Extra semicolon is unnecessary. Note

Extra semicolon is unnecessary.
else,
chan = [];
end;
end;

Check notice

Code scanning / Code Analyzer

Extra semicolon is unnecessary. Note

Extra semicolon is unnecessary.
end;
end;

if isempty(chan),

Check notice

Code scanning / Code Analyzer

Extra comma is unnecessary. Note

Extra comma is unnecessary.

if isempty(chan),
channame = [ndr.reader.base.mfdaq_prefix(type)]; % fallback
else,

Check notice

Code scanning / Code Analyzer

Extra comma is unnecessary. Note

Extra comma is unnecessary.
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

Extra semicolon is unnecessary.
@github-actions
Copy link
Contributor

github-actions bot commented Dec 12, 2025

Test Results

44 tests   44 ✅  2s ⏱️
 9 suites   0 💤
 1 files     0 ❌

Results for commit e1b50f3.

♻️ This comment has been updated with latest results.

github-actions bot and others added 2 commits December 12, 2025 21:43
- 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

Input argument might be unused. Consider replacing the argument with ~ instead.
% 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

Extra comma is unnecessary.

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

Extra comma is unnecessary.
else
chip_channel = [];
end
else,

Check notice

Code scanning / Code Analyzer

Extra comma is unnecessary. Note

Extra comma is unnecessary.
else,
name = name_or_struct;
chip_channel = [];
end;

Check notice

Code scanning / Code Analyzer

Extra semicolon is unnecessary. Note

Extra semicolon is unnecessary.
else,
chan = chan_intan + 1; % assume 0-based
end;
else,

Check notice

Code scanning / Code Analyzer

Extra comma is unnecessary. Note

Extra comma is unnecessary.
end;
else,
chan = [];
end;

Check notice

Code scanning / Code Analyzer

Extra semicolon is unnecessary. Note

Extra semicolon is unnecessary.
else,
chan = [];
end;
end;

Check notice

Code scanning / Code Analyzer

Extra semicolon is unnecessary. Note

Extra semicolon is unnecessary.
end;
end;

if isempty(chan),

Check notice

Code scanning / Code Analyzer

Extra comma is unnecessary. Note

Extra comma is unnecessary.

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

Extra comma is unnecessary.
github-actions bot and others added 2 commits December 12, 2025 22:06
- 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.
case {'time','timestamp'},
headername = 'amplifier_sample_rate';
case{'auxiliary','aux'},
case{'auxiliary','aux','auxiliary_in'},

Check notice

Code scanning / Code Analyzer

Extra comma is unnecessary. Note

Extra comma is unnecessary.
@stevevanhooser stevevanhooser marked this pull request as ready for review December 12, 2025 22:17
@stevevanhooser stevevanhooser merged commit f0594f1 into main Dec 12, 2025
1 check failed
@stevevanhooser stevevanhooser deleted the fix-intan-aux-names-182949754954685460 branch December 12, 2025 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant