-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENH] Use a BIDSLayout to index TemplateFlow
Uses pybids to access the data (fixes #4). Additionally, resorts to datalad iff there are missing files (rel. #5). I will not close that one because this is not really a datalad-free fallback.
- Loading branch information
Showing
9 changed files
with
128 additions
and
37 deletions.
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 |
---|---|---|
@@ -1,2 +0,0 @@ | ||
datalad | ||
pytest | ||
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
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
Extending pyBIDS | ||
""" | ||
from pkg_resources import resource_filename | ||
from bids.layout import BIDSLayout, add_config_paths | ||
|
||
add_config_paths(templateflow=resource_filename('templateflow', 'conf/config.json')) | ||
|
||
|
||
class Layout(BIDSLayout): | ||
def __repr__(self): | ||
# A tidy summary of key properties | ||
s = """\ | ||
TemplateFlow Layout | ||
- Home: {} | ||
- Templates: {}.""".format(self.root, ', '.join(sorted(self.get_templates()))) | ||
return s |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"name": "templateflow", | ||
"entities": [ | ||
{ | ||
"name": "template", | ||
"pattern": "[/\\\\]tpl-([a-zA-Z0-9]+)", | ||
"directory": "{{root}}{template}" | ||
}, | ||
{ | ||
"name": "resolution", | ||
"pattern": "[_/\\\\]+res-0*(\\d+)", | ||
"dtype": "int" | ||
}, | ||
{ | ||
"name": "atlas", | ||
"pattern": "[_/\\\\]atlas-([a-zA-Z0-9]+)" | ||
}, | ||
{ | ||
"name": "roi", | ||
"pattern": "[_/\\\\]roi-([a-zA-Z0-9]+)" | ||
}, | ||
{ | ||
"name": "label", | ||
"pattern": "[_/\\\\]label-([a-zA-Z0-9]+)" | ||
}, | ||
{ | ||
"name": "desc", | ||
"pattern": "[_/\\\\]desc-([a-zA-Z0-9]+)" | ||
}, | ||
{ | ||
"name": "space", | ||
"pattern": "[_/\\\\]space-([a-zA-Z0-9]+)" | ||
}, | ||
{ | ||
"name": "from", | ||
"pattern": "(?:^|_)from-([a-zA-Z0-9]+).*xfm" | ||
}, | ||
{ | ||
"name": "to", | ||
"pattern": "(?:^|_)to-([a-zA-Z0-9]+).*xfm" | ||
}, | ||
{ | ||
"name": "mode", | ||
"pattern": "(?:^|_)mode-([a-zA-Z0-9]+).*xfm" | ||
}, | ||
{ | ||
"name": "hemi", | ||
"pattern": "[_/\\\\]hemi-(L|R)" | ||
}, | ||
{ | ||
"name": "suffix", | ||
"pattern": "[._]*([a-zA-Z0-9]*?)\\.[^/\\\\]+$" | ||
}, | ||
{ | ||
"name": "description", | ||
"pattern": "(.*\\template_description.json)$" | ||
} | ||
], | ||
"default_path_patterns": [ | ||
"tpl-{template}/template_description.json", | ||
"tpl-{template}/tpl-{template}_res-{resolution}[_space-{space}][_hemi-{hemi}][_desc-{desc}]_{suffix<T1w|T2w|T1rho|T1map|T2map|T2star|FLAIR|FLASH|PDmap|PD|PDT2|inplaneT[12]|angio>}.{extension<nii|nii\\.gz>}" | ||
] | ||
} |