Timeseries extraction at mutiple ROIs at once

Hello
I am using FSL to extract timeseries from FMRI at one ROI at a time and am facing issues while scaling up this process. I there any way i can extract timeseries at all the locations simultaneously.

The script that i am using rn for extracting timeseries:

#!/bin/bash

#script name : ts_extract_CN.sh
base_dir="path/CNStandard_name"
for i in CB DMN FP OP CO SM; do
    file_path="path/DoschenbachROI/$i.txt"
    for subject_dir in "$base_dir"/*.feat; do
        if [[ -d "$subject_dir" ]]; then
            subject_name=$(basename "$subject_dir")
            echo $subject_name
            cd "$base_dir/$subject_name"
            subject_name1=$(basename "$subject_dir" .feat)
            output_file="${subject_name1}_${i}.csv"
            counter=0
            while read line; do
                IFS=',' read -r centerx centery centerz <<< "$line" 
                counter=$((counter+1))
                fslmaths roi_template.nii.gz -mul 0 -add 1 -roi $centerx 1 $centery 1 $centerz 1 0 1 ACCpoint -odt float
                fslmaths ACCpoint -kernel sphere 5 -fmean ACCsphere_$counter -odt float
                fslmaths ACCsphere_$counter.nii.gz -bin ACCsphere_bin_$counter.nii.gz
                roi_timeseries=$(fslmeants -i res_brain_std -m ACCsphere_bin_$counter)
                time_series="$roi_timeseries"
                echo "$time_series" >> $output_file
            done < $file_path
            rm -r ACC*
        fi
    done
done

It would be helpful, even if i can extract voxel level timeseries efficiently ie, in parallel.

Hi,
Have you considered using Nilearn NiftiLabelsMasker ? In my experience, this makes the process easier (assuming your images are all in MNI space).
Best,
Bertrand

Hi @NINAD_AITHAL, there are many options for running tasks in parallel - for example, you could try using GNU Parallel. Or you could use Python instead of a shell script, and use the built-in multiprocessing module.