function [fileroot] = get_rootdir(files)%Anatfiles,LogJfiles)
%function sge_sort_fluid_files(files) 
% input:  Anatfiles,LogJfiles,files = a cell array of filenames
% output: files2warp.Anat, files2warp.LogJ
fileroot ='';
for i=1:length(files);
    [pth,nam,ext]=fileparts(files{i});
    
    if isempty(fileroot);
        fileroot=pth;
    else
        while isempty(strfind(pth,fileroot))
            slash = findstr(filesep,fileroot);
            fileroot = fileroot(1:slash(end)-1);
        end
    end; 
end