gabenespoli/phzlab

Summary function not working properly when looking at combined files.

Closed this issue · 3 comments

Note: 'summary' works with 'all', but not individual parameters e.g., 'participant'


FFTStry = phz_writetable(PHZ, 'feature', 'fft100', 'region', 'target', 'FFRsummary', 'efr', 'summary', {'participant', 'session'})
Calculating features...

Feature 1/1: fft100
Restricted to 'target [0.06 0.17]' region.
Summarized data by 'participant session'.
Extracted feature 'fft100'.
Index exceeds matrix dimensions.

Error in phz_discard (line 80)
PHZ.lib.tags.(field) = PHZ.lib.tags.(field)(keep);

Error in phz_summary (line 135)
TMP = phz_discard(TMP, false); % verbose = false

Error in phz_feature (line 352)
[PHZ, preSummaryData] = phz_summary(PHZ,keepVars,verbose);

Error in phz_writetable (line 173)
[s,featureTitle] =
phz_feature(PHZ,feature{i},'summary',keepVars,'region',region,'verbose',verbose);

I fixed phz_discard.m to make sure a lib.tags field isn't collapsed before it tried to restrict to it (6befc5d). This should at least fix the error you were getting.

FFRsummary no longer works in writetable, even if used in the absence of the summary function. Here's the same code as before with new error --

FFTS = phz_writetable(PHZ, 'feature', 'fft100', 'region', 'target', 'FFRsummary', 'efr', 'summary', {'participant', 'session'})
All labels already have the same number of epochs.
Summarized data by 'participant session trials'.
Error using phz_summary>doSummary (line 296)
Cannot add unless there are exactly 2 trials.

Error in phz_summary (line 111)
PHZ.data = doSummary(PHZ, summaryFunction);

Error in phzFFR_summary (line 63)
PHZ = phz_summary(PHZ, grpVar, summaryFunction, verbose);

Error in phz_writetable (line 167)
if ~isempty(summaryFunction), PHZ = phzFFR_summary(PHZ,
summaryFunction, verbose); end

Found the bug. I was calling ismember with the wrong order of inputs for the output that was needed. Tough one to find but an easy one to fix. 89eeaf7