-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support MCRIBS derivatives #1029
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1029 +/- ##
==========================================
- Coverage 82.51% 82.45% -0.07%
==========================================
Files 48 48
Lines 5846 5871 +25
Branches 786 787 +1
==========================================
+ Hits 4824 4841 +17
- Misses 826 832 +6
- Partials 196 198 +2 ☔ View full report in Codecov by Sentry. |
@madisoth I think this should work. Would you be willing to try it out on some Nibabies+MCRIBS data? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got an error in CollectingRegistrationFiles ingressing NiBabies 24.0.0a1 MCRIBS derivatives; changing it to this fixed it for me:
class CollectRegistrationFiles(SimpleInterface):
"""Collect registration files for fsnative-to-fsLR transformation."""
input_spec = _CollectRegistrationFilesInputSpec
output_spec = _CollectRegistrationFilesOutputSpec
def _run_interface(self, runtime):
import os
from pkg_resources import resource_filename as pkgrf
from templateflow.api import get as get_template
hemisphere = self.inputs.hemisphere
hstr = f"{hemisphere.lower()}h"
participant_id = self.inputs.participant_id
if not participant_id.startswith("sub-"):
participant_id = f"sub-{participant_id}"
# Find the subject's sphere in the segmentation derivatives.
# TODO: Collect from the preprocessing derivatives if they're a compliant version.
# Namely, fMRIPrep >= 23.1.2, Nibabies >= 24.0.0a1.
self._results["subject_sphere"] = os.path.join(
self.inputs.segmentation_dir,
participant_id,
"surf",
f"{hstr}.sphere.reg",
)
# NOTE: Why do we need the fsaverage mesh?
# TODO: Replace with appropriate files.
if self.inputs.software == "FreeSurfer":
# Find the subject's sphere in the FreeSurfer derivatives.
# TODO: Collect from the preprocessing derivatives if they're a compliant version.
# Namely, fMRIPrep >= 23.1.2, Nibabies >= 24.0.0a1.
self._results["subject_sphere"] = os.path.join(
self.inputs.segmentation_dir,
participant_id,
"surf",
f"{hstr}.sphere.reg",
)
# Load the fsaverage-164k sphere
# FreeSurfer: tpl-fsaverage_hemi-?_den-164k_sphere.surf.gii
self._results["source_sphere"] = str(
get_template(
template="fsaverage",
space=None,
hemi=hemisphere,
density="164k",
desc=None,
suffix="sphere",
)
)
# NOTE: Can we upload these to templateflow?
# FreeSurfer: fs_?/fs_?-to-fs_LR_fsaverage.?_LR.spherical_std.164k_fs_?.surf.gii
self._results["sphere_to_sphere"] = pkgrf(
"xcp_d",
(
f"data/standard_mesh_atlases/fs_{hemisphere}/"
f"fs_{hemisphere}-to-fs_LR_fsaverage.{hemisphere}_LR.spherical_std."
f"164k_fs_{hemisphere}.surf.gii"
),
)
# FreeSurfer: tpl-fsLR_hemi-?_den-32k_sphere.surf.gii
self._results["target_sphere"] = str(
get_template(
template="fsLR",
space=None,
hemi=hemisphere,
density="32k",
desc=None,
suffix="sphere",
)
)
elif self.inputs.software == "MCRIBS":
# Find the subject's sphere in the MCRIBS derivatives.
# TODO: Collect from the preprocessing derivatives if they're a compliant version.
# Namely, fMRIPrep >= 23.1.2, Nibabies >= 24.0.0a1.
self._results["subject_sphere"] = os.path.join(
self.inputs.segmentation_dir,
participant_id,
"freesurfer",
participant_id,
"surf",
f"{hstr}.sphere.reg2",
)
# MCRIBS: tpl-fsaverage_hemi-?_den-41k_desc-reg_sphere.surf.gii
self._results["source_sphere"] = os.path.join(
self.inputs.segmentation_dir,
"templates_fsLR",
f"tpl-fsaverage_hemi-{hemisphere}_den-41k_desc-reg_sphere.surf.gii",
)
# MCRIBS: tpl-dHCP_space-fsaverage_hemi-?_den-41k_desc-reg_sphere.surf.gii
self._results["sphere_to_sphere"] = os.path.join(
self.inputs.segmentation_dir,
"templates_fsLR",
f"tpl-dHCP_space-fsaverage_hemi-{hemisphere}_den-41k_desc-reg_sphere.surf.gii",
)
# MCRIBS: tpl-dHCP_space-fsLR_hemi-?_den-32k_desc-week42_sphere.surf.gii
self._results["target_sphere"] = os.path.join(
self.inputs.segmentation_dir,
"templates_fsLR",
f"tpl-dHCP_space-fsLR_hemi-{hemisphere}_den-32k_desc-week42_sphere.surf.gii",
)
return runtime
Closes #840 and relates to #976.
Changes proposed in this pull request
xcp_d.interfaces.bids.CollectRegistrationFiles
, to collect FreeSurfer or MCRIBs sphere and transform files for anatomical workflow.xcp_d.utils.bids.get_freesurfer_sphere
, as the functionality is now inCollectRegistrationFiles
.xcp_d.utils.bids.get_freesurfer_dir
to support MCRIBS on top of FreeSurfer.