Skip to content

Adapt DTI representation to tighter BEP16 compliance.#78

Merged
arokem merged 6 commits intotractometry:mainfrom
arokem:dti_as_lower_triangular
Aug 19, 2025
Merged

Adapt DTI representation to tighter BEP16 compliance.#78
arokem merged 6 commits intotractometry:mainfrom
arokem:dti_as_lower_triangular

Conversation

@arokem
Copy link
Member

@arokem arokem commented Apr 9, 2025

Addresses #77

@arokem arokem force-pushed the dti_as_lower_triangular branch from 99e518a to 5960eb9 Compare April 15, 2025 21:39
@arokem arokem force-pushed the dti_as_lower_triangular branch from 5960eb9 to c14a57c Compare August 18, 2025 21:37
Copilot AI review requested due to automatic review settings August 18, 2025 21:37
Copy link
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 adapts the DTI (Diffusion Tensor Imaging) representation to achieve tighter compliance with BEP16 (BIDS Extension Proposal 16). The changes modify how DTI tensor data is stored and processed, moving from the previous format to using the lower triangular tensor representation as specified in BEP16.

  • Updates DTI parameter storage to use lower_triangular() format instead of model_params
  • Modifies tensor decomposition to use from_lower_triangular() when processing DTI data
  • Enhances metadata to include BEP16-compliant fields for tensor orientation encoding

Reviewed Changes

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

File Description
AFQ/tractography/tractography.py Updates tensor decomposition to use BEP16-compliant lower triangular format
AFQ/tasks/data.py Modifies DTI parameter storage and metadata to align with BEP16 specification

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

evals = model_params[..., :3]
evecs = model_params[..., 3:12].reshape(params_img.shape[:3] + (3, 3))
evals, evecs = decompose_tensor(
from_lower_triangular(model_params[:6]))
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

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

The slicing model_params[:6] appears incorrect. The from_lower_triangular function expects 6 values for a 3x3 symmetric tensor, but this slicing only takes the first 6 elements along the last dimension for all voxels. It should likely be model_params[..., :6] to get the first 6 tensor components for each voxel.

Suggested change
from_lower_triangular(model_params[:6]))
from_lower_triangular(model_params[..., :6]))

Copilot uses AI. Check for mistakes.
tm = dpy_dti.TensorModel(gtab)
return dpy_dti.TensorFit(tm, dti_params)
evals, evecs = dpy_dti.decompose_tensor(
dpy_dti.from_lower_triangular(dti_params))
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

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

The from_lower_triangular function is being called on the entire dti_params array, but it should likely be called on the tensor components only. Based on the context, it should be dpy_dti.from_lower_triangular(dti_params[..., :6]) to extract only the 6 lower triangular tensor components.

Suggested change
dpy_dti.from_lower_triangular(dti_params))
dpy_dti.from_lower_triangular(dti_params[..., :6]))

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

I think that this is an incorrect analysis. The parameters are being saved as the lower triangular (on L189 in the change introduced in this same PR), so I don't think this indexing should be needed.

Units="mm^2/s",
Model=dict(
Parameters=dict(
FitMethod="wls",
Copy link

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

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

The FitMethod value has been changed from "WLS" to "wls". This inconsistency in casing could affect consumers expecting a specific format. Consider maintaining consistent casing with the original "WLS" or document this change if it's intentional for BEP16 compliance.

Suggested change
FitMethod="wls",
FitMethod="WLS",

Copilot uses AI. Check for mistakes.
This indexing should not be needed.
@arokem arokem changed the title WIP: Starting to adapt DTI representation to tighter BEP16 compliance. Starting to adapt DTI representation to tighter BEP16 compliance. Aug 18, 2025
@arokem arokem changed the title Starting to adapt DTI representation to tighter BEP16 compliance. Adapt DTI representation to tighter BEP16 compliance. Aug 18, 2025
@arokem
Copy link
Member Author

arokem commented Aug 18, 2025

This is ready for review. @36000 : do you have bandwidth to take a look?

@36000
Copy link
Collaborator

36000 commented Aug 19, 2025

Yes, this looks straightforward. if the docs pass, merge!

@arokem
Copy link
Member Author

arokem commented Aug 19, 2025

OK - once this is merged, our next release should be a 3.0, to also include #103, because this introduces a breaking change, that would be incompatible with previous versions of pyAFQ.

@arokem arokem merged commit e97b5a4 into tractometry:main Aug 19, 2025
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.

2 participants

Comments