Parcellation ward connectivity

Hello ,
I have two X_train :
X_train1 of shape (100,170000) , X_train2 of shape (100,17000)
Xc=np.concatenate((X_train1,X_train2), axis=1)

 mask= np.asarray(nifti_masker.mask_img_.get_data()).astype(bool) 
 shape = mask.shape     #mask.shape(182,218,182)
 connectivity = image.grid_to_graph(
      n_x=shape[0], n_y=shape[1], n_z=shape[2], mask=mask).tocsr()

  ward = FeatureAgglomeration(n_clusters=1000,connectivity=connectivity,linkage='ward', pooling_func=np.median)
  ward.fit(Xc)

But there is an error :
ValueError: Wrong shape for connectivity matrix: (170000, 170000) when X is (340000, 100)

how can i do this (fit on the concatenation i.e Xc) please ?

@bthirion
and thank you very much !

If I understand corectly, you’ve got images of 170k voxels, and want to work with two time series of length 100.
then simply concatenate in the other dimension: Xc=np.concatenate((X_train1,X_train2), axis=0)
Does that work ?
Best,

yes, thank you very much @bthirion