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

Adjust io.load_nifti_get_mask to expect 4 dimensions in timeseries and 3 in masks by default #48

Merged
merged 1 commit into from
Dec 23, 2022
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
10 changes: 8 additions & 2 deletions nigsp/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ def load_nifti_get_mask(fname, is_mask=False, ndim=4):
is_mask : bool, optional
If the file contains a mask.
Default: False
ndim : int
The number of dimensions expected in the mask
ndim : int or None, optional
The number of dimensions expected in the data.
If None (default), 4 dimensions are expected, unless is_mask=True.
In the latter case, 3 dimensions will be checked.

Returns
-------
Expand All @@ -220,6 +222,10 @@ def load_nifti_get_mask(fname, is_mask=False, ndim=4):
LGR.info(f"Loading {fname}.")
img = nib.load(fname)
data = img.get_fdata()

if ndim is None:
ndim = 3 if is_mask else 4

data = check_nifti_dim(fname, data, dim=ndim)

if is_mask:
Expand Down