-
Notifications
You must be signed in to change notification settings - Fork 0
/
heur_tutorial.py
73 lines (65 loc) · 2.28 KB
/
heur_tutorial.py
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
import fnmatch
def heur(physinfo, take=""):
"""
Set of if .. elif statements to fill BIDS names.
It requires the user (you!) to adjust it accordingly!
It needs an ``if`` or ``elif`` statement for each file that
needs to be processed.
The statement will test if the ``physinfo``:
- is similar to a string (first case), or
- exactly matches a string (second case).
Parameters
----------
physinfo: str
Name of an input file that should be bidsified (See Notes)
Returns
-------
info: dictionary of str
Dictionary containing BIDS keys
Notes
-----
The `if ..` structure should always be similar to
```
if physinfo == 'somepattern':
info['var'] = 'somethingelse'
```
or, in case it's a partial match
```
if fnmatch.fnmatchcase(physinfo, '*somepattern?'):
info['var'] = 'somethingelse'
```
Where:
- `physinfo` and `info` are dedicated keywords,
- 'somepattern' is the name of the file,
- 'var' is a bids key in the list below
- 'somethingelse' is the value of the key
"""
info = {}
# ################################# #
# ## Modify here! ## #
# ## ## #
# ## Possible variables are: ## #
# ## -info['task'] (required) ## #
# ## -info['run'] ## #
# ## -info['rec'] ## #
# ## -info['acq'] ## #
# ## -info['dir'] ## #
# ## ## #
# ## Remember that they are ## #
# ## dictionary keys ## #
# ## See example below ## #
# ################################# #
if fnmatch.fnmatchcase(physinfo, "*multiscan*"):
if take == "01":
info["task"] = "BreathHoldsRest"
if take == "02":
info["task"] = "CuedDeepBreathing"
info["rec"] = "labchart"
elif fnmatch.fnmatchcase(physinfo, "*multifreq*"):
info["task"] = "SomeTask"
elif physinfo == "Example":
info["task"] = "sometask"
# ############################## #
# ## Don't modify below this! ## #
# ############################## #
return info