From 1c101a438a5b8be8a5a65a76d8fec35a60826e94 Mon Sep 17 00:00:00 2001 From: oliviakowalczyk Date: Fri, 26 Aug 2022 12:01:34 +0100 Subject: [PATCH] get_spm_globals added --- spm_funcs.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spm_funcs.py b/spm_funcs.py index 450c1ab..014417d 100644 --- a/spm_funcs.py +++ b/spm_funcs.py @@ -54,8 +54,16 @@ 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 image given by "fname". + img = nib.load(fname) + #- Get the data + data = img.get_fdata() + #- Calculate the SPM global value for each volume. + spm_vals = [] + for vol in range(data.shape[-1]): + glob = spm_global(data[..., vol]) + spm_vals.append(glob) + return spm_vals # Return the result. def main():