ucdavis / erplab

ERPLAB Toolbox is a free, open-source Matlab package for analyzing ERP data. It is tightly integrated with EEGLAB Toolbox, extending EEGLAB’s capabilities to provide robust, industrial-strength tools for ERP processing, visualization, and analysis. A graphical user interface makes it easy for beginners to learn, and Matlab scripting provides enormous power for intermediate and advanced users.
http://erpinfo.org/erplab
267 stars 73 forks source link

make_bootstrap_ERPSETs does not accommodate overlapping bins #162

Closed mcweenysean closed 1 year ago

mcweenysean commented 2 years ago

Description

I am attempting to recreate the boostrapped SME analyses from the Standardized Measurement Error 2021 Psychophysiology manuscript. However, my bin structure seems to be incompatible with the way bins are handled in the make_bootstrap_ERPSETs function.


Steps to Reproduce

I am working off of the OSF scripts (e.g., SME_demo_2_bSME.m) to calculate the bSME for a difference score (demo 5). I was able to recreate demo 1 for aSME on my data, but the make_bootstrap_ERPSETs function is only built to accommodate trials that only are assigned to 1 bin (bin1 OR bin2). In my data, we use tags such as all_standards and standards_before_deviants, such that a trial fits in multiple bins. Line 73 of make_bootstrap_ERPSETs .m is the culprit, and the error

Input A of class cell and input B of class double must be cell arrays of character vectors, unless one is a character vector.

is returned. My bin_list created on lines 71 and 72 of make_bootstrap_ERPSETs.m from EEG.EVENTLIST.eventinfo is of class cell, whereas the bin_list created from the sample data is of class double.

This is likely an easy fix, but I am unfamiliar enough with MATLAB that someone else will likely be able to solve this much more flexibly, quicker, and robustly than I am able.

Versions

OS version [Windows 10 Home]
Matlab version [2020b]
EEGLAB version [14.1.2b]
ERPLAB version [9.0]
ammsimmons commented 1 year ago

Thank you @mcweenysean for informing us about this. Fix is pending...

mcweenysean commented 1 year ago

Thank you! Debugging I got done so far:

elseif after lines 73-82:

`elseif isequal(class(bin_list),'cell') for bin = 1:nbin bin_count(bin) = sum(cellfun(@(x)ismember(bin,x),bin_list));

    ep_data = zeros(nelec,ntimes,bin_count(bin));
    bindatastruct(bin).ep_data = ep_data;
    bindatastruct(bin).ep_list = [];
    bindatastruct(bin).bs_ep_list = [];
end

end `

And in place of line 96:

if isequal(class(bin_list),'double') [el_where_binepoch] = find(el.bini>=0); else tmp = cellfun(@(x) x <= 0,el.bini,'UniformOutput',false); [el_where_binepoch] = find(cellfun(@(x)~ismember(1,x),tmp)); end

The tl_ev_here gave me some issues so I just forced it to 1, but then ran into downstream problems.

ammsimmons commented 1 year ago

@mcweenysean fix has been updated for this function in the current development ERPLAB version: Simply pull the changes from the development version of ERPlab at: https://github.com/lucklab/erplab

mcweenysean commented 1 year ago

Great, thank you! This generally worked, but another issue arose in the process. 18/140 of my subjects returned NaNs for each electrode of interest. I'm not sure what is causing this, but I can send 2 good and 2 NaN files over email if that would be helpful. Please let me know what works best.

ammsimmons commented 1 year ago

@mcweenysean yes, that would be helpful. Please share with me via amsimmons@ucdavis.edu

Also, thank you for your patience.