Plotting hysteresis loops from cyclic data?

I am fairly new to Igor (6.37), so I'm hoping some of you can point me in the right direction.

I have collected a very large set of data consisting of electrical resistance coupled to position, both with a sinusoidal time dependence. By inspection, I have noticed an asymmetry in the resistance response on the first half of the cycle compared to the second, and I would like to write a routine that automatically plots these two halves vs the corresponding position value, for each cycle, effectively generating a hysteresis loop.

The data set is approximately 260k cycles long, with 50 points per cycle, and manually sifting through 13 M points to see how this behavior evolves between, say, the 1st and 100,000th cycle is incredibly tedious: I must manually find the elapsed time values that correspond to the start and end of each resistance/position cycle pair, snip them out of the data, create new tables for each cycle, containing new waves (time, position, resistance) for each data snippet. Since the position signal is the most stable in time, I would like to key the resistance values off of this variable.

I suspect I need to do something like:
1) Find minima and maxima of the position signal
2) Index these extrema through the time coordinate
3) Find corresponding extrema in the resistance signal
4) Generate new waves for each cycle using these indexed values
5) Plot each cycle as a hysteresis loop

I'm not expecting a miracle, but some ideas to get me started would be most appreciated. Cheers and many thanks to all who can shed some light on this issue!
Hi,

First question is how well behaved your data is. You mention 50 points, is it always really 50 points and if so things become easier.

Can you post a small sample of your data? You mention resistance and time. Is the data regularly spaced such that you can set the x scaling to time? Or if not you might create a second wave with the time stamp.

My methodology:
Develop your analysis on a 50 point sample for example with Wavestats which will provide a wealth of information including:
V_minloc X location of minimum data value.
V_min Minimum data value.
V_maxloc X location of maximum data value.
V_max Maximum data value.
V_minRowLoc Row containing minimum data value.
V_maxRowLoc Row containing maximum data value.

You can then find the minima and maxima values and locations and then use those locations for the time stamp. You can plot the hysteria but with the number of data points I think you would be better served to generate a metric to describe the amount of hysteresis. I would then look at the values of that metric and then sample a couple of representative loops.

Once you have the metrics done then you can create a loop do go through the large dataset. Wavestats allows you set the range of the points you want to examine. Typically I create an output wave in 2 dimensions. The columns are labelled with names of the metric values and as I loop through each row is the results of the analysis that were developed on the small subset.

Andy



Below is an example for an experiment:
Function Analyze()

    //Create Wave to store results
    Make/O /N=(0,6) Metrics
   
    setdimlabel 1,0,Image,Metrics
    setdimlabel 1,1,HotArea,Metrics
    setdimlabel 1,2,ZoneArea,Metrics
    setdimlabel 1,3,XMax,Metrics
    setdimlabel 1,4,Ymax,Metrics
    setdimlabel 1,5,IntMax,Metrics

    //Define sources of waves
    Wave Image
    Wave HotArea = root:Hotspot:W_ImageobjArea 
    Wave ZoneArea= root:TotalZone:W_ImageobjArea   
   
    //define the range of inputs
    SVAR ImageList
    Variable index, maxindex
    Maxindex = itemsinlist(ImageList)// allow for indeterminent numbers of images

    For(index=0;index<maxindex;index+=1)
        loadimage(index)//load image and run image analysis
        Imagestats/Q Image
        Metrics[index][%Image]= {index+1} //make it 1 based
        Metrics[index][%hotarea] = {sum(hotarea)} // include all increase more than one
        Metrics[index][%ZoneArea] = {sum(ZoneArea)} // include all increase more than one
        Metrics[index][%Xmax] = {V_maxRowLoc} // include all increase more than one
        Metrics[index][%Ymax] = {V_maxColLoc}// include all increase more than one
        Metrics[index][%IntMax] = {V_max} // include all increase more than one
    Endfor
end