function indir_dyDC_4D(indir_FunImg,outfodr_DyDC,infile_Mask,Parameter)
%-----------------------------------------------------------
%   Written by SUN Jia-Wei 200413.
%   Mail to Authors: jiaweisun0512@163.com
%
%   Copyright(c) 2015
%	Center for Cognition and Brain Disorders, Hangzhou Normal University, Hangzhou 310015, China
%	Written by JIA Xi-Ze 201412
%	http://www.restfmri.net/
% 	Mail to Authors: jxz.rest@gmail.com, jiaxize@foxmail.com
%   Modified by Li Zi-Qi and Jia Xi-Ze 191113
%   Shirui technology co., LTD
%   Center for Cognition and Brain Disorders, Hangzhou Normal University, Hangzhou 310015, China




inpath_Misc(outfodr_DyDC,'MakeCurrentDir');
SubfodrList=dir_NameList(indir_FunImg);
[FunDir,FunName] = fileparts(indir_FunImg);
TDAPath = [outfodr_DyDC filesep 'TemporalDynamics' filesep 'TDA_4D' filesep 'DC_' FunName];
TDAMPath = [outfodr_DyDC filesep 'TemporalDynamics' filesep 'TDA_Metrics' filesep 'DC_' FunName];
inpath_Misc(TDAPath,'MakeCurrentDir');
inpath_Misc(TDAMPath,'MakeCurrentDir');

% if matlabpool('size')>0 
if ~isempty(gcp('nocreate'))
    parfor i=1:length(SubfodrList)
        [DegreeCentrality_PositiveWeightedSumBrain_AllWindow, DegreeCentrality_PositiveBinarizedSumBrain_AllWindow, Header] = ...
            infodr_dyDC_4D([indir_FunImg filesep SubfodrList{i}],...
                     [TDAPath filesep 'DC_' SubfodrList{i} '.nii'],...
                     infile_Mask,Parameter);
        MeanOut = [TDAMPath filesep 'MeanDC_W' filesep 'MeanDC_PositiveWeightedSum' SubfodrList{i} '.nii'];
        StdOut = [TDAMPath filesep 'StdDC_W' filesep 'StdDC_PositiveWeightedSum' SubfodrList{i} '.nii'];
        CVOut = [TDAMPath filesep 'CVDC_W' filesep 'CVDC_PositiveWeightedSum' SubfodrList{i} '.nii'];
        tda_GetTDAMetrics(DegreeCentrality_PositiveWeightedSumBrain_AllWindow,Header, MeanOut, StdOut, CVOut)
        MeanOut = [TDAMPath filesep 'MeanDC_B' filesep 'MeanDC_PositiveBinarizedSum' SubfodrList{i} '.nii'];
        StdOut = [TDAMPath filesep 'StdDC_B' filesep 'StdDC_PositiveBinarizedSum' SubfodrList{i} '.nii'];
        CVOut = [TDAMPath filesep 'CVDC_B' filesep 'CVDC_PositiveBinarizedSum' SubfodrList{i} '.nii'];
        tda_GetTDAMetrics(DegreeCentrality_PositiveBinarizedSumBrain_AllWindow,Header, MeanOut, StdOut, CVOut)
    end
else
    for i=1:length(SubfodrList)
        [DegreeCentrality_PositiveWeightedSumBrain_AllWindow, DegreeCentrality_PositiveBinarizedSumBrain_AllWindow, Header] = ...
        infodr_dyDC_4D([indir_FunImg filesep SubfodrList{i}],...
                     [TDAPath filesep 'DC_' SubfodrList{i} '.nii'],...
                     infile_Mask,Parameter);
        MeanOut = [TDAMPath filesep 'MeanDC_W' filesep 'MeanDC_PositiveWeightedSum' SubfodrList{i} '.nii'];
        StdOut = [TDAMPath filesep 'StdDC_W' filesep 'StdDC_PositiveWeightedSum' SubfodrList{i} '.nii'];
        CVOut = [TDAMPath filesep 'CVDC_W' filesep 'CVDC_PositiveWeightedSum' SubfodrList{i} '.nii'];
        tda_GetTDAMetrics(DegreeCentrality_PositiveWeightedSumBrain_AllWindow,Header, MeanOut, StdOut, CVOut)
        MeanOut = [TDAMPath filesep 'MeanDC_B' filesep 'MeanDC_PositiveBinarizedSum' SubfodrList{i} '.nii'];
        StdOut = [TDAMPath filesep 'StdDC_B' filesep 'StdDC_PositiveBinarizedSum' SubfodrList{i} '.nii'];
        CVOut = [TDAMPath filesep 'CVDC_B' filesep 'CVDC_PositiveBinarizedSum' SubfodrList{i} '.nii'];
        tda_GetTDAMetrics(DegreeCentrality_PositiveBinarizedSumBrain_AllWindow,Header, MeanOut, StdOut, CVOut)
                 
    end
end



end