I extracted the timeseries of each subject (100 timepoint x 400 ROIs) using nilearn and saved them as outer CSV file. Now I want to load these timeseries into memory and compute the group average timeseries for functional connectivity calculation.
I planned to read each of the CSV file with numpy.loadtxt as 2D array and combine all 2D array into a 3D array. The group average could be calculated by computing the mean over the third dimension of the 3D array. However, I am not an expert in Python, so I have no idea how to implement it in coding.
Do you know the way to calculate the group-average FC? Any ideas will be appreciated.
Moreover, I checked the document of the nilearn.ConnectivityMeasure and found that the function could compute multiple subjects’ FC in a list. Therefore, I first collected all subjects’ timeseries into one list and inputed the list into correlationMeasure.fit_transform(), resulting in a 3D array of subject x roi x roi. Finally, calling numpy.mean to obtain the group-mean FC along the subject dimension.
Your idea is more efficient than mine, I really appreciate that.