function [info] = get_para(folder,ind,SeqType)
% Function get_para creates structure info that contains repetition time,
% flip angle, echo time etc.
% The input parameters
%   o folder - path of the folder that contains subfolders with MRI data
%   o ind - vector of number of scans 
%   o SeqType - information about the sequence type
%             - 1 for FISP FID, 2 for Intragate FLASH
% The output parameters
%   o info - structure with aquizition data
info = struct;
for i = 1:length(ind)
    if SeqType == 1 % for FISP FID
        path=[folder '\' sprintf('%0.1d',ind(i))];
        % using the CKDataObject function from Bruker software package to
        % read the data
        rawObj= CKDataObject(path, 'useMethod', true);
        info.acq.FA(i) = rawObj.Acqp.ACQ_flip_angle;
        info.acq.TR(i) = rawObj.Acqp.ACQ_repetition_time;
        info.acq.TE(i) = rawObj.Acqp.ACQ_echo_time;
        info.acq.TI(i) = rawObj.Acqp.ACQ_inversion_time;
        info.acq.rg(i) = rawObj.Acqp.RG;
        info.acq.frames(i) = rawObj.Acqp.NR;
    else % for Intragate FLASH
        path=[folder '\' sprintf('%0.1d',ind(i))];
        ACQP = fopen( [path '\acqp'], 'r');
        while ~feof(ACQP) % going through the whole file
            line = fscanf(ACQP,'%s=##');
            if strcmp(line,'##$ACQ_repetition_time=(');
                temp = str2num(fscanf(ACQP,'%s=##'));
                fscanf(ACQP,'%s=##');
                for k = 1:temp
                    info.acq.TR(1) = str2num(fscanf(ACQP,'%s=##'));
                end
            end
            if strcmp(line,'##$ACQ_inversion_time=(');
                temp = str2num(fscanf(ACQP,'%s=##'));
                fscanf(ACQP,'%s=##');
                for k = 1:temp
                    info.acq.TI(1) = str2num(fscanf(ACQP,'%s=##'));
                end
            end
            if length(line)>18
                if strcmp(line(1:18),'##$ACQ_flip_angle=')
                    info.acq.FA(i) = str2double(line(19:end));
                end
            end
        end
    end
end
% closing all opened files
fclose('all');
