function varargout = Cal_property(varargin)
% CAL_PROPERTY M-file for Cal_property.fig
%      CAL_PROPERTY, by itself, creates a new CAL_PROPERTY or raises the existing
%      singleton*.
%
%      H = CAL_PROPERTY returns the handle to a new CAL_PROPERTY or the handle to
%      the existing singleton*.
%
%      CAL_PROPERTY('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in CAL_PROPERTY.M with the given input arguments.
%
%      CAL_PROPERTY('Property','Value',...) creates a new CAL_PROPERTY or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Cal_property_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Cal_property_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Cal_property

% Last Modified by GUIDE v2.5 05-Apr-2012 11:58:06

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Cal_property_OpeningFcn, ...
                   'gui_OutputFcn',  @Cal_property_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Cal_property is made visible.
function Cal_property_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Cal_property (see VARARGIN)

% Choose default command line output for Cal_property
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Cal_property wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Cal_property_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function type_Callback(hObject, eventdata, handles)
% hObject    handle to type (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of type as text
%        str2double(get(hObject,'String')) returns contents of type as a double


% --- Executes during object creation, after setting all properties.
function type_CreateFcn(hObject, eventdata, handles)
% hObject    handle to type (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function input_Callback(hObject, eventdata, handles)
% hObject    handle to input (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of input as text
%        str2double(get(hObject,'String')) returns contents of input as a double


% --- Executes during object creation, after setting all properties.
function input_CreateFcn(hObject, eventdata, handles)
% hObject    handle to input (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in inputbutton.
function inputbutton_Callback(hObject, eventdata, handles)
% hObject    handle to inputbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
directoryname = uigetdir('C:\Users');
set(handles.input,'String',directoryname);


function results_Callback(hObject, eventdata, handles)
% hObject    handle to results (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of results as text
%        str2double(get(hObject,'String')) returns contents of results as a double


% --- Executes during object creation, after setting all properties.
function results_CreateFcn(hObject, eventdata, handles)
% hObject    handle to results (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in resultsbutton.
function resultsbutton_Callback(hObject, eventdata, handles)
% hObject    handle to resultsbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
directoryname = uigetdir('C:\Users');
set(handles.results,'String',directoryname);

% --- Executes on button press in Calulation.
function Calulation_Callback(hObject, eventdata, handles)
% hObject    handle to Calulation (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% --- Executes on button press in finish.
str1 = get(handles.input,'String');
str2 = get(handles.results,'String');
prefix = get(handles.type,'String');
mkdir(strcat(str2,'/',prefix,'Intermediate results'));
str3 =strcat(str2,'/',prefix,'Intermediate results');
number = get(handles.number,'String');
if length(str1)<=0;
    errordlg('Input parameters can not be empty !')
 return;
end
if length(str2)<=0;
    errordlg('Storage address can not be empty !')
 return;
end
s1 =num2str( get(handles.shortest,'Value'));
s2 =num2str( get(handles.cluster,'Value'));
s3 =num2str( get(handles.degree,'Value'));
s4 =num2str( get(handles.between,'Value'));
s5 =num2str( get(handles.globle,'Value'));
s6 =num2str( get(handles.local,'Value'));
s7 = num2str( get(handles.assortativity,'Value'));
if s1=='1'
    bform = Bform(str1,str3 );
    getNetworkallshortpathproperty(str3,str2,prefix);
end
if s2=='1'
    bform = Bform(str1,str3 );
    getNetworkclusteringsproperty(str3,str2,prefix);
end
if s3=='1'
    degree= getNodedegreeproperty (str1,str2,prefix);
     degreesum( degree,degree,number )
end
if s4=='1'  
     bform = Bform(str1,str3 );
    getNodeBCproperty (str3,str2,prefix)
end
if s5=='1' 
   mkdir(strcat(str2,'/',prefix,'global/intermaediate1'));
   mkdir(strcat(str2,'/',prefix,'global/intermaediate2'));
   str4= strcat(str2,'/',prefix,'global/intermaediate1');
   str5= strcat(str2,'/',prefix,'global/intermaediate2');
   str6= strcat(str2,'/',prefix,'global');
   BCTpropertydataform( str1 ,str4)
   effciency_fold(str4,str5,'G')
   order_getoneDegree(str5,str6,'Global efficiency')
end
if s6=='1'  
   mkdir(strcat(str2,'/',prefix,'local/intermaediate1'));
   mkdir(strcat(str2,'/',prefix,'local/intermaediate2'));
   mkdir(strcat(str2,'/',prefix,'local/intermaediate3'));
   str7= strcat(str2,'/',prefix,'local/intermaediate1');
   str8= strcat(str2,'/',prefix,'local/intermaediate2');
   str9= strcat(str2,'/',prefix,'local/intermaediate3');
   str10= strcat(str2,'/',prefix,'local'); 
   BCTpropertydataform( str1 ,str7);
   effciency_fold(str7,str8,'l');
   mean_fold(str8,str9);
   order_getoneDegree(str9,str10,'local efficiency')
end
if  s7 == '1'
   mkdir(strcat(str2,'/',prefix,'assortativity/intermaediate1'));
   str11 = strcat(str2,'/',prefix,'assortativity/intermaediate1');
   str12 =strcat(str2,'/',prefix,'assortativity');
    BCTpropertydataform( str1 ,str11);
    BCTassortativity(str11,str12);
end
tishi='Task is completed !'
 msgbox(tishi); 

function finish_Callback(hObject, eventdata, handles)
% hObject    handle to finish (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
delete(gcf);


function path1_Callback(hObject, eventdata, handles)
% hObject    handle to path1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of path1 as text
%        str2double(get(hObject,'String')) returns contents of path1 as a double


% --- Executes during object creation, after setting all properties.
function path1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to path1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function input1_Callback(hObject, eventdata, handles)
% hObject    handle to input1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of input1 as text
%        str2double(get(hObject,'String')) returns contents of input1 as a double


% --- Executes during object creation, after setting all properties.
function input1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to input1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in inbutton.
function inbutton_Callback(hObject, eventdata, handles)
% hObject    handle to inbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
directoryname = uigetdir('C:\Users');
set(handles.input1,'String',directoryname);

% --- Executes on button press in pathbutton.
function pathbutton_Callback(hObject, eventdata, handles)
% hObject    handle to pathbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
directoryname = uigetdir('C:\Users');
set(handles.path1,'String',directoryname);

% --- Executes on button press in getonedegree.
function getonedegree_Callback(hObject, eventdata, handles)
% hObject    handle to getonedegree (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
str1 = get(handles.input1,'String');
str2 = get(handles.path1,'String');
str3 = get(handles.number,'String');
if length(str1)<=0;
    errordlg('Input parameters can not be empty !')
 return;
end
if length(str2)<=0;
    errordlg('Storage address can not be empty !')
 return;
end
if length(str2)<=0;
    errordlg('Number of ROIs  can not be empty !')
 return;
end
getoneDegrees(str1,str2,str3);
tishi='Task is completed !'
 msgbox(tishi);

% --- Executes on button press in shortest.
function shortest_Callback(hObject, eventdata, handles)
% hObject    handle to shortest (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of shortest


% --- Executes on button press in cluster.
function cluster_Callback(hObject, eventdata, handles)
% hObject    handle to cluster (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of cluster


% --- Executes on button press in degree.
function degree_Callback(hObject, eventdata, handles)
% hObject    handle to degree (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
number = get(handles.number,'String');
if length(number)<=0;
    set(handles.degree,'Value',0)
    errordlg('Number of ROIs can not be empty !')
 return;
end
% Hint: get(hObject,'Value') returns toggle state of degree


% --- Executes on button press in between.
function between_Callback(hObject, eventdata, handles)
% hObject    handle to between (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of between


% --- Executes on button press in globle.
function globle_Callback(hObject, eventdata, handles)
% hObject    handle to globle (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of globle


% --- Executes on button press in local.
function local_Callback(hObject, eventdata, handles)
% hObject    handle to local (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of local


% --- Executes on button press in assortativity.
function assortativity_Callback(hObject, eventdata, handles)
% hObject    handle to assortativity (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of assortativity


% --- Executes on button press in checkbox8.
function checkbox8_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox8



function number_Callback(hObject, eventdata, handles)
% hObject    handle to number (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of number as text
%        str2double(get(hObject,'String')) returns contents of number as a double


% --- Executes during object creation, after setting all properties.
function number_CreateFcn(hObject, eventdata, handles)
% hObject    handle to number (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
