# load matplotlib to show figures in inline mode %pylab inline import numpy as np import nibabel as nb import dicom as dcm from scipy import stats table1 = np.genfromtxt('phenotype.csv', usemask=True, names=True, delimiter=',') table1['Weight'] table2 = np.recfromtxt('phenotype.csv', usemask=True, names=True, delimiter=',') np.mean(table2.Weight) np.std(table2.Weight) _ = hist(table2.Weight[table2.Weight.mask==False], 128) _ = xlabel('Weight') _ = ylabel('Frequency') savefig('task1.png') np.unique1d(table2.Gender) import dicom as dcm from glob import glob fl = glob('/opt/data/NIPYPE_DATA/2475376/TfMRI_breathHold_1400/*.dcm') TR = [] for filename in fl: dcmobj = dcm.read_file(filename) TR.append(float(dcmobj.RepetitionTime)) np.unique1d(TR) img = nb.load('fmri.nii.gz') a = img.get_data() TSNR = np.mean(a, axis=3)/np.var(a, axis=3) TSNR.shape imshow(TSNR[:, :, 32], cmap=cm.hot)