Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What if my spiketrain or timing variables are empty for some trials. #10

Open
ehennestad opened this issue Nov 22, 2017 · 6 comments
Open

Comments

@ehennestad
Copy link

Whats the advice if my spike train or timing variables are empty during some of the trials?

Sidenote:
To get my data accepted by the addTrial, function I added a condition to only test that the timing of events happen within the duration of the trial if the data input is nonempty. (The tests in line 18 and 28 does not work on empty vectors)

Then, when I compiled the SparseDesignMatrix it gave me a warning that the design matrix contains infs and nans. Could that be due to empty timing vectors?

@ehennestad
Copy link
Author

I had forgotten to remove some nans from one of my variables, so that was the reason for the warning I received.

@memming
Copy link
Member

memming commented Nov 26, 2017

Thanks for the report. Can you provide minimal reproducible code so I can quickly fix it?

@ehennestad
Copy link
Author

ehennestad commented Nov 28, 2017

    case 'timing'
        if max(size(trial.(vname))) ~= numel(trial.(vname))
            error('Timing must be 1 dimensional')
        end
        if ~isempty(trial.(vname)) % <-- Line added
            if min(trial.(vname)) < 0 || max(trial.(vname)) > trial.duration
                error('Timing out of bound 0 <= [%f, %f] <= %f',min(trial.(vname)), max(trial.(vname)), trial.duration);
            end
        end
    case 'value'
        % no restrictions on what values can be!
    case 'spike train'
        if ~isempty(trial.(vname)) % <-- Line added
            if min(trial.(vname)) < 0 || max(trial.(vname)) > trial.duration
                error('Spike timing out of bound 0 <= [%f, %f] <= %f',min(trial.(vname)), max(trial.(vname)), trial.duration);
            end
        end
    otherwise

@ehennestad
Copy link
Author

The code is from line 17 and onwards in addTrial.m
I added the two if statements with comments after.

@memming
Copy link
Member

memming commented Dec 4, 2017

Awesome. If you want to submit this fix yourself, feel free to send a pull request. I'll merge it so that you can get proper credit. (I was asking you how to replicate the problem.)

@aboharbf
Copy link

aboharbf commented Aug 4, 2020

Hey, just as a heads up, this line appears to still need to be added to the base code. I just ran into the same issue and added these lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants