– A sudden impulsive and apparently unmotivated idea or action.
Usage example: having no sense of purpose, he was often at the mercy of the strange megrims that sprang into his head
are semantically related in thoughts
topic. In some cases you can use "Whimsy" instead a noun