Skip to content

Commit

Permalink
Merge pull request #9 from berkeley-stat159/revert-7-master
Browse files Browse the repository at this point in the history
Revert "added Makefile to verify the data (downloading the tgz file w…
  • Loading branch information
timothy1191xa committed Nov 3, 2015
2 parents d402ec1 + 259507d commit 53cdb89
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1,117 deletions.
6 changes: 2 additions & 4 deletions data/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
data:
wget http://openfmri.s3.amazonaws.com/tarballs/ds005_raw_checksums.txt
wget http://openfmri.s3.amazonaws.com/tarballs/ds005_raw.tgz
tar xvzf ds005_raw.tgz
data:
wget http://www.jarrodmillman.com/rcsds/_downloads/ds107_sub001_highres.nii

validate:
python data.py
7 changes: 0 additions & 7 deletions data/create_dict.py

This file was deleted.

29 changes: 10 additions & 19 deletions data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,23 @@
import os


d = {'ds107_sub001_highres.nii': "fd733636ae8abe8f0ffbfadedd23896c"}

def create_dict(filename):
newDict={}
f=open(filename)
num_lines = sum(1 for line in open(filename))
for line,i in zip(f,range(0,num_lines)):
info = line.split()
newDict[info[1]]=info[0]
return newDict

def generate_file_md5(filename, blocksize=2**20):
m = hashlib.md5()
f= open(filename)
while True:
buf = f.read(blocksize)
if not buf:
break
m.update(buf)
with open(filename, "rb") as f:
while True:
buf = f.read(blocksize)
if not buf:
break
m.update(buf)
return m.hexdigest()


def check_hashes(newDict):
def check_hashes(d):
all_good = True
for k, v in newDict.items():
for k, v in d.items():
digest = generate_file_md5(k)
if v == digest:
print("The file {0} has the correct hash.".format(k))
Expand All @@ -36,6 +29,4 @@ def check_hashes(newDict):
all_good = False
return all_good

if __name__=="__main__":
newDict = create_dict('ds005_raw_checksums.txt')
print(check_hashes(newDict))

Loading

0 comments on commit 53cdb89

Please sign in to comment.