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

Develop marco #3

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
mask as str, nifti img or ndarray in get_betas and get_residuals
mnlmrc committed Mar 11, 2025
commit 1ea1ecc9cf63cd5e4057e16744d615c6c3676994
23 changes: 21 additions & 2 deletions nitools/spm.py
Original file line number Diff line number Diff line change
@@ -110,7 +110,16 @@ def get_betas(self, mask):
obs_descriptors (dict): with lists reg_name and run_number (N long)
"""

coords = nt.get_mask_coords(mask)
if isinstance(mask, str):
mask = nb.load(mask)
if isinstance(mask, nb.Nifti1Image):
coords = nt.get_mask_coords(mask)
if isinstance(mask, np.ndarray):
coords = mask
try:
assert coords.shape[0] == 3
except AssertionError:
print(f"Error: Coords must have shape (3, N), but got {coords.shape} instead")

# Generate the list of relevant beta images:
indx = self.reg_of_interest - 1
@@ -132,7 +141,17 @@ def get_residuals(self, mask):
res_range (range): range of to be saved residual images per run
"""
# Sample the relevant time series data
coords = nt.get_mask_coords(mask)
if isinstance(mask, str):
mask = nb.load(mask)
if isinstance(mask, nb.Nifti1Image):
coords = nt.get_mask_coords(mask)
if isinstance(mask, np.ndarray):
coords = mask
try:
assert coords.shape[0] == 3
except AssertionError:
print(f"Error: Coords must have shape (3, N), but got {coords.shape} instead")

data = nt.sample_images(self.rawdata_files, coords, use_dataobj=True)

# Filter and temporal pre-whiten the data