Skip to content

Commit

Permalink
Bugfix: Import FieldTrip structures with NaN in trialinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ftadel committed Oct 4, 2022
1 parent 5bda543 commit 9393f8f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/license.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<body alink="#fff000" link="#fff000" vlink="#fff000">
<h4><span style="font-family: Arial Black; color: #ffffff;"><strong>THERE IS NO UNDO BUTTON!<BR>SET UP A <FONT color=red>BACKUP</FONT> OF YOUR DATABASE</strong></span></h4>
<HR>
<!-- LICENCE_START -->Version: 3.221003 (03-Oct-2022)<br>
<!-- LICENCE_START -->Version: 3.221004 (04-Oct-2022)<br>
<span style="font-style: italic;">COPYRIGHT &copy; 2000-2022
USC &amp; McGill University.<br>
</span>
Expand Down
2 changes: 1 addition & 1 deletion doc/version.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
% Brainstorm
% v. 3.221003 (03-Oct-2022)
% v. 3.221004 (04-Oct-2022)
14 changes: 11 additions & 3 deletions toolbox/io/in_data_fieldtrip.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,19 @@
% === GET TRIAL INFO ===
% Get trial info, if available
trialId = ones(length(ftMat.trial), 1);
trialinfoClean = [];
if isfield(ftMat, 'trialinfo') && (size(ftMat.trialinfo,1) == length(ftMat.trial)) && isnumeric(ftMat.trialinfo)
iGoodCol = find(~any(isnan(ftMat.trialinfo),1) & ~all(bst_bsxfun(@minus, ftMat.trialinfo, ftMat.trialinfo(1,:)) == 0, 1));
if ~isempty(iGoodCol)
trialinfoClean = ftMat.trialinfo(:, iGoodCol);
end
end
% Cleanup trialinfo
if ~isempty(trialinfoClean)
% Ask the user for confirmation
if isInteractive
% Ask which column to use in the trialinfo field
nCol = size(ftMat.trialinfo,2);
nCol = size(trialinfoClean,2);
res = java_dialog('question', [...
'A field "trialinfo" with ' num2str(nCol) ' column(s) is avaiable in the file.' 10 10 ...
'Which column to use to label the imported trials?'], ...
Expand All @@ -92,11 +100,11 @@
return;
end
if ~isequal(res, 'None')
trialId = ftMat.trialinfo(:, str2double(res));
trialId = trialinfoClean(:, str2double(res));
end
% Automatic: use the first column only
else
trialId = ftMat.trialinfo(:,1);
trialId = trialinfoClean(:,1);
end
end

Expand Down

0 comments on commit 9393f8f

Please sign in to comment.