from datamind.core import DF from datamind.stats import VBA # Optional PATH to mask and common prefix path to images import os.path BASEPATH=os.path.join(os.environ['HOME'],"Data/07Deprim/") IMAGESPATH=BASEPATH+"IRM/Data/" MASKPATH=BASEPATH+"IRM/Mask/mask.img" tab=DF.read("tuples.csv")[:,['IRM_G_file', 'Response', 'Sex','Age']] print tab #IRM_G_file Response Sex Age #smwc1S6182.img N 2.0 45.0 #smwc1S7302.img N 2.0 44.0 #.... . ... .... #smwc1S10140.img Y 1.0 38.0 #smwc1S10291.img Y 2.0 49.5 #smwc1E10590.img Y 2.0 39.5 # If the table contain the full path, Y_common_prefix_url is optional m=VBA(tab,mask_url=MASKPATH,Y_common_prefix_url=IMAGESPATH) print m.yX #url Response_N Response_Y Sex Age #smwc1S6182.img 1.0 0.0 2.0 45.0 #smwc1S7302.img 1.0 0.0 2.0 44.0 #.............. ... ... ... .... #smwc1S10291.img 0.0 1.0 2.0 49.5 #smwc1E10590.img 0.0 1.0 2.0 39.5 m.fit() m.contrast([1,-1,0,0]) t, p=m.test() m.save("/tmp/test1") #ls /tmp/test1.* #/tmp/test1.minf /tmp/test1.model.h5 /tmp/test1.yX.csv # # test1.minf essentially contains urls (mask, output dir) # test1.yX.csv contains the design matrix & url to images # test1.model.h5 model parameters beta, s2 etc... m.saveVol(t,"t") m2=VBA("/tmp/test1") m2.contrast([1,-1,0,0]) m2.save("/tmp/test2") t2, p2=m2.test() m2.saveVol(t2,"t") import numpy as N N.max(N.abs(t-t2))