Skip to content

Commit

Permalink
Draft resampling workflow (#16)
Browse files Browse the repository at this point in the history
* Work on incorporating resampler.

* Something like this?

* Keep working.

* Update base.py

* Drop task_id from collect_derivatives.

* Run ruff.

* Address ruff's concerns.

* Update resampler.py

* Work on resampling workflow.
  • Loading branch information
tsalo authored May 15, 2024
1 parent 1011ebb commit 31ff12e
Show file tree
Hide file tree
Showing 5 changed files with 957 additions and 22 deletions.
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

0 comments on commit 31ff12e

Please sign in to comment.