Skip to content

📝 Add docstrings to revise_NPR_to_CPCA#425

Closed
coderabbitai[bot] wants to merge 1 commit into
revise_NPR_to_CPCAfrom
coderabbitai/docstrings/XmdWF0J01siButwiMe8CXzfb
Closed

📝 Add docstrings to revise_NPR_to_CPCA#425
coderabbitai[bot] wants to merge 1 commit into
revise_NPR_to_CPCAfrom
coderabbitai/docstrings/XmdWF0J01siButwiMe8CXzfb

Conversation

@coderabbitai

@coderabbitai coderabbitai Bot commented Jun 23, 2025

Copy link
Copy Markdown
Contributor

Docstrings generation was requested by @Gab-D-G.

The following files were modified:

  • rabies/analysis_pkg/analysis_functions.py
  • rabies/analysis_pkg/analysis_math.py
  • rabies/analysis_pkg/analysis_wf.py
  • rabies/analysis_pkg/cpca/modeling.py
  • rabies/analysis_pkg/cpca/report.py
  • rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py
  • rabies/analysis_pkg/diagnosis_pkg/diagnosis_wf.py
  • rabies/analysis_pkg/diagnosis_pkg/interfaces.py
  • rabies/analysis_pkg/main_wf.py
  • rabies/parser.py
  • scripts/generate_graph.py
ℹ️ Note

CodeRabbit cannot perform edits on its own pull requests yet.

Docstrings generation was requested by @Gab-D-G.

* #424 (comment)

The following files were modified:

* `rabies/analysis_pkg/analysis_functions.py`
* `rabies/analysis_pkg/analysis_math.py`
* `rabies/analysis_pkg/analysis_wf.py`
* `rabies/analysis_pkg/cpca/modeling.py`
* `rabies/analysis_pkg/cpca/report.py`
* `rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py`
* `rabies/analysis_pkg/diagnosis_pkg/diagnosis_wf.py`
* `rabies/analysis_pkg/diagnosis_pkg/interfaces.py`
* `rabies/analysis_pkg/main_wf.py`
* `rabies/parser.py`
* `scripts/generate_graph.py`
@coderabbitai

coderabbitai Bot commented Jun 23, 2025

Copy link
Copy Markdown
Contributor Author

Important

Review skipped

CodeRabbit bot authored PR detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds/updates docstrings across the analysis + diagnosis + CPCA code paths to improve inline documentation, following the docstring-generation request in the CPCA migration work.

Changes:

  • Added docstrings to workflow initialization functions (analysis, main analysis, diagnosis).
  • Added docstrings to CPCA modeling/reporting utilities and analysis/diagnosis helper functions.
  • Expanded CLI parser function docstrings to better describe supported stages/options.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
rabies/analysis_pkg/analysis_functions.py Adds docstrings to CPCA interface methods.
rabies/analysis_pkg/analysis_math.py Adds a docstring to dual_regression.
rabies/analysis_pkg/analysis_wf.py Adds docstring to analysis workflow initializer.
rabies/analysis_pkg/cpca/modeling.py Adds docstrings to CPCA modeling entry points.
rabies/analysis_pkg/cpca/report.py Adds docstrings to CPCA reporting utilities (but introduces an indentation bug).
rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py Adds docstrings to diagnosis feature extraction/plotting helpers.
rabies/analysis_pkg/diagnosis_pkg/diagnosis_wf.py Adds docstrings to diagnosis workflow and nested helper.
rabies/analysis_pkg/diagnosis_pkg/interfaces.py Adds docstring to dataset-level diagnosis interface run method.
rabies/analysis_pkg/main_wf.py Adds docstrings to main analysis workflow and nested packager.
rabies/parser.py Expands docstrings for parser construction/reading and scan QC threshold parsing.
scripts/generate_graph.py Adds docstring to workflow execution helper in the graph-generation script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rabies/parser.py
Comment on lines 1164 to +1168
def parse_scan_QC_thresholds(opt):

# we must add "" around each key manually, as they are not encoded from the parser
"""
Parse and validate the scan quality control thresholds string for analysis.

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

This added docstring is not actually a docstring because there’s a comment statement before it in the function body. If you want tooling/introspection to pick it up, place the docstring as the first statement in parse_scan_QC_thresholds (move the comment below it).

Copilot uses AI. Check for mistakes.
Comment on lines 7 to +8
# estimate cosine similarity across the columns of X and Y combined
"""

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

This triple-quoted string won’t be registered as cosine_similarity’s docstring because it follows a comment statement. Move the docstring to be the first statement inside the function (and keep the existing one-line note as part of the docstring or below it).

Suggested change
# estimate cosine similarity across the columns of X and Y combined
"""
"""
Estimate cosine similarity across the columns of X and Y combined.

Copilot uses AI. Check for mistakes.
Returns:
fig_list (list): List of matplotlib Figure objects, one per prior component.
"""
fig_list = []

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

fig_list = [] is indented far deeper than the rest of the function body, which will raise an IndentationError (or change block structure) at import time. It should be aligned with the docstring and the subsequent for prior_idx in range(...) loop (same indentation level as other top-level statements in plot_report).

Suggested change
fig_list = []
fig_list = []

Copilot uses AI. Check for mistakes.
Comment thread scripts/generate_graph.py
Comment on lines 15 to +20
def execute_workflow(args=None):
# generates the parser CLI and execute the workflow based on specified parameters.
"""
Prepare and configure a RABIES workflow based on command-line arguments.

Parses CLI arguments, validates output directory paths, initializes logging, verifies template installation, checks for incompatible inclusion/exclusion parameters, and sets up the specified workflow stage (preprocess, confound correction, or analysis). Saves the modified CLI options as a pickle file and returns the prepared workflow object.

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

The triple-quoted string here won’t be treated as the function’s docstring because it’s preceded by a comment statement. If you want this to be an actual docstring (available via execute_workflow.doc and picked up by doc tools), move the docstring to be the first statement in the function body (put the existing comment below it).

Copilot uses AI. Check for mistakes.
Comment on lines 52 to +63
def dual_regression(all_IC_vectors, timeseries):
### compute dual regression
### Here, we adopt an approach where the algorithm should explain the data
### as a linear combination of spatial maps. The data itself, is only temporally
### detrended, and not spatially centered, which could cause inconsistencies during
### linear regression according to https://mandymejia.com/2018/03/29/the-role-of-centering-in-dual-regression/#:~:text=Dual%20regression%20requires%20centering%20across%20time%20and%20space&text=time%20points.,each%20time%20course%20at%20zero
### The fMRI timeseries aren't assumed theoretically to be spatially centered, and
### this measure would be removing global signal variations which we are interested in.
### Thus we prefer to avoid this step here, despite modelling limitations.
"""
Perform dual regression to decompose timeseries data into spatial weights and component timecourses using provided independent component vectors.

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

This string literal is not a real docstring because it appears after multiple comment statements inside the function body. To make it a proper docstring, it needs to be the first statement immediately under def dual_regression(...) (move the explanatory comments below the docstring, or incorporate them into the docstring).

Copilot uses AI. Check for mistakes.
@gdevenyi gdevenyi closed this May 25, 2026
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