function RSA_code (subj)

% Enter the Radium of spheric ROIs here
Radium = 6;

% %Enter the File Path of the spmT Images here:
tImagePath = 'xx/forRSA_spmTfiles/';
Subject=dir([tImagePath 'OCp*']);
Outputpath = 'xx/Results/pearson/';

%%% Enter the File Path of the Structure Images here:
StructureImagePath = 'xx/OC_normalize/preprocess/T1Img/';
StructureImage=[StructureImagePath 'mask_nocere_222.img'];
[Mask,VoxDim,Header] = rest_readfile(StructureImage);
Vref = spm_vol(StructureImage);

[~, mmCoords] = spm_read_vols(Vref);

% %Enter the File Path of the Model RDMs here:
ModelPath = 'xx/Behaviour_mat/output/';
% low lever feather-gist
gistfile=load([ModelPath 'forPixelSimComputation' filesep 'fvpic_gistRDM.mat']); 
%%% color RSA-raw map
ind_color_gsimg=zeros([Header.dim]);
%color RSA-unique map
ind_colorPLshsemgist_gsimg=zeros([Header.dim]);

% Load T Images of Each Conditon of Each Subject
tImageFiles=dir([tImagePath Subject(subj).name filesep 'spmT*.nii']);         
nCond=length(tImageFiles);
TotalTImage = zeros([Header.dim,nCond]);
item=cell(nCond,1);

for i = 1 : nCond
    [tImage,~,~] = rest_readfile([tImagePath Subject(subj).name filesep tImageFiles(i).name]);
    TotalTImage(:,:,:,i) = tImage;
    condname=tImageFiles(i).name(1:end-4);
    ulindex=strfind(condname,'_');
    item{i}=condname(ulindex(length(ulindex))+1:end);
end
PrintN = 0;
PrintSum = sum(sum(sum(int8(Mask > 1/3))));
        
for x = 1 : Header.dim(1)
    for y = 1: Header.dim(2)
        for z = 1 : Header.dim(3)
            if Mask(x,y,z) > (1/3)
               % First-level Correlation: Create the Brain RDM of Each Voxel
               Index = gen_ROI_fast(Vref,mmCoords,[x,y,z], Radium);
               nVoxel = length(Index);
               ROI_t = zeros(nVoxel,nCond);
               for Label = 1 : nCond
                   tImage_tmp = (TotalTImage(:,:,:,Label));
                   ROI_t(:,Label) = tImage_tmp(Index);
               end
               BrainRDMt = 1- corr(ROI_t,'type','Pearson','rows','all','tail','both');
                                                                       
             %% compute on individual RDMs
               % load individual behavioral RDM list
               indmodel=load([ModelPath 'IndRDMs_' Subject(subj).name filesep 'Rdmls_alltasks_' Subject(subj).name '.mat']);
               %%% define each property indls
               indls_color_gsimg = indmodel.indrdmls(:,1);
               indls_shape = indmodel.indrdmls(:,2);
               indls_sem = indmodel.indrdmls(:,3);
               %%%% compare behav RDM items and spmTfile items
               neuralRDM=BrainRDMt;
               BrainRDMtls=Matrix2List(neuralRDM);
               %%% low-level pix/gist RDM
               gistRDM=gistfile.gistMat;
               gistRDMls=Matrix2List(gistRDM);
               %%% compute color correlation
               ind_color_gsimg(x,y,z)=corr(BrainRDMtls,indls_color_gsimg,'type','Spearman','rows','all','tail','both');                     
               %%% % color corralation, partial out all(include low-level rdms)
               ind_colorPLshsemgist_gsimg(x,y,z) = partialcorr(BrainRDMtls,indls_color_gsimg,[gistRDMls,indls_sem,indls_shape],'type','Spearman','rows','all','tail','both');                       
            end
            PrintN = PrintN + 1;
            display([Subject(subj).name,': ',num2str(PrintN),'/',num2str(PrintSum)]);
        end
     end
end
        
%% write out individual-RSM-based RSA imgs
%% write out color RSA raw imgs
if ~exist([Outputpath 'indmatRSA' filesep 'color_gsimg'],'dir')
    mkdir([Outputpath 'indmatRSA' filesep 'color_gsimg']);
end               
rest_writefile(ind_color_gsimg,[Outputpath 'indmatRSA'  filesep 'color_gsimg' filesep Subject(subj).name '.nii'],Header.dim,VoxDim,Header,'double');
     
%% write out color RSA- unique imgs                
if ~exist([Outputpath 'indmatRSA'  filesep 'colorPLshsemgist_gsimg'],'dir')
    mkdir([Outputpath 'indmatRSA'  filesep 'colorPLshsemgist_gsimg']);
end               
rest_writefile(ind_colorPLshsemgist_gsimg,[Outputpath 'indmatRSA' filesep 'colorPLshsemgist_gsimg' filesep Subject(subj).name '.nii'],Header.dim,VoxDim,Header,'double');
               
end





