Skip to content

Commit

Permalink
Merge pull request #114 from HALFpipe/dev/fix-high-pass-filter-cutoff
Browse files Browse the repository at this point in the history
Fix skipping the high pass filter for task-based feature extraction
  • Loading branch information
HippocampusGirl committed May 13, 2021
2 parents b19a208 + f847ceb commit a342fb0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ RUN pip install git+https://github.com/pydata/patsy.git

# install dependencies and force reinstall of nipreps and nipype
RUN cd /halfpipe && \
pip uninstall --yes fmriprep smriprep niworkflows nipype && \
pip uninstall --yes fmriprep smriprep niworkflows nipype pybids && \
pip install -r requirements.txt

# download all resources
Expand Down
14 changes: 12 additions & 2 deletions halfpipe/model/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,19 @@ class TaskBasedFeatureSchema(BaseFeatureSchema):
conditions = fields.List(fields.Str())
contrasts = fields.List(fields.Nested(TContrastSchema))

high_pass_filter_cutoff = fields.Float(default=125.0, missing=125., validate=validate.Range(min=0.0))
high_pass_filter_cutoff = fields.Float(
default=125.0,
missing=125.,
allow_nan=True,
allow_none=True,
validate=validate.Range(min=0.0)
)

hrf = fields.Str(default="dgamma", missing="dgamma", validate=validate.OneOf(["dgamma", "dgamma_with_derivs", "flobs"]))
hrf = fields.Str(
default="dgamma",
missing="dgamma",
validate=validate.OneOf(["dgamma", "dgamma_with_derivs", "flobs"])
)


class SeedBasedConnectivityFeatureSchema(BaseFeatureSchema):
Expand Down
4 changes: 3 additions & 1 deletion halfpipe/ui/feature/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ def next(self, ctx):
if isinstance(value, float):
ctx.spec.features[-1].high_pass_filter_cutoff = value
elif value == "Skip":
pass
ctx.spec.features[-1].high_pass_filter_cutoff = None
else:
raise ValueError(f'Unknown high_pass_filter_cutoff value "{value}"')

this_next_step_type = next_step_type

Expand Down
10 changes: 7 additions & 3 deletions halfpipe/workflow/feature/taskbased.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import os
from pathlib import Path
from math import isfinite

import numpy as np

Expand Down Expand Up @@ -152,10 +153,13 @@ def init_taskbased_wf(

# first level model specification
modelspec = pe.Node(model.SpecifyModel(), name="modelspec")

modelspec.inputs.high_pass_filter_cutoff = np.inf # disable if missing
if hasattr(feature, "high_pass_filter_cutoff"):
modelspec.inputs.high_pass_filter_cutoff = feature.high_pass_filter_cutoff
else:
modelspec.inputs.high_pass_filter_cutoff = np.inf
hpfc = feature.high_pass_filter_cutoff
if isinstance(hpfc, float) and isfinite(hpfc):
modelspec.inputs.high_pass_filter_cutoff = hpfc

workflow.connect(inputnode, "bold", modelspec, "functional_runs")
workflow.connect(inputnode, "condition_units", modelspec, "input_units")
workflow.connect(inputnode, "repetition_time", modelspec, "time_repetition")
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sdcflows == 1.3.3
mriqc @ git+https://github.com/poldracklab/mriqc@0.15.3
niworkflows @ git+https://github.com/hippocampusgirl/niworkflows.git@1.3.3+halfpipe.1
templateflow @ git+https://github.com/templateflow/python-client@0.7.1
pybids >= 0.13.0
pybids @ git+https://github.com/hippocampusgirl/pybids.git@0.13+halfpipe.1
flufl.lock >= 5.0.3
fasteners >= 0.15
inflect
Expand All @@ -37,4 +37,4 @@ pympler >= 0.9
stackprinter >= 0.2.5
line_profiler
more-itertools >= 8.7.0
calamities ~= 0.0.13
calamities >= 0.0.14
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ install_requires =
mriqc
niworkflows
templateflow
pybids >= 0.13.0
pybids
flufl.lock >= 5.0.3
fasteners >= 0.15
inflect
Expand All @@ -60,7 +60,7 @@ install_requires =
stackprinter >= 0.2.5
line_profiler
more-itertools >= 8.7.0
calamities ~= 0.0.13
calamities >= 0.0.14
packages = find:

[options.entry_points]
Expand Down

0 comments on commit a342fb0

Please sign in to comment.