<commit_before>#THIS IS NOT A SCRIPT, MORE OF A COOKBOOK RIGHT NOW

#make (advanced) labels for fsaverage
cd /cluster/kuperberg/SemPrMM/MRI/structurals/subjects/fsaverage/label/
mri_annotation2label --subject fsaverage --hemi lh --annotation lh.aparc.a2009s.annot --labelbase ./aparc2009-lh


#write out a tcl script for so tksurfer makes an image for each label
good = range(1,75)
cmd = 'labl_load aparc2009-lh-%03d.label;save_tiff /cluster/kuperberg/SemPrMM/MRI/scripts/fsaverage_%03d.tiff;labl_remove 0;\n'
a = [cmd % ((g,)*2) for g in good]
bas = ('BA44', 'BA45')
cmd2 = 'labl_load lh.%s.label; save_tiff /cluster/kuperberg/SemPrMM/MRI/scripts/fsaverage_%s.tiff;labl_remove 0;\n'
b = [cmd2 % (ba,ba) for ba in bas]
f = open('blah.txt', 'w')
map(f.writelines, (a,b))
f.close()
!open blah.txt

#run the previously made script
cd /cluster/kuperberg/SemPrMM/MRI/structurals/subjects/fsaverage/label/
tksurfer fsaverage lh inflated -gray -tcl $MRISCRIPT/blah.txt


#make labels
subjects = ('ya1', 'ya2', 'ya3', 'ya4', 'ya5', 'ya6', 'ya7', 'ya8', 'ya9', 'ya10', 'ya12', 'ya13', 'ya15', 'ya16', 'ya17', 'ya18', 'ya19', 'ya20', 'ya21', 'ya22', 'ya23', 'ya24', 'ya25', 'ya26', 'ya27', 'ya29', 'ya30')
cmd = """mri_annotation2label --subject %s --hemi lh --annotation {0}/%s/label/lh.aparc.a2009s.annot --labelbase {0}/%s/label/aparc2009-lh\nmri_annotation2label --subject %s --hemi rh --annotation {0}/%s/label/rh.aparc.a2009s.annot --labelbase {0}/%s/label/aparc2009-rh\n""".format('/cluster/kuperberg/SemPrMM/MRI/structurals/subjects')
a = [cmd % (s, s, s, s, s, s) for s in subjects]
f = open('blah2.sh', 'w')
_ = map(f.writelines, (a))
f.close()
!open blah2.sh



#ROI stuff
# cd /cluster/kuperberg/SemPrMM/MRI/functionals


# space.label.map.thr.sign.roicfg


-contrast All -thresh 1.0 -sign pos

funcroi-config -roi lh.074.cespct.roicfg -label aparc2009-lh-074.label -analysis ya.BaleenHP.spm.sm8.lh -force
funcroi-sess -sf ya.BaleenHP.sessid -d . -roi lh.074.cespct.roicfg
funcroi-table-sess -roi lh.074.cespct.roicfg -sf ya.BaleenHP.sessid -analysis ya.BaleenHP.spm.sm8.lh -contrast Unrelated -o roi_summary/lh.074.cespct.dat 

funcroi-config -roi lh.074.ces.roicfg -label aparc2009-lh-074.label -analysis ya.BaleenHP.spm.sm8.lh -force
funcroi-sess -sf ya.BaleenHP.sessid -d . -roi lh.074.ces.roicfg
funcroi-table-sess -roi lh.074.ces.roicfg -sf ya.BaleenHP.sessid -analysis ya.BaleenHP.spm.sm8.lh -contrast Unrelated -map cespct -o roi_summary/lh.074.ces.dat
diff roi_summary/lh.074.cespct.dat roi_summary/lh.074.ces.dat



####################################
#
# Code below generates three files, config.sh, sess.sh, and table.sh
#
# config.sh - funcroi-config, only call once
# sess.sh - updates, call it with new subjects
# table.sh - doesn't update, call it with new subjects
#
####################################
mask_con = 'All'
mask_map = 'sig'
mask_tail = 'pos'


