Hi @dglen Thank you for your valuable suggestion. Could you please give an example or how it could be done in python language. Thanks in advance.
from nilearn.maskers import NiftiLabelsMasker
from nilearn.datasets import fetch_icbm152_2009
mnitemp = fetch_icbm152_2009()
glassermasker = NiftiLabelsMasker(labels_img='glasser360MNI.nii.gz',mask_img=mnitemp['mask'])
glassermasker.fit()
# In[3]:
import numpy as np
count = []
for i in range(0, 360):
count.append(i)
from nilearn.datasets import fetch_abide_pcp
import pandas
import os
df = pandas.read_csv('Phenotypic_V1_0b_preprocessed1.csv', sep=',')
site_id=np.unique(df['SITE_ID'])
print(site_id)
for S in (site_id):
data_dir='test'
#DX_GROUP: 1 is autism, 2 is control
abidedata_func_normal=fetch_abide_pcp(data_dir=data_dir, n_subjects= None, pipeline='cpac', band_pass_filtering=True, global_signal_regression=True, derivatives=['func_preproc'], quality_checked=True,DX_GROUP=2,SITE_ID=S)
abidedata_func_autism=fetch_abide_pcp(data_dir=data_dir, n_subjects= None, pipeline='cpac', band_pass_filtering=True, global_signal_regression=True, derivatives=['func_preproc'], quality_checked=True,DX_GROUP=1,SITE_ID=S)
##########################################Normal#########################################################################
## Extaction of time series for normal
abide_ts=[]
print(abide_ts)
abide_ts_normal=[]
filename_normal=[]
for i in range(len(abidedata_func_normal['func_preproc'])):
ts_nor = glassermasker.transform(abidedata_func_normal['func_preproc'][i])
print(abidedata_func_normal['func_preproc'][i])
filename = os.path.basename(abidedata_func_normal['func_preproc'][i])
file_name_without_extension = filename[:-7]
print(file_name_without_extension)
ts_normal = ts_nor[:,count]
abide_ts_normal.append(ts_normal)
abide_ts.append(ts_normal)
filename_normal.append(file_name_without_extension)
# Create a directory to store the text files
text_file_dir = 'Normal'
if not os.path.exists(os.path.join(S, text_file_dir)):
os.makedirs(os.path.join(S, text_file_dir))
# Iterate over the file paths in the list
for file, name in zip(abide_ts, filename_normal):
#Convert to dataframe
df = pd.DataFrame(file)
# Create a text file for the DataFrame
text_file_path = os.path.join(S, text_file_dir, '{}.txt'.format(name))
# Save the DataFrame to the text file
df.to_csv(text_file_path, index=False, header=False)
############################################# Autism ########################################################################
## Extaction of time series for normal
abide_ts=[]
print(abide_ts)
abide_ts_autism=[]
filename_autism=[]
for i in range(len(abidedata_func_autism['func_preproc'])):
ts_nor = glassermasker.transform(abidedata_func_autism['func_preproc'][i])
print(abidedata_func_autism['func_preproc'][i])
filename = os.path.basename(abidedata_func_autism['func_preproc'][i])
file_name_without_extension = filename[:-7]
print(file_name_without_extension)
ts_autism = ts_nor[:,count]
abide_ts_autism.append(ts_autism)
abide_ts.append(ts_autism)
filename_autism.append(file_name_without_extension)
# Create a directory to store the text files
text_file_dir = 'Autism'
if not os.path.exists(os.path.join(S, text_file_dir)):
os.makedirs(os.path.join(S, text_file_dir))
# Iterate over the file paths in the list
for file, name in zip(abide_ts, filename_autism):
#Convert to dataframe
df = pd.DataFrame(file)
# Create a text file for the DataFrame
text_file_path = os.path.join(S, text_file_dir, '{}.txt'.format(name))
# Save the DataFrame to the text file
df.to_csv(text_file_path, index=False, header=False)
Could you please guide where to make changes to use “MNI 2009c asymmetric volume space version of the Glasser atlas”, I have this code running.
bundle of thanks!