Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You should put the code in this `findoutlie` directory on your Python PATH.

This README file has instructions on how to get, validate and process the data.

# Added this new line.
# Instructions

## Get the data

Expand Down
40 changes: 0 additions & 40 deletions data/group-00/hash_list.txt

This file was deleted.

40 changes: 40 additions & 0 deletions data/group-02/hash_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
08987f4b8332c21199e45497a9fa2c6857e5a8bc group-02/sub-01/func/sub-01_task-taskzero_run-01_bold.nii.gz
5c7fa277512e7e8d653b0ea70c90806f09176485 group-02/sub-01/func/sub-01_task-taskzero_run-01_events.tsv
b0d39329d2aaa89c75d43d942979b8ed6d496f98 group-02/sub-01/func/sub-01_task-taskzero_run-02_bold.nii.gz
c69427bea1a5029adf82c7cc340477aef3ac0066 group-02/sub-01/func/sub-01_task-taskzero_run-02_events.tsv
4cf4c45e348a1a7c23f19c411ba017b19cb07d84 group-02/sub-02/func/sub-02_task-taskzero_run-01_bold.nii.gz
fdb93d39f4011a0ab6076455d9216f3b336f411d group-02/sub-02/func/sub-02_task-taskzero_run-01_events.tsv
e2b6301873607a2a0a2caf72d3d6e2fe5630a0c8 group-02/sub-02/func/sub-02_task-taskzero_run-02_bold.nii.gz
441a8aaf4d18a7d0782e45f59672e1ea721e2691 group-02/sub-02/func/sub-02_task-taskzero_run-02_events.tsv
ee182e71d9dd56aa7b6a68cf81f1eaf51eaf88f0 group-02/sub-03/func/sub-03_task-taskzero_run-01_bold.nii.gz
e9d7ce1ee39f4d851cc76ac9d9f7b40cda698d1f group-02/sub-03/func/sub-03_task-taskzero_run-01_events.tsv
9ca6834e78d044d459aebc9cdda4c21928419ab9 group-02/sub-03/func/sub-03_task-taskzero_run-02_bold.nii.gz
613597b36a145f8621b7d9a49d46613afc35de45 group-02/sub-03/func/sub-03_task-taskzero_run-02_events.tsv
42cb10dd9691e3282a00d900988c6b367d8a32bc group-02/sub-04/func/sub-04_task-taskzero_run-01_bold.nii.gz
84135951864c7b73959b8f5a4f016195eb3842dc group-02/sub-04/func/sub-04_task-taskzero_run-01_events.tsv
3d2256f313dc6256d2f8ebd8c1b1154a59f6449c group-02/sub-04/func/sub-04_task-taskzero_run-02_bold.nii.gz
b636ec0c2ea45425656279085f34910c8a2fa550 group-02/sub-04/func/sub-04_task-taskzero_run-02_events.tsv
e5295642bc528d1c081ac3b84379263e8f35842d group-02/sub-05/func/sub-05_task-taskzero_run-01_bold.nii.gz
4744b8bf85e25df25b95d0e3537714c65b465556 group-02/sub-05/func/sub-05_task-taskzero_run-01_events.tsv
72e2b366f78c58b480518248f6e0cf8b3bcb7ae2 group-02/sub-05/func/sub-05_task-taskzero_run-02_bold.nii.gz
6864445fd0d5a400ffc0107da767651959747b91 group-02/sub-05/func/sub-05_task-taskzero_run-02_events.tsv
1907d02c1e271d1a9f952a5cf7cbf2dfa02df86f group-02/sub-06/func/sub-06_task-taskzero_run-01_bold.nii.gz
500191bbc5b64a75e93a2077a694aaf0ad1a4672 group-02/sub-06/func/sub-06_task-taskzero_run-01_events.tsv
52d9e1ccdba5545cc2f61cbe91e5fda83812043c group-02/sub-06/func/sub-06_task-taskzero_run-02_bold.nii.gz
2e9e990c9f26047ffaec5015d7bc85120a4decfd group-02/sub-06/func/sub-06_task-taskzero_run-02_events.tsv
f076705b6b80286a96f81f916743350ed6590d2b group-02/sub-07/func/sub-07_task-taskzero_run-01_bold.nii.gz
66ea8a008eafc46e88a06aaeeb491dc89060c2b1 group-02/sub-07/func/sub-07_task-taskzero_run-01_events.tsv
9650559e6c24c74159faa4fbc8908852133a530b group-02/sub-07/func/sub-07_task-taskzero_run-02_bold.nii.gz
931a08702e5b25a438dcd30be743b6ab9b31546e group-02/sub-07/func/sub-07_task-taskzero_run-02_events.tsv
9c89c33a013ea60a7770e28c35bd5cee900694c1 group-02/sub-08/func/sub-08_task-taskzero_run-01_bold.nii.gz
20faad141870c86e6a69aac9d6c7f414001db135 group-02/sub-08/func/sub-08_task-taskzero_run-01_events.tsv
6b999ac8af50c3e43e0a2b1cd0016dbb62f1e3fe group-02/sub-08/func/sub-08_task-taskzero_run-02_bold.nii.gz
ab7eb648799ee08717211da3862b25a371545ae4 group-02/sub-08/func/sub-08_task-taskzero_run-02_events.tsv
75470b95aed4f935f2319da6f310d32f7e1d259b group-02/sub-09/func/sub-09_task-taskzero_run-01_bold.nii.gz
065cc29a50942c54510c58c88e0f2c221e8fa584 group-02/sub-09/func/sub-09_task-taskzero_run-01_events.tsv
3e320f57894e56213d7ea4a5f7d19674d3b41bd8 group-02/sub-09/func/sub-09_task-taskzero_run-02_bold.nii.gz
bd135692cf2477793315c493528d79dba8d62936 group-02/sub-09/func/sub-09_task-taskzero_run-02_events.tsv
5b9872cafb1b8375f1b9de99140386f2f349e384 group-02/sub-10/func/sub-10_task-taskzero_run-01_bold.nii.gz
9e4e364f6cdbd5e0f797534fab618cbb49490001 group-02/sub-10/func/sub-10_task-taskzero_run-01_events.tsv
5941418f1b555902a8451aad5864cea03f0272c5 group-02/sub-10/func/sub-10_task-taskzero_run-02_bold.nii.gz
689773a733b9456b3016167262843c733edd7bd9 group-02/sub-10/func/sub-10_task-taskzero_run-02_events.tsv
14 changes: 7 additions & 7 deletions findoutlie/detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

