Hysterosalpingography is a specialized X-ray test used to evaluate the inside of the uterus and fallopian tubes. During the procedure, a contrast dye is injected through the cervix, and X-ray images are taken. HSG is primarily used for investigating causes of infertility, recurrent miscarriages, and assessing tubal patency.