File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 3
3
4
4
# Any imports you need
5
5
# +++your code here+++
6
+ import numpy as np
6
7
7
8
8
9
def dvars (img ):
@@ -29,4 +30,21 @@ def dvars(img):
29
30
# You may be be able to solve this in four lines, without a loop.
30
31
# But solve it any way you can.
31
32
# This is a placeholder, replace it to write your solution.
33
+ data = img .get_fdata ()
34
+ vol_shape = data .shape [:- 1 ]
35
+ n_voxels = np .prod (vol_shape )
36
+
37
+ voxel_by_time = np .reshape (data , (n_voxels , data .shape [- 1 ]))
38
+
39
+ vol_diff = voxel_by_time [...,1 :]- voxel_by_time [...,:- 1 ] # 2D array
40
+ #print(vol_diff.shape())
41
+ print (vol_diff )
42
+ #vol_diff_1D=vol_diff.flatten()
43
+ dvar_val = np .sqrt (np .mean (vol_diff ** 2 , axis = 0 ))
44
+ #print(dvar_val.shape())
45
+ print (dvar_val )
46
+ return dvar_val
47
+
48
+
49
+
32
50
raise NotImplementedError ('Code up this function' )
You can’t perform that action at this time.
0 commit comments