def test_loadnib_dict(): # create test img t_data = np.array([1,2,3]) t_dict = {'testnib': t_data} img = nib.Nifti1Image(t_data, np.eye(4)) nib.save(img,'testnib.nii.gz') # my function my_dict = loadnib_dict('testnib.nii.gz', 'testnib') assert (list(t_dict.keys())[0] == list(my_dict.keys())[0]) assert_array_equal(list(t_dict.values())[0], list(my_dict.values())[0])
dvarsfile=txtpath+'dvars.txt' dvarsfigname=pathtofig+'dvars_sub'+`i`+'run'+`j`+'.png' dvars_dict = loadtxt_dict(dvarsfile, dvarsfigname) dvars_outliers = dvars_out['sub'+`i`+'run'+`j`] plot_dvars(dvars_dict, dvars_outliers, saveit=True) # fd path and name, call function fdfile=txtpath+'fd.txt' fdfigname=pathtofig+'fd_sub'+`i`+'run'+`j`+'.png' fd_dict = loadtxt_dict(fdfile, fdfigname) fd_outliers = fd_out['sub'+`i`+'run'+`j`] plot_fd(fd_dict, fd_outliers, saveit=True) # mean path and name, call function niipath=pathtodata+'ds005/sub00'+`i`+'/BOLD/task001_run00'+`j` meandata=niipath+'/bold.nii.gz' meanfigname=pathtofig+'mean_sub'+`i`+'run'+`j`+'.png' data_dict = loadnib_dict(meandata, meanfigname) plot_meanSig(data_dict, saveit=True) for i in range(10,17): for j in range(1,4): # set general path for reaching dvars and fd files # also path for saving files txtpath=pathtodata+'ds005/sub0'+`i`+'/BOLD/task001_run00'+`j`+'/QA/' # dvars path and name, call function dvarsfile=txtpath+'dvars.txt' dvarsfigname=pathtofig+'dvars_sub'+`i`+'run'+`j`+'.png' dvars_dict = loadtxt_dict(dvarsfile, dvarsfigname) dvars_outliers = dvars_out['sub'+`i`+'run'+`j`] plot_dvars(dvars_dict, dvars_outliers, saveit=True) # fd path and name, call function fdfile=txtpath+'fd.txt'