config_com = []
sess_com = []
table_com = []
i = 1
ii = 1
pars = ('BaleenHP', 'BaleenLP')
space = ('lh', 'rh')
shape = ('fir', 'spm')
labels = ('012', '025', '034', '037', '038', '044', '073', '074') #, 'BA44', 'BA45')
contrasts = ('Unrelated', 'Related')
map = 'cespct'


for par in pars:
    for sp in space:
        for sh in shape:
            if sh == 'fir':
                frame = '6'
            else:
                frame = '0'    
            for label in labels:
                roidef = '.'.join((par, sp, sh, label, 'roicfg'))
                analysis = 'ya.%s.%s.sm8.%s' % (par, sh, sp)
                for contrast in contrasts:
                    output = 'roi_summary/%s' % '.'.join((par, sp, sh, label, map, contrast, 'dat'))
                    #funcoir-table-sess
                    ii += 1
                    if ii > 8:
                        wait1 = 'wait\n'
                        ii = 1
                    else:
                        wait1 = ''
                    table_com.append(' '.join(['funcroi-table-sess',
                                            '-o %s' % output,
                                            '-roi %s' % roidef,
                                            '-analysis %s' % analysis,
                                            '-sf ya.BaleenHP.sessid',
                                            '-d .',
                                            '-contrast %s' % contrast,
                                            '-map %s' % map,
                                            '-frame %s' % frame,
                                            '&',
                                            '\n',
                                            wait1]))
                #funcroi-config
                if len(label) > 3:
                    label_text = 'aparc2009-%s-%s.label' * (sp, label)
                else:
                    label_text = '%s.%s.label' % (sp, label)<commit_msg>Added BA44, BA45 to labels<commit_after>#THIS IS NOT A SCRIPT, MORE OF A COOKBOOK RIGHT NOW

#make (advanced) labels for fsaverage
cd /cluster/kuperberg/SemPrMM/MRI/structurals/subjects/fsaverage/label/
mri_annotation2label --subject fsaverage --hemi lh --annotation lh.aparc.a2009s.annot --labelbase ./aparc2009-lh


#write out a tcl script for so tksurfer makes an image for each label
good = range(1,75)
cmd = 'labl_load aparc2009-lh-%03d.label;save_tiff /cluster/kuperberg/SemPrMM/MRI/scripts/fsaverage_%03d.tiff;labl_remove 0;\n'
a = [cmd % ((g,)*2) for g in good]
bas = ('BA44', 'BA45')
cmd2 = 'labl_load lh.%s.label; save_tiff /cluster/kuperberg/SemPrMM/MRI/scripts/fsaverage_%s.tiff;labl_remove 0;\n'
b = [cmd2 % (ba,ba) for ba in bas]
f = open('blah.txt', 'w')
map(f.writelines, (a,b))
f.close()
!open blah.txt

#run the previously made script
cd /cluster/kuperberg/SemPrMM/MRI/structurals/subjects/fsaverage/label/
tksurfer fsaverage lh inflated -gray -tcl $MRISCRIPT/blah.txt


#make labels
subjects = ('ya1', 'ya2', 'ya3', 'ya4', 'ya5', 'ya6', 'ya7', 'ya8', 'ya9', 'ya10', 'ya12', 'ya13', 'ya15', 'ya16', 'ya17', 'ya18', 'ya19', 'ya20', 'ya21', 'ya22', 'ya23', 'ya24', 'ya25', 'ya26', 'ya27', 'ya29', 'ya30')
cmd = """mri_annotation2label --subject %s --hemi lh --annotation {0}/%s/label/lh.aparc.a2009s.annot --labelbase {0}/%s/label/aparc2009-lh\nmri_annotation2label --subject %s --hemi rh --annotation {0}/%s/label/rh.aparc.a2009s.annot --labelbase {0}/%s/label/aparc2009-rh\n""".format('/cluster/kuperberg/SemPrMM/MRI/structurals/subjects')
a = [cmd % (s, s, s, s, s, s) for s in subjects]
f = open('blah2.sh', 'w')
_ = map(f.writelines, (a))
f.close()
!open blah2.sh



