From e03ff59806efe6b039a7ad468915b123b1a23fe6 Mon Sep 17 00:00:00 2001 From: hugofluhr Date: Thu, 5 May 2022 09:32:48 +0200 Subject: [PATCH 1/2] Ported the changes from previous exercise --- spm_funcs.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spm_funcs.py b/spm_funcs.py index 450c1ab..dacf0b5 100644 --- a/spm_funcs.py +++ b/spm_funcs.py @@ -54,8 +54,13 @@ def get_spm_globals(fname): spm_vals : array SPM global metric for each 3D volume in the 4D image. """ - # +++your code here+++ - # return + img = nib.load(fname) + data = img.get_fdata() + 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(): From 4932855511d9a1a5f00f3e023432b46a9f2588e1 Mon Sep 17 00:00:00 2001 From: hugofluhr Date: Thu, 5 May 2022 09:46:50 +0200 Subject: [PATCH 2/2] Renamed one variable and converted output of get_spm_globabls to numpy.array (was list) --- spm_funcs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spm_funcs.py b/spm_funcs.py index dacf0b5..352307e 100644 --- a/spm_funcs.py +++ b/spm_funcs.py @@ -57,10 +57,10 @@ def get_spm_globals(fname): img = nib.load(fname) data = img.get_fdata() spm_vals = [] - for i in range(data.shape[-1]): - vol = data[..., i] + for t in range(data.shape[-1]): + vol = data[..., t] spm_vals.append(spm_global(vol)) - return spm_vals # Return the result. + return np.array(spm_vals) # Return the result. def main():