Neuroimaging clustering FMRI

please i have a dataset with nifti image of dim (182,190,182) , i want to do a clustering, so i used Kmeans but it is very slow , so i find a method which is very fast which is ReNA method in Nilearn , i applied a mask with NiftIMasker and when i apply the ReNa method i have a problem

 File "<ipython-input-39-b94ed8840ef7>", line 1, in <module>
 b= rena.fit_transform(masked_data)

File "C:\Users\moham\Anaconda3\lib\site-packages\sklearn\", line 553, in 
return, **fit_params).transform(X)
File "C:\Users\moham\Anaconda3\lib\site- 
packages\nilearn\regions\", line 483, in fit estimator=self)

File "C:\Users\moham\Anaconda3\lib\site-packages\sklearn\utils\", line 
550, in check_array context))

ValueError: Found array with 1 sample(s) (shape=(1, 1534813)) while a minimum of 
2 is required by ReNA.

My Code :
from nilearn.masking import compute_epi_mask
from nilearn.masking import apply_mask

img= read_nifti(“CT01003BOIJE.nii.gz”)
img.shape # (182,218,182)

mask_img = compute_epi_mask(img)
masked_data = apply_mask(img, mask_img)
rena = ReNA(mask_img, n_clusters=20, scaling=False,
n_iter=10,threshold=1e-07, memory=None,
memory_level=1, verbose=0)
b= rena.fit_transform(masked_data)


In order to fit ReNA, the number of images required is more than 1. That is what the error message says.

ReNA is recommended if one needs to more than 2000 clusters.

The computation of masking steps can be overcome by using ReNA from the Parcellations object.
Have a look at this example which shows how to compute parcels using Parcellations object.

Thank you for your response.
But if i have 267 nifti images of shape (182,190,182)
how i can fit ReNA with all this images : which method will be used to assemble all this image to be fited by ReNA ?

If you have 267 such images then you could directly provide them as list of images to ReNA.

imgs = [“CT01001BOIJE.nii.gz”, “CT01002BOIJE.nii.gz”, “CT01003BOIJE.nii.gz”, …]

For example, look at this demo

Thank you very much @KamalakerD