Skip to content

build: replace system c3d dependency with picsl-c3d#93

Merged
tomboulier merged 2 commits into
devfrom
codex/picsl-c3d-staple
Mar 24, 2026
Merged

build: replace system c3d dependency with picsl-c3d#93
tomboulier merged 2 commits into
devfrom
codex/picsl-c3d-staple

Conversation

@tomboulier
Copy link
Copy Markdown
Owner

@tomboulier tomboulier commented Mar 24, 2026

Summary

  • replace the system c3d subprocess dependency with picsl-c3d
  • remove the non-reproducible wget/sudo install path from the makefile
  • pin picsl-c3d==1.4.6.0 and refresh the lockfile

Verification

  • uv sync --group dev
  • ./.venv/bin/pytest -q
  • result: 75 passed

Summary by CodeRabbit

  • Chores
    • Simplified installation by removing an external CLI dependency from the build/install flow.
    • Added a new integrated library dependency to handle internal processing previously delegated to that external tool.
  • Bug Fixes
    • Ensure generated output files end with a trailing newline for consistency.

Copilot AI review requested due to automatic review settings March 24, 2026 21:17
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6016e708-18d0-420b-9733-711da2523de9

📥 Commits

Reviewing files that changed from the base of the PR and between d3a5356 and 460337c.

📒 Files selected for processing (1)
  • oxytcmri/interface/mri/staple_segmenter.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • oxytcmri/interface/mri/staple_segmenter.py

Walkthrough

Replaces external c3d CLI usage with the Python picsl-c3d library, updates Makefile to remove the c3d target and its fallback install logic, and adds picsl-c3d==1.4.6.0 to project dependencies. Staple segmenter now calls the library API and adapts error handling.

Changes

Cohort / File(s) Summary
Build System
makefile
Removed the c3d target and its system-install fallback; removed c3d from install and install-dev dependencies; switched dev install invocation from uv pip install --group dev to uv sync --group dev; added trailing newline in compute-dti-normative-values output file.
Library Migration
oxytcmri/interface/mri/staple_segmenter.py
Replaced subprocess-based c3d CLI invocation with picsl_c3d.Convert3D().execute() using io.StringIO to capture output; removed subprocess import, added picsl_c3d and io imports; updated logged messages and error handling to raise RuntimeError with picsl-c3d-prefixed messages.
Project Dependencies
pyproject.toml
Added runtime dependency picsl-c3d==1.4.6.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'build: replace system c3d dependency with picsl-c3d' accurately and specifically describes the main objective of the pull request, which is to replace the system c3d subprocess dependency with the picsl-c3d Python package.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/picsl-c3d-staple

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes the build and runtime environment more reproducible by removing reliance on a system-installed c3d binary and switching the STAPLE merge implementation to use the Python package picsl-c3d instead.

Changes:

  • Add picsl-c3d==1.4.6.0 as a pinned runtime dependency.
  • Replace subprocess execution of c3d with picsl_c3d.Convert3D().execute() in the STAPLE segmentation merger.
  • Remove the Makefile’s non-reproducible wget/sudo installation path for c3d and simplify install / install-dev.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
pyproject.toml Pins and adds picsl-c3d as a project dependency to eliminate system c3d requirements.
oxytcmri/interface/mri/staple_segmenter.py Switches STAPLE merging execution from subprocess to picsl-c3d’s Python API.
makefile Removes the system-level c3d install target and updates install workflows to use uv sync.

Comment on lines +278 to +283
logger.info(f"Running c3d command: {cmd}")
picsl_c3d.Convert3D().execute(cmd, out=stdout, err=stderr)
logger.info(f"c3d command completed successfully, output saved to {output_path}")
except subprocess.CalledProcessError as e:
raise RuntimeError(f"c3d command failed: {e.stderr}")
except RuntimeError as e:
error_details = stderr.getvalue().strip() or stdout.getvalue().strip() or str(e)
raise RuntimeError(f"c3d command failed: {error_details}") from e
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The log and raised error text still refer to a “c3d command”, but this code now executes via picsl_c3d.Convert3D(). Updating these messages to mention picsl-c3d/Convert3D would avoid confusion when debugging failures.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

@tomboulier I've opened a new pull request, #94, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* fix: update log and error messages to reference picsl-c3d Convert3D

Co-authored-by: tomboulier <14161960+tomboulier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/tomboulier/oxytcmri-dti-processing/sessions/3a05aa71-12b5-4555-8c93-5eaf8e8575e9

* fix: update remaining c3d STAPLE log message to picsl-c3d Convert3D

Co-authored-by: tomboulier <14161960+tomboulier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/tomboulier/oxytcmri-dti-processing/sessions/3a05aa71-12b5-4555-8c93-5eaf8e8575e9

* Update oxytcmri/interface/mri/staple_segmenter.py

* fix: simplify redundant picsl-c3d Convert3D wording

Co-authored-by: tomboulier <14161960+tomboulier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/tomboulier/oxytcmri-dti-processing/sessions/f4f6fb26-bca3-4f32-afc2-b01ebec4c101

* Update oxytcmri/interface/mri/staple_segmenter.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update oxytcmri/interface/mri/staple_segmenter.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tomboulier <14161960+tomboulier@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

@tomboulier tomboulier merged commit fc7fab4 into dev Mar 24, 2026
4 checks passed
@tomboulier tomboulier deleted the codex/picsl-c3d-staple branch March 24, 2026 22:22
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.

3 participants