Skip to content

Better BIDS TSV reader typing (PR 3)#1426

Open
MaximeBICMTL wants to merge 3 commits into
aces:mainfrom
MaximeBICMTL:better-bids-tsv-typing
Open

Better BIDS TSV reader typing (PR 3)#1426
MaximeBICMTL wants to merge 3 commits into
aces:mainfrom
MaximeBICMTL:better-bids-tsv-typing

Conversation

@MaximeBICMTL
Copy link
Copy Markdown
Contributor

@MaximeBICMTL MaximeBICMTL commented May 18, 2026

Builds on #1425 (diff)

Description

Improve the LORIS BIDS reader TSV row typing by typing row data as dict[str, str | None] instead of dict[str, Any]. This loose typing was inherited from the old code, which read and modified the row data directly, which notably caused some bugs such as code using isisntance(row.data['field'], int | float) which is always False since raw tsv data is always a string (or None). The new approach stores the data LORIS is interested in in dedicated fields while the raw data remains unchanged.

Potential follow-ups

  1. Replace all tsv n/a values by None on parsing (I think we should do that, it makes the code easier and more intuitive with no real information loss IMO).
  2. Accept empty tsv rows (technically incorrect, but might appear in real data and does not hurt IMO, the code currently errors on trailing newlines).

@github-actions github-actions Bot added Language: Python Issue or PR related to the Python codebase Package: BIDS reader PR or issue related to the BIDS reader labels May 18, 2026
@MaximeBICMTL MaximeBICMTL force-pushed the better-bids-tsv-typing branch from 03c6979 to 3a6812f Compare May 18, 2026 10:36
@MaximeBICMTL MaximeBICMTL added Category: Refactor Issue or PR that aims to improve the existing code Complexity: Simple Issue or PR that should be simple to implement, review, or test labels May 18, 2026
@MaximeBICMTL MaximeBICMTL force-pushed the better-bids-tsv-typing branch from 3a6812f to 5c38406 Compare May 20, 2026 02:44
@MaximeBICMTL MaximeBICMTL force-pushed the better-bids-tsv-typing branch from 5c38406 to 32c9d8f Compare May 20, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: Refactor Issue or PR that aims to improve the existing code Complexity: Simple Issue or PR that should be simple to implement, review, or test Language: Python Issue or PR related to the Python codebase Package: BIDS reader PR or issue related to the BIDS reader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant