Path (datafolder) to a wave?

SPECIFIC QUESTION:

Given a wave reference, how can I obtain the "path" (meaning the datafolder path, not file path) to that wave. For example:

In datafolder root:SensorData:LF I have a wave Accel_X

In code, suppose I previously declared wave Accel_X. How can extract the datafolder path to that wave i.e. root:SensorData:LF:?

//*******

MORE DETAILS:

I am examining a graph that displays waves from multiple datafolders. The waves have the same name:

The trace Accel_X displays the wave root:SensorData:LF:Accel_X

The trace Accel_X#1 displays the wave root:SensorData:RF:Accel_X (yes, LF and RF refer to sensors on the right and left foot)

I want to create a local copy of both waves in my current dataFolder. If I use traceNameToWaveRef, the two waves have the same name, and so the second one replaces the first one. I would like access to the datafolder path so that I can create unique names:

root:SensorData:LF:Accel_X becomes LF_Accel_X, and

root:SensorData:RF:Accel_X becomes RF_Accel_X

I think I am looking for a function like, getDataFolder(wave). Or am I not understanding correctly what a wavereference is?

Pietro

pmazzoni wrote:

If I use traceNameToWaveRef, the two waves have the same name, and so the second one replaces the first one.

I don't understand what you mean here. The wave reference is unique, doesn't matter if other waves in other data folders have the same name. But if you need to grab the path as a string to figure out what the new name should be, GetWavesDataFolder should work.

In reply to by tony

tony wrote:

 

pmazzoni wrote:

 

If I use traceNameToWaveRef, the two waves have the same name, and so the second one replaces the first one.

 

 

I don't understand what you mean here. The wave reference is unique, doesn't matter if other waves in other data folders have the same name. But if you need to grab the path as a string to figure out what the new name should be, GetWavesDataFolder should work.

I was confused. I thought traceNameToWaveRef was returning the trace's wavename as a string (even though the function clearly says ...ToWaveRef...). I think I understand now, and I know what to do using dataWavesFolder.

Thanks.

 

I have a couple of questions that arise because I don't know where you are heading here. But it's really easy to ask the wrong question when you have decided on a solution to a problem; the questions tend to be about problems encountered in the implementation rather than about the implementation itself. We all do this...

You say you need to make local copies but the names are the same and they replace each other. But you are talking about TraceNameToWaveRef, so maybe it's the wave references that have the same name, so you are changing the wave that one wave reference points to? You can do something like this to avoid that situation:

Wave wLF = root:SensorData:LF:Accel_X
Wave wRF = root:SensorData:RF:Accel_X

and then simply work on the distinctly named wave references.

So my question is- do you really need copies of the waves? What are you going to do with the two waves that makes you want to create copies? If you are going to modify the data in the waves, that's a good reason to make copies.

It occurs to me that I didn't do quite what you describe. My code snippet should be like this:

Wave wLF = TraceNameToWaveRef(namestr1)
Wave wRF = TraceNametoWaveRef(namestr2)

That, of course, leaves out lots of details.

In reply to by johnweeks

Thanks, John, for trying to figure out whether I was asking the wrong question. Indeed i was, as I was confusing wavename as a string with wave reference. The function I was missing was the one that Tony suggested above, getWavesDatafolder. I do need to make local copies because I want to create snippets of a set of waves to analyze individually and to plot on top of each other for visual comparison. The records for left foot and right foot are 3 hours long sampled at 100 Hz, and I am interested in a handful of events that last a few seconds each. I guess I could work with indices alone rather than make local snippets, but that could create knots in my mind that would be difficult to untangle.

I wouldn't want to create any knots in your brain! And I know what you mean- I feel that way after thinking too much about statistics :)

You probably still need TraceNameToWaveRef; you may also want Duplicate/R=[p1, p2] that will copy a range of points from one wave and make a new wave with the copied data.

I think we may still have not answered the starting question, but perhaps we have advanced your understanding of wave references to the point that you can come up with a solution.