From fa5626cd7e12b86fb88103db0ecbbeb709e7c7cc Mon Sep 17 00:00:00 2001 From: Luke Jelen Date: Thu, 25 Aug 2022 15:22:39 +0100 Subject: [PATCH] Fixes to the SPM function script --- spm_funcs.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spm_funcs.py b/spm_funcs.py index 450c1ab..ad87e83 100644 --- a/spm_funcs.py +++ b/spm_funcs.py @@ -54,9 +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 i in range(data.shape[-1]): + volume = data[:, :, :, i] + spm_vals.append(spm_global(volume)) + return spm_vals # Return the result. def main(): # This function run when file executed as a script