[ENH/FIX] Changes for reward bundles and VOF#166
[ENH/FIX] Changes for reward bundles and VOF#16636000 wants to merge 117 commits intotractometry:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR appears to add support for “reward bundles” by introducing new template assets and enabling more flexible ROI handling (including mixed-space ROI definitions and ROI dilation behavior used in recognition/tracking workflows).
Changes:
- Add MassP template fetching/loading utilities and update bibliography references.
- Extend BundleDict ROI handling to support mixed-space ROI specifications and update ROI transformation call sites to pass images (not affines).
- Enhance
RoiImagegeneration with optional ROI dilation and WM-only masking.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/source/references.bib | Adds two new literature references. |
| AFQ/tasks/utils.py | Adjusts base filename generation to avoid unconditional trailing-char stripping. |
| AFQ/tasks/mapping.py | Updates transform_rois call to pass the DWI image (aligning with new API). |
| AFQ/tasks/decorators.py | Removes forced logger level configuration. |
| AFQ/recognition/utils.py | Introduces shared tolerance_mm_to_vox utility. |
| AFQ/recognition/preprocess.py | Refactors to delegate tolerance conversion to AFQ.recognition.utils. |
| AFQ/recognition/criteria.py | Updates ROI transformation call to pass the image instead of the affine. |
| AFQ/nn/synthseg.py | Updates label groupings used to derive PVE outputs. |
| AFQ/definitions/image.py | Adds ROI dilation + WM-only masking options for ROI-derived images. |
| AFQ/data/fetch.py | Adds MassP template fetcher/reader utilities. |
| AFQ/api/group.py | Removes logger level forcing; docstring example was modified. |
| AFQ/api/bundle_dict.py | Adds mixed-space ROI support and updates transformation helper signature to use an image object. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated 11 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@arokem This is ready for review / merge. It is a grab bag of a bunch of minor features for pyAFQ that will be useful for VOF and reward stuff. I figured it was in a spot where we could try to merge and then start a new PR, just so the PR doesn't get too big, but some of the code (like the ORG stuff) is currently unused but will be used later. A description of the main things added in this PR is available in the first comment. Also, copilot is super useful! Caught a few bugs. |
|
Actually - go ahead and review this when you get the chance but don't merge it yet, I found a bug in streamline transformation. |
|
OK - heads up that I have travel and deadlines in the next couple of weeks, so probably will not get to this before end of February. |
|
OK - I will just keep adding changes to this PR then, no need to merge it soon. |
|
@arokem This is ready for review once you get the chance |
|
|
||
| class SpectralSubbundleDict(BundleDict): | ||
| """ | ||
| A BundleDict where each bundle is defined as a spectral subbundle of a |
There was a problem hiding this comment.
Clarification question: what makes it "spectral"?
There was a problem hiding this comment.
It could also be named ORGSubbundleDict, here we use spectral embedding of the distance matrix of each streamline to some reference streamlines, then compare that embedding to the embedding of known clusters to cluster the streamline. It's all based on the ORG 800 atlas.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 58 out of 58 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
arokem
left a comment
There was a problem hiding this comment.
Some comments from an initial read through
|
|
||
| if is_trx: | ||
| seg_sft.sft.dtype_dict = {"positions": np.float16, "offsets": np.uint32} | ||
| seg_sft.sft.dtype_dict = {"positions": np.float32, "offsets": np.uint32} |
There was a problem hiding this comment.
This will result in a large increase in file size. Why is it necessary?
There was a problem hiding this comment.
Many of the DIPY functions currently require np.float32 or np.float64, and converting this to np.float16 then back for DIPY adds a lot of time. We can change it back if we change some of the Cython in DIPY, or we can write scripts to transfer tractograms to np.float16 for long term storage.
There was a problem hiding this comment.
But it works on the current main branch without these conversions, no? Is there something new here that breaks that? I think we'd want to change this on DIPY as needed, so that we can save all that memory and storage down the line.
| seed_threshold=0.5, | ||
| thresholds_as_percentages=False, | ||
| n_seeds=2000000, | ||
| n_seeds=1e7, |
There was a problem hiding this comment.
This is a pretty big jump. I assume this makes a big difference in some of the new tracts?
There was a problem hiding this comment.
I chose 10 million because it fits well in 32GB of RAM for HBN style subjects and improves all of the tracts. I guess 5 million or 2 million would also work, but I think 10 million is reasonable.
|
|
||
|
|
||
| def gwi_odf(gqmodel, data): | ||
| def get_simplified_transform(self): |
There was a problem hiding this comment.
I wonder if we would rather conform with conventions described here: https://github.com/nipy/nitransforms
There was a problem hiding this comment.
Maybe we can do this in another PR? I like this simplified transform here for now, its really easy to not have to worry about affines or pre-aligns at all when applying a transform.
For large tractographies these changes make pyAFQ much much faster in my testing. Thus, I changed default number of seeds to 10 million! On my laptop with 32GB of RAM this is still fast, even with other applications running. The testing should be much faster too.
Also, this changes the mapping output files, so we should merge it before 3.0!