Esempio n. 1
0
def screen_data_dirnme(in4d, outdir):
    """uses nipy diagnostic code to screen the data for
    outlier values and saves results to three images
    mean, std, pca, in same dir as original file(s)"""
    img = nipy.load_image(in4d)
    result = diag.screen(img)
    # save mean, std, pca
    pth, nme = os.path.split(in4d)
    stripnme = nme.split('.')[0]

    pcafile = os.path.join(outdir, 'QA-PCA_%s.nii.gz' % (nme))
    meanfile = os.path.join(outdir, 'QA-MEAN_%s.nii.gz' % (nme))
    stdfile = os.path.join(outdir, 'QA-STD_%s.nii.gz' % (nme))
    nipy.save_image(result['mean'], meanfile)
    nipy.save_image(result['std'], stdfile)
    nipy.save_image(result['pca'], pcafile)
    print 'saved: %s\n \t%s\n \t%s\n' % (pcafile, meanfile, stdfile)
Esempio n. 2
0
def screen_data_dirnme(in4d, outdir):
    """uses nipy diagnostic code to screen the data for
    outlier values and saves results to three images
    mean, std, pca, in same dir as original file(s)"""
    img = nipy.load_image(in4d)
    result = diag.screen(img)
    # save mean, std, pca
    pth, nme = os.path.split(in4d)
    stripnme = nme.split('.')[0]
    
    pcafile = os.path.join(outdir,
                           'QA-PCA_%s.nii.gz'%(nme))
    meanfile = os.path.join(outdir,
                            'QA-MEAN_%s.nii.gz'%(nme))
    stdfile = os.path.join(outdir,
                           'QA-STD_%s.nii.gz'%(nme))
    nipy.save_image(result['mean'], meanfile)
    nipy.save_image(result['std'], stdfile)
    nipy.save_image(result['pca'], pcafile)
    print 'saved: %s\n \t%s\n \t%s\n'%(pcafile, meanfile, stdfile)
Esempio n. 3
0
def test_screen():
    img = ni.load_image(funcfile)
    res = nad.screen(img)
    yield assert_equal(res['mean'].ndim, 3)
    yield assert_equal(res['pca'].ndim, 4)
    yield assert_equal(sorted(res.keys()),
                       ['max', 'mean', 'min',
                        'pca', 'pca_res',
                        'std', 'ts_res'])
    data = np.asarray(img)
    yield assert_array_equal(np.max(data, axis=-1),
                             res['max'])
    yield assert_array_equal(np.mean(data, axis=-1),
                             res['mean'])
    yield assert_array_equal(np.min(data, axis=-1),
                             res['min'])
    yield assert_array_equal(np.std(data, axis=-1),
                             res['std'])
    pca_res = nad.pca.pca(data, axis=-1, standardize=False, ncomp=10)
    for key in pca_res:
        yield assert_array_equal(pca_res[key], res['pca_res'][key])
    ts_res = nad.time_slice_diffs(data)
    for key in ts_res:
        yield assert_array_equal(ts_res[key], res['ts_res'][key])