Skip to content

Commit

Permalink
✨ Add some handling for user-defined BIDSy atlases
Browse files Browse the repository at this point in the history
  • Loading branch information
shnizzedy committed Jul 18, 2023
1 parent 0303596 commit d0e77de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## Added

- Some automatic handling of user-provided BIDSy atlas names.

## Fixed

- Fixed a bug where some connectivity matrices wouldn't generate if anatomical and functional outputs were in different resolutions.
Expand Down
10 changes: 9 additions & 1 deletion CPAC/resources/templates/lookup_table.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 C-PAC Developers
# Copyright (C) 2022-2023 C-PAC Developers

# This file is part of C-PAC.

Expand All @@ -20,6 +20,7 @@
from os import path as op
from re import search
from typing import Optional
from bids.layout import parse_file_entities
from numpy import loadtxt
from CPAC.utils.typing import TUPLE

Expand Down Expand Up @@ -81,8 +82,15 @@ def lookup_identifier(template_path: str) -> TUPLE[str, None]:
('template', None)
>>> lookup_identifier('/cpac_templates/CC200.nii.gz')
('CC', '200')
>>> lookup_identifier('s3://templateflow/tpl-MNI152NLin2009cAsym/'
... 'tpl-MNI152NLin2009cAsym_res-02_atlas-Schaefer2018_'
... 'desc-200Parcels17Networks_dseg.nii.gz")
('Schaefer2018', '200Parcels17Networks')
'''
for key, value in LOOKUP_TABLE.items():
if search(key, template_path) is not None:
return value
_bidsy = parse_file_entities(template_path)
if 'atlas' in _bidsy:
return _bidsy['atlas'], _bidsy.get('desc')
return 'template', None

0 comments on commit d0e77de

Please sign in to comment.