Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX allow any character in mask name #533

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cortex/dataset/braindata.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import hashlib
from copy import deepcopy
import numpy as np

import h5py
import numpy as np

from ..database import db


class BrainData(object):
"""
Abstract base class for brain data.
Expand Down Expand Up @@ -592,17 +594,18 @@ def blend_curvature(self, alpha, threshold=0, brightness=0.5,


def _find_mask(nvox, subject, xfmname):
import glob
import os
import re
import glob

import nibabel
files = db.get_paths(subject)['masks'].format(xfmname=xfmname, type="*")
for fname in glob.glob(files):
nib = nibabel.load(fname)
mask = nib.get_fdata().T != 0
if nvox == np.sum(mask):
fname = os.path.split(fname)[1]
name = re.compile(r'mask_([\w]+).nii.gz').search(fname)
name = re.compile(r'mask_(.+).nii.gz').search(fname)
return name.group(1), mask

raise ValueError('Cannot find a valid mask')
Expand Down