function struct = intensitiesFun(struct, user)

% Determine the number of different mixing times or relaxation times
% and calculate the intensity in accordance with the user settings

count.numMixTimes = 0;
names = fieldnames(struct);
A_Aindex = strfind(names,'A_A');                            %synth of buildups (output of series.com)
Z_Aindex = strfind(names,'Z_A');                            %synth of relaxation Data (output of fit.com)

mixTrueA_Aindex = find(~cellfun('isempty', A_Aindex(:)));   %returns indices for A_A*
mixTrueZ_Aindex = find(~cellfun('isempty', Z_Aindex(:)));   %returns indices for Z_A*

if ~isempty(mixTrueA_Aindex)
    count.numMixTimes = length(mixTrueA_Aindex);
elseif ~isempty(mixTrueZ_Aindex)
    count.numMixTimes = length(mixTrueZ_Aindex);
end

if user.heightVolume == 'h'
    
    for j=1:length(struct)
            for i = 1:count.numMixTimes
                    
                if count.numMixTimes ~= 0
                    
                    if ~isempty(mixTrueA_Aindex)
                    
                            struct(j).procAss.(sprintf('intensity_%d',i - 1)) ...
                            = struct(j).HEIGHT * struct(j).(sprintf('A_A%d',i - 1));
                
                    elseif ~isempty(mixTrueZ_Aindex)
                        
                        if user.absIntensities == 0
                            struct(j).procAss.(sprintf('intensity_%d',i - 1)) ...
                            = struct(j).HEIGHT * struct(j).(sprintf('Z_A%d',i - 1));
                        elseif user.absIntensities == 1
                            struct(j).procAss.(sprintf('intensity_%d',i - 1)) ...
                            = abs(struct(j).HEIGHT * struct(j).(sprintf('Z_A%d',i - 1)));
                        end
                        
                    end
                end
            end
    end
    
    
elseif  user.heightVolume == 'v'

    for j=1:length(struct)
            for i = 1:count.numMixTimes
                    
                if count.numMixTimes ~= 0
                    
                    if ~isempty(mixTrueA_Aindex)
                
                        struct(j).procAss.(sprintf('intensity_%d',i - 1)) ...
                        = struct(j).VOL * struct(j).(sprintf('A_A%d',i - 1));
                
                    elseif ~isempty(mixTrueZ_Aindex)
                        
                        struct(j).procAss.(sprintf('intensity_%d',i - 1)) ...
                        = struct(j).VOL * struct(j).(sprintf('Z_A%d',i - 1));
                        
                    end
                        
                        
                end
            end
    end
end

if count.numMixTimes ~= length(user.mixing_times)
    error(['The number of mixing times you supplied does not match the number of points in your raw Data!',...
          'Check the mixing times you supplied'])
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%