Skip to content

Commit

Permalink
Handle multiple paths in MNI_DATAPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Dec 30, 2022
1 parent b8cb9f1 commit 2338b21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
10 changes: 8 additions & 2 deletions civet/extraction/starting_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
Data from the `$MNI_DATAPATH/surface-extraction` directory.
"""
from pathlib import Path
from typing import Optional

from civet.extraction.surfaces import RegularSurface
from civet.globals import MNI_DATAPATH

Expand All @@ -10,8 +13,11 @@ class SurfaceModel(RegularSurface['SurfaceModel']):
Represents a surface data file from the `$MNI_DATAPATH/surface-extraction` directory.
"""
@classmethod
def get_model(cls, name: str) -> 'SurfaceModel':
return cls(MNI_DATAPATH / 'surface-extraction' / name)
def get_model(cls, name: str) -> Optional['SurfaceModel']:
data_paths = MNI_DATAPATH.split(':')
possible_models = map(lambda b: Path(b) / 'surface-extraction' / name, data_paths)
actual_models = filter(None, possible_models)
return next(actual_models, None)


WHITE_MODEL_320 = SurfaceModel.get_model('white_model_320.obj')
3 changes: 1 addition & 2 deletions civet/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
Global variables.
"""
import os
from pathlib import Path


MNI_DATAPATH = Path(os.environ['MNI_DATAPATH'])
MNI_DATAPATH = os.environ['MNI_DATAPATH']
"""
Location of data such as starting ellipsoids for surface extraction.
"""
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name='pycivet',
version='0.1.0',
version='0.1.1',
description='Object-oriented CIVET bindings for Python',
long_description=readme,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 2338b21

Please sign in to comment.