Skip to content

[ENH] Starting conforming to new BIDS#152

Merged
arokem merged 12 commits into
tractometry:mainfrom
36000:BIDS_changes
Jan 28, 2026
Merged

[ENH] Starting conforming to new BIDS#152
arokem merged 12 commits into
tractometry:mainfrom
36000:BIDS_changes

Conversation

@36000

@36000 36000 commented Jan 16, 2026

Copy link
Copy Markdown
Collaborator

Addresses #77

Some notes:

  1. I made a small change the SSST CSD filename relative to the BIDS spec in order to differentiate it from the MSMT CSD file. I think pyAFQ should be able to support generating both for a single subject still. They could be useful for comparison, or for different tissue properties.
  2. Removed GQI PMAP and AI tissue properties. These were useful for quickly generating a t1-like mask; but now we use T1s, and MSMT PMAP is better, and this was always a little awkward anyways.

Copilot AI review requested due to automatic review settings January 16, 2026 04:32

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

This pull request updates the AFQ codebase to conform to new BIDS (Brain Imaging Data Structure) standards. The changes focus on updating model naming conventions, adding S0 (baseline signal) outputs, and refactoring decorators to handle multiple outputs.

Changes:

  • Updated model naming in file suffixes (e.g., "dti" → "tensor", "dki" → "kurtosis", "fwdti" → "fwtensor", "msdki" → "mskurtosis")
  • Modified DTI, DKI, and MSDKI fitting functions to return both model parameters and S0 values
  • Refactored as_file, as_fit_deriv, and as_img decorators to support multiple outputs
  • Enhanced metadata with descriptions for all derived metrics

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
AFQ/tasks/decorators.py Refactored decorators to handle multiple output files and improved metadata handling
AFQ/tasks/data.py Updated model names, added S0 outputs, and added metadata descriptions for all metrics
AFQ/models/dti.py Added return_S0_hat parameter to DTI fitting function
AFQ/models/dki.py Added return_S0_hat parameter to DKI fitting function

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

Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/decorators.py Outdated
Comment thread AFQ/models/dti.py
@36000 36000 changed the title [ENH/WIP] Starting conforming to new BIDS [ENH] Starting conforming to new BIDS Jan 20, 2026

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

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

Comments suppressed due to low confidence (1)

AFQ/tasks/data.py:719

  • Merge conflict marker detected in the code. The function signature contains unresolved merge conflict markers (<<<<<<< HEAD, =======, >>>>>>>) that need to be resolved. The parameters 'citations', 'data', and 'brain_mask' need to be properly merged.
    data,
    brain_mask,
    citations,
    rumba_wm_response=None,
    rumba_gm_response=0.0008,
    rumba_csf_response=0.003,

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

Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/tissue.py
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/data.py
Comment thread AFQ/tasks/data.py Outdated

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 13 comments.


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

Comment thread AFQ/tasks/decorators.py
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/tissue.py Outdated
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/tissue.py
Comment thread AFQ/tasks/data.py
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/decorators.py
@36000
36000 requested a review from Copilot January 20, 2026 03:47
@36000 36000 added this to the pyAFQ 3.0 milestone Jan 20, 2026

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


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

Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/data.py Outdated
Comment thread AFQ/tasks/tissue.py Outdated
@36000

36000 commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator Author

@arokem this is ready for review

@arokem arokem left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we still need to some transformation on the DKI parameters, so that they are stored in a format that is equivalent to the lower diagonal format of the DTI model.

Also, maybe not on this PR, but there is already a rather advanced draft of what BIDS-compliant tractography results would look like: https://docs.google.com/document/d/1ubDQ2RhgjnfGqoeukzEkPV9YEHhfYMERrj7-3b0c2HI/edit?tab=t.0

Comment thread AFQ/models/QBallTP.py Outdated
@36000

36000 commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator Author

@arokem what do you have in mind? Dipy has this function:
https://github.com/dipy/dipy/blob/e2913894e770e7963f88499118ffeed2110b2929/dipy/reconst/dki.py#L3046

and should we do this in a separate PR or this PR? If it does not change filenames, maybe it can be postponed. But if its a quick fix, we can do it here.

@arokem
arokem requested a review from Copilot January 27, 2026 15:55

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Comments suppressed due to low confidence (1)

AFQ/tractography/tractography.py:191

  • odf_model == "GQ" and odf_model == "RUMBA" are handled as if model_params were full-basis SH coefficients (using order_from_ncoef + sh_to_sf). However, the GQ/RUMBA tasks now save ODFs sampled on default_sphere (i.e., already a PMF/SF over sphere vertices). With the current logic, order_from_ncoef(model_params.shape[3]) will fail for typical vertex counts and/or produce an incorrect PMF, breaking tractography. Handle GQ/RUMBA by passing model_params directly into dg.from_pmf(...) (and keep the SH->SF conversion only for AODF/full-basis SH inputs).
    elif (odf_model == "GQ") or (odf_model == "RUMBA") or ("AODF" in odf_model):
        sh_order = shm.order_from_ncoef(model_params.shape[3], full_basis=True)
        pmf = shm.sh_to_sf(model_params, sphere, sh_order_max=sh_order, full_basis=True)
        pmf[pmf < 0] = 0
        dg = dg.from_pmf(
            np.asarray(pmf, dtype=float), max_angle=max_angle, sphere=sphere
        )

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

Comment thread AFQ/tasks/tissue.py
Comment thread AFQ/tasks/data.py
Comment thread AFQ/tasks/data.py
Comment thread AFQ/tasks/data.py
Comment thread AFQ/tasks/tissue.py
Comment thread AFQ/tasks/data.py
@36000

36000 commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator Author

@arokem if this passes the test, I believe this is ready to merge

Comment thread AFQ/models/msmt.py
Q = R.T @ R

A = csr_matrix(A)
Q = csr_matrix(Q)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ha! This is probably a huge time save 😄

@arokem
arokem merged commit 0a78e2c into tractometry:main Jan 28, 2026
9 checks passed
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