NeuralAnalysis / TrialData

Code base for the Matlab TrialData analysis library.
3 stars 4 forks source link

Possible edge case in getTDidx #3

Closed raeedcho closed 7 years ago

raeedcho commented 7 years ago

Calling getTDidx(td,'time') on where td has been binned such that there's only one timepoint per trial returns all fields; not just fields pertaining to time.

raeedcho commented 7 years ago

Sorry, this is for getTDfields, not getTDidx.

mattperich commented 7 years ago

Looked at this quickly and hacked together a half-solution. I'm not sure if there can be a foolproof way of handling this case in the current struct. The real fix requires having true labels on what is "time-varying", which isn't practical as it's all set up now. This is a niche enough case that it's not worth redesigning the whole struct over, since if you've reduced things to a single time point per trial, just use an array :)

Anyway, my current fix relies on a bit of hard-coding of parameters, but seems to work for the most common types of signals. It will certainly fail in some circumstances. I throw a warning when it enters this case so that people are aware. If you have an idea for a better long-term solution, go for it!