From 5e9d642e7ad4b40dad85b506612a0bff901f37ab Mon Sep 17 00:00:00 2001 From: Kathleen Williams Date: Thu, 24 Aug 2023 15:51:18 +0200 Subject: [PATCH] added code for getting spm globals modified according to instructions --- spm_funcs.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/spm_funcs.py b/spm_funcs.py index 450c1ab..1e76241 100644 --- a/spm_funcs.py +++ b/spm_funcs.py @@ -54,8 +54,17 @@ 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]): + vol = data[..., i] + spm_vals.append(spm_global(vol)) + return spm_vals # Return the result. + def main():