#!/bin/bash

# As first thing save a mask from your results in order to have a list of clusters numbered from 1 to cn
Clust_mask=Name_of_the_mask+tlrc.

#Cluster loop (replace cn in brackets with the number of your clusters in the mask; replace the Analysis_output with your analysis output, eg LME+tlrc., and 's' in brackets with the specific sub-brick)
for cn in {1..cn} ; do 
3dcalc -a $Clust_mask -expr "amongst(a,$cn)" -prefix temp_clust_mask mask=temp_clust_mask+tlrc.
3dExtrema -prefix Name_of_the_mask_clust$cn -mask_file $mask -nbest 10 -sep_dist 10 -closure -volume Analysis_output+tlrc'[s]' >> Name_of_the_mask$cn.txt
rm temp_clust_mask*

done


#if you have deactivations, add the option -minima
