forked from cpp-lln-lab/bidsMReye
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
249 lines (195 loc) · 6.35 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
.PHONY: clean clean-build clean-pyc clean-test coverage dist help install
.DEFAULT_GOAL := help
define BROWSER_PYSCRIPT
import os, webbrowser, sys
from urllib.request import pathname2url
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"
# Put it first so that "make" without argument is like "make help".
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
clean: clean-build clean-pyc clean-test clean-models clean-demo clean-models ## remove all build, test, coverage and Python artifacts
clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache
## INSTALL
install_dev: clean ## install the package and development dependencies to the active Python's site-packages
pip install -e .[dev]
make models
release: dist ## package and upload a release
twine upload dist/*
dist: clean ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
## PRE-TRAINED MODELS
.PHONY: models
clean-models: ## remove pretrained models
rm -fr models/
models:
bidsmreye_model --model_name 1to6
models/dataset1_guided_fixations.h5:
bidsmreye_model
models/dataset2_pursuit.h5:
bidsmreye_model --model_name 2_pursuit
models/dataset3_openclosed.h5:
bidsmreye_model --model_name 3_openclosed
models/dataset3_pursuit.h5:
bidsmreye_model --model_name 3_pursuit
models/dataset4_pursuit.h5:
bidsmreye_model --model_name 4_pursuit
models/dataset5_free_viewing.h5:
bidsmreye_model --model_name 5_free_viewing
## STYLE
lint/flake8: ## check style with flake8
flake8 bidsmreye tests
lint/black: ## check style with black
black bidsmreye tests
lint/mypy: ## check style with mypy
mypy bidsmreye
lint: lint/black lint/mypy lint/flake8 ## check style
## DOC
.PHONY: docs docs/source/FAQ.md
docs/source/FAQ.md:
faqtory build
docs: docs/source/FAQ.md ## generate Sphinx HTML documentation, including API docs
rm -f docs/source/bidsmreye.rst
rm -f docs/source/modules.rst
sphinx-apidoc -o docs/source bidsmreye
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html
servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
## TESTS
test: tests/data/moae_fmriprep ## run tests quickly with the default Python
python -m pytest
tests/data/moae_fmriprep: ## gets fmriprep preprocessed data of the SPM MOAE dataset from OSF
mkdir -p tests/data
wget -q https://osf.io/vufjs/download
unzip download
rm download
mv moae_fmriprep tests/data/moae_fmriprep
## DEMO
.PHONY: clean-demo
clean-demo:
rm -fr outputs/moae_fmriprep
demo: clean-demo prepare generalize## demo: runs all demo steps on MOAE dataset
prepare: tests/data/moae_fmriprep ## demo: prepares the data of MOAE dataset
bidsmreye $$PWD/tests/data/moae_fmriprep \
$$PWD/outputs/moae_fmriprep/derivatives \
participant \
--action prepare \
-vv \
--reset_database \
--non_linear_coreg
generalize: ## demo: predicts labels of MOAE dataset
bidsmreye $$PWD/tests/data/moae_fmriprep \
$$PWD/outputs/moae_fmriprep/derivatives \
participant \
--action generalize \
-vv \
--non_linear_coreg
## Openneuro data
.PHONY: get_ds002799_dat
clean-ds002799:
rm -fr outputs/ds002799/derivatives
tests/data/data_ds002799:
datalad install -s ///openneuro/ds002799 tests/data/ds002799
get_ds002799: tests/data/data_ds002799
cd tests/data/ds002799/derivatives/fmriprep && \
datalad get sub-30[27]/ses-*/func/*run-*preproc*bold*
ds002799_prepare: get_ds002799
bidsmreye $$PWD/tests/data/ds002799/derivatives/fmriprep \
$$PWD/outputs/ds002799/derivatives \
participant \
--action prepare \
--participant_label 302 307 \
--space MNI152NLin2009cAsym \
--reset_database \
--run 1 2
ds002799_generalize:
bidsmreye $$PWD/tests/data/ds002799/derivatives/fmriprep \
$$PWD/outputs/ds002799/derivatives \
participant \
--action generalize \
--participant_label 302 307 \
--space MNI152NLin2009cAsym \
--run 1 2
ds002799: clean-ds002799 get_ds002799
bidsmreye $$PWD/tests/data/ds002799/derivatives/fmriprep \
$$PWD/outputs/ds002799/derivatives \
participant \
--action all \
--participant_label 302 307 \
--space MNI152NLin2009cAsym \
--run 1 2 \
--reset_database \
-vv
## DOCKER
.PHONY:
docker_build:
docker build --tag cpplab/bidsmreye:unstable --file Dockerfile .
docker_build_no_cache:
docker build --tag cpplab/bidsmreye:unstable --no-cache --file Dockerfile .
docker_demo: docker_build clean-demo
make docker_prepare_data
make docker_generalize
docker_prepare_data:
docker run --rm -it \
-v $$PWD/tests/data/moae_fmriprep:/home/neuro/data \
-v $$PWD/outputs/moae_fmriprep/derivatives:/home/neuro/outputs/ \
cpplab/bidsmreye:unstable \
/home/neuro/data/ \
/home/neuro/outputs/ \
participant \
--action prepare \
--reset_database
docker_generalize:
docker run --rm -it \
-v $$PWD/tests/data/moae_fmriprep:/home/neuro/data \
-v $$PWD/outputs/moae_fmriprep/derivatives:/home/neuro/outputs/ \
cpplab/bidsmreye:unstable \
/home/neuro/data/ \
/home/neuro/outputs/ \
participant \
--action generalize
docker_ds002799: get_ds002799
# datalad unlock $$PWD/tests/data/ds002799/derivatives/fmriprep/sub-30[27]/ses-*/func/*run-*preproc*bold*
docker run --rm -it \
-v $$PWD/tests/data/ds002799/derivatives/fmriprep:/home/neuro/data \
-v $$PWD/outputs/ds002799/derivatives:/home/neuro/outputs/ \
cpplab/bidsmreye:unstable \
/home/neuro/data/ \
/home/neuro/outputs/ \
participant \
--action all \
--participant_label 302 307 \
--space MNI152NLin2009cAsym \
--run 1 2 \
--reset_database \
-vv