-
Notifications
You must be signed in to change notification settings - Fork 127
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
bids_ME heuristic: add test for the dataset that raised #541, add support for MEGRE #547
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2bccb7c
Add test for the dataset that raised #541
pvelasco 6dee18a
Add test for the dataset that raised #541
pvelasco 96908bd
BF: fix call to op.join
pvelasco 4982bbb
Move data for test_ME_mag_phase_conversion to Datalad
pvelasco 79b97ee
Remove unused test data
pvelasco 958f6f7
BF: Add `has_datalad` definition to `test_bids.py`
pvelasco b66e60b
BF(TST): fix use of f-string
yarikoptic aee3d9b
FIX: `test_ME_mag_phase_conversion`: Add extension to `heuristics`
pvelasco 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 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
This file contains 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 |
---|---|---|
|
@@ -43,13 +43,23 @@ | |
KeyInfoForForce, | ||
BIDSFile, | ||
) | ||
from heudiconv.cli.run import main as runner | ||
|
||
from .utils import ( | ||
fetch_data, | ||
gen_heudiconv_args, | ||
TESTS_DATA_PATH, | ||
) | ||
|
||
import pytest | ||
|
||
have_datalad = True | ||
try: | ||
from datalad.support.exceptions import IncompleteResultsError | ||
except ImportError: | ||
have_datalad = False | ||
|
||
|
||
def gen_rand_label(label_size, label_seed, seed_stdout=True): | ||
seed(label_seed) | ||
rand_char = ''.join(choice(string.ascii_letters) for _ in range(label_size-1)) | ||
|
@@ -1116,3 +1126,32 @@ def test_BIDSFile(): | |
# -for an existing entity, you can overwrite it with "set": | ||
my_bids_file.set('echo', '2') | ||
assert my_bids_file['echo'] == '2' | ||
|
||
|
||
@pytest.mark.skipif(not have_datalad, reason="no datalad") | ||
def test_ME_mag_phase_conversion(tmpdir, subID='MEGRE', heuristic='bids_ME'): | ||
""" Unit test for the case of multi-echo GRE data with | ||
magnitude and phase. | ||
The different echoes should be labeled automatically. | ||
""" | ||
tmpdir.chdir() | ||
tmppath = tmpdir.strpath | ||
try: | ||
datadir = fetch_data(tmppath, "dicoms/velasco/{subID}") | ||
yarikoptic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
except IncompleteResultsError as exc: | ||
pytest.skip("Failed to fetch test data: %s" % str(exc)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note -- this line is "covered" which means that the test just skipped... I think I might see the reason
pvelasco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
outdir = tmpdir.mkdir('out').strpath | ||
args = gen_heudiconv_args(datadir, outdir, subID, heuristic) | ||
runner(args) # run conversion | ||
|
||
# Check that the expected files have been extracted. | ||
# This also checks that the "echo" entity comes before "part": | ||
for part in ['mag', 'phase']: | ||
for e in range(1,4): | ||
for ext in ['nii.gz', 'json']: | ||
assert op.exists( | ||
op.join(outdir, 'sub-%s', 'anat', 'sub-%s_echo-%s_part-%s_MEGRE.%s') | ||
% (subID, subID, e, part, ext) | ||
) | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this code block is not covered by tests... what data was supposed to have it covered?