<commit_before>import pylab
import numpy as N

from neuroimaging.core.image.image import Image
from neuroimaging.ui.visualization.viewer import BoxViewer

contrast_map = {'sentence': 'sen',
                'speaker': 'spk',
                'overall': 'all',
                'interaction': 'snp'}

which_map = {'contrasts': 'mag',
             'delays': 'del'}

stat_map = {'t':'t',
            'effect': 'ef',
            'sd': 'sd'}

def fmristat_run(subject=3, run=3, which='contrasts', contrast='overall', stat='t', **kw):
    contrast = contrast_map[contrast]
    which = which_map[which]
    stat = stat_map[stat]

    runfile = '/home/analysis/FIAC/fmristat/fiac%d/fiac%d_fonc%d_%s_%s_%s.img' % (subject, subject, run, contrast, which, stat)
    
    return Image(runfile)

def fmristat_rho(subject=3, run=3):

    runfile = '/home/analysis/FIAC/fmristat/fiac%d/fiac%d_fonc%d_all_cor.img' % (subject, subject, run)
    
    return Image(runfile)



def nipy_run(subject=3, run=3, which='contrasts', contrast='overall', stat='t', **extra):

    runfile = '/home/analysis/FIAC/fiac%d/fonc%d/fsl/fmristat_run/%s/%s/%s.img' % (subject, run, which, contrast, stat)

    return Image(runfile)


def nipy_rho(subject=3, run=3):

    runfile = '/home/analysis/FIAC/fiac%d/fonc%d/fsl/fmristat_run/rho.img' % (subject, run)

    return Image(runfile)

def mask(subject=3, run=3, **kw):
    runfile = '/home/analysis/FIAC/fiac%d/fonc%d/fsl/mask.img' % (subject, run)

    return Image(runfile)

import optparse

parser = optparse.OptionParser()

parser.add_option('', '--which', help='contrasts or delays', dest='which',
                      default='contrasts')
parser.add_option('', '--run', help='which run?', dest='run', default=1, type='int')
parser.add_option('', '--subject', help='which subject?', dest='subject', default=0, type='int')
parser.add_option('', '--stat', help='t, sd or effect?', dest='stat', default='t')
parser.add_option('', '--contrast', help='overall, sentence, speaker, or interaction', dest='contrast', default='overall')
parser.add_option('', '--vmin', help='min for colorbar', dest='m', type='float')
parser.add_option('', '--vmax', help='max for colorbar', dest='M', type='float')
parser.add_option('', '--rho', help='compare AR(1) coefs', dest='rho', action='store_true', default=False)

options, args = parser.parse_args()
options = parser.values.__dict__

print options

if not parser.values.rho:
    x = nipy_run(**options)
    y = fmristat_run(**options)
else:
    x = nipy_rho(**options)
    y = fmristat_rho(**options)
    
m = mask(**options)

vx = BoxViewer(x, mask=m, colormap='spectral')
vy = BoxViewer(y, mask=m, colormap='spectral')

if options['m'] is not None:
    vx.m = options['m']
    vy.m = options['m']

if options['M'] is not None:
    vx.M = options['M']
    vy.M = options['M']

vx.draw()
vy.draw()

X = x.readall() * m.readall()
X.shape = N.product(X.shape)

Y = y.readall() * m.readall()
Y.shape = N.product(Y.shape)<commit_msg>in progress: modifying compare_keith.py to be part of compare.py<commit_after>import pylab
import numpy as N

from neuroimaging.core.image.image import Image
from neuroimaging.ui.visualization.viewer import BoxViewer

import keith

def nipy_run(subject=3, run=3, which='contrasts', contrast='overall', stat='t', **extra):

    runfile = '/home/analysis/FIAC/fiac%d/fonc%d/fsl/fmristat_run/%s/%s/%s.img' % (subject, run, which, contrast, stat)

    return Image(runfile)


def nipy_rho(subject=3, run=3):

    runfile = '/home/analysis/FIAC/fiac%d/fonc%d/fsl/fmristat_run/rho.img' % (subject, run)

    return Image(runfile)

def mask(subject=3, run=3, **kw):
    runfile = '/home/analysis/FIAC/fiac%d/fonc%d/fsl/mask.img' % (subject, run)

    return Image(runfile)

import optparse

parser = optparse.OptionParser()

parser.add_option('', '--which', help='contrasts or delays', dest='which',
                      default='contrasts')
parser.add_option('', '--run', help='which run?', dest='run', default=1, type='int')
parser.add_option('', '--subject', help='which subject?', dest='subject', default=0, type='int')
parser.add_option('', '--stat', help='t, sd or effect?', dest='stat', default='t')
parser.add_option('', '--contrast', help='overall, sentence, speaker, or interaction', dest='contrast', default='overall')
parser.add_option('', '--vmin', help='min for colorbar', dest='m', type='float')
parser.add_option('', '--vmax', help='max for colorbar', dest='M', type='float')
parser.add_option('', '--rho', help='compare AR(1) coefs', dest='rho', action='store_true', default=False)

options, args = parser.parse_args()
options = parser.values.__dict__

print options

if not parser.values.rho:
    x = nipy_run(**options)
    y = keith.run(**options)
else:
    x = nipy_rho(**options)
    y = keith.rho(**options)
    
m = mask(**options)

vx = BoxViewer(x, mask=m, colormap='spectral')
vy = BoxViewer(y, mask=m, colormap='spectral')

if options['m'] is not None:
    vx.m = options['m']
    vy.m = options['m']

if options['M'] is not None:
    vx.M = options['M']
    vy.M = options['M']

vx.draw()
vy.draw()

X = x.readall() * m.readall()
X.shape = N.product(X.shape)

Y = y.readall() * m.readall()
Y.shape = N.product(Y.shape)
{'fraction_non_alphanumeric': 0.19280107218073905, 'fraction_numerical': 0.00421213861765269, 'mean_word_length': 4.282103134479272, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '752279', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1878, 'n_words': 406}