Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions findoutlie/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"""

# Any imports you need
# +++your code here+++

import numpy as np
import nibabel as nib

def dvars(img):
""" Calculate dvars metric on Nibabel image `img`
Expand All @@ -29,4 +29,8 @@ def dvars(img):
# You may be be able to solve this in four lines, without a loop.
# But solve it any way you can.
# This is a placeholder, replace it to write your solution.
raise NotImplementedError('Code up this function')
data = img.get_fdata()
diff = np.diff(data, axis=-1)
dvar = np.sqrt(np.mean(diff.reshape(-1, diff.shape[-1])**2, axis=0))

return dvar