Skip to content

Conversation

@shnizzedy
Copy link
Member

@shnizzedy shnizzedy commented Oct 14, 2025

Related to

Related to #1036 by @sgiavasis
Related to #1038 by @sgiavasis
Related to #2129 by @shnizzedy
Related to #2225 by @shnizzedy
Related to #2227 by @shnizzedy
Related to #2273 by @birajstha

Description

The handling of scan parameters has been inconsistent, using bytestrings in some places and strings in others. This PR keeps the step where strings are encoded into ASCII bytestrings, but adds a step where they're decoded back to UTF-8 ASCII before they're stored so they're strings everywhere they're used.

Tests

@pytest.mark.parametrize("participant_labels", [["NDARAB348EWR"]])
def test_scan_parameter_type(tmp_path: Path, participant_labels: list[str]) -> None:
"""Test that scan parameter types are correctly interpreted."""
bids_dir = _gather_scan_parameter_test_data(tmp_path, participant_labels)
data_config = create_cpac_data_config(bids_dir, participant_labels)
assert len(data_config) == 1
if "fmap" in data_config[0]:
assert (
data_config[0]["fmap"]["epi_PA"]["scan_parameters"][
"PhaseEncodingDirection"
]
in PHASE_ENCODING_DIRECTIONS
)

will fail if the scan parameters are bytestrings but will pass if they're strings.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I updated the changelog.
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 77.55102% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.0%. Comparing base (9c652b1) to head (1e323dd).
⚠️ Report is 7 commits behind head on develop.

Files with missing lines Patch % Lines
CPAC/utils/bids_utils.py 33.3% 6 Missing ⚠️
CPAC/utils/tests/test_bids_utils.py 88.9% 3 Missing and 1 partial ⚠️
CPAC/utils/interfaces/datasink.py 0.0% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           develop   #2291     +/-   ##
=========================================
+ Coverage     35.0%   35.0%   +0.1%     
=========================================
  Files          234     234             
  Lines        26661   26704     +43     
  Branches      4190    4195      +5     
=========================================
+ Hits          9321    9350     +29     
- Misses       16595   16611     +16     
+ Partials       745     743      -2     
Files with missing lines Coverage Δ
CPAC/utils/datasource.py 33.2% <100.0%> (+0.2%) ⬆️
CPAC/utils/datatypes.py 100.0% <100.0%> (ø)
CPAC/utils/interfaces/datasink.py 10.6% <0.0%> (-<0.1%) ⬇️
CPAC/utils/tests/test_bids_utils.py 74.5% <88.9%> (+7.4%) ⬆️
CPAC/utils/bids_utils.py 55.6% <33.3%> (+1.4%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shnizzedy shnizzedy self-assigned this Oct 14, 2025
@shnizzedy shnizzedy added the develop issue on `develop` branch label Oct 14, 2025
@shnizzedy shnizzedy moved this to 👀 In review in C-PAC Development Oct 14, 2025
@shnizzedy shnizzedy added this to the 1.8.8 release milestone Oct 14, 2025
Copy link
Contributor

@nx10 nx10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@shnizzedy shnizzedy merged commit f8c71b3 into develop Oct 31, 2025
30 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in C-PAC Development Oct 31, 2025
@shnizzedy shnizzedy deleted the fix/bytes-and-strings branch October 31, 2025 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

develop issue on `develop` branch

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants