In that code, if valid<=Nr1 is not true for any entry, then Nlabels(valid<=Nr1) would be empty, and that would not be permitted for accumarray(). I speculate that you have an empty ROI.
With regards to the art.m please show us the output of
which -all art
"art" is not part of any Mathworks toolbox, so it might not matter for your purposes if it is overshadowed, but it might matter. You might need to use pathtool to move Artifacts_Detection_Tool to further down in the path.