Skip to content

Insterted a fix #42

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/first-pull-request.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 20 additions & 2 deletions spm_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,26 @@ def get_spm_globals(fname):
spm_vals : array
SPM global metric for each 3D volume in the 4D image.
"""
# +++your code here+++
# return
# Load the 4D image using nibabel
img = nib.load(fname)

# Initialize an empty list to store SPM metric values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe too many comments? Too many comments can make the code harder to read, because there is more text. Still, too many comments is almost invariable better than not enough.

spm_vals = []

# Iterate through the volumes in the 4D image
for volume_idx in range(img.shape[-1]): # Use integer indexing
volume = img.slicer[..., volume_idx] # Use integer indexing

# Calculate SPM global metric for the current volume
spm_value = spm_global(volume.get_fdata())

# Append the SPM metric value to the list
spm_vals.append(spm_value)

# Convert the list to a NumPy array
spm_vals = np.array(spm_vals)

return spm_vals


def main():
Expand Down