Skip to content
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

Draft resampling workflow #16

Merged
merged 13 commits into from
May 15, 2024
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ classifiers = [
"Programming Language :: Python :: 3.12",
]
dependencies = [
"fmriprep",
"fmriprep @ git+https://github.com/nipreps/fmriprep.git@master",
"nipype >= 1.8.5",
"nireports",
"niworkflows",
"nireports @ git+https://github.com/nipreps/nireports.git@main",
"niworkflows @ git+https://github.com/nipreps/niworkflows.git@master",
"pybids >= 0.15.6",
"smriprep",
"sdcflows @ git+https://github.com/nipreps/sdcflows.git@master",
"smriprep @ git+https://github.com/nipreps/smriprep.git@master",
"typer",
]
dynamic = ["version"]
Expand Down
62 changes: 62 additions & 0 deletions src/fmripost_aroma/interfaces/resampler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""Interfaces for resampling."""

from nipype.interfaces.base import (
BaseInterfaceInputSpec,
File,
SimpleInterface,
TraitedSpec,
traits,
)


class _ResamplerInputSpec(BaseInterfaceInputSpec):
bold_file = File(exists=True, desc='BOLD file to resample.')
derivs_path = traits.Directory(
exists=True,
desc='Path to derivatives.',
)
output_dir = traits.Directory(
exists=True,
desc='Output directory.',
)
space = traits.Str(
'MNI152NLin6Asym',
usedefault=True,
desc='Output space.',
)
resolution = traits.Str(
'2',
usedefault=True,
desc='Output resolution.',
)


class _ResamplerOutputSpec(TraitedSpec):
output_file = File(exists=True, desc='Resampled BOLD file.')


class Resampler(SimpleInterface):
"""Extract timeseries and compute connectivity matrices.

Write out time series using Nilearn's NiftiLabelMasker
Then write out functional correlation matrix of
timeseries using numpy.
"""

input_spec = _ResamplerInputSpec
output_spec = _ResamplerOutputSpec

def _run_interface(self, runtime):
from fmripost_aroma.utils import resampler

output_file = resampler.main(
bold_file=self.inputs.bold_file,
derivs_path=self.inputs.derivs_path,
output_dir=self.inputs.output_dir,
space=self.inputs.space,
resolution=self.inputs.resolution,
)

self._results['output_file'] = output_file

return runtime
Loading
Loading