JuliaDynamics / RecurrenceAnalysis.jl

Recurrence Quantification Analysis in Julia
https://juliadynamics.github.io/RecurrenceAnalysis.jl/stable/
MIT License
44 stars 12 forks source link

Getting nzval indices from `histograms` calculations [Question] #123

Closed rs7q5 closed 2 years ago

rs7q5 commented 2 years ago

I am currently trying to calculate the number of recurrence points that create diagonal lines but are also not a part of a vertical line as well. I think I can create a modified version of diagonalhistogram and/or _linestructures to try and isolate these because I really just need the indices to compare if they are included in both. This would also allow me to calculate the number of isolated points.

I am just a little unclear on how exactly the indices work out currently in diagonalhistogram. I understand rv contains the nonzero row indices, but I am a little confused how how dh and dv work out.

Any additional information on how these work is greatly appreciated.

Datseris commented 2 years ago

@heliosdrm may know

pucicu commented 2 years ago

Hi,

does it really make sense to separate these lines? In particular for continuous-like data, even if you would have very small recurrence threshold, you will find many lines that are thicker than just 1 sampling point. These lines would all be neglected in your counting. It would better to reduce these lines to have just 1 sample point vertical extension, or not?

Best Norbert

Am 01.11.2021 um 02:57 schrieb rs7q5 @.***>:

I am currently trying to calculate the number of recurrence points that create diagonal lines but are also not a part of a vertical line as well. I think I can create a modified version of diagonalhistogram and/or _linestructures to try and isolate these because I really just need the indices to compare if they are included in both. This would also allow me to calculate the number of isolated points.

I am just a little unclear on how exactly the indices work out currently in diagonalhistogram. I understand rv contains the nonzero row indices, but I am a little confused how how dh and dv work out.

Any additional information on how these work is greatly appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JuliaDynamics/RecurrenceAnalysis.jl/issues/123, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHNNEC3SDDCZFOOLDSYLD3UJXXYDANCNFSM5HC7Y6YQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

rs7q5 commented 2 years ago

@pucicu Are you suggesting dropping all vertical and diagonal points that have a length larger than 1? That may work in getting the number of isolated points, but I am also interested in plotting each line type on a separate plot (vertical, diagonal, isolated points) and don't want points counted twice, so do need the indices at some point to do that.

pucicu commented 2 years ago

no, this was not the suggestion. I had this approach: https://doi.org/10.1016/j.physleta.2019.125977 in my mind.

Am 01.11.2021 um 15:25 schrieb rs7q5 @.***>:

@pucicu https://github.com/pucicu Are you suggesting dropping all vertical and diagonal points that have a length larger than 1? That may work in getting the number of isolated points, but I am also interested in plotting each line type on a separate plot (vertical, diagonal, isolated points) and don't want points counted twice, so do need the indices at some point to do that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/JuliaDynamics/RecurrenceAnalysis.jl/issues/123#issuecomment-956279724, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHNNEGDOHWVYV2XHZMVAKDUJ2PMNANCNFSM5HC7Y6YQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

rs7q5 commented 2 years ago

Thanks for the reference, I'll take a look at this and see if it contains what I want, but I think I would still like to extract those indices.

pucicu commented 2 years ago

but how would you do it, when the diagonal line has a width of, say, 2 points. then it would be vertical line, or not? what is the clear criterion to distinguish a collection of points as either diagonal or vertical? usually, we have a mixing of those structures.

Am 01.11.2021 um 21:09 schrieb rs7q5 @.***>:

Thanks for the reference, I'll take a look at this and see if it contains what I want, but I think I would still like to extract those indices.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/JuliaDynamics/RecurrenceAnalysis.jl/issues/123#issuecomment-956552400, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHNNEF4GEJGSOXUIMENNLTUJ3XXXANCNFSM5HC7Y6YQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

rs7q5 commented 2 years ago

I should have specified earlier that I was working with symbolic recurrence plots, as you are right you would need a criteria to distinguish which line it belongs to. Sorry for the confusion.

For reference, I am currently using the criterion specified by Cabellero-Pintado et al.

"in a diagonal line two consecutive symbolic recurrence points are of different color."

I know I will need to write a new function to perform this task, but I wanted to understand how the code is currently iterating through the diagonal lines.

heliosdrm commented 2 years ago

Sorry for the late reply. In diagonalhistogram:

The key is in _linehistograms, which returns a tuple with two values: the first one is the "histogram" of line lengths, and the second one is the "histogram" of distances between lines). Its arguments are named as for a function that looks for vertical lines in sparse matrices, but in diagonalhistogram the second argument is not the "column values", but the "diagonal values" (dv), so it actually looks for diagonal lines.

Basically, _linehistograms iterates through columns (diagonals), and compares pairs of successive row values within each column/diagonal. When two successive values are more than one row apart, that means that a line is ended, and that updates the histogram of line lengths, with the difference between the first of the compared values (the end of the line) and the starting value (rprev). The histogram of distances between lines is also updated if requested. There is also a special treatment at the start and end of each column/diagonal.

Datseris commented 2 years ago

(I'm closing this as this is a question and no longer an issue. feel free to continue the discussion here as much as you'd like, but I don't think this needs to remain open in the issue tracker)

rs7q5 commented 2 years ago

@heliosdrm thanks for the explanation. that helps.

So in my versions of diagonalhistogram and _linehistogram I send in the actual diagonal values in to check that consecutive values along the diagonal are not the same (I have more than just ones and zeros in my matrices).

Do I only need to place this additional condition where r-rprev != 1 is checked? Or do I need an additional check to deal with the start and end of each diagonal? The if statement would be something like if r-rprev !=1 || x[r]==x[rprev]... where x is the nonzero values for the row and column/diagonal.

EDIT: I think the indices for x should be i and i-1 not r.