Simplified regexp for finding IDs, moved save filename creation outside
of check for stimulus type/ID existence.