ENH: Add SpatialReference field to some outputs - #513
Conversation
|
For TemplateFlow volumetric spaces, the SpatialReference field will just have a URL (e.g., |
|
Does it make more sense to copy the BIDSURI functionality from fMRIPrep? I think threading a |
|
That makes sense. I can add that. |
|
I think it looks good now. Here's the value from ds054: {
"SpatialReference": "bids:templateflow:tpl-MNI152Lin/tpl-MNI152Lin_res-02_T1w.nii.gz"
} |
effigies
left a comment
There was a problem hiding this comment.
A few thoughts. I'm not sure that they're enough to finish this off on, but LMK what you think, and we can talk this over next week maybe?
| spatial_reference = pe.Node( | ||
| TemplateFlowReference(), | ||
| name='spatial_reference', | ||
| ) |
There was a problem hiding this comment.
I'm worried this is going to interfere with passing dataset_links from fmriprep, since that maps TF_LAYOUT.root onto bids:templateflow: and accepts raw paths.
There was a problem hiding this comment.
I think we should update fMRIPrep to point to the website when it's a built-in template, but I could pass the dataset_links into this node to use a local path if templateflow is a key in the dictionary and doesn't start with http.
There was a problem hiding this comment.
One reason I was leaning toward the website is that the CIFTI SpatialReference dictionary uses the website. If we do commit to using the local templateflow location then we should change that as well.
| if template_name in tf.TF_LAYOUT.get_templates(): | ||
| self._results['uri'] = f'{tf_url}/{str(rel_path)}' |
There was a problem hiding this comment.
Presumably this is going to return custom templates found in TF_LAYOUT, so I'm not sure that the else branch will ever get hit.
There was a problem hiding this comment.
Oh... I had hoped that get_templates would only return built-in templates, but that makes sense. Is there any way to distinguish built-in templates from custom ones?
There was a problem hiding this comment.
Hmm. I suppose we could inspect the skeleton in the templateflow client.
import zipfile
import templateflow
templates = [
tpl.name.removeprefix('tpl-')
for tpl in zipfile.Path(templateflow.conf.load_data('templateflow-skel.zip')).iterdir()
]That's very much unsupported API, but it's doable.
There was a problem hiding this comment.
Maybe it's easier to just reference TF_LAYOUT.root consistently until there's a more standard way to distinguish built-in and custom templates with the templateflow library. I would just need to change the SpatialReference in CIFTIs from URLs to BIDS-URIs.
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
|
@tsalo would nipreps/niworkflows#1024 help unlock this one? |
|
Having the BIDSURI interface in niworkflows will reduce the amount of code added in this PR, so I'm happy to wait until that is addressed before pushing forward with this, but the main hurdle currently is making sure SpatialReference for TemplateFlow templates is consistent across files (i.e., that it is either a pointer to the local TemplateFlow folder or to the right location online). |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #513 +/- ##
==========================================
+ Coverage 70.12% 75.00% +4.87%
==========================================
Files 23 24 +1
Lines 2065 2128 +63
Branches 273 290 +17
==========================================
+ Hits 1448 1596 +148
+ Misses 558 461 -97
- Partials 59 71 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I think I've addressed the main blocker by sticking to the local TemplateFlow path, but will pause this PR until nipreps/niworkflows#1031 is merged. |
Related to nipreps/fmriprep#3579.
This should add SpatialReference to volumetric, standard-space anatomical outputs.