function [completed] = create_arff_nitp(path, name,  Class1_Label, Class2_Label, data, N_Subj_Class)

% Created by Pamela Douglas :-)
%
% Feel free to email w/ questions or thoughts:
% pamelakdouglas@yahoo.com
%
% Create Attribute/ Relation File
% 
%------------------------------------------------------------------
% Variables 
%
%  1.) Path - location where file should be saved
%  2.) Name - filename 
%  3.) Name of Attributes
%  3.) Number of Attributes
%  4.) Number of Classes
%  5.) data
%
%  Options:
%------------------------------------------------------------------

N_Subj=N_Subj_Class*2;

sz=size(data); row=sz(1); col=sz(2);


pth=strcat(path,name,'.arff');
delete(pth)
dataid=fopen(pth,'a'); %CREATES A FILE and saves to path 



% 'a' --keeps appending lines to opened file

% HEADER
% Note relation name must match

fprintf(dataid, '@relation %s\n', name);

% Unwrap Data into an i x j matrix
% Assign attribute labels for all i x j connections

% Initialize Attributes 

for i =1:1:row, 
    for j=1:1:col,
        attribute=strcat('@attribute ADHD', num2str(i),'x',num2str(j),' real');
        fprintf(dataid,'%s\n', attribute);
    end
end


% Close .arff file statment
               
fprintf(dataid, '@attribute class {%s, %s}\n\n',Class1_Label, Class2_Label);
fprintf(dataid, '@data\n');

%Instances - make sure #elements per line matches #attributes

    
for sub=1:1:N_Subj,
    
    for tt_i=1:1:(row-1),
        for tt_j=1:1:col,
            inst=data(tt_i,tt_j,sub);
            fprintf(dataid,'%1.4f,',inst);
        end
    end
    
    for tt_j=1:1:col,
        if tt_j<col,
            inst=data(row,tt_j,sub);
            fprintf(dataid,'%1.4f,',inst);
        else
            if sub<=N_Subj_Class,
                inst=data(row,col,sub);
                fprintf(dataid,'%1.4f,%s\n',inst,Class1_Label);
            else
                inst=data(row,col,sub);
                fprintf(dataid,'%1.4f,%s\n',inst,  Class2_Label);
            end
        end
    end
end
    
   

fclose(dataid);

%}

complete='Attribute Relation File Created - Yay'