# Any imports you need
# +++your code here+++
import numpy as np


def iqr_detector(measures, iqr_proportion=1.5):
Expand Down Expand Up @@ -45,9 +45,9 @@ def iqr_detector(measures, iqr_proportion=1.5):
A boolean vector of same length as `measures`, where True means the
corresponding value in `measures` is an outlier.
"""
# Any imports you need
# Hints:
# * investigate np.percentile
# * You'll likely need np.logical_or
# https://textbook.nipraxis.org/numpy_logical.html
# +++your code here+++
Q1, Q3 = np.percentile(measures, [25, 75])
IQR = Q3 - Q1
lower_lim = Q1 - IQR * iqr_proportion
upper_lim = Q3 + IQR * iqr_proportion
is_outlier = np.logical_or(measures<lower_lim, measures>upper_lim)
return is_outlier
12 changes: 6 additions & 6 deletions findoutlie/metrics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
""" Scan outlier metrics
"""

# Any imports you need
# +++your code here+++
import numpy as np


def dvars(img):
Expand All @@ -26,7 +25,8 @@ def dvars(img):
# In [3]: np.mean(arr, axis=1)
# Out[2]: array([3., 6.])
#
# 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()
vol_diff = np.diff(data, axis=3) # [x,y,z,t-1]
dvar_val = np.sqrt(np.mean(vol_diff ** 2, axis=(0,1,2)))

return dvar_val
25 changes: 15 additions & 10 deletions scripts/validate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ def file_hash(filename):
SHA1 hexadecimal hash string for contents of `filename`.
"""
# Open the file, read contents as bytes.
pth = Path(filename)
file_bytes = pth.read_bytes()
# Calculate, return SHA1 has on the bytes from the file.
# This is a placeholder, replace it to write your solution.
raise NotImplementedError(
'This is just a template -- you are expected to code this.')
return hashlib.sha1(file_bytes).hexdigest()



def validate_data(data_directory):
Expand All @@ -48,13 +49,17 @@ def validate_data(data_directory):
``data_hashes.txt`` file.
"""
# Read lines from ``data_hashes.txt`` file.
# Split into SHA1 hash and filename
# Calculate actual hash for given filename.
# If hash for filename is not the same as the one in the file, raise
# ValueError
# This is a placeholder, replace it to write your solution.
raise NotImplementedError(
'This is just a template -- fill out the template with code.')
hash_path = Path(data_directory) / 'hash_list.txt'
with open(hash_path, 'r') as f:
for line in f.readlines():
# Split into SHA1 hash and filename
read_hash, filename = line.strip().split()
# Calculate actual hash for given filename.
true_hash = file_hash(hash_path.parent.parent / filename)
# If hash for filename is not the same as the one in the file, raise
if true_hash != read_hash:
raise ValueError("Hash value not as recorded.")



def main():
Expand Down