function [out]=GetRawDataPosNeg(indexin,rawdata)

if any(isnan(rawdata{7,indexin})) &&...
        any(isnan(rawdata{8,indexin})) %both are bad
    baselinepool=[]; %don't think this should happen but maybe hole in recording?
    
elseif any(isnan(rawdata{7,indexin})) &&...
        any(isnan(rawdata{8,indexin}))==0 %only 8 is ok
    baselinepool=[rawdata{8,indexin}];
    
elseif any(isnan(rawdata{7,indexin}))==0 &&...
        any(isnan(rawdata{8,indexin})) %only 7 is ok
    baselinepool=[rawdata{7,indexin}];
    
elseif  any(isnan(rawdata{7,indexin}))==0 &&...
        any(isnan(rawdata{8,indexin}))==0 %both are ok
    baselinepool=[rawdata{7,indexin},rawdata{8,indexin}];
    
else
    FORCEDERROR
end

if ~isempty(baselinepool)
    randomindices=randi(size(baselinepool,2),1,size(baselinepool,2));
for k=1:size(baselinepool,2)
    out(1,k)=baselinepool(randomindices(k));
end
else
    out=NaN;
end

end %function end