When her life began skidding, the dream would come upon her again, always the same and always terrifying. The woman called it her overwhelmed dream. She would be walking on a beach, facing the sea, and a huge wave would swell and crest and drag her under, beating the breath out of her body.

Rosalind Cartwright, Chicago psychologist and dreams researcher, brought the woman into her experimental work. "Next time you have that dream, remember that you can swim," she said - and with Cartwright's help, the woman did. Now she swims through the nightmare waves, and surfaces. That, among other things, is the thrust of Cartwright's work these days - taking repetitive nightmares and, as Cartwright explains it, "tailor-making happy endings."

It is tentative, exploratory research, but like most of ths studies being presented here at a four-day conference at Stanford University, the possibilities it yields are so compelling that a whole new scientific area has developed around the uncertain forays to the sleeping mind.

New developments in sleep research - encompassing dreams, sudden infant death syndrome, impotence and disorders ranging from insomnia to the inability to stay awake - are being aired at this meeting, the 18th annual conference of the Association for the Psychophysiological Study of Sleep, the nation's largest such con ference and in the process, carried to the local public on an unprecedented scale.

Among the researcher's offerings:

"Dreamstage," a San Francisco museum display centered on a young college student who lies down on a special bed every afternoon, her head wired with electrodes, and who sleeps for the next eight hours. A big video screen displays polygraph readings of her brain waves, eye muscle movements and heartbeat. Laser beams pulse the readings around the exhibit walls, a different color for each reading. And the whole thing is attached to an electronic music machine, so that in the urgent, melodies, a visitor hears the levels of the young woman's sleep.

An introduction to Stanford's narcoleptic dog colony, a collection of dachsnunds, poodles, beagles and other breeds all suffering from - and in some cases passing on to their puppies - the disease marked by sudden, uncontrollable sleep. As in humans, excitement seems to bring on the sleep: the puppies, for example, sometimes keel over at the sight of dog food.

Studies showing that it may be possible to distinguish between psychological and physiological impotence by monitoring patients as they sleep. Dr. Ismet Karacan, a researcher with the Houston Veterans Administration Hospital, said it has been learned that physically healthy men -even if they seem to be impotent - experience tumescence an average of three to five times during the night.

the tumescence occurs during the dream phase called rapid eye movement (REM) sleep, although it does not appear to be related to the content of the dream.

Men physically incapable of full erection experience either partial or no tumescence during sleep, Karacan said - and there is evidence, he added, that this physiological impotence may be far more common than previously believed.

New information about "sleep apnea" victims and a tape recording of their alarming snores: little gasping noises followed by frantic bass sputterings, and then silence. They are not breathing during the silence. People with sleep apnea, usually overweight, middle-aged men, fall asleep and then stop breathing - apparently because the muscles close in the throat, according to Dr. Elliot D. Weitzman of the Sleep-Wake Disorders Unit of New York's Montefiore Hospital.

By day, Weitzman said, these patients often wade through a dangerous sleepiness, sometimes falling asleep at the wheel or halfway through a mouthful of food. Their nights can become violent internal struggles just to sleep and stay alive at the same time. Heart attacks and death can result.

The syndrome may effect 100,000 people, and possibly a great many more. Researchers hope that recording snoring patterns will help identify more potential victims and bring them to treatment, which includes weight loss, and surgically cutting an air way in the patient's throat.

The work of Rosalind Cartwright, whose current goal is to ease the haunting, repetitive dreams of divorced and widowed women. The husband's death or departure is relived over and over: guilt and grief fill every night. The dreams can last for year. Another researcher likens them to the repetition of a broken record.

Cartwright begins by taping a tiny switch to the palm of her subject's hand. At the onset of each unpleasant dream, it is explained, the woman is to flip the switch with a flick of her palm - and, even in sleep, Cartwight said, "everybody does it."

Upon waking, the dreams are examined and talked out. Then, as Cartwright put it, "we sort of plot a little ending for them." Is the husband endlessly dying? Bury him and begin a new life. Are the final divorce battles being replayed again and again? End them and find a new man. Researcher and subject agree that a small "beep" will cue the new ending. Then the subject sleeps again, only this time, when she signals the onset of the bad dream, the researcher beeps back - "remember how you wanted it to end."

It is complicated and sometimes doesn't work, Cartwright said, but the successes have been frequent enough that she is now helping select subjects for a larger, major study.

What of the widely accepted belief that dreams, however fearsome, are an indispensable part of the psyche?

True for some, Cartwright said, but "if dreams function to work through emotional material, then they're certainly not functioning in the depressed . . . I think that goes on too darn long to be healthy."

For the lay person, the most unsettling and intriguing revelation at this conference may be the fact that, to this day, scientists don't know why we sleep. There are theories, some of which were presented here in new detail. One speculates that cell-building and repair take place during sleep. Another suggests that sleep is little more than a caveman's leftover, no longer really necessary.

They very idea of studying sleep is so new, in fact, that the researchers are still arguing about what to call themselves - "clinical polysomnographer" was the name being bandied about at this meeting.

The research, set in motion by the 1953 discovery of REM sleep and its relation to dreams, is now centered in this country in 12 sleep disorder centers, one of which is at Stanford.

The experimental work is not just for those with sleep problems. Sleep experts say no doctor can make a really thorough physiological check without examining the sleeping person as well. But the field is still a long way from complete acceptance.

"The mother rocks the baby to sleep, puts it in a crib and tiptoes out of the room," said Dr. William C. Dement, director of Stanford's Sleep Disorders Clinic and Research Center and one of the pioneers of sleep study, "and it's almost as if that is a sacred, secret object and place that is not to be looked at, not to be watched . . . I think that's been the attitude of the medical profession."

That tiptoeing wonder is perhaps most evident in the carpeted darkness of the San Francisco museum display, where many visitors at first find themselves unable to stare at the woman sleeping behind glass. It seems an intrusion, somehow indecent. One woman saw the exhibit and later dreamed that the sleeper leaped up and began screaming at the strangers around her.

Cartwright caught the wonder too, in a different mood. She was talking about the restless sleep of the new mothers, always poised for the baby's whimper. A woman Cartwright knew dreamed in her uneasiness that her right ear became a butterfly, detaching itself and fluttering off to the baby's room to rest at the head of the crib. And the woman slept soundly, Cartwright said, knowing the butterfly guarded her child.