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

[FIX] do not apply run found for one task to all tasks #228

Merged
merged 6 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions bidsmreye/bids_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
from bidsmreye.logging import bidsmreye_log
from bidsmreye.methods import methods
from bidsmreye.utils import copy_license, create_dir_if_absent
from bidsmreye.utils import copy_license, create_dir_if_absent, return_regex

log = bidsmreye_log("bidsmreye")

Expand Down Expand Up @@ -60,9 +60,10 @@
if generated_by["Name"].lower() == "bidsmreye":
this_filter = get_bids_filter_config()["mask"]

this_filter["task"] = cfg.task
this_filter["task"] = return_regex(cfg.task)
this_filter["space"] = cfg.space
this_filter["run"] = cfg.run
if cfg.run:
this_filter["run"] = cfg.run

Check warning on line 66 in bidsmreye/bids_utils.py

View check run for this annotation

Codecov / codecov/patch

bidsmreye/bids_utils.py#L66

Added line #L66 was not covered by tests

log.debug(f"Looking for files with filter\n{this_filter}")

Expand All @@ -78,8 +79,8 @@
raise RuntimeError(
f"Input dataset {layout.root} does not have "
f"any data to process for filter\n{this_filter}.\n"
f"This dataset contains subjects: {subjects}."
f"This dataset contains tasks: {tasks}."
f"This dataset contains subjects: {subjects}.\n"
f"This dataset contains tasks: {tasks}.\n"
"Is your dataset a BIDS derivative dataset?\n"
"Check the FAQ for more information: "
"https://bidsmreye.readthedocs.io/en/latest/FAQ.html"
Expand Down
3 changes: 3 additions & 0 deletions bidsmreye/bidsmreye.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,17 @@ def dispatch(analysis_level: str, action: str, cfg: Config) -> None:

prepare_data(cfg)
generalize(cfg)

elif action == "prepare":
from bidsmreye.prepare_data import prepare_data

prepare_data(cfg)

elif action == "generalize":
from bidsmreye.generalize import generalize

generalize(cfg)

elif action == "qc":
from bidsmreye.quality_control import quality_control_input

Expand Down
19 changes: 14 additions & 5 deletions bidsmreye/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def __attrs_post_init__(self) -> None:

self.check_argument(attribute="subjects", layout_in=layout_in)
self.check_argument(attribute="task", layout_in=layout_in)
self.check_argument(attribute="run", layout_in=layout_in)
self.check_argument(attribute="space", layout_in=layout_in)
self.check_argument(attribute="run", layout_in=layout_in)

def check_argument(self, attribute: str, layout_in: BIDSLayout) -> Config:
"""Check an attribute value compared to the input dataset content.
Expand All @@ -125,9 +125,15 @@ def check_argument(self, attribute: str, layout_in: BIDSLayout) -> Config:
if attribute == "subjects":
value = layout_in.get_subjects()
elif attribute == "task":
value = layout_in.get_tasks()
value = layout_in.get_tasks(subject=self.subjects)
elif attribute in {"space", "run"}:
value = layout_in.get(return_type="id", target=attribute, datatype="func")
value = layout_in.get(
return_type="id",
target=attribute,
datatype="func",
subject=self.subjects,
task=self.task,
)

self.listify(attribute)

Expand All @@ -148,9 +154,12 @@ def check_argument(self, attribute: str, layout_in: BIDSLayout) -> Config:
)
value = list(set(getattr(self, attribute)) & set(value))

setattr(self, attribute, value)

# run and space can be empty if their entity are not used
# we will figure out the values for run
# in subject / task wise manner later on
if attribute not in ["run"]:
setattr(self, attribute, value)

if attribute not in ["run", "space"] and not getattr(self, attribute):
raise RuntimeError(f"No {attribute} found in {self.input_dir}")

Expand Down
2 changes: 2 additions & 0 deletions docs/source/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

* [FIX] do not apply run found for one task to all tasks by @Remi-Gau in https://github.com/cpp-lln-lab/bidsMReye/pull/228

### Security


Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies = [
"kaleido",
"pooch>=1.6.0",
"pybids",
"antspyx<0.5",
"tqdm",
"tomli; python_version < '3.11'",
"keras<3.0.0",
Expand Down
6 changes: 5 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ absl-py==2.1.0
# tensorboard
# tensorflow
antspyx==0.4.2
# via deepmreye
# via
# bidsmreye (pyproject.toml)
# deepmreye
anyio==4.4.0
# via
# httpx
Expand Down Expand Up @@ -430,6 +432,8 @@ rfc3986-validator==0.1.1
# jsonschema
# jupyter-events
rich==13.7.1
# via rich-argparse
rich-argparse==1.5.2
# via bidsmreye (pyproject.toml)
rpds-py==0.19.1
# via
Expand Down
1 change: 0 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def test_set_this_filter_bold(pybids_test_dataset, output_dir):
"datatype": "func",
"desc": "preproc",
"extension": "nii.*",
"run": "1|2",
"subject": "001",
"suffix": "^bold$",
}
Expand Down