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

[FIX] fix validation of F contrasts #711

Merged
merged 7 commits into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 39 additions & 33 deletions +bids/Model.m
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,45 @@ function write(obj, filename)

end

function validate_constrasts(obj, node)

if ~isfield(node, 'Contrasts')
return
end

for iCon = 1:numel(node.Contrasts)

if ~isfield(node.Contrasts{iCon}, 'Weights')
msg = sprintf('No weights specified for Contrast %s of Node %s', ...
node.Contrasts{iCon}.Name, node.Name);
bids.internal.error_handling(mfilename(), ...
'weightsRequired', ...
msg, ...
obj.tolerant, ...
obj.verbose);
end

switch node.Contrasts{iCon}.Test
case 't'
nb_weights = numel(node.Contrasts{iCon}.Weights);
case 'F'
nb_weights = size(node.Contrasts{iCon}.Weights, 2);
end

if nb_weights ~= numel(node.Contrasts{iCon}.ConditionList)
msg = sprintf('Number of Weights and Conditions unequal for Contrast %s of Node %s', ...
node.Contrasts{iCon}.Name, node.Name);
bids.internal.error_handling(mfilename(), ...
'numelWeightsConditionMismatch', ...
msg, ...
obj.tolerant, ...
obj.verbose);
end

end

end

end

methods (Static)
Expand Down Expand Up @@ -996,39 +1035,6 @@ function write(obj, filename)
end
end

% could be made static
function validate_constrasts(node)

if ~isfield(node, 'Contrasts')
return
end

for iCon = 1:numel(node.Contrasts)

if ~isfield(node.Contrasts{iCon}, 'Weights')
msg = sprintf('No weights specified for Contrast %s of Node %s', ...
node.Contrasts{iCon}.Name, node.Name);
bids.internal.error_handling(mfilename(), ...
'weightsRequired', ...
msg, ...
obj.tolerant, ...
obj.verbose);
end

if numel(node.Contrasts{iCon}.Weights) ~= numel(node.Contrasts{iCon}.ConditionList)
msg = sprintf('Number of Weights and Conditions unequal for Contrast %s of Node %s', ...
node.Contrasts{iCon}.Name, node.Name);
bids.internal.error_handling(mfilename(), ...
'numelWeightsConditionMismatch', ...
msg, ...
obj.tolerant, ...
obj.verbose);
end

end

end

end

methods (Access = protected)
Expand Down