I don't know if you are familiar with this real life story.... but you can look it up on the net.
David Reimer was born as a male identical twin but later raised as female after his penis was accidentally destroyed during circumcision.
His normal twin brother was raised as a male.
David Reimer was born in Winnipeg Manitoba. His twin brother’s name was Brian.
At that time it was considered that a person's sexual identity was somethung that could be changed....a fashionable assumption in the 1960's ... because it was assumed a person could be trained to feel and live as either a male or female.
David was therefore "taught" to be a female... his genitals being removed and he was raised as a female.
David was only 22 months old at the time he was "re-assigned" as a female, his damaged testis was removed, and he was made a "female" by having his damaged sex organs removed and a apparent vagina constructed for him.
He was given the name of Brenda, and raised as a female.
The story does not end well, David comitted suicide later as an adult when he finally learned that he had been born a male.
By that time, most of his female classmates (who did not know that he had been born male) were in open revolt against him in school.
They refused to allow him into the female bathrooms in school, claiming that he was "creepy".
It was so bad that "Brenda" was unable to attend public school and treated by a school psychologist for "her" problems
His (or Her) childhood was hell .... he always felt he was not a woman.
"Brenda" was unable to atttend school normally ... in spite of attempts to give her female hormone treatments to give her the look of a female .... neither the male or female students accepted her.
His parents finally told him that he had ben born as a male and David decided to regain his male identity. He underwent treatment to reverse the reassignment, including testosterone injections, a double mastectomy, and two phalloplast operations. He also married a woman and became a stepfather to her 3 children. His case came to international attention in 1997 when he told his story to Milton Diamond, an academic sexologist who persuaded David to allow him to report the outcome in order to dissuade physicians from treating other infants similarly.
Today, with MRI doctors now know that there are not only physical sexual changes at the time a person beco=mes a male or female but also ... and MRIs can show this ,,, there are also changes that can be seen in the Brain at that time.
It is now considered that not only are there phyical changes associated with one's gender during development of the normal human fetus, but actual devopment changes in certain areas of the fetal brain that occur at the same time.
But this is still somewhat controversial.
"Gender re-assignment" is still done occasionally, but it is also very controversial.
"Brenda" after she went back to being "David" told his/her story to Dr. Diamond and her book was published.
I believe it is called something like, "A Stolen Childhood".
Brian, "David/Brenda's" normal twin brother also ended up developing Schisophrenia and was committed to a mental institution.
As I said, it is not a story with a happy ending for anyone.
Today, as i said, many doctor's believe that in addition to the physical changes involved with gender determination, their are mental changes in the developing fetal Brain that detrmine what a person percieves is his or her sexual Gender identity.
But as I said, this is a controversial point, and not all psycholgists would agree.
Correction: the book is called,"As Nature Made Him: The Boy Who Was Raised as a Girl".