#ROI stuff
# cd /cluster/kuperberg/SemPrMM/MRI/functionals


# space.label.map.thr.sign.roicfg


-contrast All -thresh 1.0 -sign pos

funcroi-config -roi lh.074.cespct.roicfg -label aparc2009-lh-074.label -analysis ya.BaleenHP.spm.sm8.lh -force
funcroi-sess -sf ya.BaleenHP.sessid -d . -roi lh.074.cespct.roicfg
funcroi-table-sess -roi lh.074.cespct.roicfg -sf ya.BaleenHP.sessid -analysis ya.BaleenHP.spm.sm8.lh -contrast Unrelated -o roi_summary/lh.074.cespct.dat 

funcroi-config -roi lh.074.ces.roicfg -label aparc2009-lh-074.label -analysis ya.BaleenHP.spm.sm8.lh -force
funcroi-sess -sf ya.BaleenHP.sessid -d . -roi lh.074.ces.roicfg
funcroi-table-sess -roi lh.074.ces.roicfg -sf ya.BaleenHP.sessid -analysis ya.BaleenHP.spm.sm8.lh -contrast Unrelated -map cespct -o roi_summary/lh.074.ces.dat
diff roi_summary/lh.074.cespct.dat roi_summary/lh.074.ces.dat



####################################
#
# Code below generates three files, config.sh, sess.sh, and table.sh
#
# config.sh - funcroi-config, only call once
# sess.sh - updates, call it with new subjects
# table.sh - doesn't update, call it with new subjects
#
####################################
mask_con = 'All'
mask_map = 'sig'
mask_tail = 'pos'


config_com = []
sess_com = []
table_com = []
i = 1
ii = 1
pars = ('BaleenHP', 'BaleenLP')
space = ('lh', 'rh')
shape = ('fir', 'spm')
labels = ('012', '025', '034', '037', '038', '044', '073', '074') #, 
labels = ('BA44', 'BA45')
contrasts = ('Unrelated', 'Related')
map = 'cespct'


for par in pars:
    for sp in space:
        for sh in shape:
            if sh == 'fir':
                frame = '6'
            else:
                frame = '0'    
            for label in labels:
                roidef = '.'.join((par, sp, sh, label, 'roicfg'))
                analysis = 'ya.%s.%s.sm8.%s' % (par, sh, sp)
                for contrast in contrasts:
                    output = 'roi_summary/%s' % '.'.join((par, sp, sh, label, map, contrast, 'dat'))
                    #funcoir-table-sess
                    ii += 1
                    if ii > 8:
                        wait1 = 'wait\n'
                        ii = 1
                    else:
                        wait1 = ''
                    table_com.append(' '.join(['funcroi-table-sess',
                                            '-o %s' % output,
                                            '-roi %s' % roidef,
                                            '-analysis %s' % analysis,
                                            '-sf ya.BaleenHP.sessid',
                                            '-d .',
                                            '-contrast %s' % contrast,
                                            '-map %s' % map,
                                            '-frame %s' % frame,
                                            '&',
                                            '\n',
                                            wait1]))
                #funcroi-config
                if len(label) < 4:
                    label_text = 'aparc2009-%s-%s.label' % (sp, label)
                else:
                    label_text = '%s.%s.label' % (sp, label)
{'fraction_non_alphanumeric': 0.16694231961959893, 'fraction_numerical': 0.04010750465164358, 'mean_word_length': 1.9176718938480097, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4642114', 'n_tokens_mistral': 3736, 'n_tokens_neox': 3394, 'n_words': 788}