-
Notifications
You must be signed in to change notification settings - Fork 135
FIX: Underspecified regex sets BIDSLayout to ignore data with sesions #1094
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
68da3b4
fix: add testing data to avoid regressions
oesteban e2ed100
fix: underspecified regex sets ``BIDSLayout`` to ignore data with ses…
oesteban 2a96710
enh: more programmatic testing
oesteban 18548a3
fix: final improvements
oesteban 6690ced
sty: run black on new test files
oesteban 9ee9f9a
enh: add code suggestion by @effigies
oesteban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
180 |
32,486 changes: 32,486 additions & 0 deletions
32,486
mriqc/data/tests/gh921-dmd-20220428-0.manifest
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/data/skohut/data/thc2 | ||
/data/skohut/data/thc2/template_part1_post.fsf | ||
/data/skohut/data/thc2/sub-ss34F | ||
/data/skohut/data/thc2/sub-ss34F/ses-21chronic | ||
/data/skohut/data/thc2/sub-ss34F/ses-21chronic/func | ||
/data/skohut/data/thc2/sub-ss34F/ses-21chronic/func/sub-ss34F_ses-21chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/template_part2.fsf | ||
/data/skohut/data/thc2/template_part1_pre.fsf | ||
/data/skohut/data/thc2/sub-ss26 | ||
/data/skohut/data/thc2/sub-ss26/ses-22chronic | ||
/data/skohut/data/thc2/sub-ss26/ses-22chronic/func | ||
/data/skohut/data/thc2/sub-ss26/ses-22chronic/func/sub-ss26_ses-22chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/sub-ss26/ses-21chronic | ||
/data/skohut/data/thc2/sub-ss26/ses-21chronic/func | ||
/data/skohut/data/thc2/sub-ss26/ses-21chronic/func/sub-ss26_ses-21chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/sub-ss22 | ||
/data/skohut/data/thc2/sub-ss22/ses-21chronic | ||
/data/skohut/data/thc2/sub-ss22/ses-21chronic/func | ||
/data/skohut/data/thc2/sub-ss22/ses-21chronic/func/sub-ss22_ses-21chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/preproc | ||
/data/skohut/data/thc2/sub-ss35F | ||
/data/skohut/data/thc2/sub-ss35F/ses-21chronic | ||
/data/skohut/data/thc2/sub-ss35F/ses-21chronic/func | ||
/data/skohut/data/thc2/sub-ss35F/ses-21chronic/func/sub-ss35F_ses-21chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/template_part1_pharma.fsf | ||
/data/skohut/data/thc2/sub-ss32F | ||
/data/skohut/data/thc2/sub-ss32F/ses-21chronic | ||
/data/skohut/data/thc2/sub-ss32F/ses-21chronic/func | ||
/data/skohut/data/thc2/sub-ss32F/ses-21chronic/func/sub-ss32F_ses-21chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/sub-ss25 | ||
/data/skohut/data/thc2/sub-ss25/ses-21chronic | ||
/data/skohut/data/thc2/sub-ss25/ses-21chronic/func | ||
/data/skohut/data/thc2/sub-ss25/ses-21chronic/func/sub-ss25_ses-21chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/sub-ss27 | ||
/data/skohut/data/thc2/sub-ss27/ses-21chronic | ||
/data/skohut/data/thc2/sub-ss27/ses-21chronic/func | ||
/data/skohut/data/thc2/sub-ss27/ses-21chronic/func/sub-ss27_ses-21chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/sub-ss20 | ||
/data/skohut/data/thc2/sub-ss20/ses-21chronic | ||
/data/skohut/data/thc2/sub-ss20/ses-21chronic/func | ||
/data/skohut/data/thc2/sub-ss20/ses-21chronic/func/sub-ss20_ses-21chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/sub-ss36F | ||
/data/skohut/data/thc2/sub-ss36F/ses-21chronic | ||
/data/skohut/data/thc2/sub-ss36F/ses-21chronic/func | ||
/data/skohut/data/thc2/sub-ss36F/ses-21chronic/func/sub-ss36F_ses-21chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/sub-ss24 | ||
/data/skohut/data/thc2/sub-ss24/ses-21chronic | ||
/data/skohut/data/thc2/sub-ss24/ses-21chronic/func | ||
/data/skohut/data/thc2/sub-ss24/ses-21chronic/func/sub-ss24_ses-21chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/sub-ss24/ses-22chronic | ||
/data/skohut/data/thc2/sub-ss24/ses-22chronic/func | ||
/data/skohut/data/thc2/sub-ss24/ses-22chronic/func/sub-ss24_ses-22chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/template_part1.fsf | ||
/data/skohut/data/thc2/sub-ss37F | ||
/data/skohut/data/thc2/sub-ss37F/ses-21chronic | ||
/data/skohut/data/thc2/sub-ss37F/ses-21chronic/func | ||
/data/skohut/data/thc2/sub-ss37F/ses-21chronic/func/sub-ss37F_ses-21chronic_task-rest_bold.nii | ||
/data/skohut/data/thc2/template_part1_rest.fsf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
13 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- | ||
# vi: set ft=python sts=4 ts=4 sw=4 et: | ||
# | ||
# Copyright 2021 The NiPreps Developers <nipreps@gmail.com> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# We support and encourage derived works from this project, please read | ||
# about our expectations at | ||
# | ||
# https://www.nipreps.org/community/licensing/ | ||
# | ||
"""py.test configuration""" | ||
import os | ||
from sys import version_info | ||
from pathlib import Path | ||
import numpy as np | ||
import nibabel as nb | ||
import pandas as pd | ||
import pytest | ||
import tempfile | ||
|
||
# disable ET | ||
os.environ['NO_ET'] = '1' | ||
|
||
_datadir = (Path(__file__).parent.parent / "data" / "tests").resolve(strict=True) | ||
niprepsdev_path = os.getenv("TEST_DATA_HOME", str(Path.home() / ".cache" / "mriqc")) | ||
test_output_dir = os.getenv("TEST_OUTPUT_DIR") | ||
test_workdir = os.getenv("TEST_WORK_DIR") | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def expand_namespace(doctest_namespace): | ||
doctest_namespace["PY_VERSION"] = version_info | ||
doctest_namespace["np"] = np | ||
doctest_namespace["nb"] = nb | ||
doctest_namespace["pd"] = pd | ||
doctest_namespace["os"] = os | ||
doctest_namespace["pytest"] = pytest | ||
doctest_namespace["Path"] = Path | ||
doctest_namespace["testdata_path"] = _datadir | ||
doctest_namespace["niprepsdev_path"] = niprepsdev_path | ||
|
||
doctest_namespace["os"] = os | ||
doctest_namespace["Path"] = Path | ||
|
||
tmpdir = tempfile.TemporaryDirectory() | ||
doctest_namespace["tmpdir"] = tmpdir.name | ||
|
||
doctest_namespace["output_dir"] = ( | ||
Path(test_output_dir) if test_output_dir is not None else Path(tmpdir.name) | ||
) | ||
|
||
cwd = os.getcwd() | ||
os.chdir(tmpdir.name) | ||
yield | ||
os.chdir(cwd) | ||
tmpdir.cleanup() | ||
|
||
|
||
@pytest.fixture | ||
def testdata_path(): | ||
return _datadir | ||
|
||
|
||
@pytest.fixture | ||
def workdir(): | ||
return None if test_workdir is None else Path(test_workdir) | ||
|
||
|
||
@pytest.fixture | ||
def outdir(): | ||
return None if test_output_dir is None else Path(test_output_dir) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- | ||
# vi: set ft=python sts=4 ts=4 sw=4 et: | ||
# | ||
# Copyright 2021 The NiPreps Developers <nipreps@gmail.com> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# We support and encourage derived works from this project, please read | ||
# about our expectations at | ||
# | ||
# https://www.nipreps.org/community/licensing/ | ||
# | ||
"""Exercise config module.""" | ||
from pathlib import Path | ||
import pytest | ||
|
||
|
||
def _expand_bids(tmp_path, testdata_path, testcase): | ||
"""Expand manifest file into a temporal folder.""" | ||
|
||
text = (testdata_path / f"{testcase}.manifest").read_text().splitlines() | ||
root = Path(text[0].strip()) | ||
out_path = tmp_path / testcase | ||
|
||
for path in reversed(text[1:]): | ||
relpath = Path(path).relative_to(root) | ||
if "." in relpath.name or relpath in ("CHANGES", "README", "LICENSE"): | ||
(out_path / relpath.parent).mkdir(parents=True, exist_ok=True) | ||
if not (out_path / relpath).exists(): | ||
contents = "{}" if relpath.name.endswith(".json") else "" | ||
(out_path / relpath).write_text(contents) | ||
else: | ||
(out_path / relpath).mkdir(parents=True, exist_ok=True) | ||
|
||
if ( | ||
not (out_path / "dataset_description.json").exists() | ||
or "Name" not in (out_path / "dataset_description.json").read_text() | ||
): | ||
(out_path / "dataset_description.json").write_text( | ||
'{"Name": "Example dataset", "BIDSVersion": "1.0.2"}' | ||
) | ||
|
||
return out_path | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"testcase", | ||
( | ||
"gh921-dmd-20220428-0", | ||
"gh921-dmd-20230319-0", | ||
"gh1086-ds004134", | ||
), | ||
) | ||
def test_bids_indexing_manifest(tmp_path, testdata_path, testcase): | ||
"""Check ``BIDSLayout`` is indexing what it should.""" | ||
|
||
from mriqc import config | ||
from importlib import reload | ||
|
||
reload(config) | ||
|
||
config.execution.bids_dir = _expand_bids( | ||
tmp_path, | ||
testdata_path, | ||
testcase, | ||
) | ||
config.execution.init() | ||
assert len(config.execution.layout.get()) == int( | ||
(testdata_path / f"{testcase}.oracle").read_text().strip() | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.