<jupyter_start><jupyter_text>Functional data<jupyter_code>for idx, subject_id in enumerate(subject_ids[:1]):
    
    sub_idx = '%02d' % (idx+1)
    
    path = os.path.join(os.environ['BIAS'], 'data', 'raw', 'sub-{sub_idx}'.format(**locals()), 'func')
    
    if not os.path.exists(path):
        os.makedirs(path)
        
    for run in [1,2,3]:
        run_str = '%02d' % run
        old_fn = '/home/gdholla1/projects/bias/data/raw/{subject_id}/run{run}.nii'.format(**locals())
        new_fn = os.path.join(path, 'sub-{sub_idx}_task-randomdotmotion_run-{run_str}_bold.nii'.format(**locals()))
        
#         print old_fn, new_fn

        if os.path.exists(new_fn):
            os.remove(new_fn)

        if os.path.exists(old_fn):
            os.link(old_fn, new_fn)<jupyter_output><empty_output><jupyter_text>Field maps<jupyter_code>for idx, subject_id in enumerate(subject_ids[:]):
    
    sub_idx = '%02d' % (idx+1)
    
    path = os.path.join(os.environ['BIAS'], 'data', 'raw', 'sub-{sub_idx}'.format(**locals()), 'fmap')
    
    if not os.path.exists(path):
        os.makedirs(path)
        
    old_fn = '/home/gdholla1/projects/bias/data/raw/{subject_id}/fieldmap_te6.nii'.format(**locals())
    new_fn = os.path.join(path, 'sub-{sub_idx}_magnitude1.nii'.format(**locals()))
    
    if os.path.exists(new_fn):
        os.remove(new_fn)

    if os.path.exists(old_fn):
        os.link(old_fn, new_fn)
    
    old_fn = '/home/gdholla1/projects/bias/data/raw/{subject_id}/fieldmap_te7.02_magnitude.nii'.format(**locals())
    new_fn = os.path.join(path, 'sub-{sub_idx}_magnitude2.nii'.format(**locals()))    
 
    if os.path.exists(new_fn):
        os.remove(new_fn)

    if os.path.exists(old_fn):
        os.link(old_fn, new_fn)

    old_fn = '/home/gdholla1/projects/bias/data/raw/{subject_id}/fieldmap_te7.02_phase.nii'.format(**locals())
    new_fn = os.path.join(path, 'sub-{sub_idx}_phasediff.nii'.format(**locals()))        
    
    
    if os.path.exists(new_fn):
        os.remove(new_fn)

    if os.path.exists(old_fn):
        os.link(old_fn, new_fn)<jupyter_output><empty_output><jupyter_text>Masks<jupyter_code>for idx, subject_id in enumerate(subject_ids):
    
    sub_idx = '%02d' % (idx+1)
    
    path = os.path.join(os.environ['BIAS'], 'data', 'derivatives', 'sub-{sub_idx}'.format(**locals()), 'masks', 'FLASH_space')
    
    if not os.path.exists(path):
        os.makedirs(path)
    
    
    for mask in ['STh_L', 'STh_R']:
        old_fn = '/home/gdholla1/data/bias_task/masks/flash_std/{subject_id}_{mask}.nii.gz'.format(**locals())
        
        new_fn = os.path.join(path, 'sub-{sub_idx}_mask-{mask}.nii.gz'.format(**locals()))

        if os.path.exists(new_fn):
            os.remove(new_fn)

        if os.path.exists(old_fn):
            os.link(old_fn, new_fn)<jupyter_output><empty_output><jupyter_text>T1-weighted<jupyter_code>for idx, subject_id in enumerate(subject_ids):
    
    sub_idx = '%02d' % (idx+1)
    
    path = os.path.join(os.environ['BIAS'], 'data', 'raw', 'sub-{sub_idx}'.format(**locals()), 'anat')
    
    if not os.path.exists(path):
        os.makedirs(path)
        
    old_fn = '/home/gdholla1/data/bias_task/t1_weighted/{subject_id}.nii.gz'.format(**locals())
    new_fn = os.path.join(path, 'sub-{sub_idx}_T1w.nii.gz'.format(**locals()))
        

    os.link(old_fn, new_fn)<jupyter_output><empty_output><jupyter_text>Behavioral Data<jupyter_code>import pandas

data = pandas.read_pickle('/home/gdholla1/data/bias_task/behavior/behavior.pandas')
data['subj_idx'] = data.subj_idx.map(dict([(e[1], e[0]+1) for e in enumerate(subject_ids)]))
data.groupby(['subj_idx', 'subj_idx_exp']).size()
zip([(e[0]+1, e[1]) for e in enumerate(subject_ids)])
data.to_pickle('/home/gdholla1/bias/data/behavior/behavior.pandas')
data.to_csv('/home/gdholla1/bias/data/behavior/behavior.csv')<jupyter_output><empty_output><jupyter_text>FLASH group space<jupyter_code>!mkdir /home/gdholla1/projects/bias/data/FLASH_group_space/
from nipype.interfaces import ants
for idx, subject_id in enumerate(subject_ids):
    
    sub_idx = '%02d' % (idx+1)
    
    path = os.path.join(os.environ['BIAS'], 'data', 'FLASH_group_space', 'sub-{sub_idx}'.format(**locals()))
    
    if not os.path.exists(path):
        os.makedirs(path)
        
    old_fn = '/home/gdholla1/data/ERC_FLASH_template_ants/FLASH2group/_subject_id_{subject_id}/transformComposite.h5'.format(**locals())
    new_fn = os.path.join(path, 'sub-{sub_idx}_flash2group.h5'.format(**locals()))
        

    if os.path.exists(new_fn):
        os.remove(new_fn)

    if os.path.exists(old_fn):
        os.link(old_fn, new_fn)
for idx, subject_id in enumerate(subject_ids):
    
    sub_idx = '%02d' % (idx+1)
    
    path = os.path.join(os.environ['BIAS'], 'data', 'FLASH_group_space', 'sub-{sub_idx}'.format(**locals()))
    
    if not os.path.exists(path):
        os.makedirs(path)
        
    old_fn = '/home/gdholla1/data/ERC_FLASH_template_ants/group2flash/_subject_id_{subject_id}/transformInverseComposite.h5'.format(**locals())
    new_fn = os.path.join(path, 'sub-{sub_idx}_group2flash.h5'.format(**locals()))
        

    if os.path.exists(new_fn):
        os.remove(new_fn)

    if os.path.exists(old_fn):
        os.link(old_fn, new_fn)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1764262850687253, 'fraction_numerical': 0.01167388439088684, 'mean_word_length': 3.437761069340017, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '156649', 'license': 'MIT', 'n_tokens_mistral': 2171, 'n_tokens_neox': 2068, 'n_words': 240, 'path': 'notebooks/other/Organize data to BIDS.ipynb', 'repo_name': 'Gilles86/bias_project', 'size': '5311'}