<jupyter_start><jupyter_text>func2std Code<jupyter_code>os.chdir('/home1/varunk/Autism-Connectome-Analysis-bids-related/')
# Node for applying xformation matrix to functional data
func2std_xform = Node(FLIRT(output_type='NIFTI', 
                         apply_xfm=True), name="func2std_xform")


in_file = '/home1/varunk/results_again_again/test/0050002_fc_map.nii.gz'
ref = '/home1/varunk/results_again_again/test/MNI152_T1_2mm_brain_resample.nii'
# ref = '../results_again_again/test/MNI152_T1_3mm.nii.gz'
# ref = '/home1/varunk/results_again_again/test/MNI152_T1_3mm.nii'
mat_file = '/home1/varunk/results_again_again/test/sub-0050002_task-rest_run-1_bold_roi_st_mcf_mean_bet_flirt_sub-0050002_T1w_resample_brain_flirt.mat'

# out_file = '/home1/varunk/results_again_again/test/sub-0050002_std.nii.gz'
# /home1/varunk/results_again_again/test/MNI152_T1_3mm.nii.gz
# import nibabel as nib
# brain_data = nib.load(ref)
# brain = brain_data.get_data()

# brain_with_header = nib.Nifti1Image(brain, affine=brain_data.affine,header = brain_data.header)
# nib.save(brain_with_header,'../results_again_again/test/MNI152_T1_3mm.nii.gz')
func2std_xform.inputs.in_file = in_file
func2std_xform.inputs.reference = ref
func2std_xform.inputs.in_matrix_file = mat_file
# func2std_xform.inputs.out_file = out_file
func2std_xform.inputs
result = func2std_xform.run()
# applyxfm = fsl.ApplyXfm()
# applyxfm.inputs.in_file = in_file
# applyxfm.inputs.in_matrix_file =mat_file
# # applyxfm.inputs.out_file = 'newfile.nii'
# applyxfm.inputs.reference = ref
# applyxfm.inputs.apply_xfm = True
# result = applyxfm.run() 

# func2std_xform.inputs

# (maskfunc4mean, std2func_xform, [(('out_file','reference'))]),           
                                
# (resample_atlas, std2func_xform, [('out_file','in_file')] ), 
                  
# # Now, applying the inverse matrix
                  
# (inv_mat, std2func_xform, [('out_file','in_matrix_file')]), # output: Atlas in func space
X = np.load('../results_again_again/fc_datasink/pearcoff_motionRegress0filt0global0/fc_map_brain_file_list.npy')
X<jupyter_output><empty_output><jupyter_text>Reading CSV using pandas<jupyter_code>import pandas as pd
df = pd.read_csv('/home1/varunk/data/ABIDE1/RawDataBIDs/composite_phenotypic_file.csv') # , index_col='SUB_ID'
table = df.sort_values(['SUB_ID'])
table
sub_id = df.as_matrix(columns=['SUB_ID'])#table['SUB_ID']
type(sub_id)
sub_id.shape
table.SUB_ID.loc[lambda s: s == 50002]
table.loc[(table['SUB_ID'] > 50010) & (table['SUB_ID'] < 50050)]
# selecting Autistic males of age <= 20 years
table_males = table.loc[(table['SEX'] == 1) & (table['AGE_AT_SCAN'] <=20) & (table['DX_GROUP'] == 1) ]
table_males.shape
table_males
table_males_np = table_males.as_matrix(columns=['SUB_ID','DX_GROUP', 'DSM_IV_TR', 'AGE_AT_SCAN' ,'SEX' ,'EYE_STATUS_AT_SCAN'])
table_males_np
# selecting Autistic males(DSM IV) of age <= 18 years 
df_aut_lt18_m = table.loc[(table['SEX'] == 1) & (table['AGE_AT_SCAN'] <=18) & (table['DSM_IV_TR'] == 1) ]
df_aut_lt18_m.shape
df_td_lt18_m = table.loc[(table['SEX'] == 1) & (table['AGE_AT_SCAN'] <=18) & (table['DSM_IV_TR'] == 0) ]
df_td_lt18_m.shape<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14685534591194968, 'fraction_numerical': 0.038050314465408804, 'mean_word_length': 5.572314049586777, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 10, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '25952', 'license': 'Apache-2.0', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1286, 'n_words': 159, 'path': 'notebooks/testing.ipynb', 'repo_name': 'varun-invent/ABIDE_Connectome_study', 'size': '3180'}