Script to create multiple subjects in one protocol

Hello all,
In my study protocol, i have 30 subjects, each with 10 stimuli sessions. However, i could not find any context menu, options, or plugins to create multiple subjects. I need to go through the create new subject dialog box for each and every 30 subjects. imagine if 100 and more subjects…

I could not find any discussion on how to create multiple N subjects in a study protocol. So, i decided to write a helper function to create multiple subjects.

function create_nSubjects(start, noSubject)
range = start:noSubject;
for i = range
if i < 10
subjectname = [‘Subject’, num2str(0), num2str(i)];
else
subjectname = [‘Subject’, num2str(i)];
end
[sSubject, iSubject] = db_add_subject(subjectname);
end

bst_memory('UnloadAll', 'Forced');
% Reload database
db_reload_subjects(iSubject);
panel_protocols('UpdateTree');
% Save database
db_save();

end

dont know if anyone will benefit from it
hope someday developers will add context menu or options in create new subject dialog box for creating multiple subjects.

thank you

Hello,

Indeed, db_add_subject() is the way to go to create subjects via a script. Thank you for your contribution!

Cheers,
Martin