All the fixes to work fine!
The created templates seem to be misplaced in the submenus. When I tried it, the templates created by the script were shown in the MNI submenu. I also tried to create a template through the GUI and this template got placed in the USC submenu. It does not have consequences for what I have to do, but I thought you may want to know about this issue.
I tried to integrated your code for the channel files. I managed make it save the imported file, but it does not add the channel to the study, probably because I did not use the RefChannelMat
object you used in your code. How do your get that object/structure? Here is what I got so far:
montages = {'10-5', '10-10', '10-20', 'HGSN128'};
iStudy = db_add_condition(subjectName, 'test');
sStudy = bst_get('Study', iStudy);
% Create folder for channel file
for no_montage = 1:length(montages)
montage = [montages{no_montage} '-montage.fif'];
RefChannelMat = db_template('channelmat');
% Read channel file
FifMat = import_channel([], [FsDir '/' montage], 'FIF', 0, 0, 0);
% Create destination channel file
ChannelMat = RefChannelMat;
ChannelMat.SCS.NAS = FifMat.HeadPoints.Loc(:,2);
ChannelMat.SCS.LPA = FifMat.HeadPoints.Loc(:,1);
ChannelMat.SCS.RPA = FifMat.HeadPoints.Loc(:,3);
for i = 15:size(FifMat.HeadPoints.Loc, 2)
ChannelMat.Channel(i-14).Loc = FifMat.HeadPoints.Loc(:,i);
end
ChannelMat.HeadPoints = FifMat.HeadPoints;
% Save channel file
ChannelFile = bst_fullfile(bst_fileparts(file_fullpath(sStudy.FileName)), montages{no_montage});
bst_save(ChannelFile, ChannelMat, 'v7');
end
db_reload_studies(iStudy);
Here are FreeSurfer for the ASEG issue:
- A problematic subject: https://www.dropbox.com/s/kmifh6ve7qxgfk0/ANTS1-0Months3T.7z?dl=0
- A subject that is OK: https://www.dropbox.com/s/tmtlhryfciqci3t/ANTS15-0Months3T.7z?dl=0