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

Parallelize parcellation and replace atlases #254

Merged
merged 37 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ad09dad
Work on parallelizing the parcellation.
tsalo Apr 5, 2023
cf656cf
Keep parallelizing.
tsalo Apr 5, 2023
11ec477
Replace atlas files.
tsalo Apr 5, 2023
f5ec98f
Swap out ParcellateCBF interface.
tsalo Apr 5, 2023
081d9aa
Replace ApplyTransforms throughout.
tsalo Apr 5, 2023
e477c40
Forgot to change the package name.
tsalo Apr 5, 2023
067aae6
Modify refine_ref_mask.
tsalo Apr 5, 2023
65d2020
Update API docs.
tsalo Apr 5, 2023
6c3cd2c
Fix interface.
tsalo Apr 5, 2023
45eed3b
Fix up the tests. Hopefully CircleCI works.
tsalo Apr 5, 2023
dd58475
Fix test and update gitignore.
tsalo Apr 5, 2023
b85cae0
Update expected outputs.
tsalo Apr 5, 2023
fe369d9
Try out another output space.
tsalo Apr 5, 2023
c0b8eb5
Try that.
tsalo Apr 5, 2023
e59deb8
Use NLin6Asym --> NLin2009cAsym transform.
tsalo Apr 5, 2023
c13a5b0
I forgot to fix up the GE workflow.
tsalo Apr 5, 2023
74d0500
Add output space for GE test.
tsalo Apr 5, 2023
a2491c0
Update test_cli.py
tsalo Apr 5, 2023
7509e89
Update expected outputs.
tsalo Apr 5, 2023
f760b8e
Update test_001 parameters.
tsalo Apr 5, 2023
7a1f549
Move _adjust_indices back into _gather_confounds.
tsalo Apr 6, 2023
0a4389a
Keep working on outputs.
tsalo Apr 6, 2023
8502c05
Update .gitignore
tsalo Apr 6, 2023
984e7a5
Update .gitignore
tsalo Apr 6, 2023
0aa73fa
Simplify outputs.
tsalo Apr 6, 2023
ab45f76
Fix typo in node names and fix connections.
tsalo Apr 6, 2023
f09baaa
Is it all due to den vs. density in the config?
tsalo Apr 6, 2023
aac544e
Fix up the outputs.
tsalo Apr 6, 2023
f1e9c1e
Fix standard-space output connections.
tsalo Apr 6, 2023
4048bb7
Whoops!
tsalo Apr 6, 2023
bf3ab0f
So annoying.
tsalo Apr 6, 2023
c9a6008
Update confounds.py
tsalo Apr 6, 2023
bb2a8e3
Try fixing the re-indexing function.
tsalo Apr 6, 2023
c882204
I missed CBF!
tsalo Apr 6, 2023
96d2cea
I forgot to return the modified dfs.
tsalo Apr 6, 2023
f01ced4
Fix _adjust_indices.
tsalo Apr 6, 2023
fb2f561
test_002 expected things it shouldn't expect.
tsalo Apr 6, 2023
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
92 changes: 92 additions & 0 deletions .circleci/run_local_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env python3
"""Run tests locally."""
import argparse
import os
import subprocess


def _get_parser():
"""Parse command line inputs for tests.

Returns
-------
parser.parse_args() : argparse dict
"""
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
"-k",
dest="test_regex",
metavar="PATTERN",
type=str,
help="Test pattern.",
required=False,
default=None,
)
parser.add_argument(
"-m",
dest="test_mark",
metavar="LABEL",
type=str,
help="Test mark label.",
required=False,
default=None,
)
return parser


def run_command(command, env=None):
"""Run a given shell command with certain environment variables set."""
merged_env = os.environ
if env:
merged_env.update(env)
process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True,
env=merged_env,
)
while True:
line = process.stdout.readline()
line = str(line, "utf-8")[:-1]
print(line)
if line == "" and process.poll() is not None:
break

if process.returncode != 0:
raise RuntimeError(
f"Non zero return code: {process.returncode}\n" f"{command}\n\n{process.stdout.read()}"
)


def run_tests(test_regex, test_mark):
"""Run the tests."""
local_patch = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
mounted_code = "/usr/local/miniconda/lib/python3.8/site-packages/aslprep"
run_str = "docker run --rm -ti "
run_str += f"-v {local_patch}:/usr/local/miniconda/lib/python3.8/site-packages/aslprep "
run_str += "--entrypoint pytest "
run_str += "pennlinc/aslprep:unstable "
run_str += (
f"{mounted_code}/aslprep "
f"--data_dir={mounted_code}/aslprep/tests/data/test_data "
f"--output_dir={mounted_code}/aslprep/tests/data/test_data/run_pytests/out "
f"--working_dir={mounted_code}/aslprep/tests/data/test_data/run_pytests/work "
)
if test_regex:
run_str += f"-k {test_regex} "
elif test_mark:
run_str += f"-rP -o log_cli=true -m {test_mark} "

run_command(run_str)


def _main(argv=None):
"""Run the tests."""
options = _get_parser().parse_args(argv)
kwargs = vars(options)
run_tests(**kwargs)


if __name__ == "__main__":
_main()
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
aslprep/tests/data/test_data
.circleci/local_aslprep_path.txt

.DS_Store
Expand Down
12 changes: 10 additions & 2 deletions aslprep/data/aslprep_bids_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@
{
"name": "measure",
"pattern": "(?:^|_)measure-([a-zA-Z0-9]+)"
},
{
"name": "resolution",
"pattern": "res-([a-zA-Z0-9]+)"
},
{
"name": "density",
"pattern": "den-([a-zA-Z0-9]+)"
}
],
"default_path_patterns": [
"[space-{space}_]atlas-{atlas}[_cohort-{cohort}][_res-{res}][_desc-{desc}]_{suffix<dseg>}{extension<.nii|.nii.gz|.tsv|.json>|.nii.gz}",
"[space-{space}_]atlas-{atlas}[_cohort-{cohort}][_den-{den}][_desc-{desc}]_{suffix<dseg>}{extension<.dlabel.nii|.tsv|.json>|.dlabel.nii}",
"[space-{space}_]atlas-{atlas}[_cohort-{cohort}][_res-{resolution}][_desc-{desc}]_{suffix<dseg>}{extension<.nii|.nii.gz|.tsv|.json>|.nii.gz}",
"[space-{space}_]atlas-{atlas}[_cohort-{cohort}][_den-{density}][_desc-{desc}]_{suffix<dseg>}{extension<.dlabel.nii|.tsv|.json>|.dlabel.nii}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}]_{suffix<T1w|T2w|T1rho|T1map|T2map|T2star|FLAIR|FLASH|PDmap|PD|PDT2|inplaneT[12]|angio>}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_mod-{modality}]_{suffix<defacemask>}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<func>|func}/sub-{subject}[_ses-{session}]_task-{task}[_acq-{acquisition}][_ce-{ceagent}][_dir-{direction}][_rec-{reconstruction}][_run-{run}][_echo-{echo}]_{suffix<bold|cbv|sbref>}{extension<.nii|.nii.gz|.json>|.nii.gz}",
Expand Down
1 change: 0 additions & 1 deletion aslprep/data/atlas/HarvardOxford/HarvardOxford.bib

This file was deleted.

Binary file not shown.
112 changes: 0 additions & 112 deletions aslprep/data/atlas/HarvardOxford/HarvardOxfordNodeIndex.1D

This file was deleted.

112 changes: 0 additions & 112 deletions aslprep/data/atlas/HarvardOxford/HarvardOxfordNodeNames.txt

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading