Skip to content

Commit

Permalink
Run ruff.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed May 7, 2024
1 parent d3a3680 commit d267a86
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
18 changes: 9 additions & 9 deletions src/fmripost_aroma/interfaces/resampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@


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


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


class Resampler(SimpleInterface):
Expand All @@ -57,6 +57,6 @@ def _run_interface(self, runtime):
resolution=self.inputs.resolution,
)

self._results["output_file"] = output_file
self._results['output_file'] = output_file

return runtime
5 changes: 4 additions & 1 deletion src/fmripost_aroma/utils/resampler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""Resampler methods for fMRI data."""

from __future__ import annotations

import asyncio
import os
from functools import partial
Expand All @@ -19,7 +23,6 @@
from templateflow import api as tf
from typing_extensions import Annotated


R = TypeVar('R')

nipreps_cfg = niworkflows.data.load('nipreps.json')
Expand Down
16 changes: 8 additions & 8 deletions src/fmripost_aroma/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def init_single_subject_wf(subject_id: str):

for bold_file in subject_data['bold']:
ica_aroma_wf = init_ica_aroma_wf(bold_file=bold_file)
ica_aroma_wf.__desc__ = func_pre_desc + (ica_aroma_wf.__desc__ or "")
ica_aroma_wf.__desc__ = func_pre_desc + (ica_aroma_wf.__desc__ or '')

functional_cache = {}
if config.execution.derivatives:
Expand All @@ -344,8 +344,8 @@ def init_single_subject_wf(subject_id: str):
)
workflow.connect([
(resample_raw_wf, ica_aroma_wf, [
("outputnode.bold_std", "inputnode.bold_std"),
("outputnode.bold_mask_std", "inputnode.bold_mask_std"),
('outputnode.bold_std', 'inputnode.bold_std'),
('outputnode.bold_mask_std', 'inputnode.bold_mask_std'),
]),
]) # fmt:skip
else:
Expand All @@ -358,13 +358,13 @@ def init_single_subject_wf(subject_id: str):
entities=entities,
)
)
ica_aroma_wf.inputs.inputnode.bold_std = functional_cache["bold_std"]
ica_aroma_wf.inputs.inputnode.bold_mask_std = functional_cache["bold_mask_std"]
ica_aroma_wf.inputs.inputnode.bold_std = functional_cache['bold_std']
ica_aroma_wf.inputs.inputnode.bold_mask_std = functional_cache['bold_mask_std']
workflow.add_nodes([ica_aroma_wf])

ica_aroma_wf.inputs.inputnode.movpar_file = functional_cache["movpar_file"]
ica_aroma_wf.inputs.inputnode.skip_vols = functional_cache["skip_vols"]
ica_aroma_wf.inputs.inputnode.spatial_reference = functional_cache["spatial_reference"]
ica_aroma_wf.inputs.inputnode.movpar_file = functional_cache['movpar_file']
ica_aroma_wf.inputs.inputnode.skip_vols = functional_cache['skip_vols']
ica_aroma_wf.inputs.inputnode.spatial_reference = functional_cache['spatial_reference']

# Now denoise the native-space BOLD data using ICA-AROMA

Expand Down
22 changes: 11 additions & 11 deletions src/fmripost_aroma/workflows/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ def init_resample_raw_wf(bold_file, functional_cache):

from fmripost_aroma.interfaces.resampler import Resampler

workflow = Workflow(name="resample_raw_wf")
workflow = Workflow(name='resample_raw_wf')

inputnode = pe.Node(
niu.IdentityInterface(fields=["bold_file", "mask_file"]),
name="inputnode",
niu.IdentityInterface(fields=['bold_file', 'mask_file']),
name='inputnode',
)
inputnode.inputs.bold_file = bold_file
inputnode.inputs.mask_file = functional_cache["bold_mask"]
inputnode.inputs.mask_file = functional_cache['bold_mask']

outputnode = pe.Node(
niu.IdentityInterface(fields=["bold_std", "bold_mask_std"]),
name="outputnode",
niu.IdentityInterface(fields=['bold_std', 'bold_mask_std']),
name='outputnode',
)

stc_wf = init_bold_stc_wf(name="resample_stc_wf")
stc_wf = init_bold_stc_wf(name='resample_stc_wf')
workflow.connect([
(inputnode, stc_wf, [
('bold_file', 'inputnode.bold_file'),
Expand All @@ -34,17 +34,17 @@ def init_resample_raw_wf(bold_file, functional_cache):
]) # fmt:skip

resample_bold = pe.Node(
Resampler(space="MNI152NLin6Asym", resolution="2"),
name="resample_bold",
Resampler(space='MNI152NLin6Asym', resolution='2'),
name='resample_bold',
)
workflow.connect([
(stc_wf, resample_bold, [('outputnode.bold_file', 'bold_file')]),
(resample_bold, outputnode, [('output_file', 'bold_std')]),
]) # fmt:skip

resample_bold_mask = pe.Node(
Resampler(space="MNI152NLin6Asym", resolution="2"),
name="resample_bold_mask",
Resampler(space='MNI152NLin6Asym', resolution='2'),
name='resample_bold_mask',
)
workflow.connect([
(inputnode, resample_bold_mask, [('mask_file', 'bold_file')]),
Expand Down

0 comments on commit d267a86

Please sign in to comment.