Many users find it difficult to restore a Nexus 5. In some cases even after restoring all the files such as images and videos will be still there. There are some problems faced by the rooted phones too. So you can flash your phone with the factory image so that your phone will be good as new.
****These steps can be used to flash other Nexus Devices too.
1. ABD and fastboot drivers: Download
2. Latest factory image: Download
Step 1: Install the ABD and fastboot drivers.
Step 2: Extract the archive you downloaded (factory image). Rename "bootloader-hammerhead-XXXX.img" to "bootloader.img and "radio-hammerhead-XXXX.img" to radio.img.(I have extracted it to C: Drive)
Step 3: Extract the "image-hammerhead-XXXX.zip" to the same folder.
Step 4: Power off your phone.
Step 5: Boot into fastboot by pressing Power Button and Volume Down at the same time and connect your phone to your PC through your USB cable
Step 6: Open a Command Prompt window and type the following commands.
fastboot flash bootloader C:\image-hammerhead-krt16m\bootloader.img
fastboot flash radio C:\image-hammerhead-krt16m\radio.img
fastboot flash system C:\image-hammerhead-krt16m\system.img
fastboot flash userdata C:\image-hammerhead-krt16m\userdata.img
fastboot flash boot C:\image-hammerhead-krt16m\boot.img
fastboot flash recovery C:\image-hammerhead-krt16m\recovery.img
fastboot erase cache
Step 7: When you are done, go to recovery and wipe everything.
Step 8: Reboot your phone.
******Important: Flashing stock ROM will unroot your phone.
Now your Nexus device will be running on the stock ROM